@agent-native/core 0.99.3 → 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 (362) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +15 -0
  3. package/corpus/core/docs/content/agent-surfaces.mdx +43 -0
  4. package/corpus/core/docs/content/external-agents.mdx +11 -0
  5. package/corpus/core/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
  6. package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +9 -0
  7. package/corpus/core/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
  8. package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +10 -0
  9. package/corpus/core/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
  10. package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +10 -0
  11. package/corpus/core/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
  12. package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +11 -0
  13. package/corpus/core/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
  14. package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +9 -0
  15. package/corpus/core/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
  16. package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +10 -0
  17. package/corpus/core/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
  18. package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +9 -0
  19. package/corpus/core/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
  20. package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +10 -0
  21. package/corpus/core/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
  22. package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -0
  23. package/corpus/core/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
  24. package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -0
  25. package/corpus/core/package.json +1 -1
  26. package/corpus/core/src/agent/context-xray/actions/context-evict.ts +11 -0
  27. package/corpus/core/src/agent/context-xray/actions/context-pin.ts +11 -0
  28. package/corpus/core/src/agent/context-xray/actions/context-preview-get.ts +134 -0
  29. package/corpus/core/src/agent/context-xray/actions/context-restore.ts +11 -0
  30. package/corpus/core/src/agent/context-xray/actions/errors.ts +20 -0
  31. package/corpus/core/src/agent/context-xray/manifest.ts +106 -7
  32. package/corpus/core/src/agent/engine/context-directives-transform.ts +5 -1
  33. package/corpus/core/src/agent/production-agent.ts +100 -38
  34. package/corpus/core/src/agent/run-loop-with-resume.ts +7 -2
  35. package/corpus/core/src/client/AgentPanel.tsx +35 -8
  36. package/corpus/core/src/client/agent-page/AgentContextTab.tsx +501 -0
  37. package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +370 -0
  38. package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1084 -0
  39. package/corpus/core/src/client/agent-page/types.ts +18 -0
  40. package/corpus/core/src/client/agent-page/use-jobs.ts +150 -0
  41. package/corpus/core/src/client/context-xray/ContextMeter.tsx +22 -5
  42. package/corpus/core/src/client/context-xray/ContextTreemap.tsx +16 -1
  43. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +168 -3
  44. package/corpus/core/src/client/context-xray/format.ts +6 -0
  45. package/corpus/core/src/client/index.ts +6 -0
  46. package/corpus/core/src/client/resources/ResourcesPanel.tsx +51 -23
  47. package/corpus/core/src/client/settings/AutomationsSection.tsx +407 -387
  48. package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +105 -0
  49. package/corpus/core/src/jobs/actions/manage-recurring-job.ts +85 -0
  50. package/corpus/core/src/jobs/tools.ts +1 -1
  51. package/corpus/core/src/localization/default-messages.ts +110 -0
  52. package/corpus/core/src/mcp/build-server.ts +1 -0
  53. package/corpus/core/src/mcp/connect-route.ts +62 -65
  54. package/corpus/core/src/server/action-discovery.ts +23 -0
  55. package/corpus/core/src/server/agent-chat/prompt-resources.ts +174 -2
  56. package/corpus/core/src/server/agent-chat-plugin.ts +175 -2
  57. package/corpus/core/src/server/auth.ts +1 -7
  58. package/corpus/core/src/server/google-oauth.ts +1 -7
  59. package/corpus/core/src/server/workspace-oauth.ts +31 -0
  60. package/corpus/core/src/shared/context-xray.ts +84 -1
  61. package/corpus/core/src/shared/mcp-connect-content.ts +130 -0
  62. package/corpus/core/src/templates/default/app/routes/_index.tsx +11 -0
  63. package/corpus/core/src/templates/default/app/routes/agent.tsx +33 -0
  64. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  65. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  66. package/corpus/core/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  67. package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  68. package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
  69. package/corpus/core/src/triggers/actions/list-automations.ts +99 -0
  70. package/corpus/core/src/triggers/actions/manage-automation.ts +78 -0
  71. package/corpus/templates/analytics/actions/data-source-status.ts +33 -15
  72. package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +1 -1
  73. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +149 -24
  74. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +17 -0
  75. package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
  76. package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -0
  77. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +8 -0
  78. package/corpus/templates/analytics/app/i18n/zh-TW.ts +1 -0
  79. package/corpus/templates/analytics/app/i18n-data.ts +1 -0
  80. package/corpus/templates/analytics/app/routes/agent.tsx +5 -0
  81. package/corpus/templates/analytics/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  82. package/corpus/templates/analytics/changelog/2026-07-13-analytics-answers-can-use-built-in-first-party-event-data.md +6 -0
  83. package/corpus/templates/analytics/changelog/2026-07-13-chart-legends-can-filter-to-one-series-or-hide-a-series-on-h.md +6 -0
  84. package/corpus/templates/analytics/changelog/2026-07-13-gpt-5-6-luna-answers-now-recover-normally-instead-of-showing.md +6 -0
  85. package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -2
  86. package/corpus/templates/assets/app/components/layout/Header.tsx +1 -0
  87. package/corpus/templates/assets/app/components/layout/Layout.tsx +1 -0
  88. package/corpus/templates/assets/app/components/layout/Sidebar.tsx +2 -0
  89. package/corpus/templates/assets/app/routes/agent.tsx +5 -0
  90. package/corpus/templates/assets/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  91. package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -0
  92. package/corpus/templates/brain/app/components/layout/Sidebar.tsx +4 -1
  93. package/corpus/templates/brain/app/lib/brain.ts +11 -0
  94. package/corpus/templates/brain/app/root.tsx +15 -1
  95. package/corpus/templates/brain/app/routes/agent.tsx +11 -0
  96. package/corpus/templates/brain/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  97. package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -0
  98. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +2 -0
  99. package/corpus/templates/calendar/app/root.tsx +17 -1
  100. package/corpus/templates/calendar/app/routes/_app.agent.tsx +25 -0
  101. package/corpus/templates/calendar/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  102. package/corpus/templates/chat/app/components/layout/Header.tsx +1 -0
  103. package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -0
  104. package/corpus/templates/chat/app/components/layout/Sidebar.tsx +7 -0
  105. package/corpus/templates/chat/app/hooks/use-navigation-state.ts +3 -0
  106. package/corpus/templates/chat/app/root.tsx +24 -2
  107. package/corpus/templates/chat/app/routes/agent.tsx +15 -0
  108. package/corpus/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
  109. package/corpus/templates/clips/app/components/library/library-layout.tsx +8 -0
  110. package/corpus/templates/clips/app/i18n/ar-SA.ts +2 -0
  111. package/corpus/templates/clips/app/i18n/de-DE.ts +2 -0
  112. package/corpus/templates/clips/app/i18n/en-US.ts +2 -0
  113. package/corpus/templates/clips/app/i18n/es-ES.ts +2 -0
  114. package/corpus/templates/clips/app/i18n/fr-FR.ts +2 -0
  115. package/corpus/templates/clips/app/i18n/hi-IN.ts +2 -0
  116. package/corpus/templates/clips/app/i18n/ja-JP.ts +2 -0
  117. package/corpus/templates/clips/app/i18n/ko-KR.ts +2 -0
  118. package/corpus/templates/clips/app/i18n/pt-BR.ts +2 -0
  119. package/corpus/templates/clips/app/i18n/zh-CN.ts +2 -0
  120. package/corpus/templates/clips/app/i18n/zh-TW.ts +2 -0
  121. package/corpus/templates/clips/app/root.tsx +7 -1
  122. package/corpus/templates/clips/app/routes/_app.agent.tsx +15 -0
  123. package/corpus/templates/clips/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  124. package/corpus/templates/content/app/components/layout/Layout.tsx +1 -0
  125. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +36 -0
  126. package/corpus/templates/content/app/i18n/zh-TW.ts +2 -0
  127. package/corpus/templates/content/app/i18n-data.ts +44 -6
  128. package/corpus/templates/content/app/root.tsx +8 -0
  129. package/corpus/templates/content/app/routes/_app.agent.tsx +15 -0
  130. package/corpus/templates/content/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  131. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
  132. package/corpus/templates/design/app/components/layout/Sidebar.tsx +2 -0
  133. package/corpus/templates/design/app/i18n/zh-TW.ts +2 -0
  134. package/corpus/templates/design/app/i18n-data.ts +20 -0
  135. package/corpus/templates/design/app/root.tsx +7 -1
  136. package/corpus/templates/design/app/routes/agent.tsx +15 -0
  137. package/corpus/templates/design/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  138. package/corpus/templates/dispatch/app/dispatch-extensions.tsx +10 -1
  139. package/corpus/templates/dispatch/app/i18n/zh-TW.ts +2 -0
  140. package/corpus/templates/dispatch/app/i18n-data.ts +20 -0
  141. package/corpus/templates/dispatch/app/root.tsx +7 -2
  142. package/corpus/templates/dispatch/app/routes/agent.tsx +18 -0
  143. package/corpus/templates/dispatch/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  144. package/corpus/templates/forms/app/components/layout/Layout.tsx +1 -0
  145. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +35 -0
  146. package/corpus/templates/forms/app/i18n/ar-SA.ts +2 -0
  147. package/corpus/templates/forms/app/i18n/de-DE.ts +2 -0
  148. package/corpus/templates/forms/app/i18n/en-US.ts +2 -0
  149. package/corpus/templates/forms/app/i18n/es-ES.ts +2 -0
  150. package/corpus/templates/forms/app/i18n/fr-FR.ts +2 -0
  151. package/corpus/templates/forms/app/i18n/hi-IN.ts +2 -0
  152. package/corpus/templates/forms/app/i18n/ja-JP.ts +2 -0
  153. package/corpus/templates/forms/app/i18n/ko-KR.ts +2 -0
  154. package/corpus/templates/forms/app/i18n/pt-BR.ts +2 -0
  155. package/corpus/templates/forms/app/i18n/zh-CN.ts +2 -0
  156. package/corpus/templates/forms/app/i18n/zh-TW.ts +2 -0
  157. package/corpus/templates/forms/app/root.tsx +6 -1
  158. package/corpus/templates/forms/app/routes/_app.agent.tsx +15 -0
  159. package/corpus/templates/forms/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  160. package/corpus/templates/macros/app/components/layout/AppLayout.tsx +14 -2
  161. package/corpus/templates/macros/app/components/layout/Header.tsx +1 -0
  162. package/corpus/templates/macros/app/root.tsx +17 -2
  163. package/corpus/templates/macros/app/routes/agent.tsx +15 -0
  164. package/corpus/templates/macros/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  165. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +42 -0
  166. package/corpus/templates/mail/app/components/layout/CommandPalette.tsx +6 -0
  167. package/corpus/templates/mail/app/routes/agent.tsx +15 -0
  168. package/corpus/templates/mail/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  169. package/corpus/templates/plan/app/components/layout/Header.tsx +1 -0
  170. package/corpus/templates/plan/app/components/layout/Layout.tsx +1 -0
  171. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +2 -0
  172. package/corpus/templates/plan/app/root.tsx +8 -0
  173. package/corpus/templates/plan/app/routes/agent.tsx +15 -0
  174. package/corpus/templates/plan/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  175. package/corpus/templates/slides/app/components/layout/Header.tsx +1 -0
  176. package/corpus/templates/slides/app/components/layout/Layout.tsx +1 -0
  177. package/corpus/templates/slides/app/components/layout/Sidebar.tsx +2 -0
  178. package/corpus/templates/slides/app/root.tsx +10 -1
  179. package/corpus/templates/slides/app/routes/agent.tsx +15 -0
  180. package/corpus/templates/slides/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
  181. package/dist/agent/context-xray/actions/context-evict.js +5 -2
  182. package/dist/agent/context-xray/actions/context-evict.js.map +1 -1
  183. package/dist/agent/context-xray/actions/context-pin.js +5 -2
  184. package/dist/agent/context-xray/actions/context-pin.js.map +1 -1
  185. package/dist/agent/context-xray/actions/context-preview-get.d.ts +17 -0
  186. package/dist/agent/context-xray/actions/context-preview-get.d.ts.map +1 -0
  187. package/dist/agent/context-xray/actions/context-preview-get.js +94 -0
  188. package/dist/agent/context-xray/actions/context-preview-get.js.map +1 -0
  189. package/dist/agent/context-xray/actions/context-restore.js +5 -2
  190. package/dist/agent/context-xray/actions/context-restore.js.map +1 -1
  191. package/dist/agent/context-xray/actions/errors.d.ts +3 -0
  192. package/dist/agent/context-xray/actions/errors.d.ts.map +1 -1
  193. package/dist/agent/context-xray/actions/errors.js +6 -0
  194. package/dist/agent/context-xray/actions/errors.js.map +1 -1
  195. package/dist/agent/context-xray/manifest.d.ts +18 -1
  196. package/dist/agent/context-xray/manifest.d.ts.map +1 -1
  197. package/dist/agent/context-xray/manifest.js +68 -6
  198. package/dist/agent/context-xray/manifest.js.map +1 -1
  199. package/dist/agent/engine/context-directives-transform.d.ts +2 -0
  200. package/dist/agent/engine/context-directives-transform.d.ts.map +1 -1
  201. package/dist/agent/engine/context-directives-transform.js +2 -1
  202. package/dist/agent/engine/context-directives-transform.js.map +1 -1
  203. package/dist/agent/production-agent.d.ts +15 -0
  204. package/dist/agent/production-agent.d.ts.map +1 -1
  205. package/dist/agent/production-agent.js +74 -36
  206. package/dist/agent/production-agent.js.map +1 -1
  207. package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
  208. package/dist/agent/run-loop-with-resume.js +6 -3
  209. package/dist/agent/run-loop-with-resume.js.map +1 -1
  210. package/dist/client/AgentPanel.d.ts +5 -1
  211. package/dist/client/AgentPanel.d.ts.map +1 -1
  212. package/dist/client/AgentPanel.js +9 -11
  213. package/dist/client/AgentPanel.js.map +1 -1
  214. package/dist/client/agent-page/AgentContextTab.d.ts +5 -0
  215. package/dist/client/agent-page/AgentContextTab.d.ts.map +1 -0
  216. package/dist/client/agent-page/AgentContextTab.js +202 -0
  217. package/dist/client/agent-page/AgentContextTab.js.map +1 -0
  218. package/dist/client/agent-page/AgentJobsTab.d.ts +3 -0
  219. package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -0
  220. package/dist/client/agent-page/AgentJobsTab.js +98 -0
  221. package/dist/client/agent-page/AgentJobsTab.js.map +1 -0
  222. package/dist/client/agent-page/AgentTabsPage.d.ts +20 -0
  223. package/dist/client/agent-page/AgentTabsPage.d.ts.map +1 -0
  224. package/dist/client/agent-page/AgentTabsPage.js +420 -0
  225. package/dist/client/agent-page/AgentTabsPage.js.map +1 -0
  226. package/dist/client/agent-page/types.d.ts +17 -0
  227. package/dist/client/agent-page/types.d.ts.map +1 -0
  228. package/dist/client/agent-page/types.js +9 -0
  229. package/dist/client/agent-page/types.js.map +1 -0
  230. package/dist/client/agent-page/use-jobs.d.ts +61 -0
  231. package/dist/client/agent-page/use-jobs.d.ts.map +1 -0
  232. package/dist/client/agent-page/use-jobs.js +71 -0
  233. package/dist/client/agent-page/use-jobs.js.map +1 -0
  234. package/dist/client/context-xray/ContextMeter.d.ts +3 -1
  235. package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
  236. package/dist/client/context-xray/ContextMeter.js +14 -5
  237. package/dist/client/context-xray/ContextMeter.js.map +1 -1
  238. package/dist/client/context-xray/ContextTreemap.d.ts +3 -2
  239. package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
  240. package/dist/client/context-xray/ContextTreemap.js +9 -1
  241. package/dist/client/context-xray/ContextTreemap.js.map +1 -1
  242. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  243. package/dist/client/context-xray/ContextXRayPanel.js +95 -20
  244. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  245. package/dist/client/context-xray/format.d.ts.map +1 -1
  246. package/dist/client/context-xray/format.js +12 -0
  247. package/dist/client/context-xray/format.js.map +1 -1
  248. package/dist/client/index.d.ts +3 -0
  249. package/dist/client/index.d.ts.map +1 -1
  250. package/dist/client/index.js +1 -0
  251. package/dist/client/index.js.map +1 -1
  252. package/dist/client/resources/ResourcesPanel.d.ts +9 -1
  253. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  254. package/dist/client/resources/ResourcesPanel.js +26 -10
  255. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  256. package/dist/client/settings/AutomationsSection.d.ts +9 -0
  257. package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
  258. package/dist/client/settings/AutomationsSection.js +128 -147
  259. package/dist/client/settings/AutomationsSection.js.map +1 -1
  260. package/dist/collab/routes.d.ts +1 -1
  261. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  262. package/dist/jobs/actions/list-recurring-jobs.d.ts +21 -0
  263. package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -0
  264. package/dist/jobs/actions/list-recurring-jobs.js +74 -0
  265. package/dist/jobs/actions/list-recurring-jobs.js.map +1 -0
  266. package/dist/jobs/actions/manage-recurring-job.d.ts +18 -0
  267. package/dist/jobs/actions/manage-recurring-job.d.ts.map +1 -0
  268. package/dist/jobs/actions/manage-recurring-job.js +68 -0
  269. package/dist/jobs/actions/manage-recurring-job.js.map +1 -0
  270. package/dist/jobs/tools.d.ts +13 -0
  271. package/dist/jobs/tools.d.ts.map +1 -1
  272. package/dist/jobs/tools.js +1 -1
  273. package/dist/jobs/tools.js.map +1 -1
  274. package/dist/localization/default-messages.d.ts +96 -0
  275. package/dist/localization/default-messages.d.ts.map +1 -1
  276. package/dist/localization/default-messages.js +96 -0
  277. package/dist/localization/default-messages.js.map +1 -1
  278. package/dist/mcp/build-server.d.ts.map +1 -1
  279. package/dist/mcp/build-server.js +1 -0
  280. package/dist/mcp/build-server.js.map +1 -1
  281. package/dist/mcp/connect-route.d.ts.map +1 -1
  282. package/dist/mcp/connect-route.js +44 -59
  283. package/dist/mcp/connect-route.js.map +1 -1
  284. package/dist/notifications/routes.d.ts +2 -2
  285. package/dist/observability/routes.d.ts +5 -5
  286. package/dist/progress/routes.d.ts +1 -1
  287. package/dist/resources/handlers.d.ts +1 -1
  288. package/dist/secrets/routes.d.ts +9 -9
  289. package/dist/server/action-discovery.d.ts.map +1 -1
  290. package/dist/server/action-discovery.js +23 -0
  291. package/dist/server/action-discovery.js.map +1 -1
  292. package/dist/server/agent-chat/prompt-resources.d.ts +14 -0
  293. package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -1
  294. package/dist/server/agent-chat/prompt-resources.js +139 -2
  295. package/dist/server/agent-chat/prompt-resources.js.map +1 -1
  296. package/dist/server/agent-chat-plugin.d.ts +1 -0
  297. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  298. package/dist/server/agent-chat-plugin.js +136 -3
  299. package/dist/server/agent-chat-plugin.js.map +1 -1
  300. package/dist/server/auth.d.ts.map +1 -1
  301. package/dist/server/auth.js +1 -4
  302. package/dist/server/auth.js.map +1 -1
  303. package/dist/server/google-oauth.d.ts.map +1 -1
  304. package/dist/server/google-oauth.js +1 -4
  305. package/dist/server/google-oauth.js.map +1 -1
  306. package/dist/server/workspace-oauth.d.ts +11 -0
  307. package/dist/server/workspace-oauth.d.ts.map +1 -0
  308. package/dist/server/workspace-oauth.js +25 -0
  309. package/dist/server/workspace-oauth.js.map +1 -0
  310. package/dist/shared/context-xray.d.ts +45 -1
  311. package/dist/shared/context-xray.d.ts.map +1 -1
  312. package/dist/shared/context-xray.js +12 -0
  313. package/dist/shared/context-xray.js.map +1 -1
  314. package/dist/shared/mcp-connect-content.d.ts +37 -0
  315. package/dist/shared/mcp-connect-content.d.ts.map +1 -0
  316. package/dist/shared/mcp-connect-content.js +92 -0
  317. package/dist/shared/mcp-connect-content.js.map +1 -0
  318. package/dist/templates/default/app/routes/_index.tsx +11 -0
  319. package/dist/templates/default/app/routes/agent.tsx +33 -0
  320. package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  321. package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  322. package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  323. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  324. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
  325. package/dist/triggers/actions/list-automations.d.ts +24 -0
  326. package/dist/triggers/actions/list-automations.d.ts.map +1 -0
  327. package/dist/triggers/actions/list-automations.js +72 -0
  328. package/dist/triggers/actions/list-automations.js.map +1 -0
  329. package/dist/triggers/actions/manage-automation.d.ts +18 -0
  330. package/dist/triggers/actions/manage-automation.d.ts.map +1 -0
  331. package/dist/triggers/actions/manage-automation.js +60 -0
  332. package/dist/triggers/actions/manage-automation.js.map +1 -0
  333. package/docs/content/agent-surfaces.mdx +43 -0
  334. package/docs/content/external-agents.mdx +11 -0
  335. package/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
  336. package/docs/content/locales/ar-SA/external-agents.mdx +9 -0
  337. package/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
  338. package/docs/content/locales/de-DE/external-agents.mdx +10 -0
  339. package/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
  340. package/docs/content/locales/es-ES/external-agents.mdx +10 -0
  341. package/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
  342. package/docs/content/locales/fr-FR/external-agents.mdx +11 -0
  343. package/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
  344. package/docs/content/locales/hi-IN/external-agents.mdx +9 -0
  345. package/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
  346. package/docs/content/locales/ja-JP/external-agents.mdx +10 -0
  347. package/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
  348. package/docs/content/locales/ko-KR/external-agents.mdx +9 -0
  349. package/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
  350. package/docs/content/locales/pt-BR/external-agents.mdx +10 -0
  351. package/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
  352. package/docs/content/locales/zh-CN/external-agents.mdx +8 -0
  353. package/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
  354. package/docs/content/locales/zh-TW/external-agents.mdx +8 -0
  355. package/package.json +1 -1
  356. package/src/templates/default/app/routes/_index.tsx +11 -0
  357. package/src/templates/default/app/routes/agent.tsx +33 -0
  358. package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
  359. package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
  360. package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
  361. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
  362. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
