@agent-native/core 0.99.2 → 0.100.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 (381) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +21 -0
  3. package/corpus/core/docs/content/a2a-protocol.mdx +42 -0
  4. package/corpus/core/docs/content/agent-surfaces.mdx +43 -0
  5. package/corpus/core/docs/content/external-agents.mdx +11 -0
  6. package/corpus/core/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
  7. package/corpus/core/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
  8. package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +9 -0
  9. package/corpus/core/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
  10. package/corpus/core/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
  11. package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +10 -0
  12. package/corpus/core/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
  13. package/corpus/core/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
  14. package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +10 -0
  15. package/corpus/core/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
  16. package/corpus/core/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
  17. package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +11 -0
  18. package/corpus/core/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
  19. package/corpus/core/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
  20. package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +9 -0
  21. package/corpus/core/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
  22. package/corpus/core/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
  23. package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +10 -0
  24. package/corpus/core/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
  25. package/corpus/core/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
  26. package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +9 -0
  27. package/corpus/core/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
  28. package/corpus/core/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
  29. package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +10 -0
  30. package/corpus/core/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
  31. package/corpus/core/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
  32. package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -0
  33. package/corpus/core/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
  34. package/corpus/core/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
  35. package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -0
  36. package/corpus/core/package.json +1 -1
  37. package/corpus/core/src/agent/context-xray/actions/context-evict.ts +11 -0
  38. package/corpus/core/src/agent/context-xray/actions/context-pin.ts +11 -0
  39. package/corpus/core/src/agent/context-xray/actions/context-preview-get.ts +134 -0
  40. package/corpus/core/src/agent/context-xray/actions/context-restore.ts +11 -0
  41. package/corpus/core/src/agent/context-xray/actions/errors.ts +20 -0
  42. package/corpus/core/src/agent/context-xray/manifest.ts +106 -7
  43. package/corpus/core/src/agent/engine/context-directives-transform.ts +5 -1
  44. package/corpus/core/src/agent/production-agent.ts +100 -38
  45. package/corpus/core/src/agent/run-loop-with-resume.ts +7 -2
  46. package/corpus/core/src/client/AgentPanel.tsx +35 -8
  47. package/corpus/core/src/client/agent-page/AgentContextTab.tsx +501 -0
  48. package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +370 -0
  49. package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1084 -0
  50. package/corpus/core/src/client/agent-page/types.ts +18 -0
  51. package/corpus/core/src/client/agent-page/use-jobs.ts +150 -0
  52. package/corpus/core/src/client/context-xray/ContextMeter.tsx +22 -5
  53. package/corpus/core/src/client/context-xray/ContextTreemap.tsx +16 -1
  54. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +168 -3
  55. package/corpus/core/src/client/context-xray/format.ts +6 -0
  56. package/corpus/core/src/client/index.ts +6 -0
  57. package/corpus/core/src/client/resources/ResourcesPanel.tsx +51 -23
  58. package/corpus/core/src/client/settings/AutomationsSection.tsx +407 -387
  59. package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +105 -0
  60. package/corpus/core/src/jobs/actions/manage-recurring-job.ts +85 -0
  61. package/corpus/core/src/jobs/tools.ts +1 -1
  62. package/corpus/core/src/localization/default-messages.ts +110 -0
  63. package/corpus/core/src/mcp/build-server.ts +1 -0
  64. package/corpus/core/src/mcp/connect-route.ts +62 -65
  65. package/corpus/core/src/server/action-discovery.ts +23 -0
  66. package/corpus/core/src/server/agent-chat/prompt-resources.ts +174 -2
  67. package/corpus/core/src/server/agent-chat-plugin.ts +175 -2
  68. package/corpus/core/src/server/auth.ts +1 -7
  69. package/corpus/core/src/server/google-oauth.ts +1 -7
  70. package/corpus/core/src/server/workspace-oauth.ts +31 -0
  71. package/corpus/core/src/shared/context-xray.ts +84 -1
  72. package/corpus/core/src/shared/mcp-connect-content.ts +130 -0
  73. package/corpus/core/src/templates/default/app/routes/_index.tsx +11 -0
  74. package/corpus/core/src/templates/default/app/routes/agent.tsx +33 -0
  75. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  76. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  77. package/corpus/core/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  78. package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  79. package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
  80. package/corpus/core/src/triggers/actions/list-automations.ts +99 -0
  81. package/corpus/core/src/triggers/actions/manage-automation.ts +78 -0
  82. package/corpus/templates/analytics/actions/data-source-status.ts +33 -15
  83. package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +1 -1
  84. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +149 -24
  85. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +17 -0
  86. package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
  87. package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -0
  88. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +8 -0
  89. package/corpus/templates/analytics/app/i18n/zh-TW.ts +1 -0
  90. package/corpus/templates/analytics/app/i18n-data.ts +1 -0
  91. package/corpus/templates/analytics/app/routes/agent.tsx +5 -0
  92. package/corpus/templates/analytics/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  93. package/corpus/templates/analytics/changelog/2026-07-13-analytics-answers-can-use-built-in-first-party-event-data.md +6 -0
  94. package/corpus/templates/analytics/changelog/2026-07-13-chart-legends-can-filter-to-one-series-or-hide-a-series-on-h.md +6 -0
  95. package/corpus/templates/analytics/changelog/2026-07-13-gpt-5-6-luna-answers-now-recover-normally-instead-of-showing.md +6 -0
  96. package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -2
  97. package/corpus/templates/assets/app/components/layout/Header.tsx +1 -0
  98. package/corpus/templates/assets/app/components/layout/Layout.tsx +1 -0
  99. package/corpus/templates/assets/app/components/layout/Sidebar.tsx +2 -0
  100. package/corpus/templates/assets/app/routes/agent.tsx +5 -0
  101. package/corpus/templates/assets/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  102. package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -0
  103. package/corpus/templates/brain/app/components/layout/Sidebar.tsx +4 -1
  104. package/corpus/templates/brain/app/lib/brain.ts +11 -0
  105. package/corpus/templates/brain/app/root.tsx +15 -1
  106. package/corpus/templates/brain/app/routes/agent.tsx +11 -0
  107. package/corpus/templates/brain/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  108. package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -0
  109. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +2 -0
  110. package/corpus/templates/calendar/app/root.tsx +17 -1
  111. package/corpus/templates/calendar/app/routes/_app.agent.tsx +25 -0
  112. package/corpus/templates/calendar/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  113. package/corpus/templates/chat/app/components/layout/Header.tsx +1 -0
  114. package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -0
  115. package/corpus/templates/chat/app/components/layout/Sidebar.tsx +7 -0
  116. package/corpus/templates/chat/app/hooks/use-navigation-state.ts +3 -0
  117. package/corpus/templates/chat/app/root.tsx +24 -2
  118. package/corpus/templates/chat/app/routes/agent.tsx +15 -0
  119. package/corpus/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  120. package/corpus/templates/clips/app/components/library/library-layout.tsx +8 -0
  121. package/corpus/templates/clips/app/i18n/ar-SA.ts +2 -0
  122. package/corpus/templates/clips/app/i18n/de-DE.ts +2 -0
  123. package/corpus/templates/clips/app/i18n/en-US.ts +2 -0
  124. package/corpus/templates/clips/app/i18n/es-ES.ts +2 -0
  125. package/corpus/templates/clips/app/i18n/fr-FR.ts +2 -0
  126. package/corpus/templates/clips/app/i18n/hi-IN.ts +2 -0
  127. package/corpus/templates/clips/app/i18n/ja-JP.ts +2 -0
  128. package/corpus/templates/clips/app/i18n/ko-KR.ts +2 -0
  129. package/corpus/templates/clips/app/i18n/pt-BR.ts +2 -0
  130. package/corpus/templates/clips/app/i18n/zh-CN.ts +2 -0
  131. package/corpus/templates/clips/app/i18n/zh-TW.ts +2 -0
  132. package/corpus/templates/clips/app/root.tsx +7 -1
  133. package/corpus/templates/clips/app/routes/_app.agent.tsx +15 -0
  134. package/corpus/templates/clips/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  135. package/corpus/templates/content/app/components/layout/Layout.tsx +1 -0
  136. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +36 -0
  137. package/corpus/templates/content/app/i18n/zh-TW.ts +2 -0
  138. package/corpus/templates/content/app/i18n-data.ts +44 -6
  139. package/corpus/templates/content/app/root.tsx +8 -0
  140. package/corpus/templates/content/app/routes/_app.agent.tsx +15 -0
  141. package/corpus/templates/content/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  142. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
  143. package/corpus/templates/design/app/components/layout/Sidebar.tsx +2 -0
  144. package/corpus/templates/design/app/i18n/zh-TW.ts +2 -0
  145. package/corpus/templates/design/app/i18n-data.ts +20 -0
  146. package/corpus/templates/design/app/root.tsx +7 -1
  147. package/corpus/templates/design/app/routes/agent.tsx +15 -0
  148. package/corpus/templates/design/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  149. package/corpus/templates/dispatch/app/dispatch-extensions.tsx +10 -1
  150. package/corpus/templates/dispatch/app/i18n/zh-TW.ts +2 -0
  151. package/corpus/templates/dispatch/app/i18n-data.ts +20 -0
  152. package/corpus/templates/dispatch/app/root.tsx +7 -2
  153. package/corpus/templates/dispatch/app/routes/agent.tsx +18 -0
  154. package/corpus/templates/dispatch/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  155. package/corpus/templates/forms/app/components/layout/Layout.tsx +1 -0
  156. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +35 -0
  157. package/corpus/templates/forms/app/i18n/ar-SA.ts +2 -0
  158. package/corpus/templates/forms/app/i18n/de-DE.ts +2 -0
  159. package/corpus/templates/forms/app/i18n/en-US.ts +2 -0
  160. package/corpus/templates/forms/app/i18n/es-ES.ts +2 -0
  161. package/corpus/templates/forms/app/i18n/fr-FR.ts +2 -0
  162. package/corpus/templates/forms/app/i18n/hi-IN.ts +2 -0
  163. package/corpus/templates/forms/app/i18n/ja-JP.ts +2 -0
  164. package/corpus/templates/forms/app/i18n/ko-KR.ts +2 -0
  165. package/corpus/templates/forms/app/i18n/pt-BR.ts +2 -0
  166. package/corpus/templates/forms/app/i18n/zh-CN.ts +2 -0
  167. package/corpus/templates/forms/app/i18n/zh-TW.ts +2 -0
  168. package/corpus/templates/forms/app/root.tsx +6 -1
  169. package/corpus/templates/forms/app/routes/_app.agent.tsx +15 -0
  170. package/corpus/templates/forms/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  171. package/corpus/templates/macros/app/components/layout/AppLayout.tsx +14 -2
  172. package/corpus/templates/macros/app/components/layout/Header.tsx +1 -0
  173. package/corpus/templates/macros/app/root.tsx +17 -2
  174. package/corpus/templates/macros/app/routes/agent.tsx +15 -0
  175. package/corpus/templates/macros/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  176. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +42 -0
  177. package/corpus/templates/mail/app/components/layout/CommandPalette.tsx +6 -0
  178. package/corpus/templates/mail/app/routes/agent.tsx +15 -0
  179. package/corpus/templates/mail/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  180. package/corpus/templates/plan/app/components/layout/Header.tsx +1 -0
  181. package/corpus/templates/plan/app/components/layout/Layout.tsx +1 -0
  182. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +2 -0
  183. package/corpus/templates/plan/app/root.tsx +8 -0
  184. package/corpus/templates/plan/app/routes/agent.tsx +15 -0
  185. package/corpus/templates/plan/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  186. package/corpus/templates/slides/app/components/layout/Header.tsx +1 -0
  187. package/corpus/templates/slides/app/components/layout/Layout.tsx +1 -0
  188. package/corpus/templates/slides/app/components/layout/Sidebar.tsx +2 -0
  189. package/corpus/templates/slides/app/root.tsx +10 -1
  190. package/corpus/templates/slides/app/routes/agent.tsx +15 -0
  191. package/corpus/templates/slides/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  192. package/dist/agent/context-xray/actions/context-evict.js +5 -2
  193. package/dist/agent/context-xray/actions/context-evict.js.map +1 -1
  194. package/dist/agent/context-xray/actions/context-pin.js +5 -2
  195. package/dist/agent/context-xray/actions/context-pin.js.map +1 -1
  196. package/dist/agent/context-xray/actions/context-preview-get.d.ts +17 -0
  197. package/dist/agent/context-xray/actions/context-preview-get.d.ts.map +1 -0
  198. package/dist/agent/context-xray/actions/context-preview-get.js +94 -0
  199. package/dist/agent/context-xray/actions/context-preview-get.js.map +1 -0
  200. package/dist/agent/context-xray/actions/context-restore.js +5 -2
  201. package/dist/agent/context-xray/actions/context-restore.js.map +1 -1
  202. package/dist/agent/context-xray/actions/errors.d.ts +3 -0
  203. package/dist/agent/context-xray/actions/errors.d.ts.map +1 -1
  204. package/dist/agent/context-xray/actions/errors.js +6 -0
  205. package/dist/agent/context-xray/actions/errors.js.map +1 -1
  206. package/dist/agent/context-xray/manifest.d.ts +18 -1
  207. package/dist/agent/context-xray/manifest.d.ts.map +1 -1
  208. package/dist/agent/context-xray/manifest.js +68 -6
  209. package/dist/agent/context-xray/manifest.js.map +1 -1
  210. package/dist/agent/engine/context-directives-transform.d.ts +2 -0
  211. package/dist/agent/engine/context-directives-transform.d.ts.map +1 -1
  212. package/dist/agent/engine/context-directives-transform.js +2 -1
  213. package/dist/agent/engine/context-directives-transform.js.map +1 -1
  214. package/dist/agent/production-agent.d.ts +15 -0
  215. package/dist/agent/production-agent.d.ts.map +1 -1
  216. package/dist/agent/production-agent.js +74 -36
  217. package/dist/agent/production-agent.js.map +1 -1
  218. package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
  219. package/dist/agent/run-loop-with-resume.js +6 -3
  220. package/dist/agent/run-loop-with-resume.js.map +1 -1
  221. package/dist/client/AgentPanel.d.ts +5 -1
  222. package/dist/client/AgentPanel.d.ts.map +1 -1
  223. package/dist/client/AgentPanel.js +9 -11
  224. package/dist/client/AgentPanel.js.map +1 -1
  225. package/dist/client/agent-page/AgentContextTab.d.ts +5 -0
  226. package/dist/client/agent-page/AgentContextTab.d.ts.map +1 -0
  227. package/dist/client/agent-page/AgentContextTab.js +202 -0
  228. package/dist/client/agent-page/AgentContextTab.js.map +1 -0
  229. package/dist/client/agent-page/AgentJobsTab.d.ts +3 -0
  230. package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -0
  231. package/dist/client/agent-page/AgentJobsTab.js +98 -0
  232. package/dist/client/agent-page/AgentJobsTab.js.map +1 -0
  233. package/dist/client/agent-page/AgentTabsPage.d.ts +20 -0
  234. package/dist/client/agent-page/AgentTabsPage.d.ts.map +1 -0
  235. package/dist/client/agent-page/AgentTabsPage.js +420 -0
  236. package/dist/client/agent-page/AgentTabsPage.js.map +1 -0
  237. package/dist/client/agent-page/types.d.ts +17 -0
  238. package/dist/client/agent-page/types.d.ts.map +1 -0
  239. package/dist/client/agent-page/types.js +9 -0
  240. package/dist/client/agent-page/types.js.map +1 -0
  241. package/dist/client/agent-page/use-jobs.d.ts +61 -0
  242. package/dist/client/agent-page/use-jobs.d.ts.map +1 -0
  243. package/dist/client/agent-page/use-jobs.js +71 -0
  244. package/dist/client/agent-page/use-jobs.js.map +1 -0
  245. package/dist/client/context-xray/ContextMeter.d.ts +3 -1
  246. package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
  247. package/dist/client/context-xray/ContextMeter.js +14 -5
  248. package/dist/client/context-xray/ContextMeter.js.map +1 -1
  249. package/dist/client/context-xray/ContextTreemap.d.ts +3 -2
  250. package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
  251. package/dist/client/context-xray/ContextTreemap.js +9 -1
  252. package/dist/client/context-xray/ContextTreemap.js.map +1 -1
  253. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  254. package/dist/client/context-xray/ContextXRayPanel.js +95 -20
  255. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  256. package/dist/client/context-xray/format.d.ts.map +1 -1
  257. package/dist/client/context-xray/format.js +12 -0
  258. package/dist/client/context-xray/format.js.map +1 -1
  259. package/dist/client/index.d.ts +3 -0
  260. package/dist/client/index.d.ts.map +1 -1
  261. package/dist/client/index.js +1 -0
  262. package/dist/client/index.js.map +1 -1
  263. package/dist/client/resources/ResourcesPanel.d.ts +9 -1
  264. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  265. package/dist/client/resources/ResourcesPanel.js +26 -10
  266. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  267. package/dist/client/settings/AutomationsSection.d.ts +9 -0
  268. package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
  269. package/dist/client/settings/AutomationsSection.js +128 -147
  270. package/dist/client/settings/AutomationsSection.js.map +1 -1
  271. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  272. package/dist/jobs/actions/list-recurring-jobs.d.ts +21 -0
  273. package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -0
  274. package/dist/jobs/actions/list-recurring-jobs.js +74 -0
  275. package/dist/jobs/actions/list-recurring-jobs.js.map +1 -0
  276. package/dist/jobs/actions/manage-recurring-job.d.ts +18 -0
  277. package/dist/jobs/actions/manage-recurring-job.d.ts.map +1 -0
  278. package/dist/jobs/actions/manage-recurring-job.js +68 -0
  279. package/dist/jobs/actions/manage-recurring-job.js.map +1 -0
  280. package/dist/jobs/tools.d.ts +13 -0
  281. package/dist/jobs/tools.d.ts.map +1 -1
  282. package/dist/jobs/tools.js +1 -1
  283. package/dist/jobs/tools.js.map +1 -1
  284. package/dist/localization/default-messages.d.ts +96 -0
  285. package/dist/localization/default-messages.d.ts.map +1 -1
  286. package/dist/localization/default-messages.js +96 -0
  287. package/dist/localization/default-messages.js.map +1 -1
  288. package/dist/mcp/build-server.d.ts.map +1 -1
  289. package/dist/mcp/build-server.js +1 -0
  290. package/dist/mcp/build-server.js.map +1 -1
  291. package/dist/mcp/connect-route.d.ts.map +1 -1
  292. package/dist/mcp/connect-route.js +44 -59
  293. package/dist/mcp/connect-route.js.map +1 -1
  294. package/dist/notifications/routes.d.ts +2 -2
  295. package/dist/resources/handlers.d.ts +1 -1
  296. package/dist/server/action-discovery.d.ts.map +1 -1
  297. package/dist/server/action-discovery.js +23 -0
  298. package/dist/server/action-discovery.js.map +1 -1
  299. package/dist/server/agent-chat/prompt-resources.d.ts +14 -0
  300. package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -1
  301. package/dist/server/agent-chat/prompt-resources.js +139 -2
  302. package/dist/server/agent-chat/prompt-resources.js.map +1 -1
  303. package/dist/server/agent-chat-plugin.d.ts +1 -0
  304. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  305. package/dist/server/agent-chat-plugin.js +136 -3
  306. package/dist/server/agent-chat-plugin.js.map +1 -1
  307. package/dist/server/auth.d.ts.map +1 -1
  308. package/dist/server/auth.js +1 -4
  309. package/dist/server/auth.js.map +1 -1
  310. package/dist/server/google-oauth.d.ts.map +1 -1
  311. package/dist/server/google-oauth.js +1 -4
  312. package/dist/server/google-oauth.js.map +1 -1
  313. package/dist/server/transcribe-voice.d.ts +1 -1
  314. package/dist/server/workspace-oauth.d.ts +11 -0
  315. package/dist/server/workspace-oauth.d.ts.map +1 -0
  316. package/dist/server/workspace-oauth.js +25 -0
  317. package/dist/server/workspace-oauth.js.map +1 -0
  318. package/dist/shared/context-xray.d.ts +45 -1
  319. package/dist/shared/context-xray.d.ts.map +1 -1
  320. package/dist/shared/context-xray.js +12 -0
  321. package/dist/shared/context-xray.js.map +1 -1
  322. package/dist/shared/mcp-connect-content.d.ts +37 -0
  323. package/dist/shared/mcp-connect-content.d.ts.map +1 -0
  324. package/dist/shared/mcp-connect-content.js +92 -0
  325. package/dist/shared/mcp-connect-content.js.map +1 -0
  326. package/dist/templates/default/app/routes/_index.tsx +11 -0
  327. package/dist/templates/default/app/routes/agent.tsx +33 -0
  328. package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  329. package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  330. package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  331. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  332. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
  333. package/dist/triggers/actions/list-automations.d.ts +24 -0
  334. package/dist/triggers/actions/list-automations.d.ts.map +1 -0
  335. package/dist/triggers/actions/list-automations.js +72 -0
  336. package/dist/triggers/actions/list-automations.js.map +1 -0
  337. package/dist/triggers/actions/manage-automation.d.ts +18 -0
  338. package/dist/triggers/actions/manage-automation.d.ts.map +1 -0
  339. package/dist/triggers/actions/manage-automation.js +60 -0
  340. package/dist/triggers/actions/manage-automation.js.map +1 -0
  341. package/docs/content/a2a-protocol.mdx +42 -0
  342. package/docs/content/agent-surfaces.mdx +43 -0
  343. package/docs/content/external-agents.mdx +11 -0
  344. package/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
  345. package/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
  346. package/docs/content/locales/ar-SA/external-agents.mdx +9 -0
  347. package/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
  348. package/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
  349. package/docs/content/locales/de-DE/external-agents.mdx +10 -0
  350. package/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
  351. package/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
  352. package/docs/content/locales/es-ES/external-agents.mdx +10 -0
  353. package/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
  354. package/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
  355. package/docs/content/locales/fr-FR/external-agents.mdx +11 -0
  356. package/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
  357. package/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
  358. package/docs/content/locales/hi-IN/external-agents.mdx +9 -0
  359. package/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
  360. package/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
  361. package/docs/content/locales/ja-JP/external-agents.mdx +10 -0
  362. package/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
  363. package/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
  364. package/docs/content/locales/ko-KR/external-agents.mdx +9 -0
  365. package/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
  366. package/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
  367. package/docs/content/locales/pt-BR/external-agents.mdx +10 -0
  368. package/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
  369. package/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
  370. package/docs/content/locales/zh-CN/external-agents.mdx +8 -0
  371. package/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
  372. package/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
  373. package/docs/content/locales/zh-TW/external-agents.mdx +8 -0
  374. package/package.json +1 -1
  375. package/src/templates/default/app/routes/_index.tsx +11 -0
  376. package/src/templates/default/app/routes/agent.tsx +33 -0
  377. package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  378. package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  379. package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  380. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  381. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
