@agent-native/core 0.119.3 → 0.119.5

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 (277) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +21 -0
  3. package/corpus/core/package.json +3 -3
  4. package/corpus/core/src/agent/engine/index.ts +2 -0
  5. package/corpus/core/src/agent/engine/registry.ts +95 -2
  6. package/corpus/core/src/agent/production-agent.ts +107 -125
  7. package/corpus/core/src/agent/run-manager.ts +45 -2
  8. package/corpus/core/src/agent/thread-data-builder.ts +85 -8
  9. package/corpus/core/src/client/AssistantChat.tsx +37 -9
  10. package/corpus/core/src/client/chat/message-components.tsx +9 -1
  11. package/corpus/core/src/client/chat/repo-helpers.ts +77 -0
  12. package/corpus/core/src/client/chat/tool-call-display.tsx +51 -15
  13. package/corpus/core/src/scripts/agent-engines/list-agent-engines.ts +8 -0
  14. package/corpus/core/src/scripts/agent-engines/manage-agent-engine.ts +5 -1
  15. package/corpus/core/src/scripts/agent-engines/set-agent-engine.ts +9 -1
  16. package/corpus/core/src/server/agent-chat/framework-prompts.ts +3 -1
  17. package/corpus/core/src/server/agent-chat/plugin-options.ts +9 -0
  18. package/corpus/core/src/server/agent-chat-plugin.ts +12 -3
  19. package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +512 -0
  20. package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +189 -0
  21. package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +115 -0
  22. package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
  23. package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +89 -0
  24. package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +221 -0
  25. package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +220 -0
  26. package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +263 -0
  27. package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
  28. package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +160 -0
  29. package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +232 -0
  30. package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +280 -0
  31. package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +118 -0
  32. package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +119 -0
  33. package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +100 -0
  34. package/corpus/core/src/templates/chat/.env.example +5 -0
  35. package/corpus/core/src/templates/chat/.ignore +0 -0
  36. package/corpus/core/src/templates/chat/.oxfmtrc.json +8 -0
  37. package/corpus/core/src/templates/chat/AGENTS.md +69 -0
  38. package/corpus/core/src/templates/chat/CHANGELOG.md +10 -0
  39. package/corpus/core/src/templates/chat/DEVELOPING.md +185 -0
  40. package/corpus/core/src/templates/chat/README.md +32 -0
  41. package/corpus/core/src/templates/chat/_gitignore +43 -0
  42. package/corpus/core/src/templates/chat/actions/hello.ts +13 -0
  43. package/corpus/core/src/templates/chat/actions/navigate.ts +41 -0
  44. package/corpus/core/src/templates/chat/actions/run.ts +2 -0
  45. package/corpus/core/src/templates/chat/actions/view-screen.ts +31 -0
  46. package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +60 -0
  47. package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +185 -0
  48. package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +450 -0
  49. package/corpus/core/src/templates/chat/app/components/ui/button.tsx +1 -0
  50. package/corpus/core/src/templates/chat/app/components/ui/card.tsx +1 -0
  51. package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +1 -0
  52. package/corpus/core/src/templates/chat/app/components/ui/input.tsx +1 -0
  53. package/corpus/core/src/templates/chat/app/components/ui/label.tsx +1 -0
  54. package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +1 -0
  55. package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +17 -0
  56. package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +1 -0
  57. package/corpus/core/src/templates/chat/app/design-system.ts +3 -0
  58. package/corpus/core/src/templates/chat/app/entry.client.tsx +19 -0
  59. package/corpus/core/src/templates/chat/app/entry.server.tsx +10 -0
  60. package/corpus/core/src/templates/chat/app/global.css +93 -0
  61. package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +93 -0
  62. package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +68 -0
  63. package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +71 -0
  64. package/corpus/core/src/templates/chat/app/i18n/en-US.ts +70 -0
  65. package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +71 -0
  66. package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +71 -0
  67. package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +69 -0
  68. package/corpus/core/src/templates/chat/app/i18n/index.ts +34 -0
  69. package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +70 -0
  70. package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +70 -0
  71. package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +71 -0
  72. package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +66 -0
  73. package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +66 -0
  74. package/corpus/core/src/templates/chat/app/i18n-data.ts +556 -0
  75. package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +49 -0
  76. package/corpus/core/src/templates/chat/app/lib/app-config.ts +11 -0
  77. package/corpus/core/src/templates/chat/app/lib/tab-id.ts +1 -0
  78. package/corpus/core/src/templates/chat/app/lib/utils.ts +1 -0
  79. package/corpus/core/src/templates/chat/app/root.tsx +173 -0
  80. package/corpus/core/src/templates/chat/app/routes/_index.tsx +94 -0
  81. package/corpus/core/src/templates/chat/app/routes/agent.tsx +24 -0
  82. package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +1 -0
  83. package/corpus/core/src/templates/chat/app/routes/database.tsx +17 -0
  84. package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +2 -0
  85. package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +11 -0
  86. package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +11 -0
  87. package/corpus/core/src/templates/chat/app/routes/extensions.tsx +5 -0
  88. package/corpus/core/src/templates/chat/app/routes/observability.tsx +19 -0
  89. package/corpus/core/src/templates/chat/app/routes/settings.tsx +89 -0
  90. package/corpus/core/src/templates/chat/app/routes/team.tsx +11 -0
  91. package/corpus/core/src/templates/chat/app/routes.ts +4 -0
  92. package/corpus/core/src/templates/chat/app/vite-env.d.ts +6 -0
  93. package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
  94. package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
  95. package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +6 -0
  96. package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
  97. package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
  98. package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  99. package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +6 -0
  100. package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  101. package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +6 -0
  102. package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +6 -0
  103. package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +6 -0
  104. package/corpus/core/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
  105. package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
  106. package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
  107. package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +6 -0
  108. package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
  109. package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +6 -0
  110. package/corpus/core/src/templates/chat/components.json +20 -0
  111. package/corpus/core/src/templates/chat/learnings.defaults.md +5 -0
  112. package/corpus/core/src/templates/chat/netlify.toml +10 -0
  113. package/corpus/core/src/templates/chat/package.json +92 -0
  114. package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +10 -0
  115. package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +10 -0
  116. package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +21 -0
  117. package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +21 -0
  118. package/corpus/core/src/templates/chat/public/favicon.svg +1 -0
  119. package/corpus/core/src/templates/chat/public/icon-180.svg +1 -0
  120. package/corpus/core/src/templates/chat/public/icon-192.svg +1 -0
  121. package/corpus/core/src/templates/chat/public/icon-512.svg +1 -0
  122. package/corpus/core/src/templates/chat/public/manifest.json +21 -0
  123. package/corpus/core/src/templates/chat/react-router.config.ts +7 -0
  124. package/corpus/core/src/templates/chat/server/middleware/auth.ts +15 -0
  125. package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +21 -0
  126. package/corpus/core/src/templates/chat/server/plugins/auth.ts +17 -0
  127. package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +5 -0
  128. package/corpus/core/src/templates/chat/ssr-entry.ts +15 -0
  129. package/corpus/core/src/templates/chat/tsconfig.json +21 -0
  130. package/corpus/core/src/templates/chat/vite.config.ts +19 -0
  131. package/corpus/templates/analytics/AGENTS.md +19 -11
  132. package/corpus/templates/analytics/actions/list-data-dictionary.ts +3 -1
  133. package/corpus/templates/analytics/actions/save-data-dictionary-entry.ts +14 -0
  134. package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +41 -0
  135. package/corpus/templates/analytics/app/components/dashboard/DashboardPanelSkeleton.tsx +13 -0
  136. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +12 -11
  137. package/corpus/templates/analytics/app/pages/adhoc/DashboardSkeleton.tsx +3 -3
  138. package/corpus/templates/analytics/changelog/2026-07-23-dashboard-chart-loading-placeholders-are-easier-to-see-in-da.md +6 -0
  139. package/corpus/templates/analytics/changelog/2026-07-23-routine-analytics-lookups-reuse-existing-query-definitions.md +6 -0
  140. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +1 -12
  141. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +405 -0
  142. package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -16
  143. package/corpus/templates/content/changelog/2026-07-23-database-toolbar-sort-and-filter-controls-open-reliably.md +6 -0
  144. package/corpus/templates/forms/app/lib/public-form-link.ts +14 -0
  145. package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +6 -14
  146. package/corpus/templates/forms/changelog/2026-07-23-published-form-links-can-be-copied-without-being-asked-to-re.md +6 -0
  147. package/corpus/templates/mail/changelog/2026-07-23-scheduled-emails-now-send-only-once-when-multiple-requests-r.md +6 -0
  148. package/corpus/templates/mail/server/lib/jobs.ts +13 -4
  149. package/corpus/templates/mail/server/plugins/mail-jobs.ts +1 -1
  150. package/corpus/templates/slides/actions/patch-deck.ts +2 -1
  151. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +7 -18
  152. package/corpus/templates/slides/app/lib/agent-visible-message.ts +28 -0
  153. package/corpus/templates/slides/app/pages/Index.tsx +6 -34
  154. package/corpus/templates/slides/changelog/2026-07-23-full-prompts-stay-visible-in-chat-when-creating-decks-or-add.md +6 -0
  155. package/corpus/templates/slides/changelog/2026-07-23-opening-or-refining-a-deck-no-longer-crashes-with-a-blank-er.md +6 -0
  156. package/corpus/templates/slides/shared/aspect-ratios.ts +4 -1
  157. package/corpus/templates/tasks/.oxfmtrc.json +8 -0
  158. package/corpus/templates/tasks/AGENTS.md +34 -41
  159. package/corpus/templates/tasks/README.md +13 -6
  160. package/corpus/templates/tasks/actions/bulk-delete-inbox-items.ts +10 -8
  161. package/corpus/templates/tasks/actions/bulk-delete-tasks.ts +10 -8
  162. package/corpus/templates/tasks/actions/bulk-mark-inbox-items-ready.ts +1 -1
  163. package/corpus/templates/tasks/actions/bulk-update-tasks.ts +12 -10
  164. package/corpus/templates/tasks/actions/create-inbox-item.ts +7 -4
  165. package/corpus/templates/tasks/actions/create-task.ts +2 -1
  166. package/corpus/templates/tasks/actions/delete-inbox-item.ts +6 -4
  167. package/corpus/templates/tasks/actions/delete-task.ts +1 -1
  168. package/corpus/templates/tasks/actions/list-inbox-items.ts +4 -2
  169. package/corpus/templates/tasks/actions/list-visible-task-fields.ts +3 -1
  170. package/corpus/templates/tasks/actions/mark-inbox-item-ready.ts +6 -4
  171. package/corpus/templates/tasks/actions/navigate.ts +16 -14
  172. package/corpus/templates/tasks/actions/reorder-inbox-items.ts +9 -7
  173. package/corpus/templates/tasks/actions/update-inbox-item.ts +6 -4
  174. package/corpus/templates/tasks/actions/update-task.ts +12 -9
  175. package/corpus/templates/tasks/actions/update-visible-task-fields.ts +10 -8
  176. package/corpus/templates/tasks/actions/view-screen.ts +1 -1
  177. package/corpus/templates/tasks/app/components/tasks/fields/TaskFieldsSidebar.tsx +15 -0
  178. package/corpus/templates/tasks/changelog/2026-07-23-task-detail-extensions.md +6 -0
  179. package/corpus/templates/tasks/drizzle.config.ts +3 -0
  180. package/corpus/templates/tasks/package.json +4 -1
  181. package/corpus/templates/tasks/server/db/schema.ts +0 -10
  182. package/corpus/templates/tasks/server/db/test-tasks-table.ts +0 -5
  183. package/corpus/templates/tasks/server/plugins/agent-chat.ts +1 -1
  184. package/corpus/templates/tasks/server/plugins/db.ts +43 -10
  185. package/corpus/templates/tasks/server/user-config/store.ts +42 -81
  186. package/corpus/templates/tasks/tsconfig.json +1 -2
  187. package/corpus/templates/tasks/vitest.config.ts +10 -1
  188. package/corpus/toolkit/CHANGELOG.md +13 -0
  189. package/corpus/toolkit/package.json +1 -1
  190. package/corpus/toolkit/src/editor/SharedRichEditor.tsx +23 -2
  191. package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +68 -2
  192. package/corpus/toolkit/src/editor/index.ts +1 -0
  193. package/corpus/toolkit/src/editor.css +75 -0
  194. package/corpus/toolkit/src/ui/button.tsx +3 -2
  195. package/dist/agent/engine/index.d.ts +1 -1
  196. package/dist/agent/engine/index.d.ts.map +1 -1
  197. package/dist/agent/engine/index.js +1 -1
  198. package/dist/agent/engine/index.js.map +1 -1
  199. package/dist/agent/engine/registry.d.ts +32 -1
  200. package/dist/agent/engine/registry.d.ts.map +1 -1
  201. package/dist/agent/engine/registry.js +75 -3
  202. package/dist/agent/engine/registry.js.map +1 -1
  203. package/dist/agent/production-agent.d.ts.map +1 -1
  204. package/dist/agent/production-agent.js +96 -115
  205. package/dist/agent/production-agent.js.map +1 -1
  206. package/dist/agent/run-manager.d.ts +9 -1
  207. package/dist/agent/run-manager.d.ts.map +1 -1
  208. package/dist/agent/run-manager.js +26 -0
  209. package/dist/agent/run-manager.js.map +1 -1
  210. package/dist/agent/thread-data-builder.d.ts +2 -0
  211. package/dist/agent/thread-data-builder.d.ts.map +1 -1
  212. package/dist/agent/thread-data-builder.js +69 -9
  213. package/dist/agent/thread-data-builder.js.map +1 -1
  214. package/dist/client/AssistantChat.d.ts.map +1 -1
  215. package/dist/client/AssistantChat.js +32 -10
  216. package/dist/client/AssistantChat.js.map +1 -1
  217. package/dist/client/chat/message-components.d.ts +2 -1
  218. package/dist/client/chat/message-components.d.ts.map +1 -1
  219. package/dist/client/chat/message-components.js +9 -3
  220. package/dist/client/chat/message-components.js.map +1 -1
  221. package/dist/client/chat/repo-helpers.d.ts +4 -0
  222. package/dist/client/chat/repo-helpers.d.ts.map +1 -1
  223. package/dist/client/chat/repo-helpers.js +61 -0
  224. package/dist/client/chat/repo-helpers.js.map +1 -1
  225. package/dist/client/chat/tool-call-display.d.ts +2 -1
  226. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  227. package/dist/client/chat/tool-call-display.js +10 -9
  228. package/dist/client/chat/tool-call-display.js.map +1 -1
  229. package/dist/collab/struct-routes.d.ts +1 -1
  230. package/dist/observability/routes.d.ts +5 -5
  231. package/dist/progress/routes.d.ts +1 -1
  232. package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
  233. package/dist/provider-api/actions/provider-api.d.ts +7 -7
  234. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  235. package/dist/resources/handlers.d.ts +1 -1
  236. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  237. package/dist/scripts/agent-engines/list-agent-engines.js +8 -2
  238. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  239. package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
  240. package/dist/scripts/agent-engines/manage-agent-engine.js +5 -2
  241. package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
  242. package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
  243. package/dist/scripts/agent-engines/set-agent-engine.js +9 -2
  244. package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
  245. package/dist/secrets/routes.d.ts +9 -9
  246. package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
  247. package/dist/server/agent-chat/framework-prompts.js +3 -1
  248. package/dist/server/agent-chat/framework-prompts.js.map +1 -1
  249. package/dist/server/agent-chat/plugin-options.d.ts +9 -0
  250. package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
  251. package/dist/server/agent-chat/plugin-options.js.map +1 -1
  252. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  253. package/dist/server/agent-chat-plugin.js +11 -2
  254. package/dist/server/agent-chat-plugin.js.map +1 -1
  255. package/dist/server/realtime-token.d.ts +1 -1
  256. package/dist/server/transcribe-voice.d.ts +1 -1
  257. package/package.json +4 -4
  258. package/src/agent/engine/index.ts +2 -0
  259. package/src/agent/engine/registry.ts +95 -2
  260. package/src/agent/production-agent.ts +107 -125
  261. package/src/agent/run-manager.ts +45 -2
  262. package/src/agent/thread-data-builder.ts +85 -8
  263. package/src/client/AssistantChat.tsx +37 -9
  264. package/src/client/chat/message-components.tsx +9 -1
  265. package/src/client/chat/repo-helpers.ts +77 -0
  266. package/src/client/chat/tool-call-display.tsx +51 -15
  267. package/src/scripts/agent-engines/list-agent-engines.ts +8 -0
  268. package/src/scripts/agent-engines/manage-agent-engine.ts +5 -1
  269. package/src/scripts/agent-engines/set-agent-engine.ts +9 -1
  270. package/src/server/agent-chat/framework-prompts.ts +3 -1
  271. package/src/server/agent-chat/plugin-options.ts +9 -0
  272. package/src/server/agent-chat-plugin.ts +12 -3
  273. package/corpus/templates/tasks/.prettierrc +0 -5
  274. package/src/templates/chat/actions/hello.spec.ts +0 -23
  275. package/src/templates/chat/actions/navigate.spec.ts +0 -68
  276. package/src/templates/chat/actions/view-screen.spec.ts +0 -40
  277. package/src/templates/chat/app/lib/agent-page.spec.tsx +0 -61
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { getAgentAppModelDefaultForCurrentRequest } from "../../agent/app-model-defaults.js";
5
5
  import { DEFAULT_MODEL } from "../../agent/default-model.js";