@@ -13,6 +13,7 @@ import {
13
13
  } from "@agent-native/core/client";
14
14
  import { configureTracking } from "@agent-native/core/client";
15
15
  import {
16
+ IconBrain,
16
17
  IconMoon,
17
18
  IconScribble,
18
19
  IconShape2,
@@ -176,6 +177,13 @@ function AppContent() {
176
177
  <CommandMenu.Item onSelect={() => go("/recaps")}>
177
178
  {t("root.openRecaps")}
178
179
  </CommandMenu.Item>
180
+ <CommandMenu.Item
181
+ onSelect={() => go("/agent")}
182
+ keywords={["agent", "context", "connections", "jobs", "access"]}
183
+ >
184
+ <IconBrain size={16} />
185
+ {t("settings.openAgentSettings")}
186
+ </CommandMenu.Item>
179
187
  </CommandMenu.Group>
180
188
  <CommandMenu.Group heading={t("root.commandAppearance")}>
181
189
  <CommandMenu.Item
@@ -0,0 +1,15 @@
1
+ import { AgentTabsPage, useT } from "@agent-native/core/client";
2
+ import { useSetPageTitle } from "@agent-native/toolkit/app-shell";
3
+
4
+ import messages from "@/i18n/en-US";
5
+
6
+ export function meta() {
7
+ return [{ title: messages.settings.agentTitle }];
8
+ }
9
+
10
+ export default function AgentRoute() {
11
+ const t = useT();
12
+ useSetPageTitle(t("settings.agentTitle"));
13
+
14
+ return <AgentTabsPage appName="Plan" />;
15
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: added
3
+ date: 2026-07-13
4
+ ---
5
+
6
+ New Agent page: see and manage your agent's context, files, connections, jobs, and external access in one place
@@ -11,6 +11,7 @@ import { useDecks } from "@/context/DeckContext";
11
11
  const pageTitleKeys: Record<string, string> = {
12
12
  "/": "header.decks",
13
13
  "/design-systems": "header.designSystems",
14
+ "/agent": "settings.agentTitle",
14
15
  "/settings": "header.settings",
15
16
  "/extensions": "header.extensions",
16
17
  };
@@ -77,6 +77,7 @@ export function Layout({ children }: LayoutProps) {
77
77
  ]}
78
78
  scope={deckScope}
79
79
  browserTabId={TAB_ID}
80
+ agentPageHref="/agent"
80
81
  >
81
82
  <div className="agent-layout-shell flex h-screen w-full overflow-hidden bg-background text-foreground">
82
83
  {sidebarOpen && (
@@ -8,6 +8,7 @@ import { ExtensionsSidebarSection } from "@agent-native/core/client/extensions";
8
8
  import { OrgSwitcher } from "@agent-native/core/client/org";
9
9
  import {
10
10
  IconStack2,
11
+ IconBrain,
11
12
  IconPalette,
12
13
  IconSettings,
13
14
  IconLayoutSidebarLeftCollapse,
@@ -29,6 +30,7 @@ const navItems = [
29
30
  labelKey: "navigation.designSystems",
30
31
  href: "/design-systems",
31
32
  },
33
+ { icon: IconBrain, labelKey: "settings.agentTitle", href: "/agent" },
32
34
  { icon: IconSettings, labelKey: "navigation.settings", href: "/settings" },
33
35
  ];
34
36
 
@@ -15,7 +15,7 @@ import {
15
15
  getLocaleInitScript,
16
16
  getThemeInitScript,
17
17
  } from "@agent-native/core/client";
18
- import { IconSun, IconMoon } from "@tabler/icons-react";
18
+ import { IconBrain, IconSun, IconMoon } from "@tabler/icons-react";
19
19
  import { useQueryClient } from "@tanstack/react-query";
20
20
  import { useTheme } from "next-themes";
21
21
  import { useCallback, useEffect, useState } from "react";
@@ -26,6 +26,7 @@ import {
26
26
  Scripts,
27
27
  ScrollRestoration,
28
28
  useLocation,
29
+ useNavigate,
29
30
  } from "react-router";
30
31
  import type { LinksFunction } from "react-router";
31
32
 
@@ -184,6 +185,7 @@ function AppContent() {
184
185
  const isDark = resolvedTheme === "dark";
185
186
  const [cmdkOpen, setCmdkOpen] = useState(false);
186
187
  const t = useT();
188
+ const navigate = useNavigate();
187
189
  useCommandMenuShortcut(useCallback(() => setCmdkOpen(true), []));
188
190
  const location = useLocation();
189
191
 
@@ -212,6 +214,13 @@ function AppContent() {
212
214
  <CommandMenu.Item onSelect={() => {}}>
213
215
  {t("root.searchDecks")}
214
216
  </CommandMenu.Item>
217
+ <CommandMenu.Item
218
+ onSelect={() => navigate("/agent")}
219
+ keywords={["agent", "context", "connections", "jobs", "access"]}
220
+ >
221
+ <IconBrain size={16} />
222
+ {t("settings.openAgentSettings")}
223
+ </CommandMenu.Item>
215
224
  </CommandMenu.Group>
216
225
  <CommandMenu.Group heading={t("root.commandAppearance")}>
217
226
  <CommandMenu.Item
@@ -0,0 +1,15 @@
1
+ import { AgentTabsPage, useT } from "@agent-native/core/client";
2
+ import { useSetPageTitle } from "@agent-native/toolkit/app-shell";
3
+
4
+ import messages from "@/i18n/en-US";
5
+
6
+ export function meta() {
7
+ return [{ title: messages.settings.agentTitle }];
8
+ }
9
+
10
+ export default function AgentRoute() {
11
+ const t = useT();
12
+ useSetPageTitle(t("settings.agentTitle"));
13
+
14
+ return <AgentTabsPage appName="Slides" />;
15
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: added
3
+ date: 2026-07-13
4
+ ---
5
+
6
+ New Agent page: see and manage your agent's context, files, connections, jobs, and external access in one place
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import { defineAction } from "../../../action.js";
3
3
  import { getRequestOrgId, getRequestUserEmail, } from "../../../server/request-context.js";
4
4
  import { callerOwnsThread } from "../../run-ownership.js";
5
- import { upsertContextDirective, writeContextManifestStatus, } from "../directives-store.js";
6
- import { contextXrayAuthError, contextXrayThreadNotFoundError, } from "./errors.js";
5
+ import { readContextManifest, upsertContextDirective, writeContextManifestStatus, } from "../directives-store.js";
6
+ import { contextXrayAuthError, contextXraySystemSegmentError, contextXrayThreadNotFoundError, isContextXraySystemSegment, } from "./errors.js";
7
7
  export default defineAction({
8
8
  description: "Evict a Context X-Ray segment from future model calls. This excludes the segment from context; it does not delete chat history and can be restored.",
9
9
  schema: z.object({
@@ -17,6 +17,9 @@ export default defineAction({
17
17
  if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
18
18
  throw contextXrayThreadNotFoundError();
19
19
  }
20
+ if (isContextXraySystemSegment(await readContextManifest(args.threadId), args.segmentId)) {
21
+ throw contextXraySystemSegmentError();
22
+ }
20
23
  const directive = await upsertContextDirective({
21
24
  threadId: args.threadId,
22
25
  segmentId: args.segmentId,
@@ -1 +1 @@
1
- {"version":3,"file":"context-evict.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-evict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,qJAAqJ;IACvJ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU;YAAE,MAAM,oBAAoB,EAAE,CAAC;QAC9C,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,8BAA8B,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;YAC7C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,OAAO;YACf,UAAU;YACV,KAAK,EAAE,eAAe,EAAE,IAAI,IAAI;SACjC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../../action.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n upsertContextDirective,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXrayThreadNotFoundError,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Evict a Context X-Ray segment from future model calls. This excludes the segment from context; it does not delete chat history and can be restored.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n const directive = await upsertContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n action: \"evict\",\n ownerEmail,\n orgId: getRequestOrgId() ?? null,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"evicted\",\n });\n return { directive, manifest };\n },\n});\n"]}
1
+ {"version":3,"file":"context-evict.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-evict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,GA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";\n\nimport { defineAction } from \"../../../action.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n readContextManifest,\n upsertContextDirective,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXraySystemSegmentError,\n contextXrayThreadNotFoundError,\n isContextXraySystemSegment,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Evict a Context X-Ray segment from future model calls. This excludes the segment from context; it does not delete chat history and can be restored.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n if (\n isContextXraySystemSegment(\n await readContextManifest(args.threadId),\n args.segmentId,\n )\n ) {\n throw contextXraySystemSegmentError();\n }\n const directive = await upsertContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n action: \"evict\",\n ownerEmail,\n orgId: getRequestOrgId() ?? null,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"evicted\",\n });\n return { directive, manifest };\n },\n});\n"]}
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import { defineAction } from "../../../action.js";
3
3
  import { getRequestOrgId, getRequestUserEmail, } from "../../../server/request-context.js";
4
4
  import { callerOwnsThread } from "../../run-ownership.js";
5
- import { upsertContextDirective, writeContextManifestStatus, } from "../directives-store.js";
6
- import { contextXrayAuthError, contextXrayThreadNotFoundError, } from "./errors.js";
5
+ import { readContextManifest, upsertContextDirective, writeContextManifestStatus, } from "../directives-store.js";
6
+ import { contextXrayAuthError, contextXraySystemSegmentError, contextXrayThreadNotFoundError, isContextXraySystemSegment, } from "./errors.js";
7
7
  export default defineAction({
8
8
  description: "Pin a Context X-Ray segment so it is preserved through future context compaction.",
9
9
  schema: z.object({
@@ -17,6 +17,9 @@ export default defineAction({
17
17
  if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
18
18
  throw contextXrayThreadNotFoundError();
19
19
  }
20
+ if (isContextXraySystemSegment(await readContextManifest(args.threadId), args.segmentId)) {
21
+ throw contextXraySystemSegmentError();
22
+ }
20
23
  const directive = await upsertContextDirective({
21
24
  threadId: args.threadId,
22
25
  segmentId: args.segmentId,
@@ -1 +1 @@
1
- {"version":3,"file":"context-pin.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-pin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,mFAAmF;IACrF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU;YAAE,MAAM,oBAAoB,EAAE,CAAC;QAC9C,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,8BAA8B,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC;YAC7C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,KAAK;YACb,UAAU;YACV,KAAK,EAAE,eAAe,EAAE,IAAI,IAAI;SACjC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../../action.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n upsertContextDirective,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXrayThreadNotFoundError,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Pin a Context X-Ray segment so it is preserved through future context compaction.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n const directive = await upsertContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n action: \"pin\",\n ownerEmail,\n orgId: getRequestOrgId() ?? null,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"pinned\",\n });\n return { directive, manifest };\n },\n});\n"]}
1
+ {"version":3,"file":"context-pin.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-pin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CA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A0B,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../../action.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n readContextManifest,\n upsertContextDirective,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXraySystemSegmentError,\n contextXrayThreadNotFoundError,\n isContextXraySystemSegment,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Pin a Context X-Ray segment so it is preserved through future context compaction.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n if (\n isContextXraySystemSegment(\n await readContextManifest(args.threadId),\n args.segmentId,\n )\n ) {\n throw contextXraySystemSegmentError();\n }\n const directive = await upsertContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n action: \"pin\",\n ownerEmail,\n orgId: getRequestOrgId() ?? null,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"pinned\",\n });\n return { directive, manifest };\n },\n});\n"]}
@@ -0,0 +1,17 @@
1
+ import { type ContextPreview } from "../../../shared/context-xray.js";
2
+ export declare function buildContextPreview(input: {
3
+ ownerEmail: string;
4
+ orgId?: string | null;
5
+ scope: "user" | "org";
6
+ appId?: string;
7
+ compact?: boolean;
8
+ model?: string;
9
+ }): Promise<ContextPreview>;
10
+ declare const _default: import("../../../action.js").ActionDefinition<{
11
+ scope?: "org" | "user";
12
+ appId?: string;
13
+ compact?: boolean;
14
+ model?: string;
15
+ }, ContextPreview>;
16
+ export default _default;
17
+ //# sourceMappingURL=context-preview-get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-preview-get.d.ts","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-preview-get.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,iCAAiC,CAAC;AAWzC,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,cAAc,CAAC,CAqD1B"}
@@ -0,0 +1,94 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../../action.js";
3
+ import { embedApp } from "../../../mcp/embed-app.js";
4
+ import { SHARED_OWNER } from "../../../resources/store.js";
5
+ import { buildFrameworkPrompts, buildSchemaBlock, } from "../../../server/agent-chat/framework-prompts.js";
6
+ import { loadResourcesForPrompt, promptResourceManifestSections, } from "../../../server/agent-chat/prompt-resources.js";
7
+ import { getRequestOrgId, getRequestUserEmail, } from "../../../server/request-context.js";
8
+ import { buildSystemManifestSections } from "../manifest.js";
9
+ import { contextXrayAuthError } from "./errors.js";
10
+ function combineMethods(left, right) {
11
+ return left === "estimate" || right === "estimate" ? "estimate" : "exact";
12
+ }
13
+ export async function buildContextPreview(input) {
14
+ const compact = input.compact ?? false;
15
+ const prompts = buildFrameworkPrompts();
16
+ const resources = await loadResourcesForPrompt(input.scope === "org" ? SHARED_OWNER : input.ownerEmail, compact, input.appId, input.orgId ?? null);
17
+ const schemaBlock = compact
18
+ ? ""
19
+ : await buildSchemaBlock(input.ownerEmail, "read");
20
+ const sections = await buildSystemManifestSections([
21
+ {
22
+ label: "Framework core",
23
+ provenance: "framework-core",
24
+ governance: "required",
25
+ content: compact
26
+ ? prompts.PROD_FRAMEWORK_PROMPT_COMPACT
27
+ : prompts.PROD_FRAMEWORK_PROMPT,
28
+ sourceRef: { scope: "framework" },
29
+ },
30
+ ...promptResourceManifestSections(resources),
31
+ ...(schemaBlock
32
+ ? [
33
+ {
34
+ label: "SQL schema",
35
+ provenance: "db-schema",
36
+ governance: "required",
37
+ content: schemaBlock,
38
+ sourceRef: { scope: "sql" },
39
+ },
40
+ ]
41
+ : []),
42
+ ]);
43
+ const systemTokens = sections.reduce((total, section) => total + section.tokenCount, 0);
44
+ const tokenCountMethod = sections.reduce((method, section) => combineMethods(method, section.tokenMethod), "exact");
45
+ return {
46
+ computedAt: Date.now(),
47
+ ...(input.model ? { model: input.model } : {}),
48
+ scope: input.scope,
49
+ totalTokens: systemTokens,
50
+ systemTokens,
51
+ tokenCountMethod,
52
+ sections,
53
+ source: "preview",
54
+ };
55
+ }
56
+ export default defineAction({
57
+ description: "Preview the system-prompt context that would be composed for the current user, organization, and app without a live chat thread.",
58
+ schema: z.object({
59
+ scope: z
60
+ .enum(["user", "org"])
61
+ .default("user")
62
+ .describe("Configuration scope to preview: user includes personal context; org includes inherited organization context."),
63
+ appId: z.string().optional().describe("Current app id, when available."),
64
+ compact: z.boolean().optional().describe("Use the compact startup prompt."),
65
+ model: z.string().optional().describe("Model id for display metadata."),
66
+ }),
67
+ http: { method: "GET" },
68
+ readOnly: true,
69
+ publicAgent: { expose: true, readOnly: true, requiresAuth: true },
70
+ mcpApp: {
71
+ compactCatalog: true,
72
+ resource: embedApp({
73
+ title: "Context preview",
74
+ description: "Preview the system-prompt context before starting a thread.",
75
+ iframeTitle: "Context preview",
76
+ openLabel: "Open context preview",
77
+ height: 720,
78
+ }),
79
+ },
80
+ run: async (args) => {
81
+ const ownerEmail = getRequestUserEmail();
82
+ if (!ownerEmail)
83
+ throw contextXrayAuthError();
84
+ return await buildContextPreview({
85
+ ownerEmail,
86
+ orgId: getRequestOrgId() ?? null,
87
+ scope: args.scope,
88
+ ...(args.appId ? { appId: args.appId } : {}),
89
+ ...(args.compact !== undefined ? { compact: args.compact } : {}),
90
+ ...(args.model ? { model: args.model } : {}),
91
+ });
92
+ },
93
+ });
94
+ //# sourceMappingURL=context-preview-get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-preview-get.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-preview-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAK5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,SAAS,cAAc,CACrB,IAA6B,EAC7B,KAA8B;IAE9B,OAAO,IAAI,KAAK,UAAU,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAOzC;IACC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;IACvC,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IACxC,MAAM,SAAS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;KACH;IACD,GAAG,EAAE,KAAK,EAAE,IAAI,EAA2B,EAAE;QAC3C,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU;YAAE,MAAM,oBAAoB,EAAE,CAAC;QAC9C,OAAO,MAAM,mBAAmB,CAAC;YAC/B,UAAU;YACV,KAAK,EAAE,eAAe,EAAE,IAAI,IAAI;YAChC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../../action.js\";\nimport { embedApp } from \"../../../mcp/embed-app.js\";\nimport { SHARED_OWNER } from \"../../../resources/store.js\";\nimport {\n buildFrameworkPrompts,\n buildSchemaBlock,\n} from \"../../../server/agent-chat/framework-prompts.js\";\nimport {\n loadResourcesForPrompt,\n promptResourceManifestSections,\n} from \"../../../server/agent-chat/prompt-resources.js\";\nimport {\n getRequestOrgId,\n getRequestUserEmail,\n} from \"../../../server/request-context.js\";\nimport {\n type ContextPreview,\n type ContextTokenCountMethod,\n} from \"../../../shared/context-xray.js\";\nimport { buildSystemManifestSections } from \"../manifest.js\";\nimport { contextXrayAuthError } from \"./errors.js\";\n\nfunction combineMethods(\n left: ContextTokenCountMethod,\n right: ContextTokenCountMethod,\n): ContextTokenCountMethod {\n return left === \"estimate\" || right === \"estimate\" ? \"estimate\" : \"exact\";\n}\n\nexport async function buildContextPreview(input: {\n ownerEmail: string;\n orgId?: string | null;\n scope: \"user\" | \"org\";\n appId?: string;\n compact?: boolean;\n model?: string;\n}): Promise<ContextPreview> {\n const compact = input.compact ?? false;\n const prompts = buildFrameworkPrompts();\n const resources = await loadResourcesForPrompt(\n input.scope === \"org\" ? SHARED_OWNER : input.ownerEmail,\n compact,\n input.appId,\n input.orgId ?? null,\n );\n const schemaBlock = compact\n ? \"\"\n : await buildSchemaBlock(input.ownerEmail, \"read\");\n const sections = await buildSystemManifestSections([\n {\n label: \"Framework core\",\n provenance: \"framework-core\",\n governance: \"required\",\n content: compact\n ? prompts.PROD_FRAMEWORK_PROMPT_COMPACT\n : prompts.PROD_FRAMEWORK_PROMPT,\n sourceRef: { scope: \"framework\" },\n },\n ...promptResourceManifestSections(resources),\n ...(schemaBlock\n ? [\n {\n label: \"SQL schema\",\n provenance: \"db-schema\" as const,\n governance: \"required\" as const,\n content: schemaBlock,\n sourceRef: { scope: \"sql\" },\n },\n ]\n : []),\n ]);\n const systemTokens = sections.reduce(\n (total, section) => total + section.tokenCount,\n 0,\n );\n const tokenCountMethod = sections.reduce(\n (method, section) => combineMethods(method, section.tokenMethod),\n \"exact\" as ContextTokenCountMethod,\n );\n return {\n computedAt: Date.now(),\n ...(input.model ? { model: input.model } : {}),\n scope: input.scope,\n totalTokens: systemTokens,\n systemTokens,\n tokenCountMethod,\n sections,\n source: \"preview\",\n };\n}\n\nexport default defineAction({\n description:\n \"Preview the system-prompt context that would be composed for the current user, organization, and app without a live chat thread.\",\n schema: z.object({\n scope: z\n .enum([\"user\", \"org\"])\n .default(\"user\")\n .describe(\n \"Configuration scope to preview: user includes personal context; org includes inherited organization context.\",\n ),\n appId: z.string().optional().describe(\"Current app id, when available.\"),\n compact: z.boolean().optional().describe(\"Use the compact startup prompt.\"),\n model: z.string().optional().describe(\"Model id for display metadata.\"),\n }),\n http: { method: \"GET\" },\n readOnly: true,\n publicAgent: { expose: true, readOnly: true, requiresAuth: true },\n mcpApp: {\n compactCatalog: true,\n resource: embedApp({\n title: \"Context preview\",\n description:\n \"Preview the system-prompt context before starting a thread.\",\n iframeTitle: \"Context preview\",\n openLabel: \"Open context preview\",\n height: 720,\n }),\n },\n run: async (args): Promise<ContextPreview> => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n return await buildContextPreview({\n ownerEmail,\n orgId: getRequestOrgId() ?? null,\n scope: args.scope,\n ...(args.appId ? { appId: args.appId } : {}),\n ...(args.compact !== undefined ? { compact: args.compact } : {}),\n ...(args.model ? { model: args.model } : {}),\n });\n },\n});\n"]}
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import { defineAction } from "../../../action.js";
3
3
  import { getRequestUserEmail } from "../../../server/request-context.js";
4
4
  import { callerOwnsThread } from "../../run-ownership.js";
5
- import { deactivateContextDirective, writeContextManifestStatus, } from "../directives-store.js";
6
- import { contextXrayAuthError, contextXrayThreadNotFoundError, } from "./errors.js";
5
+ import { deactivateContextDirective, readContextManifest, writeContextManifestStatus, } from "../directives-store.js";
6
+ import { contextXrayAuthError, contextXraySystemSegmentError, contextXrayThreadNotFoundError, isContextXraySystemSegment, } from "./errors.js";
7
7
  export default defineAction({
8
8
  description: "Restore a Context X-Ray segment by deactivating its pin, evict, or summarize directive.",
9
9
  schema: z.object({
@@ -17,6 +17,9 @@ export default defineAction({
17
17
  if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
18
18
  throw contextXrayThreadNotFoundError();
19
19
  }
20
+ if (isContextXraySystemSegment(await readContextManifest(args.threadId), args.segmentId)) {
21
+ throw contextXraySystemSegmentError();
22
+ }
20
23
  const restored = await deactivateContextDirective({
21
24
  threadId: args.threadId,
22
25
  segmentId: args.segmentId,
@@ -1 +1 @@
1
- {"version":3,"file":"context-restore.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-restore.ts"],"names":[],"mappings":"A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";\n\nimport { defineAction } from \"../../../action.js\";\nimport { getRequestUserEmail } from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n deactivateContextDirective,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXrayThreadNotFoundError,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Restore a Context X-Ray segment by deactivating its pin, evict, or summarize directive.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n const restored = await deactivateContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n ownerEmail,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"active\",\n });\n return { restored, manifest };\n },\n});\n"]}
1
+ {"version":3,"file":"context-restore.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/context-restore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,yFAAyF;IAC3F,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,MAAM,UAAU,GAAG,mBAAmB,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU;YAAE,MAAM,oBAAoB,EAAE,CAAC;QAC9C,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YACzD,MAAM,8BAA8B,EAAE,CAAC;QACzC,CAAC;QACD,IACE,0BAA0B,CACxB,MAAM,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxC,IAAI,CAAC,SAAS,CACf,EACD,CAAC;YACD,MAAM,6BAA6B,EAAE,CAAC;QACxC,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU;SACX,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../../action.js\";\nimport { getRequestUserEmail } from \"../../../server/request-context.js\";\nimport { callerOwnsThread } from \"../../run-ownership.js\";\nimport {\n deactivateContextDirective,\n readContextManifest,\n writeContextManifestStatus,\n} from \"../directives-store.js\";\nimport {\n contextXrayAuthError,\n contextXraySystemSegmentError,\n contextXrayThreadNotFoundError,\n isContextXraySystemSegment,\n} from \"./errors.js\";\n\nexport default defineAction({\n description:\n \"Restore a Context X-Ray segment by deactivating its pin, evict, or summarize directive.\",\n schema: z.object({\n threadId: z.string(),\n segmentId: z.string(),\n }),\n run: async (args) => {\n const ownerEmail = getRequestUserEmail();\n if (!ownerEmail) throw contextXrayAuthError();\n if (!(await callerOwnsThread(ownerEmail, args.threadId))) {\n throw contextXrayThreadNotFoundError();\n }\n if (\n isContextXraySystemSegment(\n await readContextManifest(args.threadId),\n args.segmentId,\n )\n ) {\n throw contextXraySystemSegmentError();\n }\n const restored = await deactivateContextDirective({\n threadId: args.threadId,\n segmentId: args.segmentId,\n ownerEmail,\n });\n const manifest = await writeContextManifestStatus({\n threadId: args.threadId,\n segmentId: args.segmentId,\n status: \"active\",\n });\n return { restored, manifest };\n },\n});\n"]}
@@ -1,7 +1,10 @@
1
+ import type { ContextManifest } from "../../../shared/context-xray.js";
1
2
  export declare class ContextXrayActionError extends Error {
2
3
  readonly statusCode: number;
3
4
  constructor(message: string, statusCode: number);
4
5
  }
5
6
  export declare function contextXrayAuthError(): ContextXrayActionError;
6
7
  export declare function contextXrayThreadNotFoundError(): ContextXrayActionError;
8
+ export declare function contextXraySystemSegmentError(): ContextXrayActionError;
9
+ export declare function isContextXraySystemSegment(manifest: ContextManifest | null, segmentId: string): boolean;
7
10
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;IAG7C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAF7B,YACE,OAAO,EAAE,MAAM,EACN,UAAU,EAAE,MAAM,EAI5B;CACF;AAED,wBAAgB,oBAAoB,IAAI,sBAAsB,CAK7D;AAED,wBAAgB,8BAA8B,IAAI,sBAAsB,CAEvE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,qBAAa,sBAAuB,SAAQ,KAAK;IAG7C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAF7B,YACE,OAAO,EAAE,MAAM,EACN,UAAU,EAAE,MAAM,EAI5B;CACF;AAED,wBAAgB,oBAAoB,IAAI,sBAAsB,CAK7D;AAED,wBAAgB,8BAA8B,IAAI,sBAAsB,CAEvE;AAED,wBAAgB,6BAA6B,IAAI,sBAAsB,CAKtE;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,eAAe,GAAG,IAAI,EAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT"}
@@ -12,4 +12,10 @@ export function contextXrayAuthError() {
12
12
  export function contextXrayThreadNotFoundError() {
13
13
  return new ContextXrayActionError("Thread not found.", 404);
14
14
  }
15
+ export function contextXraySystemSegmentError() {
16
+ return new ContextXrayActionError("System Context X-Ray sections are required and cannot be pinned, evicted, or restored.", 400);
17
+ }
18
+ export function isContextXraySystemSegment(manifest, segmentId) {
19
+ return (manifest?.systemSections?.some((section) => section.segmentId === segmentId) ?? false);
20
+ }
15
21
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAGpC,UAAU;IAFrB,YACE,OAAe,EACN,UAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;0BAFN,UAAU;QAGnB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,sBAAsB,CAC/B,0CAA0C,EAC1C,GAAG,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO,IAAI,sBAAsB,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export class ContextXrayActionError extends Error {\n constructor(\n message: string,\n readonly statusCode: number,\n ) {\n super(message);\n this.name = \"ContextXrayActionError\";\n }\n}\n\nexport function contextXrayAuthError(): ContextXrayActionError {\n return new ContextXrayActionError(\n \"Context X-Ray requires a signed-in user.\",\n 401,\n );\n}\n\nexport function contextXrayThreadNotFoundError(): ContextXrayActionError {\n return new ContextXrayActionError(\"Thread not found.\", 404);\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/agent/context-xray/actions/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAGpC,UAAU;IAFrB,YACE,OAAe,EACN,UAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;0BAFN,UAAU;QAGnB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,sBAAsB,CAC/B,0CAA0C,EAC1C,GAAG,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO,IAAI,sBAAsB,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO,IAAI,sBAAsB,CAC/B,wFAAwF,EACxF,GAAG,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAgC,EAChC,SAAiB;IAEjB,OAAO,CACL,QAAQ,EAAE,cAAc,EAAE,IAAI,CAC5B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAC7C,IAAI,KAAK,CACX,CAAC;AACJ,CAAC","sourcesContent":["import type { ContextManifest } from \"../../../shared/context-xray.js\";\n\nexport class ContextXrayActionError extends Error {\n constructor(\n message: string,\n readonly statusCode: number,\n ) {\n super(message);\n this.name = \"ContextXrayActionError\";\n }\n}\n\nexport function contextXrayAuthError(): ContextXrayActionError {\n return new ContextXrayActionError(\n \"Context X-Ray requires a signed-in user.\",\n 401,\n );\n}\n\nexport function contextXrayThreadNotFoundError(): ContextXrayActionError {\n return new ContextXrayActionError(\"Thread not found.\", 404);\n}\n\nexport function contextXraySystemSegmentError(): ContextXrayActionError {\n return new ContextXrayActionError(\n \"System Context X-Ray sections are required and cannot be pinned, evicted, or restored.\",\n 400,\n );\n}\n\nexport function isContextXraySystemSegment(\n manifest: ContextManifest | null,\n segmentId: string,\n): boolean {\n return (\n manifest?.systemSections?.some(\n (section) => section.segmentId === segmentId,\n ) ?? false\n );\n}\n"]}
@@ -1,6 +1,21 @@
1
- import { CONTEXT_XRAY_MANIFEST_KEY, type ContextDirective, type ContextManifest, type ContextManifestSource, type ContextSegmentStatus } from "../../shared/context-xray.js";
1
+ import { CONTEXT_XRAY_MANIFEST_KEY, type ContextDirective, type ContextManifest, type ContextManifestSourceRef, type ContextManifestSystemSection, type ContextManifestSource, type ContextSegmentStatus, type ContextGovernanceTier, type ContextSystemProvenance } from "../../shared/context-xray.js";
2
2
  import type { EngineMessage } from "../engine/types.js";
3
3
  export { CONTEXT_XRAY_MANIFEST_KEY };
4
+ export declare const CONTEXT_XRAY_REQUEST_SECTIONS_KEY = "__agentNativeContextXraySystemSections";
5
+ export interface SystemManifestSectionInput {
6
+ label: string;
7
+ provenance: ContextSystemProvenance;
8
+ governance: ContextGovernanceTier;
9
+ content: string;
10
+ group?: string;
11
+ sourceRef?: ContextManifestSourceRef;
12
+ }
13
+ export declare function buildSystemManifestSections(inputs: SystemManifestSectionInput[]): Promise<ContextManifestSystemSection[]>;
14
+ type ContextXRayEvent = {
15
+ context?: Record<string, unknown>;
16
+ };
17
+ export declare function setContextXraySystemSections(event: ContextXRayEvent, sections: ContextManifestSystemSection[]): void;
18
+ export declare function readContextXraySystemSections(event: ContextXRayEvent): ContextManifestSystemSection[];
4
19
  export interface BuildManifestInput {
5
20
  threadId: string;
6
21
  turnId?: string;
@@ -12,7 +27,9 @@ export interface BuildManifestInput {
12
27
  protectedSegmentIds?: Set<string>;
13
28
  source?: ContextManifestSource;
14
29
  enforceable?: boolean;
30
+ systemSections?: ContextManifestSystemSection[];
15
31
  }
32
+ export declare function contextXrayDeepLink(threadId: string): string;
16
33
  export declare function buildManifest(input: BuildManifestInput): Promise<ContextManifest>;
17
34
  export declare function writeContextManifest(threadId: string, manifest: ContextManifest): Promise<void>;
18
35
  export declare function updateManifestSegmentStatus(manifest: ContextManifest, segmentId: string, status: ContextSegmentStatus): ContextManifest;
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/agent/context-xray/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAE1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQxD,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACjD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA0CD,wBAAsB,aAAa,CACjC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,eAAe,CAAC,CAgE1B;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,eAAe,GACxB,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ACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACjD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,4BAA4B,EAAE,CAAC;CACjD;AAgCD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,eAAe,CAAC,CA6E1B;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,GAC3B,eAAe,CAwBjB"}
@@ -1,9 +1,61 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { appStatePut } from "../../application-state/store.js";
2
3
  import { buildDeepLink } from "../../server/deep-link.js";
3
4
  import { CONTEXT_XRAY_MANIFEST_KEY, } from "../../shared/context-xray.js";
4
5
  import { computeSegments } from "./segments.js";
5
6
  import { countMessageTokens, countPartTokens, countTextTokens, } from "./tokenize.js";
6
7
  export { CONTEXT_XRAY_MANIFEST_KEY };
8
+ export const CONTEXT_XRAY_REQUEST_SECTIONS_KEY = "__agentNativeContextXraySystemSections";
9
+ function sha256(value) {
10
+ return createHash("sha256").update(value).digest("hex");
11
+ }
12
+ function previewText(value) {
13
+ const normalized = value.replace(/\s+/g, " ").trim();
14
+ if (normalized.length <= 200)
15
+ return normalized;
16
+ return `${normalized.slice(0, 197)}...`;
17
+ }
18
+ export async function buildSystemManifestSections(inputs) {
19
+ const timestamp = Date.now();
20
+ return await Promise.all(inputs
21
+ .filter((input) => input.content.trim().length > 0)
22
+ .map(async (input, index) => {
23
+ const content = input.content.trim();
24
+ const count = await countTextTokens(content);
25
+ const identity = [
26
+ input.provenance,
27
+ input.label,
28
+ input.sourceRef?.resourceId ?? "",
29
+ input.sourceRef?.path ?? "",
30
+ content,
31
+ index,
32
+ ].join("\u0000");
33
+ return {
34
+ kind: "system",
35
+ segmentId: `system:${sha256(identity).slice(0, 16)}`,
36
+ group: input.group ?? "System",
37
+ label: input.label,
38
+ provenance: input.provenance,
39
+ governance: input.governance,
40
+ tokenCount: count.tokens,
41
+ tokenMethod: count.method,
42
+ ...(input.sourceRef ? { sourceRef: input.sourceRef } : {}),
43
+ contentHash: sha256(content),
44
+ preview: previewText(content),
45
+ timestamp,
46
+ };
47
+ }));
48
+ }
49
+ export function setContextXraySystemSections(event, sections) {
50
+ event.context = event.context ?? {};
51
+ event.context[CONTEXT_XRAY_REQUEST_SECTIONS_KEY] = sections;
52
+ }
53
+ export function readContextXraySystemSections(event) {
54
+ const sections = event.context?.[CONTEXT_XRAY_REQUEST_SECTIONS_KEY];
55
+ return Array.isArray(sections)
56
+ ? sections
57
+ : [];
58
+ }
7
59
  function combineMethods(left, right) {
8
60
  return left === "estimate" || right === "estimate" ? "estimate" : "exact";
9
61
  }
@@ -24,7 +76,7 @@ async function summaryTokenCount(segmentId, status, directives) {
24
76
  return undefined;
25
77
  return (await countTextTokens(text)).tokens;
26
78
  }
27
- function contextXrayUrl(threadId) {
79
+ export function contextXrayDeepLink(threadId) {
28
80
  const to = `/?contextXray=1&threadId=${encodeURIComponent(threadId)}`;
29
81
  return buildDeepLink({
30
82
  app: "agent-native",
@@ -63,8 +115,15 @@ export async function buildManifest(input) {
63
115
  partIndex: segment.partIndex,
64
116
  });
65
117
  }
66
- const totalTokens = sentTokenTotals.tokens;
67
- const rawTokens = rawTokenTotals.tokens;
118
+ const systemSections = input.systemSections ?? [];
119
+ const systemTokenTotals = systemSections.reduce((acc, section) => ({
120
+ tokens: acc.tokens + section.tokenCount,
121
+ method: combineMethods(acc.method, section.tokenMethod),
122
+ }), { tokens: 0, method: "exact" });
123
+ const conversationTokens = sentTokenTotals.tokens;
124
+ const rawConversationTokens = rawTokenTotals.tokens;
125
+ const totalTokens = systemTokenTotals.tokens + conversationTokens;
126
+ const rawTokens = systemTokenTotals.tokens + rawConversationTokens;
68
127
  return {
69
128
  threadId: input.threadId,
70
129
  ...(input.turnId ? { turnId: input.turnId } : {}),
@@ -72,12 +131,15 @@ export async function buildManifest(input) {
72
131
  ...(input.model ? { model: input.model } : {}),
73
132
  totalTokens,
74
133
  rawTokens,
75
- reclaimedTokens: Math.max(0, rawTokens - totalTokens),
76
- tokenCountMethod: combineMethods(rawTokenTotals.method, sentTokenTotals.method),
134
+ reclaimedTokens: Math.max(0, rawConversationTokens - conversationTokens),
135
+ tokenCountMethod: combineMethods(combineMethods(rawTokenTotals.method, sentTokenTotals.method), systemTokenTotals.method),
136
+ conversationTokens,
137
+ systemTokens: systemTokenTotals.tokens,
77
138
  source: input.source ?? "structured",
78
139
  enforceable: input.enforceable ?? true,
79
140
  segments,
80
- url: contextXrayUrl(input.threadId),
141
+ ...(systemSections.length > 0 ? { systemSections } : {}),
142
+ url: contextXrayDeepLink(input.threadId),
81
143
  };
82
144
  }
83
145
  export async function writeContextManifest(threadId, manifest) {