@@ -14,6 +14,11 @@ import {
14
14
  sharedResourceOwner,
15
15
  WORKSPACE_OWNER,
16
16
  } from "../../resources/store.js";
17
+ import type {
18
+ ContextGovernanceTier,
19
+ ContextManifestSourceRef,
20
+ ContextSystemProvenance,
21
+ } from "../../shared/context-xray.js";
17
22
  import { discoverAgents } from "../agent-discovery.js";
18
23
  import { getRequestOrgId } from "../request-context.js";
19
24
  import { parseSkillFrontmatter } from "./skill-frontmatter.js";
@@ -40,10 +45,177 @@ const PROMPT_SKILL_METADATA_READ_LIMIT = 80;
40
45
  const PROMPT_INSTRUCTION_SUMMARY_LIMIT = 20;
41
46
  const PROMPT_SUMMARY_DESCRIPTION_MAX_CHARS = 180;
42
47
 
48
+ export interface PromptResourceManifestSection {
49
+ label: string;
50
+ provenance: ContextSystemProvenance;
51
+ governance: ContextGovernanceTier;
52
+ content: string;
53
+ sourceRef?: ContextManifestSourceRef;
54
+ }
55
+
43
56
  function normalizeResourcePathForPrompt(path: string): string {
44
57
  return path.replace(/^\/+/, "").trim();
45
58
  }
