@agent-native/core 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (844) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +32 -0
  3. package/corpus/core/docs/content/authentication.mdx +3 -3
  4. package/corpus/core/docs/content/doctor.mdx +170 -0
  5. package/corpus/core/docs/content/external-agents.mdx +8 -7
  6. package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +2 -2
  7. package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +8 -7
  8. package/corpus/core/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
  9. package/corpus/core/docs/content/locales/ar-SA/security.mdx +2 -0
  10. package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
  11. package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +8 -7
  12. package/corpus/core/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
  13. package/corpus/core/docs/content/locales/de-DE/security.mdx +2 -0
  14. package/corpus/core/docs/content/locales/es-ES/authentication.mdx +2 -2
  15. package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +8 -7
  16. package/corpus/core/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
  17. package/corpus/core/docs/content/locales/es-ES/security.mdx +2 -0
  18. package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
  19. package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +8 -7
  20. package/corpus/core/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
  21. package/corpus/core/docs/content/locales/fr-FR/security.mdx +2 -0
  22. package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +2 -2
  23. package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +8 -7
  24. package/corpus/core/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
  25. package/corpus/core/docs/content/locales/hi-IN/security.mdx +2 -0
  26. package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +2 -2
  27. package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +8 -7
  28. package/corpus/core/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
  29. package/corpus/core/docs/content/locales/ja-JP/security.mdx +2 -0
  30. package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +2 -2
  31. package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +8 -7
  32. package/corpus/core/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
  33. package/corpus/core/docs/content/locales/ko-KR/security.mdx +2 -0
  34. package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +2 -2
  35. package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +8 -7
  36. package/corpus/core/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
  37. package/corpus/core/docs/content/locales/pt-BR/security.mdx +2 -0
  38. package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +2 -2
  39. package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -7
  40. package/corpus/core/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
  41. package/corpus/core/docs/content/locales/zh-CN/security.mdx +2 -0
  42. package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +2 -2
  43. package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -7
  44. package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
  45. package/corpus/core/docs/content/locales/zh-TW/security.mdx +2 -0
  46. package/corpus/core/docs/content/mcp-protocol.mdx +1 -1
  47. package/corpus/core/docs/content/security.mdx +2 -0
  48. package/corpus/core/package.json +5 -1
  49. package/corpus/core/scripts/finalize-build.mjs +63 -3
  50. package/corpus/core/scripts/materialize-source-corpus.mjs +101 -15
  51. package/corpus/core/src/action.ts +42 -0
  52. package/corpus/core/src/agent/engine/builder-engine.ts +3 -0
  53. package/corpus/core/src/agent/engine/context-directives-transform.ts +69 -0
  54. package/corpus/core/src/agent/engine/continuation-dispatch-retry.ts +168 -0
  55. package/corpus/core/src/agent/engine/tool-call-journal-seed.ts +85 -0
  56. package/corpus/core/src/agent/production-agent.ts +129 -244
  57. package/corpus/core/src/cli/doctor.ts +9 -3
  58. package/corpus/core/src/cli/plan-local.ts +10 -2
  59. package/corpus/core/src/cli/skills-content/assets-skill.ts +83 -0
  60. package/corpus/core/src/cli/skills-content/canvas.ts +153 -0
  61. package/corpus/core/src/cli/skills-content/connection.ts +52 -0
  62. package/corpus/core/src/cli/skills-content/content-skill.ts +109 -0
  63. package/corpus/core/src/cli/skills-content/design-exploration-skill.ts +118 -0
  64. package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
  65. package/corpus/core/src/cli/skills-content/document-quality.ts +196 -0
  66. package/corpus/core/src/cli/skills-content/exemplar.ts +69 -0
  67. package/corpus/core/src/cli/skills-content/help.ts +77 -0
  68. package/corpus/core/src/cli/skills-content/index.ts +22 -0
  69. package/corpus/core/src/cli/skills-content/local-files.ts +95 -0
  70. package/corpus/core/src/cli/skills-content/plan-setup-auth.ts +80 -0
  71. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +470 -0
  72. package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +547 -0
  73. package/corpus/core/src/cli/skills-content/visualize-repo-skill.ts +93 -0
  74. package/corpus/core/src/cli/skills-content/wireframe.ts +349 -0
  75. package/corpus/core/src/cli/skills.ts +27 -2733
  76. package/corpus/core/src/client/AgentPanel.tsx +6 -5
  77. package/corpus/core/src/client/CommandMenu.tsx +16 -5
  78. package/corpus/core/src/client/FeedbackButton.tsx +2 -2
  79. package/corpus/core/src/client/app-providers.tsx +18 -5
  80. package/corpus/core/src/client/chat/tool-call-display.tsx +3 -3
  81. package/corpus/core/src/client/composer/PastedTextChip.tsx +1 -1
  82. package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +143 -45
  83. package/corpus/core/src/client/composer/TiptapComposer.tsx +1 -1
  84. package/corpus/core/src/client/composer/VoiceButton.tsx +21 -5
  85. package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +107 -10
  86. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +5 -2
  87. package/corpus/core/src/client/extensions/ExtensionEditor.tsx +37 -4
  88. package/corpus/core/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
  89. package/corpus/core/src/client/extensions/ExtensionSlot.tsx +39 -10
  90. package/corpus/core/src/client/extensions/ExtensionViewer.tsx +44 -6
  91. package/corpus/core/src/client/extensions/ExtensionsListPage.tsx +12 -3
  92. package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +49 -11
  93. package/corpus/core/src/client/index.ts +0 -13
  94. package/corpus/core/src/client/progress/RunsTray.tsx +10 -3
  95. package/corpus/core/src/client/settings/SettingsTabsPage.tsx +7 -0
  96. package/corpus/core/src/client/settings/useBuilderStatus.ts +6 -0
  97. package/corpus/core/src/client/tool-cells/EditCell.tsx +19 -16
  98. package/corpus/core/src/client/tool-cells/FilesChangedSummary.tsx +26 -23
  99. package/corpus/core/src/client/tool-cells/WriteCell.tsx +19 -16
  100. package/corpus/core/src/client/visual-style-controls.tsx +1 -1
  101. package/corpus/core/src/deploy/build.ts +36 -14
  102. package/corpus/core/src/integrations/google-docs-poller.ts +23 -2
  103. package/corpus/core/src/integrations/plugin.ts +10 -0
  104. package/corpus/core/src/integrations/webhook-handler.ts +27 -2
  105. package/corpus/core/src/jobs/scheduler.ts +28 -2
  106. package/corpus/core/src/localization/default-messages.ts +8 -1
  107. package/corpus/core/src/mcp/oauth-token.ts +6 -1
  108. package/corpus/core/src/observability/routes.ts +36 -0
  109. package/corpus/core/src/observability/sentiment.ts +261 -0
  110. package/corpus/core/src/observability/store.ts +23 -0
  111. package/corpus/core/src/observability/traces.ts +49 -63
  112. package/corpus/core/src/observability/tracking-identity.ts +55 -0
  113. package/corpus/core/src/observability/types.ts +13 -0
  114. package/corpus/core/src/secrets/storage.ts +67 -3
  115. package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +199 -0
  116. package/corpus/core/src/server/agent-chat/browser-team-tools.ts +510 -0
  117. package/corpus/core/src/server/agent-chat/context-tools.ts +595 -0
  118. package/corpus/core/src/server/agent-chat/framework-prompts.ts +470 -0
  119. package/corpus/core/src/server/agent-chat/lazy-fs.ts +11 -0
  120. package/corpus/core/src/server/agent-chat/mcp-glue.ts +91 -0
  121. package/corpus/core/src/server/agent-chat/plugin-options.ts +350 -0
  122. package/corpus/core/src/server/agent-chat/process-run-failure.ts +62 -0
  123. package/corpus/core/src/server/agent-chat/prompt-resources.ts +688 -0
  124. package/corpus/core/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
  125. package/corpus/core/src/server/agent-chat/request-surface.ts +71 -0
  126. package/corpus/core/src/server/agent-chat/run-code-tools.ts +67 -0
  127. package/corpus/core/src/server/agent-chat/script-entries.ts +779 -0
  128. package/corpus/core/src/server/agent-chat/shared-thread.ts +301 -0
  129. package/corpus/core/src/server/agent-chat/skill-frontmatter.ts +41 -0
  130. package/corpus/core/src/server/agent-chat-plugin.ts +364 -4182
  131. package/corpus/core/src/server/agent-teams.ts +26 -3
  132. package/corpus/core/src/server/auth.ts +55 -57
  133. package/corpus/core/src/server/credential-provider.ts +22 -25
  134. package/corpus/core/src/server/edge.ts +1 -0
  135. package/corpus/core/src/server/onboarding-html.ts +1 -16
  136. package/corpus/core/src/server/realtime-voice.ts +40 -5
  137. package/corpus/core/src/server/request-origin.ts +6 -2
  138. package/corpus/core/src/server/ssr-handler.ts +55 -2
  139. package/corpus/core/src/sharing/access.ts +155 -11
  140. package/corpus/core/src/sharing/registry.ts +7 -0
  141. package/corpus/core/src/styles/agent-native.css +15 -14
  142. package/corpus/core/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  143. package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +6 -0
  144. package/corpus/core/src/templates/default/app/i18n/de-DE.ts +6 -0
  145. package/corpus/core/src/templates/default/app/i18n/en-US.ts +6 -0
  146. package/corpus/core/src/templates/default/app/i18n/es-ES.ts +6 -0
  147. package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +6 -0
  148. package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +6 -0
  149. package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +6 -0
  150. package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +6 -0
  151. package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +6 -0
  152. package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +6 -0
  153. package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +6 -0
  154. package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  155. package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  156. package/corpus/core/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  157. package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  158. package/corpus/core/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  159. package/corpus/core/src/templates/workspace-core/src/server/index.ts +4 -2
  160. package/corpus/core/src/testing.ts +26 -0
  161. package/corpus/core/src/triggers/dispatcher.ts +23 -2
  162. package/corpus/core/src/vite/client.ts +126 -2
  163. package/corpus/core/tsconfig.cli.json +1 -1
  164. package/corpus/core/tsconfig.json +5 -1
  165. package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +2 -2
  166. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -1
  167. package/corpus/templates/analytics/AGENTS.md +19 -6
  168. package/corpus/templates/analytics/actions/install-dashboard-template.ts +79 -43
  169. package/corpus/templates/analytics/actions/list-explorer-dashboards.ts +3 -3
  170. package/corpus/templates/analytics/actions/list-sql-dashboards.ts +8 -3
  171. package/corpus/templates/analytics/actions/rename-analysis.ts +8 -2
  172. package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -7
  173. package/corpus/templates/analytics/actions/view-screen.ts +4 -23
  174. package/corpus/templates/analytics/app/components/ResourceLoadError.tsx +42 -0
  175. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +85 -70
  176. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +107 -89
  177. package/corpus/templates/analytics/app/components/layout/SidebarLoadError.tsx +24 -0
  178. package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -5
  179. package/corpus/templates/analytics/app/i18n/zh-TW.ts +4 -0
  180. package/corpus/templates/analytics/app/i18n-data.ts +40 -0
  181. package/corpus/templates/analytics/app/pages/Settings.tsx +6 -2
  182. package/corpus/templates/analytics/app/pages/adhoc/explorer/components/SqlPreview.tsx +36 -20
  183. package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +34 -20
  184. package/corpus/templates/analytics/app/pages/adhoc/explorer/use-explorer-config.ts +42 -41
  185. package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +43 -36
  186. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +11 -2
  187. package/corpus/templates/analytics/app/root.tsx +13 -1
  188. package/corpus/templates/analytics/app/routes/_index.tsx +14 -2
  189. package/corpus/templates/analytics/changelog/2026-07-03-agent-llm-observability-dashboard.md +1 -1
  190. package/corpus/templates/analytics/changelog/2026-07-11-agent-feedback-sentiment-dashboard.md +6 -0
  191. package/corpus/templates/analytics/changelog/2026-07-11-analytics-chats-now-start-faster-by-loading-metric-definitio.md +6 -0
  192. package/corpus/templates/analytics/changelog/2026-07-11-command-and-sql-previews-now-respond-without-lag.md +6 -0
  193. package/corpus/templates/analytics/changelog/2026-07-11-command-search-now-reports-loading-failures-and-lets-you-ret.md +6 -0
  194. package/corpus/templates/analytics/changelog/2026-07-11-dashboard-navigation-now-loads-faster-and-reports-request-fa.md +6 -0
  195. package/corpus/templates/analytics/changelog/2026-07-11-inferred-message-sentiment-dashboard.md +6 -0
  196. package/corpus/templates/analytics/changelog/2026-07-11-microphone-settings-from-realtime-voice-mode-now-open-the-vo.md +6 -0
  197. package/corpus/templates/analytics/changelog/2026-07-11-more-dashboard-edit-paths-are-now-safe-against-simultaneous-.md +6 -0
  198. package/corpus/templates/analytics/changelog/2026-07-11-renaming-a-dashboard-is-now-safe-against-simultaneous-agent-.md +6 -0
  199. package/corpus/templates/analytics/changelog/2026-07-11-renaming-an-analysis-is-now-safe-against-simultaneous-edits.md +6 -0
  200. package/corpus/templates/analytics/changelog/2026-07-11-workspace-mounted-analytics-now-opens-ask-reliably-and-route.md +6 -0
  201. package/corpus/templates/analytics/docs/schemas/first-party-analytics.md +37 -3
  202. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +339 -1
  203. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +1 -24
  204. package/corpus/templates/analytics/server/lib/dashboard-seeds.ts +0 -5
  205. package/corpus/templates/analytics/server/lib/dashboards-store.ts +289 -20
  206. package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +106 -34
  207. package/corpus/templates/analytics/server/lib/demo-dashboards.ts +4 -1
  208. package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -39
  209. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -1
  210. package/corpus/templates/assets/app/components/create/RecentDraftsSection.tsx +30 -4
  211. package/corpus/templates/assets/app/routes/library.tsx +49 -5
  212. package/corpus/templates/assets/changelog/2026-07-11-library-load-failures-now-show-a-retry-action.md +6 -0
  213. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -1
  214. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +1 -1
  215. package/corpus/templates/calendar/.env.example +5 -0
  216. package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +2 -2
  217. package/corpus/templates/calendar/app/i18n/zh-TW.ts +2 -0
  218. package/corpus/templates/calendar/app/i18n-data.ts +20 -0
  219. package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +37 -1
  220. package/corpus/templates/calendar/app/pages/BookingsList.tsx +20 -3
  221. package/corpus/templates/calendar/changelog/2026-07-11-booking-load-failures-now-show-a-retry-action.md +6 -0
  222. package/corpus/templates/calendar/changelog/2026-07-11-event-cards-give-subtle-press-feedback-and-smoother-hover.md +6 -0
  223. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -1
  224. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -1
  225. package/corpus/templates/clips/actions/decline-invite.ts +8 -0
  226. package/corpus/templates/clips/app/components/library/folder-tree.tsx +209 -187
  227. package/corpus/templates/clips/app/components/meetings/meeting-card.tsx +2 -2
  228. package/corpus/templates/clips/app/components/player/reactions-tray.tsx +17 -5
  229. package/corpus/templates/clips/app/components/player/scrubber.tsx +5 -3
  230. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +2 -2
  231. package/corpus/templates/clips/app/components/workspace/insights-hub.tsx +119 -95
  232. package/corpus/templates/clips/app/global.css +45 -0
  233. package/corpus/templates/clips/app/root.tsx +4 -0
  234. package/corpus/templates/clips/app/routes/_app.notifications.tsx +23 -2
  235. package/corpus/templates/clips/app/routes/_app.trash.tsx +24 -2
  236. package/corpus/templates/clips/changelog/2026-07-11-controls-and-folders-now-move-more-smoothly.md +6 -0
  237. package/corpus/templates/clips/changelog/2026-07-11-declining-an-invitation-now-requires-being-its-recipient.md +6 -0
  238. package/corpus/templates/clips/changelog/2026-07-11-recording-overlays-are-lighter-weight-and-no-longer-cause-pa.md +6 -0
  239. package/corpus/templates/clips/changelog/2026-07-11-workspace-load-failures-now-show-a-retry-action.md +6 -0
  240. package/corpus/templates/clips/chrome-extension/src/overlay.css +34 -5
  241. package/corpus/templates/clips/chrome-extension/src/styles.css +2 -2
  242. package/corpus/templates/clips/desktop/src/styles.css +71 -26
  243. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -1
  244. package/corpus/templates/content/actions/move-document.ts +34 -18
  245. package/corpus/templates/content/app/components/QueryErrorState.tsx +39 -0
  246. package/corpus/templates/content/app/components/editor/LinkHoverPreview.tsx +1 -1
  247. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +225 -1435
  248. package/corpus/templates/content/app/components/editor/database/GalleryView.tsx +368 -0
  249. package/corpus/templates/content/app/components/editor/database/ListView.tsx +353 -0
  250. package/corpus/templates/content/app/components/editor/database/TimelineView.tsx +580 -0
  251. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -2
  252. package/corpus/templates/content/app/global.css +19 -19
  253. package/corpus/templates/content/app/root.tsx +2 -2
  254. package/corpus/templates/content/app/routes/_app._index.tsx +11 -1
  255. package/corpus/templates/content/changelog/2026-07-11-document-load-failures-now-show-a-retry-action.md +6 -0
  256. package/corpus/templates/content/changelog/2026-07-11-editor-toggle-feedback-now-feels-more-responsive.md +6 -0
  257. package/corpus/templates/content/changelog/2026-07-11-moving-documents-at-the-same-time-no-longer-scrambles-their-.md +6 -0
  258. package/corpus/templates/content/changelog/2026-07-11-public-document-chats-now-start-faster-while-keeping-full-do.md +6 -0
  259. package/corpus/templates/content/changelog/2026-07-11-reopening-a-comment-now-uses-consistent-permissions-everywhe.md +6 -0
  260. package/corpus/templates/content/changelog/2026-07-11-sidebar-resizing-now-tracks-your-cursor-instantly-instead-of.md +6 -0
  261. package/corpus/templates/content/server/lib/public-documents.ts +47 -10
  262. package/corpus/templates/content/server/routes/api/comments/[id].patch.ts +24 -24
  263. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -1
  264. package/corpus/templates/design/app/components/QueryErrorState.tsx +24 -0
  265. package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +1 -1
  266. package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +5 -2
  267. package/corpus/templates/design/app/components/design/EditPanel.tsx +326 -319
  268. package/corpus/templates/design/app/components/design/LayersPanel.tsx +198 -193
  269. package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +11 -4
  270. package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +1 -1
  271. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -1
  272. package/corpus/templates/design/app/pages/DesignSystems.tsx +7 -1
  273. package/corpus/templates/design/app/pages/Index.tsx +14 -2
  274. package/corpus/templates/design/app/pages/Present.tsx +16 -3
  275. package/corpus/templates/design/app/pages/Templates.tsx +10 -4
  276. package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +484 -0
  277. package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +378 -0
  278. package/corpus/templates/design/app/pages/design-editor/design-data-geometry-utils.ts +138 -0
  279. package/corpus/templates/design/app/pages/design-editor/dom-utils.ts +15 -0
  280. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +180 -0
  281. package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +226 -0
  282. package/corpus/templates/design/app/pages/design-editor/png-export-render.ts +348 -0
  283. package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +160 -0
  284. package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +238 -0
  285. package/corpus/templates/design/app/pages/design-editor/tool-state.ts +23 -1
  286. package/corpus/templates/design/app/pages/design-editor/types.ts +25 -0
  287. package/corpus/templates/design/app/root.tsx +10 -1
  288. package/corpus/templates/design/changelog/2026-07-11-canvas-context-menus-now-open-without-motion-jitter.md +6 -0
  289. package/corpus/templates/design/changelog/2026-07-11-design-load-failures-now-show-a-retry-action.md +6 -0
  290. package/corpus/templates/design/changelog/2026-07-11-inspector-tooltips-appear-instantly-as-you-sweep-across-icon.md +6 -0
  291. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -1
  292. package/corpus/templates/dispatch/app/i18n/zh-TW.ts +10 -0
  293. package/corpus/templates/dispatch/app/i18n-data.ts +123 -0
  294. package/corpus/templates/dispatch/app/routes/integrations.tsx +163 -144
  295. package/corpus/templates/dispatch/changelog/2026-07-11-dispatch-mcp-connections-now-start-with-safer-app-access-and.md +6 -0
  296. package/corpus/templates/dispatch/changelog/2026-07-11-overview-and-chat-now-share-a-cleaner-more-stable-flow.md +6 -0
  297. package/corpus/templates/dispatch/changelog/2026-07-11-query-errors-now-show-a-retry-option.md +6 -0
  298. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -1
  299. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +3 -3
  300. package/corpus/templates/forms/app/root.tsx +34 -8
  301. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -1
  302. package/corpus/templates/macros/app/components/DailyProgress.tsx +25 -5
  303. package/corpus/templates/macros/app/components/QueryErrorState.tsx +31 -0
  304. package/corpus/templates/macros/app/components/WeightTracker.tsx +5 -1
  305. package/corpus/templates/macros/app/components/ui/button.tsx +1 -1
  306. package/corpus/templates/macros/app/components/ui/progress.tsx +1 -1
  307. package/corpus/templates/macros/app/components/ui/tabs.tsx +1 -1
  308. package/corpus/templates/macros/app/i18n/ar-SA.ts +2 -0
  309. package/corpus/templates/macros/app/i18n/de-DE.ts +2 -0
  310. package/corpus/templates/macros/app/i18n/en-US.ts +2 -0
  311. package/corpus/templates/macros/app/i18n/es-ES.ts +2 -0
  312. package/corpus/templates/macros/app/i18n/fr-FR.ts +2 -0
  313. package/corpus/templates/macros/app/i18n/hi-IN.ts +2 -0
  314. package/corpus/templates/macros/app/i18n/ja-JP.ts +2 -0
  315. package/corpus/templates/macros/app/i18n/ko-KR.ts +2 -0
  316. package/corpus/templates/macros/app/i18n/pt-BR.ts +2 -0
  317. package/corpus/templates/macros/app/i18n/zh-CN.ts +2 -0
  318. package/corpus/templates/macros/app/i18n/zh-TW.ts +2 -0
  319. package/corpus/templates/macros/app/routes/_index.tsx +22 -12
  320. package/corpus/templates/macros/app/routes/analytics.tsx +31 -10
  321. package/corpus/templates/macros/changelog/2026-07-11-daily-tracking-now-loads-and-updates-more-quickly.md +6 -0
  322. package/corpus/templates/macros/changelog/2026-07-11-data-load-failures-now-show-a-clear-error-with-a-retry-actio.md +6 -0
  323. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -1
  324. package/corpus/templates/mail/.env.example +16 -11
  325. package/corpus/templates/mail/actions/list-emails.ts +39 -35
  326. package/corpus/templates/mail/app/components/email/ComposeModal.tsx +58 -6
  327. package/corpus/templates/mail/app/components/email/EmailListItem.tsx +35 -2
  328. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +113 -104
  329. package/corpus/templates/mail/app/root.tsx +8 -10
  330. package/corpus/templates/mail/changelog/2026-07-11-compose-and-navigation-motion-now-feel-faster-and-smoother.md +6 -0
  331. package/corpus/templates/mail/changelog/2026-07-11-swipe-to-archive-or-snooze-now-responds-to-quick-flicks-not-.md +6 -0
  332. package/corpus/templates/mail/changelog/2026-07-11-the-assistant-now-sees-the-same-inbox-you-do-snoozed-mail-st.md +6 -0
  333. package/corpus/templates/mail/server/handlers/emails.ts +25 -69
  334. package/corpus/templates/mail/server/lib/list-inbox-emails.ts +169 -0
  335. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -1
  336. package/corpus/templates/plan/.env.example +4 -0
  337. package/corpus/templates/plan/actions/create-plan-design.ts +89 -81
  338. package/corpus/templates/plan/actions/create-prototype-plan.ts +72 -59
  339. package/corpus/templates/plan/actions/create-ui-plan.ts +70 -55
  340. package/corpus/templates/plan/actions/create-visual-plan.ts +65 -51
  341. package/corpus/templates/plan/actions/update-local-plan-folder.ts +43 -30
  342. package/corpus/templates/plan/actions/update-visual-plan.ts +81 -64
  343. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +17 -0
  344. package/corpus/templates/plan/app/components/ui/tabs.tsx +1 -1
  345. package/corpus/templates/plan/app/i18n/ar-SA.ts +10 -0
  346. package/corpus/templates/plan/app/i18n/de-DE.ts +10 -0
  347. package/corpus/templates/plan/app/i18n/en-US.ts +10 -0
  348. package/corpus/templates/plan/app/i18n/es-ES.ts +10 -0
  349. package/corpus/templates/plan/app/i18n/fr-FR.ts +10 -0
  350. package/corpus/templates/plan/app/i18n/hi-IN.ts +10 -0
  351. package/corpus/templates/plan/app/i18n/ja-JP.ts +10 -0
  352. package/corpus/templates/plan/app/i18n/ko-KR.ts +10 -0
  353. package/corpus/templates/plan/app/i18n/pt-BR.ts +10 -0
  354. package/corpus/templates/plan/app/i18n/zh-CN.ts +10 -0
  355. package/corpus/templates/plan/app/i18n/zh-TW.ts +10 -0
  356. package/corpus/templates/plan/app/lib/plan-local-bridge.ts +80 -1
  357. package/corpus/templates/plan/app/pages/PlansPage.tsx +152 -4
  358. package/corpus/templates/plan/app/root.tsx +11 -0
  359. package/corpus/templates/plan/changelog/2026-07-11-local-plans-now-explain-and-recover-from-browser-permission-.md +6 -0
  360. package/corpus/templates/plan/changelog/2026-07-11-plan-edits-now-save-atomically-and-can-no-longer-partially-a.md +6 -0
  361. package/corpus/templates/plan/changelog/2026-07-11-plan-lists-now-show-a-clear-error-with-a-retry-action-when-t.md +6 -0
  362. package/corpus/templates/plan/shared/plan-content.ts +546 -260
  363. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -1
  364. package/corpus/templates/slides/actions/delete-slide-comment.ts +49 -0
  365. package/corpus/templates/slides/actions/update-slide-comment.ts +93 -0
  366. package/corpus/templates/slides/actions/view-screen.ts +14 -6
  367. package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +33 -10
  368. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +1 -1
  369. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +1 -1
  370. package/corpus/templates/slides/app/components/editor/GenerateSlidesDialog.tsx +2 -2
  371. package/corpus/templates/slides/app/components/presentation/PresentationView.tsx +4 -2
  372. package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +4 -3
  373. package/corpus/templates/slides/app/context/DeckContext.tsx +9 -0
  374. package/corpus/templates/slides/app/i18n/ar-SA.ts +6 -0
  375. package/corpus/templates/slides/app/i18n/de-DE.ts +6 -0
  376. package/corpus/templates/slides/app/i18n/en-US.ts +6 -0
  377. package/corpus/templates/slides/app/i18n/es-ES.ts +6 -0
  378. package/corpus/templates/slides/app/i18n/fr-FR.ts +6 -0
  379. package/corpus/templates/slides/app/i18n/hi-IN.ts +6 -0
  380. package/corpus/templates/slides/app/i18n/ja-JP.ts +6 -0
  381. package/corpus/templates/slides/app/i18n/ko-KR.ts +6 -0
  382. package/corpus/templates/slides/app/i18n/pt-BR.ts +6 -0
  383. package/corpus/templates/slides/app/i18n/zh-CN.ts +5 -0
  384. package/corpus/templates/slides/app/i18n/zh-TW.ts +5 -0
  385. package/corpus/templates/slides/app/pages/DesignSystems.tsx +23 -2
  386. package/corpus/templates/slides/app/pages/Index.tsx +29 -1
  387. package/corpus/templates/slides/changelog/2026-07-11-comment-load-failures-now-show-a-retry-action-instead-of-say.md +6 -0
  388. package/corpus/templates/slides/changelog/2026-07-11-comment-pins-now-clear-with-a-faster-smoother-confirmation.md +6 -0
  389. package/corpus/templates/slides/changelog/2026-07-11-deck-and-design-system-load-failures-now-show-a-retry-action.md +6 -0
  390. package/corpus/templates/slides/changelog/2026-07-11-editor-toggles-and-toolbar-menus-now-animate-smoothly.md +6 -0
  391. package/corpus/templates/slides/changelog/2026-07-11-the-assistant-can-now-resolve-reopen-and-delete-slide-commen.md +6 -0
  392. package/corpus/templates/slides/changelog/2026-07-11-viewing-slides-no-longer-loads-every-deck-s-full-contents-in.md +6 -0
  393. package/corpus/templates/slides/server/routes/api/comments/[id].delete.ts +29 -48
  394. package/corpus/templates/slides/server/routes/api/comments/[id].patch.ts +29 -65
  395. package/dist/action.d.ts +23 -0
  396. package/dist/action.d.ts.map +1 -1
  397. package/dist/action.js +13 -0
  398. package/dist/action.js.map +1 -1
  399. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  400. package/dist/agent/engine/builder-engine.js +3 -0
  401. package/dist/agent/engine/builder-engine.js.map +1 -1
  402. package/dist/agent/engine/context-directives-transform.d.ts +25 -0
  403. package/dist/agent/engine/context-directives-transform.d.ts.map +1 -0
  404. package/dist/agent/engine/context-directives-transform.js +53 -0
  405. package/dist/agent/engine/context-directives-transform.js.map +1 -0
  406. package/dist/agent/engine/continuation-dispatch-retry.d.ts +40 -0
  407. package/dist/agent/engine/continuation-dispatch-retry.d.ts.map +1 -0
  408. package/dist/agent/engine/continuation-dispatch-retry.js +109 -0
  409. package/dist/agent/engine/continuation-dispatch-retry.js.map +1 -0
  410. package/dist/agent/engine/tool-call-journal-seed.d.ts +46 -0
  411. package/dist/agent/engine/tool-call-journal-seed.d.ts.map +1 -0
  412. package/dist/agent/engine/tool-call-journal-seed.js +60 -0
  413. package/dist/agent/engine/tool-call-journal-seed.js.map +1 -0
  414. package/dist/agent/production-agent.d.ts +7 -0
  415. package/dist/agent/production-agent.d.ts.map +1 -1
  416. package/dist/agent/production-agent.js +102 -222
  417. package/dist/agent/production-agent.js.map +1 -1
  418. package/dist/cli/doctor.d.ts.map +1 -1
  419. package/dist/cli/doctor.js +7 -3
  420. package/dist/cli/doctor.js.map +1 -1
  421. package/dist/cli/plan-local.d.ts.map +1 -1
  422. package/dist/cli/plan-local.js +8 -2
  423. package/dist/cli/plan-local.js.map +1 -1
  424. package/dist/cli/skills-content/assets-skill.d.ts +2 -0
  425. package/dist/cli/skills-content/assets-skill.d.ts.map +1 -0
  426. package/dist/cli/skills-content/assets-skill.js +84 -0
  427. package/dist/cli/skills-content/assets-skill.js.map +1 -0
  428. package/dist/cli/skills-content/canvas.d.ts +4 -0
  429. package/dist/cli/skills-content/canvas.d.ts.map +1 -0
  430. package/dist/cli/skills-content/canvas.js +152 -0
  431. package/dist/cli/skills-content/canvas.js.map +1 -0
  432. package/dist/cli/skills-content/connection.d.ts +2 -0
  433. package/dist/cli/skills-content/connection.d.ts.map +1 -0
  434. package/dist/cli/skills-content/connection.js +53 -0
  435. package/dist/cli/skills-content/connection.js.map +1 -0
  436. package/dist/cli/skills-content/content-skill.d.ts +2 -0
  437. package/dist/cli/skills-content/content-skill.d.ts.map +1 -0
  438. package/dist/cli/skills-content/content-skill.js +110 -0
  439. package/dist/cli/skills-content/content-skill.js.map +1 -0
  440. package/dist/cli/skills-content/design-exploration-skill.d.ts +2 -0
  441. package/dist/cli/skills-content/design-exploration-skill.d.ts.map +1 -0
  442. package/dist/cli/skills-content/design-exploration-skill.js +119 -0
  443. package/dist/cli/skills-content/design-exploration-skill.js.map +1 -0
  444. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +2 -0
  445. package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -0
  446. package/dist/cli/skills-content/design-visual-edit-skill.js +229 -0
  447. package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -0
  448. package/dist/cli/skills-content/document-quality.d.ts +4 -0
  449. package/dist/cli/skills-content/document-quality.d.ts.map +1 -0
  450. package/dist/cli/skills-content/document-quality.js +195 -0
  451. package/dist/cli/skills-content/document-quality.js.map +1 -0
  452. package/dist/cli/skills-content/exemplar.d.ts +4 -0
  453. package/dist/cli/skills-content/exemplar.d.ts.map +1 -0
  454. package/dist/cli/skills-content/exemplar.js +68 -0
  455. package/dist/cli/skills-content/exemplar.js.map +1 -0
  456. package/dist/cli/skills-content/help.d.ts +2 -0
  457. package/dist/cli/skills-content/help.d.ts.map +1 -0
  458. package/dist/cli/skills-content/help.js +78 -0
  459. package/dist/cli/skills-content/help.js.map +1 -0
  460. package/dist/cli/skills-content/index.d.ts +23 -0
  461. package/dist/cli/skills-content/index.d.ts.map +1 -0
  462. package/dist/cli/skills-content/index.js +23 -0
  463. package/dist/cli/skills-content/index.js.map +1 -0
  464. package/dist/cli/skills-content/local-files.d.ts +2 -0
  465. package/dist/cli/skills-content/local-files.d.ts.map +1 -0
  466. package/dist/cli/skills-content/local-files.js +96 -0
  467. package/dist/cli/skills-content/local-files.js.map +1 -0
  468. package/dist/cli/skills-content/plan-setup-auth.d.ts +9 -0
  469. package/dist/cli/skills-content/plan-setup-auth.d.ts.map +1 -0
  470. package/dist/cli/skills-content/plan-setup-auth.js +81 -0
  471. package/dist/cli/skills-content/plan-setup-auth.js.map +1 -0
  472. package/dist/cli/skills-content/visual-plan-skill.d.ts +2 -0
  473. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -0
  474. package/dist/cli/skills-content/visual-plan-skill.js +471 -0
  475. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -0
  476. package/dist/cli/skills-content/visual-recap-skill.d.ts +2 -0
  477. package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -0
  478. package/dist/cli/skills-content/visual-recap-skill.js +548 -0
  479. package/dist/cli/skills-content/visual-recap-skill.js.map +1 -0
  480. package/dist/cli/skills-content/visualize-repo-skill.d.ts +2 -0
  481. package/dist/cli/skills-content/visualize-repo-skill.d.ts.map +1 -0
  482. package/dist/cli/skills-content/visualize-repo-skill.js +94 -0
  483. package/dist/cli/skills-content/visualize-repo-skill.js.map +1 -0
  484. package/dist/cli/skills-content/wireframe.d.ts +4 -0
  485. package/dist/cli/skills-content/wireframe.d.ts.map +1 -0
  486. package/dist/cli/skills-content/wireframe.js +347 -0
  487. package/dist/cli/skills-content/wireframe.js.map +1 -0
  488. package/dist/cli/skills.d.ts +2 -10
  489. package/dist/cli/skills.d.ts.map +1 -1
  490. package/dist/cli/skills.js +2 -2710
  491. package/dist/cli/skills.js.map +1 -1
  492. package/dist/client/AgentPanel.d.ts.map +1 -1
  493. package/dist/client/AgentPanel.js +4 -2
  494. package/dist/client/AgentPanel.js.map +1 -1
  495. package/dist/client/CommandMenu.d.ts.map +1 -1
  496. package/dist/client/CommandMenu.js +15 -3
  497. package/dist/client/CommandMenu.js.map +1 -1
  498. package/dist/client/FeedbackButton.js +2 -2
  499. package/dist/client/FeedbackButton.js.map +1 -1
  500. package/dist/client/app-providers.d.ts +13 -5
  501. package/dist/client/app-providers.d.ts.map +1 -1
  502. package/dist/client/app-providers.js +9 -6
  503. package/dist/client/app-providers.js.map +1 -1
  504. package/dist/client/chat/tool-call-display.d.ts +4 -0
  505. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  506. package/dist/client/chat/tool-call-display.js +3 -3
  507. package/dist/client/chat/tool-call-display.js.map +1 -1
  508. package/dist/client/composer/PastedTextChip.js +1 -1
  509. package/dist/client/composer/PastedTextChip.js.map +1 -1
  510. package/dist/client/composer/RealtimeVoiceMode.d.ts +3 -1
  511. package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
  512. package/dist/client/composer/RealtimeVoiceMode.js +35 -14
  513. package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
  514. package/dist/client/composer/TiptapComposer.js +1 -1
  515. package/dist/client/composer/TiptapComposer.js.map +1 -1
  516. package/dist/client/composer/VoiceButton.d.ts +2 -0
  517. package/dist/client/composer/VoiceButton.d.ts.map +1 -1
  518. package/dist/client/composer/VoiceButton.js +9 -3
  519. package/dist/client/composer/VoiceButton.js.map +1 -1
  520. package/dist/client/composer/useRealtimeVoiceMode.d.ts +5 -0
  521. package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
  522. package/dist/client/composer/useRealtimeVoiceMode.js +91 -12
  523. package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
  524. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  525. package/dist/client/context-xray/ContextXRayPanel.js +4 -1
  526. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  527. package/dist/client/extensions/ExtensionEditor.d.ts.map +1 -1
  528. package/dist/client/extensions/ExtensionEditor.js +15 -5
  529. package/dist/client/extensions/ExtensionEditor.js.map +1 -1
  530. package/dist/client/extensions/ExtensionQueryErrorState.d.ts +8 -0
  531. package/dist/client/extensions/ExtensionQueryErrorState.d.ts.map +1 -0
  532. package/dist/client/extensions/ExtensionQueryErrorState.js +11 -0
  533. package/dist/client/extensions/ExtensionQueryErrorState.js.map +1 -0
  534. package/dist/client/extensions/ExtensionSlot.d.ts.map +1 -1
  535. package/dist/client/extensions/ExtensionSlot.js +17 -7
  536. package/dist/client/extensions/ExtensionSlot.js.map +1 -1
  537. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  538. package/dist/client/extensions/ExtensionViewer.js +17 -7
  539. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  540. package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
  541. package/dist/client/extensions/ExtensionsListPage.js +5 -3
  542. package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
  543. package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
  544. package/dist/client/extensions/ExtensionsSidebarSection.js +21 -8
  545. package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
  546. package/dist/client/index.d.ts +0 -2
  547. package/dist/client/index.d.ts.map +1 -1
  548. package/dist/client/index.js +0 -5
  549. package/dist/client/index.js.map +1 -1
  550. package/dist/client/progress/RunsTray.d.ts.map +1 -1
  551. package/dist/client/progress/RunsTray.js +7 -3
  552. package/dist/client/progress/RunsTray.js.map +1 -1
  553. package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
  554. package/dist/client/settings/SettingsTabsPage.js +4 -0
  555. package/dist/client/settings/SettingsTabsPage.js.map +1 -1
  556. package/dist/client/settings/useBuilderStatus.d.ts +2 -0
  557. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
  558. package/dist/client/settings/useBuilderStatus.js +4 -0
  559. package/dist/client/settings/useBuilderStatus.js.map +1 -1
  560. package/dist/client/tool-cells/EditCell.d.ts.map +1 -1
  561. package/dist/client/tool-cells/EditCell.js +2 -1
  562. package/dist/client/tool-cells/EditCell.js.map +1 -1
  563. package/dist/client/tool-cells/FilesChangedSummary.d.ts.map +1 -1
  564. package/dist/client/tool-cells/FilesChangedSummary.js +2 -1
  565. package/dist/client/tool-cells/FilesChangedSummary.js.map +1 -1
  566. package/dist/client/tool-cells/WriteCell.d.ts.map +1 -1
  567. package/dist/client/tool-cells/WriteCell.js +2 -1
  568. package/dist/client/tool-cells/WriteCell.js.map +1 -1
  569. package/dist/client/visual-style-controls.js +1 -1
  570. package/dist/client/visual-style-controls.js.map +1 -1
  571. package/dist/collab/routes.d.ts +1 -1
  572. package/dist/deploy/build.d.ts.map +1 -1
  573. package/dist/deploy/build.js +36 -14
  574. package/dist/deploy/build.js.map +1 -1
  575. package/dist/integrations/google-docs-poller.d.ts +7 -0
  576. package/dist/integrations/google-docs-poller.d.ts.map +1 -1
  577. package/dist/integrations/google-docs-poller.js +13 -3
  578. package/dist/integrations/google-docs-poller.js.map +1 -1
  579. package/dist/integrations/plugin.d.ts.map +1 -1
  580. package/dist/integrations/plugin.js +10 -0
  581. package/dist/integrations/plugin.js.map +1 -1
  582. package/dist/integrations/webhook-handler.d.ts +11 -0
  583. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  584. package/dist/integrations/webhook-handler.js +16 -4
  585. package/dist/integrations/webhook-handler.js.map +1 -1
  586. package/dist/jobs/scheduler.d.ts +12 -0
  587. package/dist/jobs/scheduler.d.ts.map +1 -1
  588. package/dist/jobs/scheduler.js +13 -3
  589. package/dist/jobs/scheduler.js.map +1 -1
  590. package/dist/localization/default-messages.d.ts +7 -0
  591. package/dist/localization/default-messages.d.ts.map +1 -1
  592. package/dist/localization/default-messages.js +8 -1
  593. package/dist/localization/default-messages.js.map +1 -1
  594. package/dist/mcp/oauth-token.d.ts +1 -1
  595. package/dist/mcp/oauth-token.d.ts.map +1 -1
  596. package/dist/mcp/oauth-token.js +6 -1
  597. package/dist/mcp/oauth-token.js.map +1 -1
  598. package/dist/notifications/routes.d.ts +2 -2
  599. package/dist/observability/routes.d.ts.map +1 -1
  600. package/dist/observability/routes.js +32 -0
  601. package/dist/observability/routes.js.map +1 -1
  602. package/dist/observability/sentiment.d.ts +42 -0
  603. package/dist/observability/sentiment.d.ts.map +1 -0
  604. package/dist/observability/sentiment.js +196 -0
  605. package/dist/observability/sentiment.js.map +1 -0
  606. package/dist/observability/store.d.ts +5 -0
  607. package/dist/observability/store.d.ts.map +1 -1
  608. package/dist/observability/store.js +17 -0
  609. package/dist/observability/store.js.map +1 -1
  610. package/dist/observability/traces.d.ts +2 -0
  611. package/dist/observability/traces.d.ts.map +1 -1
  612. package/dist/observability/traces.js +42 -57
  613. package/dist/observability/traces.js.map +1 -1
  614. package/dist/observability/tracking-identity.d.ts +3 -0
  615. package/dist/observability/tracking-identity.d.ts.map +1 -0
  616. package/dist/observability/tracking-identity.js +51 -0
  617. package/dist/observability/tracking-identity.js.map +1 -0
  618. package/dist/observability/types.d.ts +10 -0
  619. package/dist/observability/types.d.ts.map +1 -1
  620. package/dist/observability/types.js +3 -0
  621. package/dist/observability/types.js.map +1 -1
  622. package/dist/progress/routes.d.ts +1 -1
  623. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  624. package/dist/resources/handlers.d.ts +1 -1
  625. package/dist/secrets/storage.d.ts +6 -0
  626. package/dist/secrets/storage.d.ts.map +1 -1
  627. package/dist/secrets/storage.js +61 -3
  628. package/dist/secrets/storage.js.map +1 -1
  629. package/dist/server/agent-chat/action-filters-a2a.d.ts +50 -0
  630. package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -0
  631. package/dist/server/agent-chat/action-filters-a2a.js +127 -0
  632. package/dist/server/agent-chat/action-filters-a2a.js.map +1 -0
  633. package/dist/server/agent-chat/browser-team-tools.d.ts +21 -0
  634. package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -0
  635. package/dist/server/agent-chat/browser-team-tools.js +417 -0
  636. package/dist/server/agent-chat/browser-team-tools.js.map +1 -0
  637. package/dist/server/agent-chat/context-tools.d.ts +33 -0
  638. package/dist/server/agent-chat/context-tools.d.ts.map +1 -0
  639. package/dist/server/agent-chat/context-tools.js +520 -0
  640. package/dist/server/agent-chat/context-tools.js.map +1 -0
  641. package/dist/server/agent-chat/framework-prompts.d.ts +65 -0
  642. package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -0
  643. package/dist/server/agent-chat/framework-prompts.js +403 -0
  644. package/dist/server/agent-chat/framework-prompts.js.map +1 -0
  645. package/dist/server/agent-chat/lazy-fs.d.ts +2 -0
  646. package/dist/server/agent-chat/lazy-fs.d.ts.map +1 -0
  647. package/dist/server/agent-chat/lazy-fs.js +11 -0
  648. package/dist/server/agent-chat/lazy-fs.js.map +1 -0
  649. package/dist/server/agent-chat/mcp-glue.d.ts +9 -0
  650. package/dist/server/agent-chat/mcp-glue.d.ts.map +1 -0
  651. package/dist/server/agent-chat/mcp-glue.js +63 -0
  652. package/dist/server/agent-chat/mcp-glue.js.map +1 -0
  653. package/dist/server/agent-chat/plugin-options.d.ts +322 -0
  654. package/dist/server/agent-chat/plugin-options.d.ts.map +1 -0
  655. package/dist/server/agent-chat/plugin-options.js +2 -0
  656. package/dist/server/agent-chat/plugin-options.js.map +1 -0
  657. package/dist/server/agent-chat/process-run-failure.d.ts +12 -0
  658. package/dist/server/agent-chat/process-run-failure.d.ts.map +1 -0
  659. package/dist/server/agent-chat/process-run-failure.js +24 -0
  660. package/dist/server/agent-chat/process-run-failure.js.map +1 -0
  661. package/dist/server/agent-chat/prompt-resources.d.ts +28 -0
  662. package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -0
  663. package/dist/server/agent-chat/prompt-resources.js +514 -0
  664. package/dist/server/agent-chat/prompt-resources.js.map +1 -0
  665. package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +5 -0
  666. package/dist/server/agent-chat/recurring-jobs-runtime.d.ts.map +1 -0
  667. package/dist/server/agent-chat/recurring-jobs-runtime.js +53 -0
  668. package/dist/server/agent-chat/recurring-jobs-runtime.js.map +1 -0
  669. package/dist/server/agent-chat/request-surface.d.ts +8 -0
  670. package/dist/server/agent-chat/request-surface.d.ts.map +1 -0
  671. package/dist/server/agent-chat/request-surface.js +56 -0
  672. package/dist/server/agent-chat/request-surface.js.map +1 -0
  673. package/dist/server/agent-chat/run-code-tools.d.ts +17 -0
  674. package/dist/server/agent-chat/run-code-tools.d.ts.map +1 -0
  675. package/dist/server/agent-chat/run-code-tools.js +55 -0
  676. package/dist/server/agent-chat/run-code-tools.js.map +1 -0
  677. package/dist/server/agent-chat/script-entries.d.ts +47 -0
  678. package/dist/server/agent-chat/script-entries.d.ts.map +1 -0
  679. package/dist/server/agent-chat/script-entries.js +633 -0
  680. package/dist/server/agent-chat/script-entries.js.map +1 -0
  681. package/dist/server/agent-chat/shared-thread.d.ts +33 -0
  682. package/dist/server/agent-chat/shared-thread.d.ts.map +1 -0
  683. package/dist/server/agent-chat/shared-thread.js +242 -0
  684. package/dist/server/agent-chat/shared-thread.js.map +1 -0
  685. package/dist/server/agent-chat/skill-frontmatter.d.ts +7 -0
  686. package/dist/server/agent-chat/skill-frontmatter.d.ts.map +1 -0
  687. package/dist/server/agent-chat/skill-frontmatter.js +26 -0
  688. package/dist/server/agent-chat/skill-frontmatter.js.map +1 -0
  689. package/dist/server/agent-chat-plugin.d.ts +45 -486
  690. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  691. package/dist/server/agent-chat-plugin.js +173 -3005
  692. package/dist/server/agent-chat-plugin.js.map +1 -1
  693. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  694. package/dist/server/agent-teams.d.ts +10 -0
  695. package/dist/server/agent-teams.d.ts.map +1 -1
  696. package/dist/server/agent-teams.js +13 -3
  697. package/dist/server/agent-teams.js.map +1 -1
  698. package/dist/server/auth.d.ts.map +1 -1
  699. package/dist/server/auth.js +50 -52
  700. package/dist/server/auth.js.map +1 -1
  701. package/dist/server/credential-provider.d.ts.map +1 -1
  702. package/dist/server/credential-provider.js +22 -21
  703. package/dist/server/credential-provider.js.map +1 -1
  704. package/dist/server/edge.d.ts +1 -0
  705. package/dist/server/edge.d.ts.map +1 -1
  706. package/dist/server/edge.js +1 -0
  707. package/dist/server/edge.js.map +1 -1
  708. package/dist/server/onboarding-html.d.ts.map +1 -1
  709. package/dist/server/onboarding-html.js +1 -16
  710. package/dist/server/onboarding-html.js.map +1 -1
  711. package/dist/server/realtime-voice.d.ts +3 -0
  712. package/dist/server/realtime-voice.d.ts.map +1 -1
  713. package/dist/server/realtime-voice.js +29 -5
  714. package/dist/server/realtime-voice.js.map +1 -1
  715. package/dist/server/request-origin.d.ts.map +1 -1
  716. package/dist/server/request-origin.js +6 -3
  717. package/dist/server/request-origin.js.map +1 -1
  718. package/dist/server/ssr-handler.d.ts.map +1 -1
  719. package/dist/server/ssr-handler.js +47 -2
  720. package/dist/server/ssr-handler.js.map +1 -1
  721. package/dist/sharing/access.d.ts +63 -3
  722. package/dist/sharing/access.d.ts.map +1 -1
  723. package/dist/sharing/access.js +53 -15
  724. package/dist/sharing/access.js.map +1 -1
  725. package/dist/sharing/registry.d.ts +7 -0
  726. package/dist/sharing/registry.d.ts.map +1 -1
  727. package/dist/sharing/registry.js.map +1 -1
  728. package/dist/styles/agent-native.css +15 -14
  729. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  730. package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
  731. package/dist/templates/default/app/i18n/de-DE.ts +6 -0
  732. package/dist/templates/default/app/i18n/en-US.ts +6 -0
  733. package/dist/templates/default/app/i18n/es-ES.ts +6 -0
  734. package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
  735. package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
  736. package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
  737. package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
  738. package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
  739. package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
  740. package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
  741. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  742. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  743. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  744. package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  745. package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  746. package/dist/templates/workspace-core/src/server/index.ts +4 -2
  747. package/dist/testing.d.ts +16 -0
  748. package/dist/testing.d.ts.map +1 -0
  749. package/dist/testing.js +16 -0
  750. package/dist/testing.js.map +1 -0
  751. package/dist/triggers/dispatcher.d.ts +7 -0
  752. package/dist/triggers/dispatcher.d.ts.map +1 -1
  753. package/dist/triggers/dispatcher.js +13 -3
  754. package/dist/triggers/dispatcher.js.map +1 -1
  755. package/dist/vite/client.d.ts +16 -1
  756. package/dist/vite/client.d.ts.map +1 -1
  757. package/dist/vite/client.js +105 -2
  758. package/dist/vite/client.js.map +1 -1
  759. package/docs/content/authentication.mdx +3 -3
  760. package/docs/content/doctor.mdx +170 -0
  761. package/docs/content/external-agents.mdx +8 -7
  762. package/docs/content/locales/ar-SA/authentication.mdx +2 -2
  763. package/docs/content/locales/ar-SA/external-agents.mdx +8 -7
  764. package/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
  765. package/docs/content/locales/ar-SA/security.mdx +2 -0
  766. package/docs/content/locales/de-DE/authentication.mdx +1 -1
  767. package/docs/content/locales/de-DE/external-agents.mdx +8 -7
  768. package/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
  769. package/docs/content/locales/de-DE/security.mdx +2 -0
  770. package/docs/content/locales/es-ES/authentication.mdx +2 -2
  771. package/docs/content/locales/es-ES/external-agents.mdx +8 -7
  772. package/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
  773. package/docs/content/locales/es-ES/security.mdx +2 -0
  774. package/docs/content/locales/fr-FR/authentication.mdx +1 -1
  775. package/docs/content/locales/fr-FR/external-agents.mdx +8 -7
  776. package/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
  777. package/docs/content/locales/fr-FR/security.mdx +2 -0
  778. package/docs/content/locales/hi-IN/authentication.mdx +2 -2
  779. package/docs/content/locales/hi-IN/external-agents.mdx +8 -7
  780. package/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
  781. package/docs/content/locales/hi-IN/security.mdx +2 -0
  782. package/docs/content/locales/ja-JP/authentication.mdx +2 -2
  783. package/docs/content/locales/ja-JP/external-agents.mdx +8 -7
  784. package/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
  785. package/docs/content/locales/ja-JP/security.mdx +2 -0
  786. package/docs/content/locales/ko-KR/authentication.mdx +2 -2
  787. package/docs/content/locales/ko-KR/external-agents.mdx +8 -7
  788. package/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
  789. package/docs/content/locales/ko-KR/security.mdx +2 -0
  790. package/docs/content/locales/pt-BR/authentication.mdx +2 -2
  791. package/docs/content/locales/pt-BR/external-agents.mdx +8 -7
  792. package/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
  793. package/docs/content/locales/pt-BR/security.mdx +2 -0
  794. package/docs/content/locales/zh-CN/authentication.mdx +2 -2
  795. package/docs/content/locales/zh-CN/external-agents.mdx +8 -7
  796. package/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
  797. package/docs/content/locales/zh-CN/security.mdx +2 -0
  798. package/docs/content/locales/zh-TW/authentication.mdx +2 -2
  799. package/docs/content/locales/zh-TW/external-agents.mdx +8 -7
  800. package/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
  801. package/docs/content/locales/zh-TW/security.mdx +2 -0
  802. package/docs/content/mcp-protocol.mdx +1 -1
  803. package/docs/content/security.mdx +2 -0
  804. package/package.json +6 -2
  805. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  806. package/src/templates/default/app/i18n/ar-SA.ts +6 -0
  807. package/src/templates/default/app/i18n/de-DE.ts +6 -0
  808. package/src/templates/default/app/i18n/en-US.ts +6 -0
  809. package/src/templates/default/app/i18n/es-ES.ts +6 -0
  810. package/src/templates/default/app/i18n/fr-FR.ts +6 -0
  811. package/src/templates/default/app/i18n/hi-IN.ts +6 -0
  812. package/src/templates/default/app/i18n/ja-JP.ts +6 -0
  813. package/src/templates/default/app/i18n/ko-KR.ts +6 -0
  814. package/src/templates/default/app/i18n/pt-BR.ts +6 -0
  815. package/src/templates/default/app/i18n/zh-CN.ts +6 -0
  816. package/src/templates/default/app/i18n/zh-TW.ts +6 -0
  817. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  818. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  819. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  820. package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  821. package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  822. package/src/templates/workspace-core/src/server/index.ts +4 -2
  823. package/corpus/core/src/client/ProductionAgentPanel.tsx +0 -9
  824. package/corpus/core/src/client/auth-redirect-url.ts +0 -23
  825. package/corpus/core/src/client/useProductionAgent.ts +0 -253
  826. package/corpus/core/src/shared/auth-redirect-url.ts +0 -1
  827. package/corpus/templates/analytics/app/pages/Index.tsx +0 -16
  828. package/corpus/templates/analytics/seeds/dashboards/agent-observability-llm.json +0 -173
  829. package/dist/client/ProductionAgentPanel.d.ts +0 -6
  830. package/dist/client/ProductionAgentPanel.d.ts.map +0 -1
  831. package/dist/client/ProductionAgentPanel.js +0 -6
  832. package/dist/client/ProductionAgentPanel.js.map +0 -1
  833. package/dist/client/auth-redirect-url.d.ts +0 -2
  834. package/dist/client/auth-redirect-url.d.ts.map +0 -1
  835. package/dist/client/auth-redirect-url.js +0 -19
  836. package/dist/client/auth-redirect-url.js.map +0 -1
  837. package/dist/client/useProductionAgent.d.ts +0 -24
  838. package/dist/client/useProductionAgent.d.ts.map +0 -1
  839. package/dist/client/useProductionAgent.js +0 -179
  840. package/dist/client/useProductionAgent.js.map +0 -1
  841. package/dist/shared/auth-redirect-url.d.ts +0 -2
  842. package/dist/shared/auth-redirect-url.d.ts.map +0 -1
  843. package/dist/shared/auth-redirect-url.js +0 -2
  844. package/dist/shared/auth-redirect-url.js.map +0 -1