6
- import { listAgentEngines, registerBuiltinEngines, detectEngineFromEnv, detectEngineFromUserSecrets, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, normalizeModelForEngine, } from "../../agent/engine/index.js";
6
+ import { listAgentEngines, registerBuiltinEngines, detectEngineFromEnv, detectEngineFromUserSecrets, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, normalizeModelForEngine, resolveEnginePreservesCustomModels, } from "../../agent/engine/index.js";
7
7
  import { getSetting } from "../../settings/index.js";
8
8
  export const tool = {
9
9
  description: 'List all available AI agent engines (Anthropic, OpenAI, Gemini, Groq, etc.) and the currently selected engine. Use this to check what engines are available before calling manage-agent-engine with action="set".',
@@ -59,8 +59,14 @@ export async function run(args = {}) {
59
59
  ? current?.model
60
60
  : undefined;
61
61
  const currentEngineName = currentEntry?.name ?? "anthropic";
62
+ // Resolve the OpenAI-compatible-endpoint capability so a custom gateway model
63
+ // is reported as-is instead of being normalized to the engine default — the
64
+ // read-side counterpart of the same fix in set-/manage-agent-engine.
65
+ const preserveCustomModels = currentEntry
66
+ ? await resolveEnginePreservesCustomModels(currentEntry)
67
+ : false;
62
68
  const currentModel = currentEntry && !envUnavailable
63
- ? normalizeModelForEngine(currentEntry, currentModelCandidate ?? currentEntry.defaultModel)
69
+ ? normalizeModelForEngine(currentEntry, currentModelCandidate ?? currentEntry.defaultModel, { preserveCustomModels })
64
70
  : (currentModelCandidate ?? DEFAULT_MODEL);
65
71
  const result = {
66
72
  engines: engines.map((e) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"list-agent-engines.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/list-agent-engines.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,wCAAwC,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAA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C,qBAAqB,IAAI,aAAa,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,gBAAgB,EAAE,6BAA6B,CAAC,CAAC,CAAC;SACnD,CAAC,CAAC;QACH,OAAO,EAAE,cAAc;YACrB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACE,MAAM,EAAE,iBAAiB;gBACzB,KAAK,EAAE,YAAY;aACpB;KACN,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/**\n * list-agent-engines — returns the registered engine registry and current selection.\n */\n\nimport { getAgentAppModelDefaultForCurrentRequest } from \"../../agent/app-model-defaults.js\";\nimport { DEFAULT_MODEL } from \"../../agent/default-model.js\";\nimport {\n listAgentEngines,\n registerBuiltinEngines,\n detectEngineFromEnv,\n detectEngineFromUserSecrets,\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n isStoredEngineUsableForRequest,\n normalizeModelForEngine,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport { getSetting } from \"../../settings/index.js\";\n\nexport const tool: ActionTool = {\n description:\n 'List all available AI agent engines (Anthropic, OpenAI, Gemini, Groq, etc.) and the currently selected engine. Use this to check what engines are available before calling manage-agent-engine with action=\"set\".',\n parameters: {\n type: \"object\",\n properties: {},\n required: [],\n },\n};\n\nexport async function run(args: Record<string, string> = {}): Promise<string> {\n registerBuiltinEngines();\n\n const engines = listAgentEngines();\n const currentSetting = await getSetting(\"agent-engine\");\n const current = currentSetting\n ? (currentSetting as { engine?: string; model?: string })\n : null;\n\n // Same priority chain resolveEngine uses after explicit request options:\n // AGENT_ENGINE → app default → stored (if usable) → user/Builder app_secrets\n // → env → anthropic. Gating stored/app defaults on the request-aware helper\n // keeps the picker in step with the runtime.\n const storedEntry =\n typeof current?.engine === \"string\"\n ? getAgentEngineEntry(current.engine)\n : undefined;\n const storedUsable =\n !!storedEntry &&\n (await isStoredEngineUsableForRequest(current, storedEntry));\n const appDefault = await getAgentAppModelDefaultForCurrentRequest(args.appId);\n const appDefaultEntry =\n typeof appDefault?.engine === \"string\"\n ? getAgentEngineEntry(appDefault.engine)\n : undefined;\n const appDefaultUsable =\n !!appDefault &&\n !!appDefaultEntry &&\n (await isStoredEngineUsableForRequest(appDefault, appDefaultEntry));\n const detectedFromUser = await detectEngineFromUserSecrets();\n const envEntry = process.env.AGENT_ENGINE\n ? getAgentEngineEntry(process.env.AGENT_ENGINE)\n : undefined;\n const envUsable =\n !!envEntry &&\n (await isStoredEngineUsableForRequest({ engine: envEntry.name }, envEntry));\n const envUnavailable = !!envEntry && !envUsable;\n const detectedFromEnv = detectEngineFromEnv();\n const envSelectedEntry = envUsable ? envEntry : undefined;\n\n const currentEntry = envUnavailable\n ? undefined\n : (envSelectedEntry ??\n (appDefaultUsable ? appDefaultEntry : undefined) ??\n (storedUsable ? storedEntry : undefined) ??\n detectedFromUser ??\n detectedFromEnv ??\n undefined);\n const currentModelCandidate =\n appDefaultUsable && currentEntry?.name === appDefault?.engine\n ? appDefault?.model\n : storedUsable && currentEntry?.name === current?.engine\n ? current?.model\n : undefined;\n const currentEngineName = currentEntry?.name ?? \"anthropic\";\n const currentModel =\n currentEntry && !envUnavailable\n ? normalizeModelForEngine(\n currentEntry,\n currentModelCandidate ?? currentEntry.defaultModel,\n )\n : (currentModelCandidate ?? DEFAULT_MODEL);\n const result = {\n engines: engines.map((e) => ({\n name: e.name,\n label: e.label,\n description: e.description,\n defaultModel: e.defaultModel,\n supportedModels: e.supportedModels,\n capabilities: e.capabilities,\n requiredEnvVars: e.requiredEnvVars,\n installPackage: e.installPackage,\n packageInstalled: isAgentEnginePackageInstalled(e),\n })),\n current: envUnavailable\n ? null\n : {\n engine: currentEngineName,\n model: currentModel,\n },\n };\n\n return JSON.stringify(result, null, 2);\n}\n"]}
1
+ {"version":3,"file":"list-agent-engines.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/list-agent-engines.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,wCAAwC,EAAE,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,IAAI,GAAe;IAC9B,WAAW,EACT,mNAAmN;IACrN,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAI,GAA2B,EAAE;IACzD,sBAAsB,EAAE,CAAC;IAEzB,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,cAAc;QAC5B,CAAC,CAAE,cAAsD;QACzD,CAAC,CAAC,IAAI,CAAC;IAET,yEAAyE;IACzE,6EAA6E;IAC7E,4EAA4E;IAC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AAE,CAAC,CAAC,YAAY;YAC5B,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,gBAAgB,EAAE,6BAA6B,CAAC,CAAC,CAAC;SACnD,CAAC,CAAC;QACH,OAAO,EAAE,cAAc;YACrB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACE,MAAM,EAAE,iBAAiB;gBACzB,KAAK,EAAE,YAAY;aACpB;KACN,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/**\n * list-agent-engines — returns the registered engine registry and current selection.\n */\n\nimport { getAgentAppModelDefaultForCurrentRequest } from \"../../agent/app-model-defaults.js\";\nimport { DEFAULT_MODEL } from \"../../agent/default-model.js\";\nimport {\n listAgentEngines,\n registerBuiltinEngines,\n detectEngineFromEnv,\n detectEngineFromUserSecrets,\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n isStoredEngineUsableForRequest,\n normalizeModelForEngine,\n resolveEnginePreservesCustomModels,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport { getSetting } from \"../../settings/index.js\";\n\nexport const tool: ActionTool = {\n description:\n 'List all available AI agent engines (Anthropic, OpenAI, Gemini, Groq, etc.) and the currently selected engine. Use this to check what engines are available before calling manage-agent-engine with action=\"set\".',\n parameters: {\n type: \"object\",\n properties: {},\n required: [],\n },\n};\n\nexport async function run(args: Record<string, string> = {}): Promise<string> {\n registerBuiltinEngines();\n\n const engines = listAgentEngines();\n const currentSetting = await getSetting(\"agent-engine\");\n const current = currentSetting\n ? (currentSetting as { engine?: string; model?: string })\n : null;\n\n // Same priority chain resolveEngine uses after explicit request options:\n // AGENT_ENGINE → app default → stored (if usable) → user/Builder app_secrets\n // → env → anthropic. Gating stored/app defaults on the request-aware helper\n // keeps the picker in step with the runtime.\n const storedEntry =\n typeof current?.engine === \"string\"\n ? getAgentEngineEntry(current.engine)\n : undefined;\n const storedUsable =\n !!storedEntry &&\n (await isStoredEngineUsableForRequest(current, storedEntry));\n const appDefault = await getAgentAppModelDefaultForCurrentRequest(args.appId);\n const appDefaultEntry =\n typeof appDefault?.engine === \"string\"\n ? getAgentEngineEntry(appDefault.engine)\n : undefined;\n const appDefaultUsable =\n !!appDefault &&\n !!appDefaultEntry &&\n (await isStoredEngineUsableForRequest(appDefault, appDefaultEntry));\n const detectedFromUser = await detectEngineFromUserSecrets();\n const envEntry = process.env.AGENT_ENGINE\n ? getAgentEngineEntry(process.env.AGENT_ENGINE)\n : undefined;\n const envUsable =\n !!envEntry &&\n (await isStoredEngineUsableForRequest({ engine: envEntry.name }, envEntry));\n const envUnavailable = !!envEntry && !envUsable;\n const detectedFromEnv = detectEngineFromEnv();\n const envSelectedEntry = envUsable ? envEntry : undefined;\n\n const currentEntry = envUnavailable\n ? undefined\n : (envSelectedEntry ??\n (appDefaultUsable ? appDefaultEntry : undefined) ??\n (storedUsable ? storedEntry : undefined) ??\n detectedFromUser ??\n detectedFromEnv ??\n undefined);\n const currentModelCandidate =\n appDefaultUsable && currentEntry?.name === appDefault?.engine\n ? appDefault?.model\n : storedUsable && currentEntry?.name === current?.engine\n ? current?.model\n : undefined;\n const currentEngineName = currentEntry?.name ?? \"anthropic\";\n // Resolve the OpenAI-compatible-endpoint capability so a custom gateway model\n // is reported as-is instead of being normalized to the engine default — the\n // read-side counterpart of the same fix in set-/manage-agent-engine.\n const preserveCustomModels = currentEntry\n ? await resolveEnginePreservesCustomModels(currentEntry)\n : false;\n const currentModel =\n currentEntry && !envUnavailable\n ? normalizeModelForEngine(\n currentEntry,\n currentModelCandidate ?? currentEntry.defaultModel,\n { preserveCustomModels },\n )\n : (currentModelCandidate ?? DEFAULT_MODEL);\n const result = {\n engines: engines.map((e) => ({\n name: e.name,\n label: e.label,\n description: e.description,\n defaultModel: e.defaultModel,\n supportedModels: e.supportedModels,\n capabilities: e.capabilities,\n requiredEnvVars: e.requiredEnvVars,\n installPackage: e.installPackage,\n packageInstalled: isAgentEnginePackageInstalled(e),\n })),\n current: envUnavailable\n ? null\n : {\n engine: currentEngineName,\n model: currentModel,\n },\n };\n\n return JSON.stringify(result, null, 2);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"manage-agent-engine.d.ts","sourceRoot":"","sources":["../../../src/scripts/agent-engines/manage-agent-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD,eAAO,MAAM,IAAI,EAAE,UA0ClB,CAAC;AAwGF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBvE"}
1
+ {"version":3,"file":"manage-agent-engine.d.ts","sourceRoot":"","sources":["../../../src/scripts/agent-engines/manage-agent-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASvD,eAAO,MAAM,IAAI,EAAE,UA0ClB,CAAC;AA2GF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBvE"}
@@ -5,7 +5,7 @@
5
5
  * tools into a single tool with an `action` discriminator.
6
6
  */
7
7
  import { canUpdateAgentAppModelDefaultSettings, normalizeAgentAppModelDefaultAppId, readAgentAppModelDefaultSettings, resetAgentAppModelDefaultSettings, writeAgentAppModelDefaultSettings, } from "../../agent/app-model-defaults.js";
8
- import { getAgentEngineEntry, isAgentEnginePackageInstalled, normalizeModelForEngine, registerBuiltinEngines, } from "../../agent/engine/index.js";
8
+ import { getAgentEngineEntry, isAgentEnginePackageInstalled, normalizeModelForEngine, resolveEnginePreservesCustomModels, registerBuiltinEngines, } from "../../agent/engine/index.js";
9
9
  import { getRequestOrgId, getRequestUserEmail, } from "../../server/request-context.js";
10
10
  import { run as runList } from "./list-agent-engines.js";
11
11
  import { run as runSet } from "./set-agent-engine.js";
@@ -87,7 +87,10 @@ async function runSetAppDefault(args) {
87
87
  if (!isAgentEnginePackageInstalled(entry)) {
88
88
  return `Error: Engine "${engine}" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;
89
89
  }
90
- const normalizedModel = normalizeModelForEngine(entry, model);
90
+ const preserveCustomModels = await resolveEnginePreservesCustomModels(entry);
91
+ const normalizedModel = normalizeModelForEngine(entry, model, {
92
+ preserveCustomModels,
93
+ });
91
94
  const ctx = currentContext();
92
95
  const canUpdate = await canUpdateAgentAppModelDefaultSettings(ctx.userEmail, ctx.orgId);
93
96
  if (!canUpdate) {
@@ -1 +1 @@
1
- {"version":3,"file":"manage-agent-engine.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/manage-agent-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qCAAqC,EACrC,kCAAkC,EAClC,gCAAgC,EAChC,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,MAAM,IAAI,GAAe;IAC9B,WAAW,EACT,+ZAA+Z;IACja,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ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IAAI,CAAC,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,KAAK,iBAAiB;YACpB,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,iBAAiB;YACpB,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,mBAAmB;YACtB,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAClC;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,mBAAmB,MAAM,0FAA0F;aAC3H,CAAC,CAAC;IACP,CAAC;AACH,CAAC","sourcesContent":["/**\n * manage-agent-engine — unified tool for listing, setting, and testing agent engines.\n *\n * Consolidates the former list-agent-engines, set-agent-engine, and test-agent-engine\n * tools into a single tool with an `action` discriminator.\n */\n\nimport {\n canUpdateAgentAppModelDefaultSettings,\n normalizeAgentAppModelDefaultAppId,\n readAgentAppModelDefaultSettings,\n resetAgentAppModelDefaultSettings,\n writeAgentAppModelDefaultSettings,\n} from \"../../agent/app-model-defaults.js\";\nimport {\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n normalizeModelForEngine,\n registerBuiltinEngines,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../server/request-context.js\";\nimport { run as runList } from \"./list-agent-engines.js\";\nimport { run as runSet } from \"./set-agent-engine.js\";\nimport { run as runTest } from \"./test-agent-engine.js\";\n\nexport const tool: ActionTool = {\n description:\n 'Manage AI agent engines: list available engines, set the active global engine/model, test an engine, or manage the current app/template default model. Pass action=\"list\" to see options, action=\"set\" to change the global default, action=\"test\" to verify connectivity, action=\"get-app-default\" to inspect this app default, action=\"set-app-default\" to set this app default, or action=\"reset-app-default\" to clear it.',\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n enum: [\n \"list\",\n \"set\",\n \"test\",\n \"get-app-default\",\n \"set-app-default\",\n \"reset-app-default\",\n ],\n description:\n '\"list\" — show available engines and current global selection. \"set\" — change the active global engine/model. \"test\" — send a trivial prompt to verify connectivity. \"get-app-default\" — show this app/template default. \"set-app-default\" — set this app/template default. \"reset-app-default\" — clear this app/template default.',\n },\n engine: {\n type: \"string\",\n description:\n 'Engine name (e.g. \"builder\", \"anthropic\", \"ai-sdk:openai\", \"ai-sdk:google\"). Required for \"set\" and \"set-app-default\", optional for \"test\" (defaults to \"anthropic\").',\n },\n model: {\n type: \"string\",\n description:\n \"Model ID (e.g. 'gpt-5.6-sol', 'claude-sonnet-5', 'gemini-3-1-pro'). Required for \\\"set-app-default\\\"; optional for \\\"set\\\" and \\\"test\\\" where it defaults to the engine's default model.\",\n },\n baseUrl: {\n type: \"string\",\n description:\n 'Optional OpenAI-compatible endpoint URL for action=\"test\" with engine=\"ai-sdk:openai\". Saved endpoint settings are used when omitted.',\n },\n appId: {\n type: \"string\",\n description:\n \"App/template id whose default model should be managed. Defaults to the current app.\",\n },\n },\n required: [\"action\"],\n },\n};\n\nfunction currentContext(): { userEmail?: string; orgId?: string | null } {\n try {\n return {\n userEmail: getRequestUserEmail(),\n orgId: getRequestOrgId(),\n };\n } catch {\n return {};\n }\n}\n\nfunction resolveAppId(args: Record<string, string>): string | null {\n return normalizeAgentAppModelDefaultAppId(args.appId);\n}\n\nasync function runGetAppDefault(args: Record<string, string>): Promise<string> {\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n const ctx = currentContext();\n const settings = await readAgentAppModelDefaultSettings(ctx, appId);\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n return JSON.stringify({ ok: true, ...settings, canUpdate }, null, 2);\n}\n\nasync function runSetAppDefault(args: Record<string, string>): Promise<string> {\n registerBuiltinEngines();\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n\n const engine = args.engine?.trim();\n const model = args.model?.trim();\n if (!engine) return \"Error: engine is required\";\n if (!model) return \"Error: model is required\";\n\n const entry = getAgentEngineEntry(engine);\n if (!entry) return `Error: Unknown engine \"${engine}\"`;\n if (!isAgentEnginePackageInstalled(entry)) {\n return `Error: Engine \"${engine}\" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;\n }\n const normalizedModel = normalizeModelForEngine(entry, model);\n\n const ctx = currentContext();\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n if (!canUpdate) {\n return ctx.orgId\n ? \"Error: Only organization owners and admins can change app model defaults.\"\n : \"Error: Authentication required to change app model defaults.\";\n }\n\n const settings = await writeAgentAppModelDefaultSettings(ctx, appId, {\n engine,\n model: normalizedModel,\n updatedBy: ctx.userEmail,\n });\n const normalizedNote =\n normalizedModel === model\n ? \"\"\n : ` Requested model \"${model}\" is no longer supported, so \"${normalizedModel}\" was saved instead.`;\n return JSON.stringify(\n {\n ok: true,\n ...settings,\n message: `Default model for ${appId} set to ${normalizedModel} via ${entry.label}.${normalizedNote}`,\n },\n null,\n 2,\n );\n}\n\nasync function runResetAppDefault(\n args: Record<string, string>,\n): Promise<string> {\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n const ctx = currentContext();\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n if (!canUpdate) {\n return ctx.orgId\n ? \"Error: Only organization owners and admins can reset app model defaults.\"\n : \"Error: Authentication required to reset app model defaults.\";\n }\n const settings = await resetAgentAppModelDefaultSettings(ctx, appId);\n return JSON.stringify(\n {\n ok: true,\n ...settings,\n message: `Default model for ${appId} reset to the global LLM default.`,\n },\n null,\n 2,\n );\n}\n\nexport async function run(args: Record<string, string>): Promise<string> {\n const { action } = args;\n\n switch (action) {\n case \"list\":\n return runList(args);\n case \"set\":\n return runSet(args);\n case \"test\":\n return runTest(args);\n case \"get-app-default\":\n return runGetAppDefault(args);\n case \"set-app-default\":\n return runSetAppDefault(args);\n case \"reset-app-default\":\n return runResetAppDefault(args);\n default:\n return JSON.stringify({\n error: `Unknown action \"${action}\". Must be one of: list, set, test, get-app-default, set-app-default, reset-app-default.`,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"manage-agent-engine.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/manage-agent-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qCAAqC,EACrC,kCAAkC,EAClC,gCAAgC,EAChC,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,uBAAuB,EACvB,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,MAAM,IAAI,GAAe;IAC9B,WAAW,EACT,+ZAA+Z;IACja,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE;oBACJ,MAAM;oBACN,KAAK;oBACL,MAAM;oBACN,iBAAiB;oBACjB,iBAAiB;oBACjB,mBAAmB;iBACpB;gBACD,WAAW,EACT,mUAAmU;aACtU;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,uKAAuK;aAC1K;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,0LAA0L;aAC7L;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,uIAAuI;aAC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AC;QAClC;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,mBAAmB,MAAM,0FAA0F;aAC3H,CAAC,CAAC;IACP,CAAC;AACH,CAAC","sourcesContent":["/**\n * manage-agent-engine — unified tool for listing, setting, and testing agent engines.\n *\n * Consolidates the former list-agent-engines, set-agent-engine, and test-agent-engine\n * tools into a single tool with an `action` discriminator.\n */\n\nimport {\n canUpdateAgentAppModelDefaultSettings,\n normalizeAgentAppModelDefaultAppId,\n readAgentAppModelDefaultSettings,\n resetAgentAppModelDefaultSettings,\n writeAgentAppModelDefaultSettings,\n} from \"../../agent/app-model-defaults.js\";\nimport {\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n normalizeModelForEngine,\n resolveEnginePreservesCustomModels,\n registerBuiltinEngines,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../server/request-context.js\";\nimport { run as runList } from \"./list-agent-engines.js\";\nimport { run as runSet } from \"./set-agent-engine.js\";\nimport { run as runTest } from \"./test-agent-engine.js\";\n\nexport const tool: ActionTool = {\n description:\n 'Manage AI agent engines: list available engines, set the active global engine/model, test an engine, or manage the current app/template default model. Pass action=\"list\" to see options, action=\"set\" to change the global default, action=\"test\" to verify connectivity, action=\"get-app-default\" to inspect this app default, action=\"set-app-default\" to set this app default, or action=\"reset-app-default\" to clear it.',\n parameters: {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n enum: [\n \"list\",\n \"set\",\n \"test\",\n \"get-app-default\",\n \"set-app-default\",\n \"reset-app-default\",\n ],\n description:\n '\"list\" — show available engines and current global selection. \"set\" — change the active global engine/model. \"test\" — send a trivial prompt to verify connectivity. \"get-app-default\" — show this app/template default. \"set-app-default\" — set this app/template default. \"reset-app-default\" — clear this app/template default.',\n },\n engine: {\n type: \"string\",\n description:\n 'Engine name (e.g. \"builder\", \"anthropic\", \"ai-sdk:openai\", \"ai-sdk:google\"). Required for \"set\" and \"set-app-default\", optional for \"test\" (defaults to \"anthropic\").',\n },\n model: {\n type: \"string\",\n description:\n \"Model ID (e.g. 'gpt-5.6-sol', 'claude-sonnet-5', 'gemini-3-1-pro'). Required for \\\"set-app-default\\\"; optional for \\\"set\\\" and \\\"test\\\" where it defaults to the engine's default model.\",\n },\n baseUrl: {\n type: \"string\",\n description:\n 'Optional OpenAI-compatible endpoint URL for action=\"test\" with engine=\"ai-sdk:openai\". Saved endpoint settings are used when omitted.',\n },\n appId: {\n type: \"string\",\n description:\n \"App/template id whose default model should be managed. Defaults to the current app.\",\n },\n },\n required: [\"action\"],\n },\n};\n\nfunction currentContext(): { userEmail?: string; orgId?: string | null } {\n try {\n return {\n userEmail: getRequestUserEmail(),\n orgId: getRequestOrgId(),\n };\n } catch {\n return {};\n }\n}\n\nfunction resolveAppId(args: Record<string, string>): string | null {\n return normalizeAgentAppModelDefaultAppId(args.appId);\n}\n\nasync function runGetAppDefault(args: Record<string, string>): Promise<string> {\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n const ctx = currentContext();\n const settings = await readAgentAppModelDefaultSettings(ctx, appId);\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n return JSON.stringify({ ok: true, ...settings, canUpdate }, null, 2);\n}\n\nasync function runSetAppDefault(args: Record<string, string>): Promise<string> {\n registerBuiltinEngines();\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n\n const engine = args.engine?.trim();\n const model = args.model?.trim();\n if (!engine) return \"Error: engine is required\";\n if (!model) return \"Error: model is required\";\n\n const entry = getAgentEngineEntry(engine);\n if (!entry) return `Error: Unknown engine \"${engine}\"`;\n if (!isAgentEnginePackageInstalled(entry)) {\n return `Error: Engine \"${engine}\" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;\n }\n const preserveCustomModels = await resolveEnginePreservesCustomModels(entry);\n const normalizedModel = normalizeModelForEngine(entry, model, {\n preserveCustomModels,\n });\n\n const ctx = currentContext();\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n if (!canUpdate) {\n return ctx.orgId\n ? \"Error: Only organization owners and admins can change app model defaults.\"\n : \"Error: Authentication required to change app model defaults.\";\n }\n\n const settings = await writeAgentAppModelDefaultSettings(ctx, appId, {\n engine,\n model: normalizedModel,\n updatedBy: ctx.userEmail,\n });\n const normalizedNote =\n normalizedModel === model\n ? \"\"\n : ` Requested model \"${model}\" is no longer supported, so \"${normalizedModel}\" was saved instead.`;\n return JSON.stringify(\n {\n ok: true,\n ...settings,\n message: `Default model for ${appId} set to ${normalizedModel} via ${entry.label}.${normalizedNote}`,\n },\n null,\n 2,\n );\n}\n\nasync function runResetAppDefault(\n args: Record<string, string>,\n): Promise<string> {\n const appId = resolveAppId(args);\n if (!appId) return \"Error: appId is required\";\n const ctx = currentContext();\n const canUpdate = await canUpdateAgentAppModelDefaultSettings(\n ctx.userEmail,\n ctx.orgId,\n );\n if (!canUpdate) {\n return ctx.orgId\n ? \"Error: Only organization owners and admins can reset app model defaults.\"\n : \"Error: Authentication required to reset app model defaults.\";\n }\n const settings = await resetAgentAppModelDefaultSettings(ctx, appId);\n return JSON.stringify(\n {\n ok: true,\n ...settings,\n message: `Default model for ${appId} reset to the global LLM default.`,\n },\n null,\n 2,\n );\n}\n\nexport async function run(args: Record<string, string>): Promise<string> {\n const { action } = args;\n\n switch (action) {\n case \"list\":\n return runList(args);\n case \"set\":\n return runSet(args);\n case \"test\":\n return runTest(args);\n case \"get-app-default\":\n return runGetAppDefault(args);\n case \"set-app-default\":\n return runSetAppDefault(args);\n case \"reset-app-default\":\n return runResetAppDefault(args);\n default:\n return JSON.stringify({\n error: `Unknown action \"${action}\". Must be one of: list, set, test, get-app-default, set-app-default, reset-app-default.`,\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"set-agent-engine.d.ts","sourceRoot":"","sources":["../../../src/scripts/agent-engines/set-agent-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAO,MAAM,IAAI,EAAE,UAmBlB,CAAC;AAEF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CA+CvE"}
1
+ {"version":3,"file":"set-agent-engine.d.ts","sourceRoot":"","sources":["../../../src/scripts/agent-engines/set-agent-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,eAAO,MAAM,IAAI,EAAE,UAmBlB,CAAC;AAEF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDvE"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * set-agent-engine — validates and writes agent engine selection to settings.
3
3
  */
4
- import { listAgentEngines, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, normalizeModelForEngine, registerBuiltinEngines, } from "../../agent/engine/index.js";
4
+ import { listAgentEngines, getAgentEngineEntry, isAgentEnginePackageInstalled, isStoredEngineUsableForRequest, normalizeModelForEngine, resolveEnginePreservesCustomModels, registerBuiltinEngines, } from "../../agent/engine/index.js";
5
5
  import { putSetting } from "../../settings/index.js";
6
6
  export const tool = {
7
7
  description: 'Set the active AI agent engine and model. Changes take effect on the next conversation. Use manage-agent-engine with action="list" first to see available options.',
@@ -36,7 +36,14 @@ export async function run(args) {
36
36
  return `Error: Engine "${engineName}" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;
37
37
  }
38
38
  const requestedModel = model ?? entry.defaultModel;
39
- const resolvedModel = normalizeModelForEngine(entry, requestedModel);
39
+ // A static registry entry can't carry the runtime `preserveCustomModels`
40
+ // flag, so resolve the OpenAI-compatible-endpoint capability here and pass it
41
+ // through — otherwise a gateway model (e.g. an Ollama id) is rewritten to the
42
+ // engine default on save.
43
+ const preserveCustomModels = await resolveEnginePreservesCustomModels(entry);
44
+ const resolvedModel = normalizeModelForEngine(entry, requestedModel, {
45
+ preserveCustomModels,
46
+ });
40
47
  const usable = await isStoredEngineUsableForRequest({ engine: engineName }, entry);
41
48
  if (!usable) {
42
49
  const missingEnvVars = entry.requiredEnvVars.join(", ");
@@ -1 +1 @@
1
- {"version":3,"file":"set-agent-engine.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/set-agent-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,IAAI,GAAe;IAC9B,WAAW,EACT,oKAAoK;IACtK,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kIAAkI;aACrI;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8HAA8H;aACjI;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAA4B;IACpD,sBAAsB,EAAE,CAAC;IAEzB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE3C,IAAI,CAAC,UAAU;QAAE,OAAO,6BAA6B,CAAC;IAEtD,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;Q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ection to settings.\n */\n\nimport {\n listAgentEngines,\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n isStoredEngineUsableForRequest,\n normalizeModelForEngine,\n registerBuiltinEngines,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport { putSetting } from \"../../settings/index.js\";\n\nexport const tool: ActionTool = {\n description:\n 'Set the active AI agent engine and model. Changes take effect on the next conversation. Use manage-agent-engine with action=\"list\" first to see available options.',\n parameters: {\n type: \"object\",\n properties: {\n engine: {\n type: \"string\",\n description:\n 'Engine name (e.g. \"anthropic\", \"ai-sdk:openai\", \"ai-sdk:google\"). Use manage-agent-engine with action=\"list\" to see all options.',\n },\n model: {\n type: \"string\",\n description:\n \"Model ID to use with this engine (e.g. 'gpt-5.6-sol', 'claude-sonnet-5'). Defaults to the engine's default model if omitted.\",\n },\n },\n required: [\"engine\"],\n },\n};\n\nexport async function run(args: Record<string, string>): Promise<string> {\n registerBuiltinEngines();\n\n const { engine: engineName, model } = args;\n\n if (!engineName) return \"Error: --engine is required\";\n\n const entry = getAgentEngineEntry(engineName);\n if (!entry) {\n const available = listAgentEngines()\n .map((e) => e.name)\n .join(\", \");\n return `Error: Engine \"${engineName}\" not found. Available engines: ${available}`;\n }\n\n if (!isAgentEnginePackageInstalled(entry)) {\n return `Error: Engine \"${engineName}\" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;\n }\n\n const requestedModel = model ?? entry.defaultModel;\n const resolvedModel = normalizeModelForEngine(entry, requestedModel);\n\n const usable = await isStoredEngineUsableForRequest(\n { engine: engineName },\n entry,\n );\n if (!usable) {\n const missingEnvVars = entry.requiredEnvVars.join(\", \");\n return `Warning: Engine \"${engineName}\" requires the following credentials which are not configured for this request: ${missingEnvVars}. The engine will fail at runtime without them.`;\n }\n\n await putSetting(\"agent-engine\", {\n engine: engineName,\n model: resolvedModel,\n });\n\n const normalizedNote =\n resolvedModel === requestedModel\n ? \"\"\n : ` Requested model \"${requestedModel}\" is no longer supported, so \"${resolvedModel}\" was saved instead.`;\n\n return JSON.stringify({\n ok: true,\n engine: engineName,\n model: resolvedModel,\n message: `Agent engine set to ${entry.label} with model ${resolvedModel}. Takes effect on the next conversation.${normalizedNote}`,\n });\n}\n"]}
1
+ {"version":3,"file":"set-agent-engine.js","sourceRoot":"","sources":["../../../src/scripts/agent-engines/set-agent-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,EACvB,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,IAAI,GAAe;IAC9B,WAAW,EACT,oKAAoK;IACtK,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kIAAkI;aACrI;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8HAA8H;aACjI;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAA4B;IACpD,sBAAsB,EAAE,CAAC;IAEzB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE3C,IAAI,CAAC,UAAU;QAAE,OAAO,6BAA6B,CAAC;IAEtD,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,SAAS,GAAG,gBAAgB,EAAE;aACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OA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ine selection to settings.\n */\n\nimport {\n listAgentEngines,\n getAgentEngineEntry,\n isAgentEnginePackageInstalled,\n isStoredEngineUsableForRequest,\n normalizeModelForEngine,\n resolveEnginePreservesCustomModels,\n registerBuiltinEngines,\n} from \"../../agent/engine/index.js\";\nimport type { ActionTool } from \"../../agent/types.js\";\nimport { putSetting } from \"../../settings/index.js\";\n\nexport const tool: ActionTool = {\n description:\n 'Set the active AI agent engine and model. Changes take effect on the next conversation. Use manage-agent-engine with action=\"list\" first to see available options.',\n parameters: {\n type: \"object\",\n properties: {\n engine: {\n type: \"string\",\n description:\n 'Engine name (e.g. \"anthropic\", \"ai-sdk:openai\", \"ai-sdk:google\"). Use manage-agent-engine with action=\"list\" to see all options.',\n },\n model: {\n type: \"string\",\n description:\n \"Model ID to use with this engine (e.g. 'gpt-5.6-sol', 'claude-sonnet-5'). Defaults to the engine's default model if omitted.\",\n },\n },\n required: [\"engine\"],\n },\n};\n\nexport async function run(args: Record<string, string>): Promise<string> {\n registerBuiltinEngines();\n\n const { engine: engineName, model } = args;\n\n if (!engineName) return \"Error: --engine is required\";\n\n const entry = getAgentEngineEntry(engineName);\n if (!entry) {\n const available = listAgentEngines()\n .map((e) => e.name)\n .join(\", \");\n return `Error: Engine \"${engineName}\" not found. Available engines: ${available}`;\n }\n\n if (!isAgentEnginePackageInstalled(entry)) {\n return `Error: Engine \"${engineName}\" requires optional packages that are not installed in this app. Run: pnpm add ${entry.installPackage}`;\n }\n\n const requestedModel = model ?? entry.defaultModel;\n // A static registry entry can't carry the runtime `preserveCustomModels`\n // flag, so resolve the OpenAI-compatible-endpoint capability here and pass it\n // through — otherwise a gateway model (e.g. an Ollama id) is rewritten to the\n // engine default on save.\n const preserveCustomModels = await resolveEnginePreservesCustomModels(entry);\n const resolvedModel = normalizeModelForEngine(entry, requestedModel, {\n preserveCustomModels,\n });\n\n const usable = await isStoredEngineUsableForRequest(\n { engine: engineName },\n entry,\n );\n if (!usable) {\n const missingEnvVars = entry.requiredEnvVars.join(\", \");\n return `Warning: Engine \"${engineName}\" requires the following credentials which are not configured for this request: ${missingEnvVars}. The engine will fail at runtime without them.`;\n }\n\n await putSetting(\"agent-engine\", {\n engine: engineName,\n model: resolvedModel,\n });\n\n const normalizedNote =\n resolvedModel === requestedModel\n ? \"\"\n : ` Requested model \"${requestedModel}\" is no longer supported, so \"${resolvedModel}\" was saved instead.`;\n\n return JSON.stringify({\n ok: true,\n engine: engineName,\n model: resolvedModel,\n message: `Agent engine set to ${entry.label} with model ${resolvedModel}. Takes effect on the next conversation.${normalizedNote}`,\n });\n}\n"]}
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- ok?: undefined;
38
37
  status?: undefined;
38
+ ok?: undefined;
39
39
  } | {
40
- error?: undefined;
41
40
  ok: boolean;
42
41
  status: string;
42
+ error?: undefined;
43
43
  } | {
44
- ok?: undefined;
45
44
  error: string;
46
45
  removed?: undefined;
46
+ ok?: undefined;
47
47
  } | {
48
- error?: undefined;
49
48
  ok: boolean;
50
49
  removed: boolean;
50
+ error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — re-run the validator against the
54
54
  * current stored value without changing anything. Useful for the "Test" button.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
- ok?: undefined;
58
57
  error: string;
59
58
  note?: undefined;
59
+ ok?: undefined;
60
60
  } | {
61
- error?: undefined;
62
61
  ok: boolean;
63
62
  note?: undefined;
64
- } | {
65
63
  error?: undefined;
64
+ } | {
66
65
  ok: boolean;
67
66
  note: string;
67
+ error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
- error?: undefined;
99
98
  ok: boolean;
100
99
  key: string;
101
- } | {
102
100
  error?: undefined;
101
+ } | {
103
102
  ok: boolean;
104
103
  removed: boolean;
104
+ error?: undefined;
105
105
  }>>;
106
106
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"framework-prompts.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,6BAA6B,EAE9B,MAAM,oBAAoB,CAAC;AAY5B;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,cAAc,EACzB,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1E;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6BAA6B,EAAE,MAAM,CAAC;IACtC,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAoLA;AAED,eAAO,MAAM,gCAAgC;;;;;;;;CAezC,CAAC;AAEL;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,aAAa,GAAE,mBAA4B,GAC1C,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;;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Ac,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6BAA6B,EAAE,MAAM,CAAC;IACtC,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAoLA;AAED,eAAO,MAAM,gCAAgC;;;;;;;;CAezC,CAAC;AAEL;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,aAAa,GAAE,mBAA4B,GAC1C,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,IAAI,GAAE,KAAK,GAAG,MAAe,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,MAAM,CA6ER;AAoBD,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,MAAM,EAAE,CAEV;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GACpC,MAAM,CAkCR;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC,GACtE,OAAO,CAAC,IAAI,CAAC,CAqCf"}
@@ -352,7 +352,9 @@ export function generateCorpusToolsPrompt(registry) {
352
352
 
353
353
  Available corpus-capable tools: ${available.join(", ")}.
354
354
 
355
- For broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification/counting over 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.
355
+ This 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.
356
+
357
+ For 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.
356
358
 
357
359
  When \`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.`;
358
360
  }
@@ -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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AAc;QACd,MAAM;QACN,OAAO;QACP,SAAS;QACT,MAAM;QACN,QAAQ;QACR,QAAQ;QACR,MAAM;KACP,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\";\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\nFor broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification/counting over 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;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;;;;;;;;GAQ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AG,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\";\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"]}
@@ -192,6 +192,15 @@ export interface AgentChatPluginOptions {
192
192
  * tool-search unless the app explicitly includes them in this list.
193
193
  */
194
194
  initialToolNames?: string[];
195
+ /**
196
+ * Controls whether broad provider/corpus tools and their workflow prompt are
197
+ * loaded into the first model request. Use `"lazy"` for apps that can answer
198
+ * ordinary lookups from a compact curated tool set; corpus tools remain
199
+ * discoverable through tool-search and the full retry surface.
200
+ *
201
+ * @default "initial"
202
+ */
203
+ corpusTools?: "initial" | "lazy";
195
204
  /**
196
205
  * Use a compact system prompt with on-demand context loading. The system
197
206
  * prompt includes essential behavioral rules and action signatures, but
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-options.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,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