46
59
 
60
+ function xmlAttribute(attrs: string, name: string): string | undefined {
61
+ const match = new RegExp(`\\b${name}="([^"]*)"`).exec(attrs);
62
+ return match?.[1];
63
+ }
64
+
65
+ function resourceManifestClassification(
66
+ scope: string,
67
+ path: string,
68
+ index: number,
69
+ ): {
70
+ provenance: ContextSystemProvenance;
71
+ governance: ContextGovernanceTier;
72
+ } {
73
+ const normalizedPath = normalizeResourcePathForPrompt(path);
74
+ if (scope === "template") {
75
+ return { provenance: "template", governance: "inherited" };
76
+ }
77
+ if (scope.startsWith("workspace")) {
78
+ return {
79
+ provenance:
80
+ scope === "workspace" && index === 0
81
+ ? "enterprise-workspace-core"
82
+ : "sql-workspace",
83
+ governance:
84
+ scope === "workspace" && index === 0 ? "required" : "inherited",
85
+ };
86
+ }
87
+ if (scope.startsWith("personal")) {
88
+ return {
89
+ provenance: normalizedPath === "memory/MEMORY.md" ? "memory" : "personal",
90
+ governance: "user",
91
+ };
92
+ }
93
+ if (scope.startsWith("app-default")) {
94
+ return { provenance: "legacy-app-default", governance: "inherited" };
95
+ }
96
+ if (scope.startsWith("organization")) {
97
+ return { provenance: "organization", governance: "inherited" };
98
+ }
99
+ if (scope.startsWith("shared")) {
100
+ return {
101
+ provenance:
102
+ normalizedPath === "LEARNINGS.md"
103
+ ? "organization"
104
+ : "legacy-app-default",
105
+ governance: "inherited",
106
+ };
107
+ }
108
+ return { provenance: "template", governance: "inherited" };
109
+ }
110
+
111
+ /**
112
+ * Extracts bounded-in-memory metadata from the already-composed resource
113
+ * prompt. The caller turns these inputs into hashed/previews before anything
114
+ * is persisted; this helper never writes or returns the full manifest.
115
+ */
116
+ export function promptResourceManifestSections(
117
+ prompt: string,
118
+ ): PromptResourceManifestSection[] {
119
+ const sections: PromptResourceManifestSection[] = [];
120
+ const resourcePattern = /<resource\b([^>]*)>([\s\S]*?)<\/resource>/g;
121
+ let match: RegExpExecArray | null;
122
+ let workspaceIndex = 0;
123
+ let sharedIndex = 0;
124
+ while ((match = resourcePattern.exec(prompt))) {
125
+ const attrs = match[1] ?? "";
126
+ const scope = xmlAttribute(attrs, "scope") ?? "resource";
127
+ const path =
128
+ xmlAttribute(attrs, "path") ?? xmlAttribute(attrs, "name") ?? "";
129
+ const name = xmlAttribute(attrs, "name") ?? (path || "resource");
130
+ const index = scope.startsWith("workspace")
131
+ ? workspaceIndex++
132
+ : scope.startsWith("shared")
133
+ ? sharedIndex++
134
+ : 0;
135
+ const classification = resourceManifestClassification(scope, path, index);
136
+ sections.push({
137
+ label: name,
138
+ ...classification,
139
+ content: match[2] ?? "",
140
+ sourceRef: {
141
+ ...(path ? { path } : {}),
142
+ scope,
143
+ },
144
+ });
145
+ }
146
+
147
+ const taggedSections = [
148
+ {
149
+ tag: "skills-summary",
150
+ label: "Workspace skills index",
151
+ provenance: "template" as const,
152
+ governance: "inherited" as const,
153
+ },
154
+ {
155
+ tag: "resource-skills",
156
+ label: "Workspace resource skills",
157
+ provenance: "template" as const,
158
+ governance: "inherited" as const,
159
+ },
160
+ {
161
+ tag: "instruction-resources",
162
+ label: "Instruction resources index",
163
+ provenance: "sql-workspace" as const,
164
+ governance: "inherited" as const,
165
+ },
166
+ {
167
+ tag: "workspace-resources",
168
+ label: "Workspace reference resources",
169
+ provenance: "sql-workspace" as const,
170
+ governance: "inherited" as const,
171
+ },
172
+ {
173
+ tag: "context-note",
174
+ label: "Resource availability note",
175
+ provenance: "framework-core" as const,
176
+ governance: "required" as const,
177
+ },
178
+ {
179
+ tag: "context-budget-note",
180
+ label: "Context budget note",
181
+ provenance: "framework-core" as const,
182
+ governance: "required" as const,
183
+ },
184
+ {
185
+ tag: "available-apps",
186
+ label: "Available workspace apps",
187
+ provenance: "tools" as const,
188
+ governance: "required" as const,
189
+ },
190
+ ];
191
+ for (const tagged of taggedSections) {
192
+ const pattern = new RegExp(
193
+ `<${tagged.tag}\\b[^>]*>([\\s\\S]*?)</${tagged.tag}>`,
194
+ "g",
195
+ );
196
+ let taggedMatch: RegExpExecArray | null;
197
+ while ((taggedMatch = pattern.exec(prompt))) {
198
+ const taggedAttrs =
199
+ taggedMatch[0]?.slice(tagged.tag.length + 1).split(">")[0] ?? "";
200
+ const taggedScope = xmlAttribute(taggedAttrs, "scope");
201
+ const taggedClassification =
202
+ tagged.tag === "instruction-resources" && taggedScope
203
+ ? resourceManifestClassification(taggedScope, "", 0)
204
+ : {
205
+ provenance: tagged.provenance,
206
+ governance: tagged.governance,
207
+ };
208
+ sections.push({
209
+ label: tagged.label,
210
+ ...taggedClassification,
211
+ content: taggedMatch[1] ?? "",
212
+ ...(taggedScope ? { sourceRef: { scope: taggedScope } } : {}),
213
+ });
214
+ }
215
+ }
216
+ return sections;
217
+ }
218
+
47
219
  function resourceToolHint(
48
220
  action: "list" | "read" | "effective" | "write" | "delete" | "promote",
49
221
  extra?: string,
@@ -541,14 +713,14 @@ export async function loadResourcesForPrompt(
541
713
  if (organizationOwner !== SHARED_OWNER) {
542
714
  const organizationAgents = await loadAgentsResourceForPrompt(
543
715
  organizationOwner,
544
- "shared",
716
+ "organization",
545
717
  promptResourceMaxChars,
546
718
  );
547
719
  if (organizationAgents) sections.push(organizationAgents);
548
720
  sections.push(
549
721
  ...(await loadInstructionResourcesForPrompt(
550
722
  organizationOwner,
551
- "shared-instruction",
723
+ "organization-instruction",
552
724
  promptResourceMaxChars,
553
725
  compact,
554
726
  )),
@@ -189,6 +189,10 @@ async function lazyFs(): Promise<typeof import("fs")> {
189
189
  return _fs;
190
190
  }
191
191
 
192
+ import {
193
+ buildSystemManifestSections,
194
+ setContextXraySystemSections,
195
+ } from "../agent/context-xray/manifest.js";
192
196
  // ---------------------------------------------------------------------------
193
197
  // The bulk of this file's former implementation now lives in focused sibling
194
198
  // modules under `./agent-chat/`. This file re-imports them (and re-exports
@@ -233,6 +237,7 @@ import {
233
237
  import { finalizeClaimedAgentChatProcessRunFailure } from "./agent-chat/process-run-failure.js";
234
238
  import {
235
239
  loadResourcesForPrompt,
240
+ promptResourceManifestSections,
236
241
  resourceScopeForOwner,
237
242
  } from "./agent-chat/prompt-resources.js";
238
243
  import { shouldDisableRecurringJobsRuntime } from "./agent-chat/recurring-jobs-runtime.js";
@@ -265,6 +270,13 @@ export { loadRunCodeToolEntries };
265
270
  export { shouldDisableRecurringJobsRuntime };
266
271
  export { finalizeClaimedAgentChatProcessRunFailure };
267
272
 
273
+ export function buildLeanRunPolicyPrompt(
274
+ codeEditingSurfaceRestriction: string,
275
+ prodCodeExecPromptNote: string,
276
+ ): string {
277
+ return codeEditingSurfaceRestriction + prodCodeExecPromptNote;
278
+ }
279
+
268
280
  /**
269
281
  * Returns whether `owner` has already finished (or explicitly skipped) the
270
282
  * First-Session Personalization flow, via the owner-scoped
@@ -2329,6 +2341,104 @@ export function createAgentChatPlugin(
2329
2341
  return prompt;
2330
2342
  };
2331
2343
 
2344
+ const emitContextXraySystemSections = async (
2345
+ event: any,
2346
+ input: {
2347
+ frameworkPrompt?: string;
2348
+ actionsPrompt?: string;
2349
+ resources?: string;
2350
+ schemaBlock?: string;
2351
+ modelOverlay?: string;
2352
+ runtimeContext?: string;
2353
+ additionalFramework?: string;
2354
+ extra?: string;
2355
+ },
2356
+ ): Promise<void> => {
2357
+ const sections = await buildSystemManifestSections([
2358
+ ...(input.frameworkPrompt
2359
+ ? [
2360
+ {
2361
+ label: "Framework core",
2362
+ provenance: "framework-core" as const,
2363
+ governance: "required" as const,
2364
+ content: input.frameworkPrompt,
2365
+ sourceRef: { scope: "framework" },
2366
+ },
2367
+ ]
2368
+ : []),
2369
+ ...(input.actionsPrompt
2370
+ ? [
2371
+ {
2372
+ label: "Available actions prompt",
2373
+ provenance: "actions-prompt" as const,
2374
+ governance: "required" as const,
2375
+ content: input.actionsPrompt,
2376
+ sourceRef: { scope: "actions" },
2377
+ },
2378
+ ]
2379
+ : []),
2380
+ ...(input.resources
2381
+ ? promptResourceManifestSections(input.resources)
2382
+ : []),
2383
+ ...(input.schemaBlock
2384
+ ? [
2385
+ {
2386
+ label: "SQL schema",
2387
+ provenance: "db-schema" as const,
2388
+ governance: "required" as const,
2389
+ content: input.schemaBlock,
2390
+ sourceRef: { scope: "sql" },
2391
+ },
2392
+ ]
2393
+ : []),
2394
+ ...(input.additionalFramework
2395
+ ? [
2396
+ {
2397
+ label: "Framework run policy",
2398
+ provenance: "framework-core" as const,
2399
+ governance: "required" as const,
2400
+ content: input.additionalFramework,
2401
+ sourceRef: { scope: "framework" },
2402
+ },
2403
+ ]
2404
+ : []),
2405
+ ...(input.extra
2406
+ ? [
2407
+ {
2408
+ label: "App runtime context",
2409
+ provenance: "runtime-context" as const,
2410
+ governance: "inherited" as const,
2411
+ content: input.extra,
2412
+ sourceRef: { scope: "app" },
2413
+ },
2414
+ ]
2415
+ : []),
2416
+ ...(input.modelOverlay
2417
+ ? [
2418
+ {
2419
+ label: "Model overlay",
2420
+ provenance: "model-overlay" as const,
2421
+ governance: "required" as const,
2422
+ content: input.modelOverlay,
2423
+ sourceRef: { scope: "model" },
2424
+ },
2425
+ ]
2426
+ : []),
2427
+ ...(input.runtimeContext
2428
+ ? [
2429
+ {
2430
+ label: "Runtime context",
2431
+ provenance: "runtime-context" as const,
2432
+ governance: "required" as const,
2433
+ content: input.runtimeContext,
2434
+ sourceRef: { scope: "runtime" },
2435
+ },
2436
+ ]
2437
+ : []),
2438
+ ]);
2439
+ setContextXraySystemSections(event, sections);
2440
+ };
2441
+
2332
2442
  /**
2333
2443
  * Read the model family overlay for the currently-resolved model.
2334
2444
  * onEngineResolved sets runCtx.model before systemPrompt is called, so
@@ -2420,10 +2530,24 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2420
2530
  // everything that follows it — putting it last means a day
2421
2531
  // rollover invalidates as little of the prefix as possible.
2422
2532
  if (leanPrompt) {
2533
+ const leanRunPolicyPrompt = buildLeanRunPolicyPrompt(
2534
+ codeEditingSurfaceRestriction,
2535
+ prodCodeExecPromptNote,
2536
+ );
2537
+ await emitContextXraySystemSections(event, {
2538
+ frameworkPrompt: leanBasePrompt.slice(
2539
+ 0,
2540
+ Math.max(0, leanBasePrompt.length - prodActionsPrompt.length),
2541
+ ),
2542
+ actionsPrompt: prodActionsPrompt,
2543
+ additionalFramework: leanRunPolicyPrompt,
2544
+ extra,
2545
+ modelOverlay,
2546
+ runtimeContext,
2547
+ });
2423
2548
  return setSystemPromptOnContext(
2424
2549
  leanBasePrompt +
2425
- codeEditingSurfaceRestriction +
2426
- prodCodeExecPromptNote +
2550
+ leanRunPolicyPrompt +
2427
2551
  extra +
2428
2552
  modelOverlay +
2429
2553
  runtimeContext,
@@ -2439,6 +2563,22 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2439
2563
  const schemaBlock = lazyContext
2440
2564
  ? ""
2441
2565
  : await buildSchemaBlock(owner, databaseToolsMode);
2566
+ await emitContextXraySystemSections(event, {
2567
+ frameworkPrompt: basePrompt.slice(
2568
+ 0,
2569
+ Math.max(0, basePrompt.length - prodActionsPrompt.length),
2570
+ ),
2571
+ actionsPrompt: prodActionsPrompt,
2572
+ resources,
2573
+ schemaBlock,
2574
+ extra,
2575
+ modelOverlay,
2576
+ runtimeContext,
2577
+ additionalFramework:
2578
+ personalizationBlock +
2579
+ codeEditingSurfaceRestriction +
2580
+ prodCodeExecPromptNote,
2581
+ });
2442
2582
  return setSystemPromptOnContext(
2443
2583
  basePrompt +
2444
2584
  personalizationBlock +
@@ -2548,6 +2688,11 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2548
2688
  actions: anonymousReadOnlyActions,
2549
2689
  systemPrompt: async (event: any) => {
2550
2690
  const { extra } = await prepareRun(event);
2691
+ await emitContextXraySystemSections(event, {
2692
+ frameworkPrompt: anonymousReadOnlyPrompt,
2693
+ extra,
2694
+ runtimeContext: runtimeContextForEvent(event),
2695
+ });
2551
2696
  return setSystemPromptOnContext(
2552
2697
  anonymousReadOnlyPrompt +
2553
2698
  extra +
@@ -2668,6 +2813,16 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2668
2813
  // cached prompt prefix as possible. See the prod handler above
2669
2814
  // for the same pattern.
2670
2815
  if (leanPrompt) {
2816
+ await emitContextXraySystemSections(event, {
2817
+ frameworkPrompt: leanBasePrompt.slice(
2818
+ 0,
2819
+ Math.max(0, leanBasePrompt.length - prodActionsPrompt.length),
2820
+ ),
2821
+ actionsPrompt: prodActionsPrompt,
2822
+ extra,
2823
+ modelOverlay,
2824
+ runtimeContext,
2825
+ });
2671
2826
  return setSystemPromptOnContext(
2672
2827
  leanBasePrompt + extra + modelOverlay + runtimeContext,
2673
2828
  );
@@ -2681,6 +2836,24 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2681
2836
  lazyContext || !databaseToolsEnabled
2682
2837
  ? ""
2683
2838
  : await buildSchemaBlock(owner, databaseToolsMode);
2839
+ await emitContextXraySystemSections(event, {
2840
+ frameworkPrompt: devNative
2841
+ ? basePrompt.slice(
2842
+ 0,
2843
+ Math.max(0, basePrompt.length - prodActionsPrompt.length),
2844
+ )
2845
+ : devPrompt.slice(
2846
+ 0,
2847
+ Math.max(0, devPrompt.length - devActionsPrompt.length),
2848
+ ),
2849
+ actionsPrompt: devNative ? prodActionsPrompt : devActionsPrompt,
2850
+ resources,
2851
+ schemaBlock,
2852
+ extra,
2853
+ modelOverlay,
2854
+ runtimeContext,
2855
+ additionalFramework: personalizationBlock,
2856
+ });
2684
2857
  return setSystemPromptOnContext(
2685
2858
  devPrompt +
2686
2859
  personalizationBlock +
@@ -144,6 +144,7 @@ import {
144
144
  type OnboardingHtmlOptions,
145
145
  } from "./onboarding-html.js";
146
146
  import { captureAuthError } from "./sentry.js";
147
+ import { isWorkspaceOAuthCallbackRelayEnabled } from "./workspace-oauth.js";
147
148
 
148
149
  /**
149
150
  * Get the configured session max age. Desktop SSO broker writes from
@@ -1455,13 +1456,6 @@ function mountAuthCorsMiddleware(app: H3App): void {
1455
1456
  app.use("/_agent-native/google", handler);
1456
1457
  }
1457
1458
 
1458
- function isWorkspaceOAuthCallbackRelayEnabled(): boolean {
1459
- return (
1460
- process.env.AGENT_NATIVE_WORKSPACE === "1" ||
1461
- process.env.VITE_AGENT_NATIVE_WORKSPACE === "1"
1462
- );
1463
- }
1464
-
1465
1459
  function isFrameworkOAuthCallbackPath(pathname: string): boolean {
1466
1460
  return (
1467
1461
  pathname.startsWith("/_agent-native/") &&
@@ -34,6 +34,7 @@ import {
34
34
  import { getWorkspaceA2ADerivedSecret } from "./derived-secret.js";
35
35
  import { writeDesktopSso } from "./desktop-sso.js";
36
36
  import { appendSessionToOAuthReturnUrl } from "./oauth-return-url.js";
37
+ import { isWorkspaceOAuthCallbackRelayEnabled } from "./workspace-oauth.js";
37
38
 
38
39
  // ─── Platform Detection ─────────────────────────────────────────────────────
39
40
 
@@ -294,13 +295,6 @@ export function getAppUrl(event: H3Event, path = "/"): string {
294
295
  return `${getOrigin(event)}${getAppBasePath()}${cleanPath}`;
295
296
  }
296
297
 
297
- function isWorkspaceOAuthCallbackRelayEnabled(): boolean {
298
- return (
299
- process.env.AGENT_NATIVE_WORKSPACE === "1" ||
300
- process.env.VITE_AGENT_NATIVE_WORKSPACE === "1"
301
- );
302
- }
303
-
304
298
  function isFrameworkOAuthCallbackPath(pathname: string): boolean {
305
299
  return (
306
300
  pathname.startsWith("/_agent-native/") &&
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Whether workspace OAuth callbacks use the root framework relay.
3
+ *
4
+ * Workspace deploy wrappers normally provide the runtime flags, but mounted
5
+ * app bundles can retain only their workspace app id or build-time Vite env.
6
+ * Redirect construction and callback handling must use this exact same
7
+ * predicate so a callback sent to the root relay is always forwarded back to
8
+ * the mounted app that initiated it.
9
+ */
10
+ export function isWorkspaceOAuthCallbackRelayEnabled(): boolean {
11
+ const metaEnv = (
12
+ import.meta as unknown as {
13
+ env?: Record<string, string | undefined>;
14
+ }
15
+ ).env;
16
+
17
+ return (
18
+ [
19
+ process.env.AGENT_NATIVE_WORKSPACE,
20
+ process.env.VITE_AGENT_NATIVE_WORKSPACE,
21
+ metaEnv?.AGENT_NATIVE_WORKSPACE,
22
+ metaEnv?.VITE_AGENT_NATIVE_WORKSPACE,
23
+ ].some((value) => value === "1" || value === "true") ||
24
+ [
25
+ process.env.AGENT_NATIVE_WORKSPACE_APP_ID,
26
+ process.env.VITE_AGENT_NATIVE_WORKSPACE_APP_ID,
27
+ metaEnv?.AGENT_NATIVE_WORKSPACE_APP_ID,
28
+ metaEnv?.VITE_AGENT_NATIVE_WORKSPACE_APP_ID,
29
+ ].some((value) => typeof value === "string" && value.trim().length > 0)
30
+ );
31
+ }
@@ -16,7 +16,63 @@ export type ContextSegmentStatus =
16
16
  | "evicted"
17
17
  | "summarized";
18
18
  export type ContextTokenCountMethod = "exact" | "estimate";
19
- export type ContextManifestSource = "structured" | "flattened" | "external";
19
+ export type ContextManifestSource =
20
+ | "structured"
21
+ | "flattened"
22
+ | "external"
23
+ | "preview";
24
+ export type ContextSystemProvenance =
25
+ | "framework-core"
26
+ | "actions-prompt"
27
+ | "template"
28
+ | "enterprise-workspace-core"
29
+ | "sql-workspace"
30
+ | "legacy-app-default"
31
+ | "organization"
32
+ | "personal"
33
+ | "memory"
34
+ | "db-schema"
35
+ | "tools"
36
+ | "model-overlay"
37
+ | "runtime-context";
38
+ export type ContextGovernanceTier = "required" | "inherited" | "user";
39
+
40
+ export interface ContextManifestSourceRef {
41
+ resourceId?: string;
42
+ path?: string;
43
+ scope?: string;
44
+ }
45
+
46
+ /**
47
+ * A non-evictable system-prompt contribution. This is intentionally separate
48
+ * from conversation segments so old manifests can be read without a schema
49
+ * migration and directive code can never accidentally evict system context.
50
+ */
51
+ export interface ContextManifestSystemSection {
52
+ kind: "system";
53
+ segmentId: string;
54
+ group: string;
55
+ label: string;
56
+ provenance: ContextSystemProvenance;
57
+ governance: ContextGovernanceTier;
58
+ tokenCount: number;
59
+ tokenMethod: ContextTokenCountMethod;
60
+ sourceRef?: ContextManifestSourceRef;
61
+ contentHash: string;
62
+ preview: string;
63
+ timestamp: number;
64
+ }
65
+
66
+ export interface ContextPreview {
67
+ computedAt: number;
68
+ model?: string;
69
+ scope: "user" | "org";
70
+ totalTokens: number;
71
+ systemTokens: number;
72
+ tokenCountMethod: ContextTokenCountMethod;
73
+ sections: ContextManifestSystemSection[];
74
+ source: "preview";
75
+ }
20
76
 
21
77
  export interface ContextDirective {
22
78
  id?: string;
@@ -58,12 +114,36 @@ export interface ContextManifest {
58
114
  rawTokens: number;
59
115
  reclaimedTokens: number;
60
116
  tokenCountMethod: ContextTokenCountMethod;
117
+ /** Conversation-only total. Old manifests omit this and are conversation-only. */
118
+ conversationTokens?: number;
119
+ /** System-prompt total. Old manifests omit this and have no system sections. */
120
+ systemTokens?: number;
61
121
  source: ContextManifestSource;
62
122
  enforceable: boolean;
63
123
  segments: ContextManifestSegment[];
124
+ /** Optional for strict backward compatibility with persisted old manifests. */
125
+ systemSections?: ContextManifestSystemSection[];
64
126
  url?: string;
65
127
  }
66
128
 
129
+ export function manifestSystemTokens(manifest: ContextManifest): number {
130
+ return (
131
+ manifest.systemTokens ??
132
+ manifest.systemSections?.reduce(
133
+ (total, section) => total + section.tokenCount,
134
+ 0,
135
+ ) ??
136
+ 0
137
+ );
138
+ }
139
+
140
+ export function manifestConversationTokens(manifest: ContextManifest): number {
141
+ return (
142
+ manifest.conversationTokens ??
143
+ Math.max(0, manifest.totalTokens - manifestSystemTokens(manifest))
144
+ );
145
+ }
146
+
67
147
  export function emptyContextManifest(
68
148
  threadId: string,
69
149
  opts: {
@@ -85,5 +165,8 @@ export function emptyContextManifest(
85
165
  source: opts.source ?? "structured",
86
166
  enforceable: opts.enforceable ?? true,
87
167
  segments: [],
168
+ conversationTokens: 0,
169
+ systemTokens: 0,
170
+ systemSections: [],
88
171
  };
89
172
  }