@@ -0,0 +1,514 @@
1
+ import { getFrontmatterValue, getSkillNameFromPath, parseFrontmatter, } from "../../resources/metadata.js";
2
+ import { ensurePersonalDefaults, organizationIdFromResourceOwner, resourceGet, resourceGetByPath, resourceList, resourceListAccessible, SHARED_OWNER, sharedResourceOwner, WORKSPACE_OWNER, } from "../../resources/store.js";
3
+ import { discoverAgents } from "../agent-discovery.js";
4
+ import { getRequestOrgId } from "../request-context.js";
5
+ import { parseSkillFrontmatter } from "./skill-frontmatter.js";
6
+ // ---------------------------------------------------------------------------
7
+ // System-prompt resource loading: AGENTS.md, instructions/*.md, skills
8
+ // summaries, and the shared/workspace resource index. Assembled by
9
+ // `loadResourcesForPrompt`, the top-level orchestrator called once per
10
+ // request to build the "here's what you should know" context block.
11
+ // ---------------------------------------------------------------------------
12
+ const SHARED_PROMPT_RESOURCE_MAX_CHARS = 30_000;
13
+ export const COMPACT_PROMPT_RESOURCE_MAX_CHARS = 6_000;
14
+ const COMPACT_PROMPT_RESOURCES_TOTAL_MAX_CHARS = 48_000;
15
+ export function compactPromptLine(value, maxChars) {
16
+ const line = value.replace(/\s+/g, " ").trim();
17
+ if (line.length <= maxChars)
18
+ return line;
19
+ return `${line.slice(0, maxChars - 1)}…`;
20
+ }
21
+ const SHARED_RESOURCE_INDEX_LIMIT = 40;
22
+ const PROMPT_SKILL_SUMMARY_LIMIT = 40;
23
+ const PROMPT_SKILL_METADATA_READ_LIMIT = 80;
24
+ const PROMPT_INSTRUCTION_SUMMARY_LIMIT = 20;
25
+ const PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS = 180;
26
+ function normalizeResourcePathForPrompt(path) {
27
+ return path.replace(/^\/+/, "").trim();
28
+ }
29
+ function resourceToolHint(action, extra) {
30
+ return `Use the \`resources\` tool with \`action: "${action}"\`${extra ? `, ${extra}` : ""}.`;
31
+ }
32
+ function skillDocsSlug(name) {
33
+ return `skill-${name
34
+ .trim()
35
+ .toLowerCase()
36
+ .replace(/[^a-z0-9]+/g, "-")
37
+ .replace(/^-+|-+$/g, "")}`;
38
+ }
39
+ function ensureSentence(value) {
40
+ const trimmed = value.trim();
41
+ if (!trimmed)
42
+ return "";
43
+ return /[.!?]$/.test(trimmed) ? trimmed : `${trimmed}.`;
44
+ }
45
+ function escapeXmlAttribute(value) {
46
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
47
+ }
48
+ function truncatePromptResourceContent(content, path, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS, readHint) {
49
+ const trimmed = content.trim();
50
+ if (trimmed.length <= maxChars)
51
+ return trimmed;
52
+ const omitted = trimmed.length - maxChars;
53
+ const hint = readHint ??
54
+ resourceToolHint("read", `\`path: "${path}"\` and the resource's \`scope\` for the full content`);
55
+ return `${trimmed.slice(0, maxChars)}\n\n[Resource ${path} truncated after ${maxChars.toLocaleString()} characters; ${omitted.toLocaleString()} characters omitted. ${hint}]`;
56
+ }
57
+ function promptResourceBlock(input) {
58
+ const normalizedPath = input.path
59
+ ? normalizeResourcePathForPrompt(input.path)
60
+ : undefined;
61
+ const content = truncatePromptResourceContent(input.content, normalizedPath ?? input.name, input.maxChars, input.readHint);
62
+ if (!content)
63
+ return null;
64
+ const pathAttr = normalizedPath
65
+ ? ` path="${escapeXmlAttribute(normalizedPath)}"`
66
+ : "";
67
+ return `<resource name="${escapeXmlAttribute(input.name)}" scope="${escapeXmlAttribute(input.scope)}"${pathAttr}>\n${content}\n</resource>`;
68
+ }
69
+ function selectPromptSectionsWithinBudget(sections, maxChars) {
70
+ const omissionNote = `<context-budget-note>Some startup context sections were omitted to keep the first model request responsive. Use \`resources\` with \`action: "list"\` or \`"read"\`, \`docs-search\`, and \`tool-search\` to retrieve relevant depth on demand.</context-budget-note>`;
71
+ const contentBudget = Math.max(0, maxChars - omissionNote.length - 2);
72
+ const selected = [];
73
+ let used = 0;
74
+ let omitted = 0;
75
+ for (const section of sections) {
76
+ const separatorChars = selected.length > 0 ? 2 : 0;
77
+ if (used + separatorChars + section.length <= contentBudget) {
78
+ selected.push(section);
79
+ used += separatorChars + section.length;
80
+ }
81
+ else {
82
+ omitted++;
83
+ }
84
+ }
85
+ if (omitted > 0)
86
+ selected.push(omissionNote);
87
+ return selected;
88
+ }
89
+ function isAutoLoadedInstructionPath(path) {
90
+ const normalized = normalizeResourcePathForPrompt(path);
91
+ return normalized.startsWith("instructions/") && normalized.endsWith(".md");
92
+ }
93
+ function isSpecialPromptResourcePath(path) {
94
+ const normalized = normalizeResourcePathForPrompt(path);
95
+ return (normalized === "AGENTS.md" ||
96
+ normalized === "LEARNINGS.md" ||
97
+ normalized.startsWith("instructions/") ||
98
+ normalized.startsWith("skills/") ||
99
+ normalized.startsWith("agents/") ||
100
+ normalized.startsWith("remote-agents/") ||
101
+ normalized.startsWith("jobs/") ||
102
+ normalized.startsWith("memory/"));
103
+ }
104
+ function isTextLikeResource(mimeType) {
105
+ return (mimeType.startsWith("text/") ||
106
+ mimeType === "application/json" ||
107
+ mimeType === "application/yaml" ||
108
+ mimeType === "application/x-yaml");
109
+ }
110
+ function getResourceSummaryFromContent(content) {
111
+ const frontmatter = parseFrontmatter(content);
112
+ const title = getFrontmatterValue(frontmatter, "title") ||
113
+ getFrontmatterValue(frontmatter, "name");
114
+ const description = getFrontmatterValue(frontmatter, "description");
115
+ if (title && description)
116
+ return `${title}: ${description}`;
117
+ if (title)
118
+ return title;
119
+ if (description)
120
+ return description;
121
+ const heading = content
122
+ .split(/\r?\n/)
123
+ .map((line) => line.trim())
124
+ .find((line) => /^#{1,3}\s+\S/.test(line));
125
+ if (heading)
126
+ return heading.replace(/^#{1,3}\s+/, "").trim();
127
+ return null;
128
+ }
129
+ export function resourceScopeForOwner(owner, currentOwner) {
130
+ if (owner === WORKSPACE_OWNER)
131
+ return "workspace";
132
+ if (owner === SHARED_OWNER || organizationIdFromResourceOwner(owner)) {
133
+ return "shared";
134
+ }
135
+ if (currentOwner && owner === currentOwner)
136
+ return "personal";
137
+ return "resource";
138
+ }
139
+ async function loadAgentsResourceForPrompt(owner, scope, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS) {
140
+ try {
141
+ const agents = await resourceGetByPath(owner, "AGENTS.md");
142
+ if (!agents?.content?.trim())
143
+ return null;
144
+ return promptResourceBlock({
145
+ name: "AGENTS.md",
146
+ scope,
147
+ path: "AGENTS.md",
148
+ content: agents.content,
149
+ maxChars,
150
+ });
151
+ }
152
+ catch {
153
+ return null;
154
+ }
155
+ }
156
+ async function loadInstructionResourcesForPrompt(owner, scope, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS, summaryOnly = false) {
157
+ try {
158
+ const resources = await resourceList(owner, "instructions/");
159
+ const sorted = resources
160
+ .filter((resource) => isAutoLoadedInstructionPath(resource.path))
161
+ .sort((a, b) => a.path.localeCompare(b.path));
162
+ if (summaryOnly) {
163
+ if (sorted.length === 0)
164
+ return [];
165
+ const resourceScope = scope.startsWith("workspace")
166
+ ? "workspace"
167
+ : scope.startsWith("personal")
168
+ ? "personal"
169
+ : "shared";
170
+ const listed = sorted.slice(0, PROMPT_INSTRUCTION_SUMMARY_LIMIT);
171
+ const lines = listed.map((resource) => `- \`${resource.path}\` - ${resourceToolHint("read", `\`path: "${resource.path}"\` and \`scope: "${resourceScope}"\` when it applies`)}`);
172
+ if (sorted.length > listed.length) {
173
+ lines.push(`- ...${sorted.length - listed.length} more instruction files. ${resourceToolHint("list", `\`scope: "${resourceScope}"\` and \`prefix: "instructions/"\``)}`);
174
+ }
175
+ return [
176
+ `<instruction-resources scope="${escapeXmlAttribute(scope)}">\nDetailed instruction files are loaded on demand so the first model request stays compact. Read a relevant file before following its workflow.\n\n${lines.join("\n")}\n</instruction-resources>`,
177
+ ];
178
+ }
179
+ const fullResources = await Promise.all(sorted.map((resource) => resourceGet(resource.id).catch(() => null)));
180
+ const blocks = [];
181
+ for (let index = 0; index < sorted.length; index++) {
182
+ const resource = sorted[index];
183
+ const full = fullResources[index];
184
+ if (!full?.content?.trim())
185
+ continue;
186
+ const block = promptResourceBlock({
187
+ name: resource.path,
188
+ scope,
189
+ path: resource.path,
190
+ content: full.content,
191
+ maxChars,
192
+ });
193
+ if (block)
194
+ blocks.push(block);
195
+ }
196
+ return blocks;
197
+ }
198
+ catch {
199
+ return [];
200
+ }
201
+ }
202
+ async function loadResourceSkillsPromptBlock(owner, orgId) {
203
+ try {
204
+ const organizationOwner = sharedResourceOwner(orgId);
205
+ const resources = owner === SHARED_OWNER
206
+ ? [
207
+ ...(await resourceList(SHARED_OWNER, "skills/")),
208
+ ...(await resourceList(WORKSPACE_OWNER, "skills/")),
209
+ ]
210
+ : await resourceListAccessible(owner, "skills/", { orgId });
211
+ const sorted = resources.sort((a, b) => {
212
+ const ownerOrder = (a.owner === owner
213
+ ? 0
214
+ : a.owner === organizationOwner
215
+ ? 1
216
+ : a.owner === SHARED_OWNER
217
+ ? 2
218
+ : a.owner === WORKSPACE_OWNER
219
+ ? 3
220
+ : 4) -
221
+ (b.owner === owner
222
+ ? 0
223
+ : b.owner === organizationOwner
224
+ ? 1
225
+ : b.owner === SHARED_OWNER
226
+ ? 2
227
+ : b.owner === WORKSPACE_OWNER
228
+ ? 3
229
+ : 4);
230
+ if (ownerOrder !== 0)
231
+ return ownerOrder;
232
+ return a.path.localeCompare(b.path);
233
+ });
234
+ const skillCandidates = sorted.slice(0, PROMPT_SKILL_METADATA_READ_LIMIT);
235
+ const loaded = await Promise.all(skillCandidates.map(async (resource) => ({
236
+ resource,
237
+ full: await resourceGet(resource.id).catch(() => null),
238
+ })));
239
+ const seen = new Set();
240
+ const lines = [];
241
+ for (const { resource, full } of loaded) {
242
+ if (!full?.content)
243
+ continue;
244
+ const meta = parseSkillFrontmatter(full.content);
245
+ if (meta.userInvocable === false)
246
+ continue;
247
+ if (meta.scope === "dev")
248
+ continue;
249
+ const name = meta.name || getSkillNameFromPath(resource.path);
250
+ if (!name || seen.has(name))
251
+ continue;
252
+ seen.add(name);
253
+ const scope = resourceScopeForOwner(resource.owner, owner);
254
+ const description = compactPromptLine(meta.description || "(no description)", PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS);
255
+ lines.push(`- \`${name}\` at resource \`${resource.path}\` (${scope}) - ${ensureSentence(description)} ${resourceToolHint("read", `\`path: "${resource.path}"\` and \`scope: "${scope}"\` before starting a task it applies to`)}`);
256
+ if (lines.length >= PROMPT_SKILL_SUMMARY_LIMIT)
257
+ break;
258
+ }
259
+ if (lines.length === 0)
260
+ return null;
261
+ if (sorted.length > skillCandidates.length ||
262
+ loaded.length > PROMPT_SKILL_SUMMARY_LIMIT) {
263
+ lines.push(`- ...more skills omitted from the startup summary. ${resourceToolHint("list", '`prefix: "skills/"` to inspect the full catalog')}`);
264
+ }
265
+ return `<resource-skills>\nThe following workspace skills are available in addition to codebase skills. They may come from SQL resources, Dispatch workspace resources, or local file mode. Read a matching skill before starting a task it applies to.\n\n${lines.join("\n")}\n</resource-skills>`;
266
+ }
267
+ catch {
268
+ return null;
269
+ }
270
+ }
271
+ async function loadResourceIndexForPrompt(owner, scope) {
272
+ try {
273
+ const resources = (await resourceList(owner))
274
+ .filter((resource) => !isSpecialPromptResourcePath(resource.path) &&
275
+ isTextLikeResource(resource.mimeType))
276
+ .sort((a, b) => a.path.localeCompare(b.path));
277
+ if (resources.length === 0)
278
+ return null;
279
+ const listed = resources.slice(0, SHARED_RESOURCE_INDEX_LIMIT);
280
+ const lines = [];
281
+ const fullResources = await Promise.all(listed.map((resource) => resourceGet(resource.id).catch(() => null)));
282
+ for (let index = 0; index < listed.length; index++) {
283
+ const resource = listed[index];
284
+ const full = fullResources[index];
285
+ const summary = full?.content
286
+ ? getResourceSummaryFromContent(full.content)
287
+ : null;
288
+ lines.push(`- \`${resource.path}\`${summary ? ` - ${summary}` : ""}`);
289
+ }
290
+ if (resources.length > listed.length) {
291
+ lines.push(`- ...${resources.length - listed.length} more ${scope} resources. ${resourceToolHint("list", `\`scope: "${scope}"\` to inspect them`)}`);
292
+ }
293
+ const label = scope === "workspace"
294
+ ? "Workspace reference resources are inherited by every app and are available for company, brand, positioning, persona, product, or domain context."
295
+ : "Shared app/organization reference resources are available for app-specific or team context.";
296
+ return `<workspace-resources scope="${scope}">\n${label} ${resourceToolHint("read", `\`path: <path>\` and \`scope: "${scope}"\` when a task may depend on them`)} Do not assume their contents without reading the relevant file.\n\n${lines.join("\n")}\n</workspace-resources>`;
297
+ }
298
+ catch {
299
+ return null;
300
+ }
301
+ }
302
+ /**
303
+ * Pre-load the agent's context: AGENTS.md (workspace/template/runtime
304
+ * instructions), the skills index, shared LEARNINGS.md (team notes), a shared
305
+ * resource index, and memory/MEMORY.md (personal structured memory index).
306
+ * These all get appended to the system prompt so the agent has everything it
307
+ * needs from the first turn.
308
+ *
309
+ * Six sources are layered:
310
+ *
311
+ * 1. `<workspace>` — AGENTS.md from the enterprise workspace core.
312
+ * 2. `<template>` — AGENTS.md + skills index from the Vite plugin bundle.
313
+ * 3. `<workspace>` — SQL workspace AGENTS.md and instructions/*.md.
314
+ * Runtime global defaults managed from Dispatch and inherited by apps.
315
+ * 4. `<app-default>` — legacy app-wide SQL defaults.
316
+ * 5. `<shared>` — organization AGENTS.md, instructions, and LEARNINGS.md.
317
+ * These are isolated by active org and override app/workspace defaults.
318
+ * 6. `<personal>` — memory/MEMORY.md from the SQL personal scope. The
319
+ * current user's structured memory index.
320
+ *
321
+ * Each source is read independently — no copying between them. Editing
322
+ * AGENTS.md and restarting the server is all it takes; Vite HMR invalidates
323
+ * the bundle in dev so changes land instantly.
324
+ */
325
+ export async function loadResourcesForPrompt(owner, compact = false, selfAppId, orgId = getRequestOrgId() ?? null) {
326
+ await ensurePersonalDefaults(owner);
327
+ const sections = [];
328
+ const promptResourceMaxChars = compact
329
+ ? COMPACT_PROMPT_RESOURCE_MAX_CHARS
330
+ : SHARED_PROMPT_RESOURCE_MAX_CHARS;
331
+ // 1. Workspace AGENTS.md + skills merged into the template bundle.
332
+ try {
333
+ const { loadAgentsBundle, generateSkillsPromptBlock, getRuntimeSkills } = await import("../agents-bundle.js");
334
+ const bundle = await loadAgentsBundle();
335
+ // Workspace-core AGENTS.md (enterprise-wide instructions), if present.
336
+ if (bundle.workspaceAgentsMd && bundle.workspaceAgentsMd.trim()) {
337
+ const block = promptResourceBlock({
338
+ name: "AGENTS.md",
339
+ scope: "workspace",
340
+ path: "AGENTS.md",
341
+ content: bundle.workspaceAgentsMd,
342
+ maxChars: promptResourceMaxChars,
343
+ readHint: 'Use docs-search --slug "agents-workspace" to read the full workspace AGENTS.md.',
344
+ });
345
+ if (block)
346
+ sections.push(block);
347
+ }
348
+ // 2. Template AGENTS.md — always included (critical template instructions).
349
+ if (bundle.agentsMd.trim()) {
350
+ const block = promptResourceBlock({
351
+ name: "AGENTS.md",
352
+ scope: "template",
353
+ path: "AGENTS.md",
354
+ content: bundle.agentsMd,
355
+ maxChars: promptResourceMaxChars,
356
+ readHint: 'Use docs-search --slug "agents-template" to read the full template AGENTS.md.',
357
+ });
358
+ if (block)
359
+ sections.push(block);
360
+ }
361
+ // In compact mode, skip the full skills block — the agent can use
362
+ // `docs-search` to find skills when it needs them. Either way, `scope: dev`
363
+ // skills are excluded: they're for the human's coding agent, not runtime.
364
+ const runtimeSkills = getRuntimeSkills(bundle);
365
+ if (!compact) {
366
+ const skillsBlock = generateSkillsPromptBlock(bundle);
367
+ if (skillsBlock)
368
+ sections.push(skillsBlock);
369
+ }
370
+ else if (runtimeSkills.length > 0) {
371
+ const listedSkills = runtimeSkills.slice(0, PROMPT_SKILL_SUMMARY_LIMIT);
372
+ const lines = listedSkills.map((s) => {
373
+ const description = s.meta.description?.trim()
374
+ ? ` - ${ensureSentence(compactPromptLine(s.meta.description, PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS))}`
375
+ : "";
376
+ return `- \`${s.meta.name}\`${description} Read with \`docs-search --slug "${skillDocsSlug(s.meta.name)}"\` before starting a task it applies to.`;
377
+ });
378
+ if (runtimeSkills.length > listedSkills.length) {
379
+ lines.push(`- ...${runtimeSkills.length - listedSkills.length} more codebase skills. Use \`docs-search --query "<topic>"\` to discover the relevant one.`);
380
+ }
381
+ sections.push(`<skills-summary>\nCodebase skills bundled from \`.agents/skills/\` (or legacy \`.agent/skills/\`) are available as docs-search pages. Do not use MCP resource reads for these skills.\n\n${lines.join("\n")}\n</skills-summary>`);
382
+ }
383
+ }
384
+ catch { }
385
+ // 3. Runtime workspace resources. These are global defaults inherited by
386
+ // every app in the workspace, not copied into app scopes. They may come from
387
+ // SQL, Dispatch, or local file mode.
388
+ const workspaceAgents = await loadAgentsResourceForPrompt(WORKSPACE_OWNER, "workspace", promptResourceMaxChars);
389
+ if (workspaceAgents)
390
+ sections.push(workspaceAgents);
391
+ sections.push(...(await loadInstructionResourcesForPrompt(WORKSPACE_OWNER, "workspace-instruction", promptResourceMaxChars, compact)));
392
+ const organizationOwner = sharedResourceOwner(orgId);
393
+ // 4. Legacy app-wide defaults. Existing deployments keep their seeded
394
+ // shared guidance as an inherited fallback; organization writes never
395
+ // mutate this owner.
396
+ const appDefaultAgents = await loadAgentsResourceForPrompt(SHARED_OWNER, organizationOwner === SHARED_OWNER ? "shared" : "app-default", promptResourceMaxChars);
397
+ if (appDefaultAgents)
398
+ sections.push(appDefaultAgents);
399
+ sections.push(...(await loadInstructionResourcesForPrompt(SHARED_OWNER, organizationOwner === SHARED_OWNER
400
+ ? "shared-instruction"
401
+ : "app-default-instruction", promptResourceMaxChars, compact)));
402
+ // 5. Active organization resources. These are the durable team rules and
403
+ // learnings that Slack/integration runs share with interactive app chat.
404
+ if (organizationOwner !== SHARED_OWNER) {
405
+ const organizationAgents = await loadAgentsResourceForPrompt(organizationOwner, "shared", promptResourceMaxChars);
406
+ if (organizationAgents)
407
+ sections.push(organizationAgents);
408
+ sections.push(...(await loadInstructionResourcesForPrompt(organizationOwner, "shared-instruction", promptResourceMaxChars, compact)));
409
+ }
410
+ // 6. Personal SQL resources. These come last in the instruction stack so a
411
+ // user can narrow or override organization/app and workspace defaults.
412
+ if (owner !== SHARED_OWNER && owner !== WORKSPACE_OWNER) {
413
+ const personalAgents = await loadAgentsResourceForPrompt(owner, "personal", promptResourceMaxChars);
414
+ if (personalAgents)
415
+ sections.push(personalAgents);
416
+ sections.push(...(await loadInstructionResourcesForPrompt(owner, "personal-instruction", promptResourceMaxChars, compact)));
417
+ }
418
+ const resourceSkillsBlock = await loadResourceSkillsPromptBlock(owner, orgId);
419
+ if (resourceSkillsBlock)
420
+ sections.push(resourceSkillsBlock);
421
+ let sharedLearnings = null;
422
+ try {
423
+ sharedLearnings =
424
+ (organizationOwner !== SHARED_OWNER
425
+ ? await resourceGetByPath(organizationOwner, "LEARNINGS.md")
426
+ : null) ?? (await resourceGetByPath(SHARED_OWNER, "LEARNINGS.md"));
427
+ }
428
+ catch { }
429
+ if (compact) {
430
+ // Integration/Slack turns use compact context, but organization learnings
431
+ // are operational routing input, not optional background. Preload the
432
+ // bounded shared file so canonical destinations/fields are available on
433
+ // the first turn; keep personal memory on-demand to preserve the compact
434
+ // budget.
435
+ if (sharedLearnings?.content?.trim()) {
436
+ const block = promptResourceBlock({
437
+ name: "LEARNINGS.md",
438
+ scope: "shared",
439
+ path: "LEARNINGS.md",
440
+ content: sharedLearnings.content,
441
+ maxChars: COMPACT_PROMPT_RESOURCE_MAX_CHARS,
442
+ });
443
+ if (block)
444
+ sections.push(block);
445
+ }
446
+ sections.push(`<context-note>Organization learnings above and your personal memory (memory/MEMORY.md) are available via the \`resources\` tool. Save durable team facts and routing conventions to shared LEARNINGS.md; keep personal preferences in save-memory.</context-note>`);
447
+ }
448
+ else {
449
+ // LEARNINGS.md from SQL (template-level instructions are in AGENTS.md
450
+ // above). Capped like every other prompt resource — an unbounded team
451
+ // notes file would otherwise inline in full on every non-lazy request.
452
+ if (sharedLearnings?.content?.trim()) {
453
+ const block = promptResourceBlock({
454
+ name: "LEARNINGS.md",
455
+ scope: "shared",
456
+ path: "LEARNINGS.md",
457
+ content: sharedLearnings.content,
458
+ maxChars: SHARED_PROMPT_RESOURCE_MAX_CHARS,
459
+ });
460
+ if (block)
461
+ sections.push(block);
462
+ }
463
+ // 3. Personal memory index (skip if owner is the shared sentinel).
464
+ // Same cap as LEARNINGS.md — a large personal MEMORY.md index must not
465
+ // inline without bound just because this request opted out of lazy
466
+ // context.
467
+ if (owner !== SHARED_OWNER) {
468
+ try {
469
+ const memoryIndex = await resourceGetByPath(owner, "memory/MEMORY.md");
470
+ if (memoryIndex?.content?.trim()) {
471
+ const block = promptResourceBlock({
472
+ name: "memory/MEMORY.md",
473
+ scope: "personal",
474
+ path: "memory/MEMORY.md",
475
+ content: memoryIndex.content,
476
+ maxChars: SHARED_PROMPT_RESOURCE_MAX_CHARS,
477
+ });
478
+ if (block)
479
+ sections.push(block);
480
+ }
481
+ }
482
+ catch { }
483
+ }
484
+ }
485
+ const workspaceResourceIndex = await loadResourceIndexForPrompt(WORKSPACE_OWNER, "workspace");
486
+ if (workspaceResourceIndex)
487
+ sections.push(workspaceResourceIndex);
488
+ const appDefaultResourceIndex = await loadResourceIndexForPrompt(SHARED_OWNER, "shared");
489
+ if (appDefaultResourceIndex)
490
+ sections.push(appDefaultResourceIndex);
491
+ if (organizationOwner !== SHARED_OWNER) {
492
+ const organizationResourceIndex = await loadResourceIndexForPrompt(organizationOwner, "shared");
493
+ if (organizationResourceIndex)
494
+ sections.push(organizationResourceIndex);
495
+ }
496
+ try {
497
+ const agents = (await discoverAgents(selfAppId)).slice(0, 30);
498
+ if (agents.length > 0) {
499
+ const lines = agents.map((agent) => `- ${agent.name} (${agent.id}) — ${agent.description || "Connected A2A app"}`);
500
+ sections.push(`<available-apps>\nWorkspace apps available over A2A/call-agent:\n${lines.join("\n")}\n\nUse \`call-agent\` with the app id when another app owns the work or data. Use tool-search or app-specific actions for details only when needed.\n</available-apps>`);
501
+ }
502
+ }
503
+ catch {
504
+ // Agent discovery is helpful context, not required for the run.
505
+ }
506
+ if (sections.length === 0)
507
+ return "";
508
+ const selectedSections = compact
509
+ ? selectPromptSectionsWithinBudget(sections, COMPACT_PROMPT_RESOURCES_TOTAL_MAX_CHARS)
510
+ : sections;
511
+ return ("\n\nThe following resources contain template-specific instructions and user context. Use the information in them to help the user.\n\n" +
512
+ selectedSections.join("\n\n"));
513
+ }
514
+ //# sourceMappingURL=prompt-resources.js.map
@@ -0,0 +1 @@
1
+ {"version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,oEAAoE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,yKAAyK,CAC9P,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;IAClE,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,gBAAgB,GAAG,OAAO;QAC9B,CAAC,CAAC,gCAAgC,CAC9B,QAAQ,EACR,wCAAwC,CACzC;QACH,CAAC,CAAC,QAAQ,CAAC;IACb,OAAO,CACL,wIAAwI;QACxI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getFrontmatterValue,\n getSkillNameFromPath,\n parseFrontmatter,\n} from \"../../resources/metadata.js\";\nimport {\n ensurePersonalDefaults,\n organizationIdFromResourceOwner,\n resourceGet,\n resourceGetByPath,\n resourceList,\n resourceListAccessible,\n SHARED_OWNER,\n sharedResourceOwner,\n WORKSPACE_OWNER,\n} from \"../../resources/store.js\";\nimport { discoverAgents } from \"../agent-discovery.js\";\nimport { getRequestOrgId } from \"../request-context.js\";\nimport { parseSkillFrontmatter } from \"./skill-frontmatter.js\";\n\n// ---------------------------------------------------------------------------\n// System-prompt resource loading: AGENTS.md, instructions/*.md, skills\n// summaries, and the shared/workspace resource index. Assembled by\n// `loadResourcesForPrompt`, the top-level orchestrator called once per\n// request to build the \"here's what you should know\" context block.\n// ---------------------------------------------------------------------------\n\nconst SHARED_PROMPT_RESOURCE_MAX_CHARS = 30_000;\nexport const COMPACT_PROMPT_RESOURCE_MAX_CHARS = 6_000;\nconst COMPACT_PROMPT_RESOURCES_TOTAL_MAX_CHARS = 48_000;\n\nexport function compactPromptLine(value: string, maxChars: number): string {\n const line = value.replace(/\\s+/g, \" \").trim();\n if (line.length <= maxChars) return line;\n return `${line.slice(0, maxChars - 1)}…`;\n}\nconst SHARED_RESOURCE_INDEX_LIMIT = 40;\nconst PROMPT_SKILL_SUMMARY_LIMIT = 40;\nconst PROMPT_SKILL_METADATA_READ_LIMIT = 80;\nconst PROMPT_INSTRUCTION_SUMMARY_LIMIT = 20;\nconst PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS = 180;\n\nfunction normalizeResourcePathForPrompt(path: string): string {\n return path.replace(/^\\/+/, \"\").trim();\n}\n\nfunction resourceToolHint(\n action: \"list\" | \"read\" | \"effective\" | \"write\" | \"delete\" | \"promote\",\n extra?: string,\n): string {\n return `Use the \\`resources\\` tool with \\`action: \"${action}\"\\`${extra ? `, ${extra}` : \"\"}.`;\n}\n\nfunction skillDocsSlug(name: string): string {\n return `skill-${name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")}`;\n}\n\nfunction ensureSentence(value: string): string {\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n return /[.!?]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\n\nfunction escapeXmlAttribute(value: string): string {\n return value.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\");\n}\n\nfunction truncatePromptResourceContent(\n content: string,\n path: string,\n maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS,\n readHint?: string,\n): string {\n const trimmed = content.trim();\n if (trimmed.length <= maxChars) return trimmed;\n const omitted = trimmed.length - maxChars;\n const hint =\n readHint ??\n resourceToolHint(\n \"read\",\n `\\`path: \"${path}\"\\` and the resource's \\`scope\\` for the full content`,\n );\n return `${trimmed.slice(0, maxChars)}\\n\\n[Resource ${path} truncated after ${maxChars.toLocaleString()} characters; ${omitted.toLocaleString()} characters omitted. ${hint}]`;\n}\n\nfunction promptResourceBlock(input: {\n name: string;\n scope: string;\n content: string;\n path?: string;\n maxChars?: number;\n readHint?: string;\n}): string | null {\n const normalizedPath = input.path\n ? normalizeResourcePathForPrompt(input.path)\n : undefined;\n const content = truncatePromptResourceContent(\n input.content,\n normalizedPath ?? input.name,\n input.maxChars,\n input.readHint,\n );\n if (!content) return null;\n const pathAttr = normalizedPath\n ? ` path=\"${escapeXmlAttribute(normalizedPath)}\"`\n : \"\";\n return `<resource name=\"${escapeXmlAttribute(input.name)}\" scope=\"${escapeXmlAttribute(input.scope)}\"${pathAttr}>\\n${content}\\n</resource>`;\n}\n\nfunction selectPromptSectionsWithinBudget(\n sections: string[],\n maxChars: number,\n): string[] {\n const omissionNote = `<context-budget-note>Some startup context sections were omitted to keep the first model request responsive. Use \\`resources\\` with \\`action: \"list\"\\` or \\`\"read\"\\`, \\`docs-search\\`, and \\`tool-search\\` to retrieve relevant depth on demand.</context-budget-note>`;\n const contentBudget = Math.max(0, maxChars - omissionNote.length - 2);\n const selected: string[] = [];\n let used = 0;\n let omitted = 0;\n\n for (const section of sections) {\n const separatorChars = selected.length > 0 ? 2 : 0;\n if (used + separatorChars + section.length <= contentBudget) {\n selected.push(section);\n used += separatorChars + section.length;\n } else {\n omitted++;\n }\n }\n\n if (omitted > 0) selected.push(omissionNote);\n return selected;\n}\n\nfunction isAutoLoadedInstructionPath(path: string): boolean {\n const normalized = normalizeResourcePathForPrompt(path);\n return normalized.startsWith(\"instructions/\") && normalized.endsWith(\".md\");\n}\n\nfunction isSpecialPromptResourcePath(path: string): boolean {\n const normalized = normalizeResourcePathForPrompt(path);\n return (\n normalized === \"AGENTS.md\" ||\n normalized === \"LEARNINGS.md\" ||\n normalized.startsWith(\"instructions/\") ||\n normalized.startsWith(\"skills/\") ||\n normalized.startsWith(\"agents/\") ||\n normalized.startsWith(\"remote-agents/\") ||\n normalized.startsWith(\"jobs/\") ||\n normalized.startsWith(\"memory/\")\n );\n}\n\nfunction isTextLikeResource(mimeType: string): boolean {\n return (\n mimeType.startsWith(\"text/\") ||\n mimeType === \"application/json\" ||\n mimeType === \"application/yaml\" ||\n mimeType === \"application/x-yaml\"\n );\n}\n\nfunction getResourceSummaryFromContent(content: string): string | null {\n const frontmatter = parseFrontmatter(content);\n const title =\n getFrontmatterValue(frontmatter, \"title\") ||\n getFrontmatterValue(frontmatter, \"name\");\n const description = getFrontmatterValue(frontmatter, \"description\");\n if (title && description) return `${title}: ${description}`;\n if (title) return title;\n if (description) return description;\n\n const heading = content\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .find((line) => /^#{1,3}\\s+\\S/.test(line));\n if (heading) return heading.replace(/^#{1,3}\\s+/, \"\").trim();\n return null;\n}\n\nexport function resourceScopeForOwner(\n owner: string,\n currentOwner?: string,\n): string {\n if (owner === WORKSPACE_OWNER) return \"workspace\";\n if (owner === SHARED_OWNER || organizationIdFromResourceOwner(owner)) {\n return \"shared\";\n }\n if (currentOwner && owner === currentOwner) return \"personal\";\n return \"resource\";\n}\n\nasync function loadAgentsResourceForPrompt(\n owner: string,\n scope: string,\n maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS,\n): Promise<string | null> {\n try {\n const agents = await resourceGetByPath(owner, \"AGENTS.md\");\n if (!agents?.content?.trim()) return null;\n return promptResourceBlock({\n name: \"AGENTS.md\",\n scope,\n path: \"AGENTS.md\",\n content: agents.content,\n maxChars,\n });\n } catch {\n return null;\n }\n}\n\nasync function loadInstructionResourcesForPrompt(\n owner: string,\n scope: string,\n maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS,\n summaryOnly = false,\n): Promise<string[]> {\n try {\n const resources = await resourceList(owner, \"instructions/\");\n const sorted = resources\n .filter((resource) => isAutoLoadedInstructionPath(resource.path))\n .sort((a, b) => a.path.localeCompare(b.path));\n\n if (summaryOnly) {\n if (sorted.length === 0) return [];\n const resourceScope = scope.startsWith(\"workspace\")\n ? \"workspace\"\n : scope.startsWith(\"personal\")\n ? \"personal\"\n : \"shared\";\n const listed = sorted.slice(0, PROMPT_INSTRUCTION_SUMMARY_LIMIT);\n const lines = listed.map(\n (resource) =>\n `- \\`${resource.path}\\` - ${resourceToolHint(\"read\", `\\`path: \"${resource.path}\"\\` and \\`scope: \"${resourceScope}\"\\` when it applies`)}`,\n );\n if (sorted.length > listed.length) {\n lines.push(\n `- ...${sorted.length - listed.length} more instruction files. ${resourceToolHint(\"list\", `\\`scope: \"${resourceScope}\"\\` and \\`prefix: \"instructions/\"\\``)}`,\n );\n }\n return [\n `<instruction-resources scope=\"${escapeXmlAttribute(scope)}\">\\nDetailed instruction files are loaded on demand so the first model request stays compact. Read a relevant file before following its workflow.\\n\\n${lines.join(\"\\n\")}\\n</instruction-resources>`,\n ];\n }\n\n const fullResources = await Promise.all(\n sorted.map((resource) => resourceGet(resource.id).catch(() => null)),\n );\n const blocks: string[] = [];\n for (let index = 0; index < sorted.length; index++) {\n const resource = sorted[index]!;\n const full = fullResources[index];\n if (!full?.content?.trim()) continue;\n const block = promptResourceBlock({\n name: resource.path,\n scope,\n path: resource.path,\n content: full.content,\n maxChars,\n });\n if (block) blocks.push(block);\n }\n return blocks;\n } catch {\n return [];\n }\n}\n\nasync function loadResourceSkillsPromptBlock(\n owner: string,\n orgId?: string | null,\n): Promise<string | null> {\n try {\n const organizationOwner = sharedResourceOwner(orgId);\n const resources =\n owner === SHARED_OWNER\n ? [\n ...(await resourceList(SHARED_OWNER, \"skills/\")),\n ...(await resourceList(WORKSPACE_OWNER, \"skills/\")),\n ]\n : await resourceListAccessible(owner, \"skills/\", { orgId });\n const sorted = resources.sort((a, b) => {\n const ownerOrder =\n (a.owner === owner\n ? 0\n : a.owner === organizationOwner\n ? 1\n : a.owner === SHARED_OWNER\n ? 2\n : a.owner === WORKSPACE_OWNER\n ? 3\n : 4) -\n (b.owner === owner\n ? 0\n : b.owner === organizationOwner\n ? 1\n : b.owner === SHARED_OWNER\n ? 2\n : b.owner === WORKSPACE_OWNER\n ? 3\n : 4);\n if (ownerOrder !== 0) return ownerOrder;\n return a.path.localeCompare(b.path);\n });\n const skillCandidates = sorted.slice(0, PROMPT_SKILL_METADATA_READ_LIMIT);\n const loaded = await Promise.all(\n skillCandidates.map(async (resource) => ({\n resource,\n full: await resourceGet(resource.id).catch(() => null),\n })),\n );\n const seen = new Set<string>();\n const lines: string[] = [];\n for (const { resource, full } of loaded) {\n if (!full?.content) continue;\n const meta = parseSkillFrontmatter(full.content);\n if (meta.userInvocable === false) continue;\n if (meta.scope === \"dev\") continue;\n const name = meta.name || getSkillNameFromPath(resource.path);\n if (!name || seen.has(name)) continue;\n seen.add(name);\n const scope = resourceScopeForOwner(resource.owner, owner);\n const description = compactPromptLine(\n meta.description || \"(no description)\",\n PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS,\n );\n lines.push(\n `- \\`${name}\\` at resource \\`${resource.path}\\` (${scope}) - ${ensureSentence(description)} ${resourceToolHint(\n \"read\",\n `\\`path: \"${resource.path}\"\\` and \\`scope: \"${scope}\"\\` before starting a task it applies to`,\n )}`,\n );\n if (lines.length >= PROMPT_SKILL_SUMMARY_LIMIT) break;\n }\n if (lines.length === 0) return null;\n if (\n sorted.length > skillCandidates.length ||\n loaded.length > PROMPT_SKILL_SUMMARY_LIMIT\n ) {\n lines.push(\n `- ...more skills omitted from the startup summary. ${resourceToolHint(\"list\", '`prefix: \"skills/\"` to inspect the full catalog')}`,\n );\n }\n return `<resource-skills>\\nThe following workspace skills are available in addition to codebase skills. They may come from SQL resources, Dispatch workspace resources, or local file mode. Read a matching skill before starting a task it applies to.\\n\\n${lines.join(\"\\n\")}\\n</resource-skills>`;\n } catch {\n return null;\n }\n}\n\nasync function loadResourceIndexForPrompt(\n owner: string,\n scope: \"workspace\" | \"shared\",\n): Promise<string | null> {\n try {\n const resources = (await resourceList(owner))\n .filter(\n (resource) =>\n !isSpecialPromptResourcePath(resource.path) &&\n isTextLikeResource(resource.mimeType),\n )\n .sort((a, b) => a.path.localeCompare(b.path));\n if (resources.length === 0) return null;\n\n const listed = resources.slice(0, SHARED_RESOURCE_INDEX_LIMIT);\n const lines: string[] = [];\n const fullResources = await Promise.all(\n listed.map((resource) => resourceGet(resource.id).catch(() => null)),\n );\n for (let index = 0; index < listed.length; index++) {\n const resource = listed[index]!;\n const full = fullResources[index];\n const summary = full?.content\n ? getResourceSummaryFromContent(full.content)\n : null;\n lines.push(`- \\`${resource.path}\\`${summary ? ` - ${summary}` : \"\"}`);\n }\n if (resources.length > listed.length) {\n lines.push(\n `- ...${resources.length - listed.length} more ${scope} resources. ${resourceToolHint(\n \"list\",\n `\\`scope: \"${scope}\"\\` to inspect them`,\n )}`,\n );\n }\n\n const label =\n scope === \"workspace\"\n ? \"Workspace reference resources are inherited by every app and are available for company, brand, positioning, persona, product, or domain context.\"\n : \"Shared app/organization reference resources are available for app-specific or team context.\";\n return `<workspace-resources scope=\"${scope}\">\\n${label} ${resourceToolHint(\n \"read\",\n `\\`path: <path>\\` and \\`scope: \"${scope}\"\\` when a task may depend on them`,\n )} Do not assume their contents without reading the relevant file.\\n\\n${lines.join(\"\\n\")}\\n</workspace-resources>`;\n } catch {\n return null;\n }\n}\n\n/**\n * Pre-load the agent's context: AGENTS.md (workspace/template/runtime\n * instructions), the skills index, shared LEARNINGS.md (team notes), a shared\n * resource index, and memory/MEMORY.md (personal structured memory index).\n * These all get appended to the system prompt so the agent has everything it\n * needs from the first turn.\n *\n * Six sources are layered:\n *\n * 1. `<workspace>` — AGENTS.md from the enterprise workspace core.\n * 2. `<template>` — AGENTS.md + skills index from the Vite plugin bundle.\n * 3. `<workspace>` — SQL workspace AGENTS.md and instructions/*.md.\n * Runtime global defaults managed from Dispatch and inherited by apps.\n * 4. `<app-default>` — legacy app-wide SQL defaults.\n * 5. `<shared>` — organization AGENTS.md, instructions, and LEARNINGS.md.\n * These are isolated by active org and override app/workspace defaults.\n * 6. `<personal>` — memory/MEMORY.md from the SQL personal scope. The\n * current user's structured memory index.\n *\n * Each source is read independently — no copying between them. Editing\n * AGENTS.md and restarting the server is all it takes; Vite HMR invalidates\n * the bundle in dev so changes land instantly.\n */\nexport async function loadResourcesForPrompt(\n owner: string,\n compact = false,\n selfAppId?: string,\n orgId: string | null = getRequestOrgId() ?? null,\n): Promise<string> {\n await ensurePersonalDefaults(owner);\n\n const sections: string[] = [];\n const promptResourceMaxChars = compact\n ? COMPACT_PROMPT_RESOURCE_MAX_CHARS\n : SHARED_PROMPT_RESOURCE_MAX_CHARS;\n\n // 1. Workspace AGENTS.md + skills merged into the template bundle.\n try {\n const { loadAgentsBundle, generateSkillsPromptBlock, getRuntimeSkills } =\n await import(\"../agents-bundle.js\");\n const bundle = await loadAgentsBundle();\n\n // Workspace-core AGENTS.md (enterprise-wide instructions), if present.\n if (bundle.workspaceAgentsMd && bundle.workspaceAgentsMd.trim()) {\n const block = promptResourceBlock({\n name: \"AGENTS.md\",\n scope: \"workspace\",\n path: \"AGENTS.md\",\n content: bundle.workspaceAgentsMd,\n maxChars: promptResourceMaxChars,\n readHint:\n 'Use docs-search --slug \"agents-workspace\" to read the full workspace AGENTS.md.',\n });\n if (block) sections.push(block);\n }\n\n // 2. Template AGENTS.md — always included (critical template instructions).\n if (bundle.agentsMd.trim()) {\n const block = promptResourceBlock({\n name: \"AGENTS.md\",\n scope: \"template\",\n path: \"AGENTS.md\",\n content: bundle.agentsMd,\n maxChars: promptResourceMaxChars,\n readHint:\n 'Use docs-search --slug \"agents-template\" to read the full template AGENTS.md.',\n });\n if (block) sections.push(block);\n }\n\n // In compact mode, skip the full skills block — the agent can use\n // `docs-search` to find skills when it needs them. Either way, `scope: dev`\n // skills are excluded: they're for the human's coding agent, not runtime.\n const runtimeSkills = getRuntimeSkills(bundle);\n if (!compact) {\n const skillsBlock = generateSkillsPromptBlock(bundle);\n if (skillsBlock) sections.push(skillsBlock);\n } else if (runtimeSkills.length > 0) {\n const listedSkills = runtimeSkills.slice(0, PROMPT_SKILL_SUMMARY_LIMIT);\n const lines = listedSkills.map((s) => {\n const description = s.meta.description?.trim()\n ? ` - ${ensureSentence(compactPromptLine(s.meta.description, PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS))}`\n : \"\";\n return `- \\`${s.meta.name}\\`${description} Read with \\`docs-search --slug \"${skillDocsSlug(s.meta.name)}\"\\` before starting a task it applies to.`;\n });\n if (runtimeSkills.length > listedSkills.length) {\n lines.push(\n `- ...${runtimeSkills.length - listedSkills.length} more codebase skills. Use \\`docs-search --query \"<topic>\"\\` to discover the relevant one.`,\n );\n }\n sections.push(\n `<skills-summary>\\nCodebase skills bundled from \\`.agents/skills/\\` (or legacy \\`.agent/skills/\\`) are available as docs-search pages. Do not use MCP resource reads for these skills.\\n\\n${lines.join(\"\\n\")}\\n</skills-summary>`,\n );\n }\n } catch {}\n\n // 3. Runtime workspace resources. These are global defaults inherited by\n // every app in the workspace, not copied into app scopes. They may come from\n // SQL, Dispatch, or local file mode.\n const workspaceAgents = await loadAgentsResourceForPrompt(\n WORKSPACE_OWNER,\n \"workspace\",\n promptResourceMaxChars,\n );\n if (workspaceAgents) sections.push(workspaceAgents);\n sections.push(\n ...(await loadInstructionResourcesForPrompt(\n WORKSPACE_OWNER,\n \"workspace-instruction\",\n promptResourceMaxChars,\n compact,\n )),\n );\n\n const organizationOwner = sharedResourceOwner(orgId);\n\n // 4. Legacy app-wide defaults. Existing deployments keep their seeded\n // shared guidance as an inherited fallback; organization writes never\n // mutate this owner.\n const appDefaultAgents = await loadAgentsResourceForPrompt(\n SHARED_OWNER,\n organizationOwner === SHARED_OWNER ? \"shared\" : \"app-default\",\n promptResourceMaxChars,\n );\n if (appDefaultAgents) sections.push(appDefaultAgents);\n sections.push(\n ...(await loadInstructionResourcesForPrompt(\n SHARED_OWNER,\n organizationOwner === SHARED_OWNER\n ? \"shared-instruction\"\n : \"app-default-instruction\",\n promptResourceMaxChars,\n compact,\n )),\n );\n\n // 5. Active organization resources. These are the durable team rules and\n // learnings that Slack/integration runs share with interactive app chat.\n if (organizationOwner !== SHARED_OWNER) {\n const organizationAgents = await loadAgentsResourceForPrompt(\n organizationOwner,\n \"shared\",\n promptResourceMaxChars,\n );\n if (organizationAgents) sections.push(organizationAgents);\n sections.push(\n ...(await loadInstructionResourcesForPrompt(\n organizationOwner,\n \"shared-instruction\",\n promptResourceMaxChars,\n compact,\n )),\n );\n }\n\n // 6. Personal SQL resources. These come last in the instruction stack so a\n // user can narrow or override organization/app and workspace defaults.\n if (owner !== SHARED_OWNER && owner !== WORKSPACE_OWNER) {\n const personalAgents = await loadAgentsResourceForPrompt(\n owner,\n \"personal\",\n promptResourceMaxChars,\n );\n if (personalAgents) sections.push(personalAgents);\n sections.push(\n ...(await loadInstructionResourcesForPrompt(\n owner,\n \"personal-instruction\",\n promptResourceMaxChars,\n compact,\n )),\n );\n }\n\n const resourceSkillsBlock = await loadResourceSkillsPromptBlock(owner, orgId);\n if (resourceSkillsBlock) sections.push(resourceSkillsBlock);\n\n let sharedLearnings: Awaited<ReturnType<typeof resourceGetByPath>> = null;\n try {\n sharedLearnings =\n (organizationOwner !== SHARED_OWNER\n ? await resourceGetByPath(organizationOwner, \"LEARNINGS.md\")\n : null) ?? (await resourceGetByPath(SHARED_OWNER, \"LEARNINGS.md\"));\n } catch {}\n\n if (compact) {\n // Integration/Slack turns use compact context, but organization learnings\n // are operational routing input, not optional background. Preload the\n // bounded shared file so canonical destinations/fields are available on\n // the first turn; keep personal memory on-demand to preserve the compact\n // budget.\n if (sharedLearnings?.content?.trim()) {\n const block = promptResourceBlock({\n name: \"LEARNINGS.md\",\n scope: \"shared\",\n path: \"LEARNINGS.md\",\n content: sharedLearnings.content,\n maxChars: COMPACT_PROMPT_RESOURCE_MAX_CHARS,\n });\n if (block) sections.push(block);\n }\n sections.push(\n `<context-note>Organization learnings above and your personal memory (memory/MEMORY.md) are available via the \\`resources\\` tool. Save durable team facts and routing conventions to shared LEARNINGS.md; keep personal preferences in save-memory.</context-note>`,\n );\n } else {\n // LEARNINGS.md from SQL (template-level instructions are in AGENTS.md\n // above). Capped like every other prompt resource — an unbounded team\n // notes file would otherwise inline in full on every non-lazy request.\n if (sharedLearnings?.content?.trim()) {\n const block = promptResourceBlock({\n name: \"LEARNINGS.md\",\n scope: \"shared\",\n path: \"LEARNINGS.md\",\n content: sharedLearnings.content,\n maxChars: SHARED_PROMPT_RESOURCE_MAX_CHARS,\n });\n if (block) sections.push(block);\n }\n\n // 3. Personal memory index (skip if owner is the shared sentinel).\n // Same cap as LEARNINGS.md — a large personal MEMORY.md index must not\n // inline without bound just because this request opted out of lazy\n // context.\n if (owner !== SHARED_OWNER) {\n try {\n const memoryIndex = await resourceGetByPath(owner, \"memory/MEMORY.md\");\n if (memoryIndex?.content?.trim()) {\n const block = promptResourceBlock({\n name: \"memory/MEMORY.md\",\n scope: \"personal\",\n path: \"memory/MEMORY.md\",\n content: memoryIndex.content,\n maxChars: SHARED_PROMPT_RESOURCE_MAX_CHARS,\n });\n if (block) sections.push(block);\n }\n } catch {}\n }\n }\n\n const workspaceResourceIndex = await loadResourceIndexForPrompt(\n WORKSPACE_OWNER,\n \"workspace\",\n );\n if (workspaceResourceIndex) sections.push(workspaceResourceIndex);\n\n const appDefaultResourceIndex = await loadResourceIndexForPrompt(\n SHARED_OWNER,\n \"shared\",\n );\n if (appDefaultResourceIndex) sections.push(appDefaultResourceIndex);\n if (organizationOwner !== SHARED_OWNER) {\n const organizationResourceIndex = await loadResourceIndexForPrompt(\n organizationOwner,\n \"shared\",\n );\n if (organizationResourceIndex) sections.push(organizationResourceIndex);\n }\n\n try {\n const agents = (await discoverAgents(selfAppId)).slice(0, 30);\n if (agents.length > 0) {\n const lines = agents.map(\n (agent) =>\n `- ${agent.name} (${agent.id}) — ${agent.description || \"Connected A2A app\"}`,\n );\n sections.push(\n `<available-apps>\\nWorkspace apps available over A2A/call-agent:\\n${lines.join(\"\\n\")}\\n\\nUse \\`call-agent\\` with the app id when another app owns the work or data. Use tool-search or app-specific actions for details only when needed.\\n</available-apps>`,\n );\n }\n } catch {\n // Agent discovery is helpful context, not required for the run.\n }\n\n if (sections.length === 0) return \"\";\n const selectedSections = compact\n ? selectPromptSectionsWithinBudget(\n sections,\n COMPACT_PROMPT_RESOURCES_TOTAL_MAX_CHARS,\n )\n : sections;\n return (\n \"\\n\\nThe following resources contain template-specific instructions and user context. Use the information in them to help the user.\\n\\n\" +\n selectedSections.join(\"\\n\\n\")\n );\n}\n"]}
@@ -0,0 +1,5 @@
1
+ type RecurringJobsRuntimeEnvKey = "AGENT_NATIVE_DISABLE_RECURRING_JOBS" | "AGENT_NATIVE_ENABLE_LOCAL_RECURRING_JOBS" | "APP_URL" | "BETTER_AUTH_URL" | "DEPLOY_URL" | "NODE_ENV" | "URL" | "VITE_APP_URL" | "VITE_WORKSPACE_GATEWAY_URL" | "WORKSPACE_GATEWAY_URL";
2
+ type RecurringJobsRuntimeEnv = Partial<Record<RecurringJobsRuntimeEnvKey, string | undefined>>;
3
+ export declare function shouldDisableRecurringJobsRuntime(env?: RecurringJobsRuntimeEnv): boolean;
4
+ export {};
5
+ //# sourceMappingURL=recurring-jobs-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recurring-jobs-runtime.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/recurring-jobs-runtime.ts"],"names":[],"mappings":"AAMA,KAAK,0BAA0B,GAC3B,qCAAqC,GACrC,0CAA0C,GAC1C,SAAS,GACT,iBAAiB,GACjB,YAAY,GACZ,UAAU,GACV,KAAK,GACL,cAAc,GACd,4BAA4B,GAC5B,uBAAuB,CAAC;AAE5B,KAAK,uBAAuB,GAAG,OAAO,CACpC,MAAM,CAAC,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC,CACvD,CAAC;AAiCF,wBAAgB,iCAAiC,CAC/C,GAAG,GAAE,uBAAqC,GACzC,OAAO,CAwBT"}