@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.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +21 -0
- package/corpus/core/docs/content/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/agent-surfaces.mdx +43 -0
- package/corpus/core/docs/content/external-agents.mdx +11 -0
- package/corpus/core/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
- package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +9 -0
- package/corpus/core/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
- package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +10 -0
- package/corpus/core/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
- package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +10 -0
- package/corpus/core/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
- package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +11 -0
- package/corpus/core/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
- package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +9 -0
- package/corpus/core/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
- package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +10 -0
- package/corpus/core/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
- package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +9 -0
- package/corpus/core/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
- package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +10 -0
- package/corpus/core/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
- package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
- package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/context-xray/actions/context-evict.ts +11 -0
- package/corpus/core/src/agent/context-xray/actions/context-pin.ts +11 -0
- package/corpus/core/src/agent/context-xray/actions/context-preview-get.ts +134 -0
- package/corpus/core/src/agent/context-xray/actions/context-restore.ts +11 -0
- package/corpus/core/src/agent/context-xray/actions/errors.ts +20 -0
- package/corpus/core/src/agent/context-xray/manifest.ts +106 -7
- package/corpus/core/src/agent/engine/context-directives-transform.ts +5 -1
- package/corpus/core/src/agent/production-agent.ts +100 -38
- package/corpus/core/src/agent/run-loop-with-resume.ts +7 -2
- package/corpus/core/src/client/AgentPanel.tsx +35 -8
- package/corpus/core/src/client/agent-page/AgentContextTab.tsx +501 -0
- package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +370 -0
- package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1084 -0
- package/corpus/core/src/client/agent-page/types.ts +18 -0
- package/corpus/core/src/client/agent-page/use-jobs.ts +150 -0
- package/corpus/core/src/client/context-xray/ContextMeter.tsx +22 -5
- package/corpus/core/src/client/context-xray/ContextTreemap.tsx +16 -1
- package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +168 -3
- package/corpus/core/src/client/context-xray/format.ts +6 -0
- package/corpus/core/src/client/index.ts +6 -0
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +51 -23
- package/corpus/core/src/client/settings/AutomationsSection.tsx +407 -387
- package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +105 -0
- package/corpus/core/src/jobs/actions/manage-recurring-job.ts +85 -0
- package/corpus/core/src/jobs/tools.ts +1 -1
- package/corpus/core/src/localization/default-messages.ts +110 -0
- package/corpus/core/src/mcp/build-server.ts +1 -0
- package/corpus/core/src/mcp/connect-route.ts +62 -65
- package/corpus/core/src/server/action-discovery.ts +23 -0
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +174 -2
- package/corpus/core/src/server/agent-chat-plugin.ts +175 -2
- package/corpus/core/src/server/auth.ts +1 -7
- package/corpus/core/src/server/google-oauth.ts +1 -7
- package/corpus/core/src/server/workspace-oauth.ts +31 -0
- package/corpus/core/src/shared/context-xray.ts +84 -1
- package/corpus/core/src/shared/mcp-connect-content.ts +130 -0
- package/corpus/core/src/templates/default/app/routes/_index.tsx +11 -0
- package/corpus/core/src/templates/default/app/routes/agent.tsx +33 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
- package/corpus/core/src/triggers/actions/list-automations.ts +99 -0
- package/corpus/core/src/triggers/actions/manage-automation.ts +78 -0
- package/corpus/templates/analytics/actions/data-source-status.ts +33 -15
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +1 -1
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +149 -24
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +17 -0
- package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +8 -0
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/analytics/app/i18n-data.ts +1 -0
- package/corpus/templates/analytics/app/routes/agent.tsx +5 -0
- package/corpus/templates/analytics/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-13-analytics-answers-can-use-built-in-first-party-event-data.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-13-chart-legends-can-filter-to-one-series-or-hide-a-series-on-h.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-13-gpt-5-6-luna-answers-now-recover-normally-instead-of-showing.md +6 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -2
- package/corpus/templates/assets/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/assets/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/assets/app/routes/agent.tsx +5 -0
- package/corpus/templates/assets/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +4 -1
- package/corpus/templates/brain/app/lib/brain.ts +11 -0
- package/corpus/templates/brain/app/root.tsx +15 -1
- package/corpus/templates/brain/app/routes/agent.tsx +11 -0
- package/corpus/templates/brain/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +1 -0
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/calendar/app/root.tsx +17 -1
- package/corpus/templates/calendar/app/routes/_app.agent.tsx +25 -0
- package/corpus/templates/calendar/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/chat/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +7 -0
- package/corpus/templates/chat/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/chat/app/root.tsx +24 -2
- package/corpus/templates/chat/app/routes/agent.tsx +15 -0
- package/corpus/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/templates/clips/app/components/library/library-layout.tsx +8 -0
- package/corpus/templates/clips/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/clips/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +2 -0
- package/corpus/templates/clips/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/clips/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/clips/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/clips/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/clips/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/clips/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/clips/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/clips/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/clips/app/root.tsx +7 -1
- package/corpus/templates/clips/app/routes/_app.agent.tsx +15 -0
- package/corpus/templates/clips/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/content/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +36 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/content/app/i18n-data.ts +44 -6
- package/corpus/templates/content/app/root.tsx +8 -0
- package/corpus/templates/content/app/routes/_app.agent.tsx +15 -0
- package/corpus/templates/content/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/design/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/design/app/i18n-data.ts +20 -0
- package/corpus/templates/design/app/root.tsx +7 -1
- package/corpus/templates/design/app/routes/agent.tsx +15 -0
- package/corpus/templates/design/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/dispatch/app/dispatch-extensions.tsx +10 -1
- package/corpus/templates/dispatch/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +20 -0
- package/corpus/templates/dispatch/app/root.tsx +7 -2
- package/corpus/templates/dispatch/app/routes/agent.tsx +18 -0
- package/corpus/templates/dispatch/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/forms/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +35 -0
- package/corpus/templates/forms/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/forms/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/forms/app/i18n/en-US.ts +2 -0
- package/corpus/templates/forms/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/forms/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/forms/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/forms/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/forms/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/forms/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/forms/app/root.tsx +6 -1
- package/corpus/templates/forms/app/routes/_app.agent.tsx +15 -0
- package/corpus/templates/forms/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +14 -2
- package/corpus/templates/macros/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/macros/app/root.tsx +17 -2
- package/corpus/templates/macros/app/routes/agent.tsx +15 -0
- package/corpus/templates/macros/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +42 -0
- package/corpus/templates/mail/app/components/layout/CommandPalette.tsx +6 -0
- package/corpus/templates/mail/app/routes/agent.tsx +15 -0
- package/corpus/templates/mail/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/plan/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/plan/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/plan/app/root.tsx +8 -0
- package/corpus/templates/plan/app/routes/agent.tsx +15 -0
- package/corpus/templates/plan/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/corpus/templates/slides/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/slides/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/slides/app/root.tsx +10 -1
- package/corpus/templates/slides/app/routes/agent.tsx +15 -0
- package/corpus/templates/slides/changelog/2026-07-13-new-agent-page-see-and-manage-your-agent-s-context-files-con.md +6 -0
- package/dist/agent/context-xray/actions/context-evict.js +5 -2
- package/dist/agent/context-xray/actions/context-evict.js.map +1 -1
- package/dist/agent/context-xray/actions/context-pin.js +5 -2
- package/dist/agent/context-xray/actions/context-pin.js.map +1 -1
- package/dist/agent/context-xray/actions/context-preview-get.d.ts +17 -0
- package/dist/agent/context-xray/actions/context-preview-get.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-preview-get.js +94 -0
- package/dist/agent/context-xray/actions/context-preview-get.js.map +1 -0
- package/dist/agent/context-xray/actions/context-restore.js +5 -2
- package/dist/agent/context-xray/actions/context-restore.js.map +1 -1
- package/dist/agent/context-xray/actions/errors.d.ts +3 -0
- package/dist/agent/context-xray/actions/errors.d.ts.map +1 -1
- package/dist/agent/context-xray/actions/errors.js +6 -0
- package/dist/agent/context-xray/actions/errors.js.map +1 -1
- package/dist/agent/context-xray/manifest.d.ts +18 -1
- package/dist/agent/context-xray/manifest.d.ts.map +1 -1
- package/dist/agent/context-xray/manifest.js +68 -6
- package/dist/agent/context-xray/manifest.js.map +1 -1
- package/dist/agent/engine/context-directives-transform.d.ts +2 -0
- package/dist/agent/engine/context-directives-transform.d.ts.map +1 -1
- package/dist/agent/engine/context-directives-transform.js +2 -1
- package/dist/agent/engine/context-directives-transform.js.map +1 -1
- package/dist/agent/production-agent.d.ts +15 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +74 -36
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +6 -3
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +9 -11
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/agent-page/AgentContextTab.d.ts +5 -0
- package/dist/client/agent-page/AgentContextTab.d.ts.map +1 -0
- package/dist/client/agent-page/AgentContextTab.js +202 -0
- package/dist/client/agent-page/AgentContextTab.js.map +1 -0
- package/dist/client/agent-page/AgentJobsTab.d.ts +3 -0
- package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -0
- package/dist/client/agent-page/AgentJobsTab.js +98 -0
- package/dist/client/agent-page/AgentJobsTab.js.map +1 -0
- package/dist/client/agent-page/AgentTabsPage.d.ts +20 -0
- package/dist/client/agent-page/AgentTabsPage.d.ts.map +1 -0
- package/dist/client/agent-page/AgentTabsPage.js +420 -0
- package/dist/client/agent-page/AgentTabsPage.js.map +1 -0
- package/dist/client/agent-page/types.d.ts +17 -0
- package/dist/client/agent-page/types.d.ts.map +1 -0
- package/dist/client/agent-page/types.js +9 -0
- package/dist/client/agent-page/types.js.map +1 -0
- package/dist/client/agent-page/use-jobs.d.ts +61 -0
- package/dist/client/agent-page/use-jobs.d.ts.map +1 -0
- package/dist/client/agent-page/use-jobs.js +71 -0
- package/dist/client/agent-page/use-jobs.js.map +1 -0
- package/dist/client/context-xray/ContextMeter.d.ts +3 -1
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
- package/dist/client/context-xray/ContextMeter.js +14 -5
- package/dist/client/context-xray/ContextMeter.js.map +1 -1
- package/dist/client/context-xray/ContextTreemap.d.ts +3 -2
- package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
- package/dist/client/context-xray/ContextTreemap.js +9 -1
- package/dist/client/context-xray/ContextTreemap.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +95 -20
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/context-xray/format.d.ts.map +1 -1
- package/dist/client/context-xray/format.js +12 -0
- package/dist/client/context-xray/format.js.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts +9 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +26 -10
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/AutomationsSection.d.ts +9 -0
- package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
- package/dist/client/settings/AutomationsSection.js +128 -147
- package/dist/client/settings/AutomationsSection.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/jobs/actions/list-recurring-jobs.d.ts +21 -0
- package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -0
- package/dist/jobs/actions/list-recurring-jobs.js +74 -0
- package/dist/jobs/actions/list-recurring-jobs.js.map +1 -0
- package/dist/jobs/actions/manage-recurring-job.d.ts +18 -0
- package/dist/jobs/actions/manage-recurring-job.d.ts.map +1 -0
- package/dist/jobs/actions/manage-recurring-job.js +68 -0
- package/dist/jobs/actions/manage-recurring-job.js.map +1 -0
- package/dist/jobs/tools.d.ts +13 -0
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +1 -1
- package/dist/jobs/tools.js.map +1 -1
- package/dist/localization/default-messages.d.ts +96 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +96 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +1 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/connect-route.d.ts.map +1 -1
- package/dist/mcp/connect-route.js +44 -59
- package/dist/mcp/connect-route.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +23 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat/prompt-resources.d.ts +14 -0
- package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -1
- package/dist/server/agent-chat/prompt-resources.js +139 -2
- package/dist/server/agent-chat/prompt-resources.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +1 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +136 -3
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +1 -4
- package/dist/server/auth.js.map +1 -1
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +1 -4
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/server/workspace-oauth.d.ts +11 -0
- package/dist/server/workspace-oauth.d.ts.map +1 -0
- package/dist/server/workspace-oauth.js +25 -0
- package/dist/server/workspace-oauth.js.map +1 -0
- package/dist/shared/context-xray.d.ts +45 -1
- package/dist/shared/context-xray.d.ts.map +1 -1
- package/dist/shared/context-xray.js +12 -0
- package/dist/shared/context-xray.js.map +1 -1
- package/dist/shared/mcp-connect-content.d.ts +37 -0
- package/dist/shared/mcp-connect-content.d.ts.map +1 -0
- package/dist/shared/mcp-connect-content.js +92 -0
- package/dist/shared/mcp-connect-content.js.map +1 -0
- package/dist/templates/default/app/routes/_index.tsx +11 -0
- package/dist/templates/default/app/routes/agent.tsx +33 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
- package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
- package/dist/triggers/actions/list-automations.d.ts +24 -0
- package/dist/triggers/actions/list-automations.d.ts.map +1 -0
- package/dist/triggers/actions/list-automations.js +72 -0
- package/dist/triggers/actions/list-automations.js.map +1 -0
- package/dist/triggers/actions/manage-automation.d.ts +18 -0
- package/dist/triggers/actions/manage-automation.d.ts.map +1 -0
- package/dist/triggers/actions/manage-automation.js +60 -0
- package/dist/triggers/actions/manage-automation.js.map +1 -0
- package/docs/content/a2a-protocol.mdx +42 -0
- package/docs/content/agent-surfaces.mdx +43 -0
- package/docs/content/external-agents.mdx +11 -0
- package/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
- package/docs/content/locales/ar-SA/agent-surfaces.mdx +30 -0
- package/docs/content/locales/ar-SA/external-agents.mdx +9 -0
- package/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
- package/docs/content/locales/de-DE/agent-surfaces.mdx +34 -0
- package/docs/content/locales/de-DE/external-agents.mdx +10 -0
- package/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
- package/docs/content/locales/es-ES/agent-surfaces.mdx +34 -0
- package/docs/content/locales/es-ES/external-agents.mdx +10 -0
- package/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
- package/docs/content/locales/fr-FR/agent-surfaces.mdx +34 -0
- package/docs/content/locales/fr-FR/external-agents.mdx +11 -0
- package/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
- package/docs/content/locales/hi-IN/agent-surfaces.mdx +31 -0
- package/docs/content/locales/hi-IN/external-agents.mdx +9 -0
- package/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
- package/docs/content/locales/ja-JP/agent-surfaces.mdx +32 -0
- package/docs/content/locales/ja-JP/external-agents.mdx +10 -0
- package/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
- package/docs/content/locales/ko-KR/agent-surfaces.mdx +32 -0
- package/docs/content/locales/ko-KR/external-agents.mdx +9 -0
- package/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
- package/docs/content/locales/pt-BR/agent-surfaces.mdx +33 -0
- package/docs/content/locales/pt-BR/external-agents.mdx +10 -0
- package/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
- package/docs/content/locales/zh-CN/agent-surfaces.mdx +29 -0
- package/docs/content/locales/zh-CN/external-agents.mdx +8 -0
- package/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
- package/docs/content/locales/zh-TW/agent-surfaces.mdx +29 -0
- package/docs/content/locales/zh-TW/external-agents.mdx +8 -0
- package/package.json +1 -1
- package/src/templates/default/app/routes/_index.tsx +11 -0
- package/src/templates/default/app/routes/agent.tsx +33 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +59 -0
- package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +25 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +7 -0
- package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +9 -0
|
@@ -117,6 +117,14 @@ https://<your-app>.agent-native.com/mcp
|
|
|
117
117
|
`https://<app>/mcp/connect` 與可複製的 URL 和
|
|
118
118
|
Claude、ChatGPT、游標、Claude 程式碼、Codex 和其他的主機特定分頁。
|
|
119
119
|
|
|
120
|
+
### 應用程式內的 Access 分頁 {#access-tab}
|
|
121
|
+
|
|
122
|
+
掛載 `AgentTabsPage` 的應用程式也會在 **Access** 分頁提供相同的連線流程。
|
|
123
|
+
它會顯示 MCP URL、可用時的 A2A 代理卡片,以及 Claude、ChatGPT、Cursor、Claude
|
|
124
|
+
Code、Codex 和其他用戶端的共用設定指南。可將它作為應用程式內的起點,並開啟
|
|
125
|
+
`/mcp/connect` 查看完整流程和權杖備援。這是連線設定介面,不是通用存取控制台;
|
|
126
|
+
此分頁目前還不管理 grants、範圍編輯或撤銷。
|
|
127
|
+
|
|
120
128
|
### Claude 和 ChatGPT OAuth {#oauth}
|
|
121
129
|
|
|
122
130
|
Claude / Claude 桌面:新增自訂連線器,貼上 MCP URL,點選
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.0",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
} from "../../../server/request-context.js";
|
|
8
8
|
import { callerOwnsThread } from "../../run-ownership.js";
|
|
9
9
|
import {
|
|
10
|
+
readContextManifest,
|
|
10
11
|
upsertContextDirective,
|
|
11
12
|
writeContextManifestStatus,
|
|
12
13
|
} from "../directives-store.js";
|
|
13
14
|
import {
|
|
14
15
|
contextXrayAuthError,
|
|
16
|
+
contextXraySystemSegmentError,
|
|
15
17
|
contextXrayThreadNotFoundError,
|
|
18
|
+
isContextXraySystemSegment,
|
|
16
19
|
} from "./errors.js";
|
|
17
20
|
|
|
18
21
|
export default defineAction({
|
|
@@ -28,6 +31,14 @@ export default defineAction({
|
|
|
28
31
|
if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
|
|
29
32
|
throw contextXrayThreadNotFoundError();
|
|
30
33
|
}
|
|
34
|
+
if (
|
|
35
|
+
isContextXraySystemSegment(
|
|
36
|
+
await readContextManifest(args.threadId),
|
|
37
|
+
args.segmentId,
|
|
38
|
+
)
|
|
39
|
+
) {
|
|
40
|
+
throw contextXraySystemSegmentError();
|
|
41
|
+
}
|
|
31
42
|
const directive = await upsertContextDirective({
|
|
32
43
|
threadId: args.threadId,
|
|
33
44
|
segmentId: args.segmentId,
|
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
} from "../../../server/request-context.js";
|
|
8
8
|
import { callerOwnsThread } from "../../run-ownership.js";
|
|
9
9
|
import {
|
|
10
|
+
readContextManifest,
|
|
10
11
|
upsertContextDirective,
|
|
11
12
|
writeContextManifestStatus,
|
|
12
13
|
} from "../directives-store.js";
|
|
13
14
|
import {
|
|
14
15
|
contextXrayAuthError,
|
|
16
|
+
contextXraySystemSegmentError,
|
|
15
17
|
contextXrayThreadNotFoundError,
|
|
18
|
+
isContextXraySystemSegment,
|
|
16
19
|
} from "./errors.js";
|
|
17
20
|
|
|
18
21
|
export default defineAction({
|
|
@@ -28,6 +31,14 @@ export default defineAction({
|
|
|
28
31
|
if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
|
|
29
32
|
throw contextXrayThreadNotFoundError();
|
|
30
33
|
}
|
|
34
|
+
if (
|
|
35
|
+
isContextXraySystemSegment(
|
|
36
|
+
await readContextManifest(args.threadId),
|
|
37
|
+
args.segmentId,
|
|
38
|
+
)
|
|
39
|
+
) {
|
|
40
|
+
throw contextXraySystemSegmentError();
|
|
41
|
+
}
|
|
31
42
|
const directive = await upsertContextDirective({
|
|
32
43
|
threadId: args.threadId,
|
|
33
44
|
segmentId: args.segmentId,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { defineAction } from "../../../action.js";
|
|
4
|
+
import { embedApp } from "../../../mcp/embed-app.js";
|
|
5
|
+
import { SHARED_OWNER } from "../../../resources/store.js";
|
|
6
|
+
import {
|
|
7
|
+
buildFrameworkPrompts,
|
|
8
|
+
buildSchemaBlock,
|
|
9
|
+
} from "../../../server/agent-chat/framework-prompts.js";
|
|
10
|
+
import {
|
|
11
|
+
loadResourcesForPrompt,
|
|
12
|
+
promptResourceManifestSections,
|
|
13
|
+
} from "../../../server/agent-chat/prompt-resources.js";
|
|
14
|
+
import {
|
|
15
|
+
getRequestOrgId,
|
|
16
|
+
getRequestUserEmail,
|
|
17
|
+
} from "../../../server/request-context.js";
|
|
18
|
+
import {
|
|
19
|
+
type ContextPreview,
|
|
20
|
+
type ContextTokenCountMethod,
|
|
21
|
+
} from "../../../shared/context-xray.js";
|
|
22
|
+
import { buildSystemManifestSections } from "../manifest.js";
|
|
23
|
+
import { contextXrayAuthError } from "./errors.js";
|
|
24
|
+
|
|
25
|
+
function combineMethods(
|
|
26
|
+
left: ContextTokenCountMethod,
|
|
27
|
+
right: ContextTokenCountMethod,
|
|
28
|
+
): ContextTokenCountMethod {
|
|
29
|
+
return left === "estimate" || right === "estimate" ? "estimate" : "exact";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function buildContextPreview(input: {
|
|
33
|
+
ownerEmail: string;
|
|
34
|
+
orgId?: string | null;
|
|
35
|
+
scope: "user" | "org";
|
|
36
|
+
appId?: string;
|
|
37
|
+
compact?: boolean;
|
|
38
|
+
model?: string;
|
|
39
|
+
}): Promise<ContextPreview> {
|
|
40
|
+
const compact = input.compact ?? false;
|
|
41
|
+
const prompts = buildFrameworkPrompts();
|
|
42
|
+
const resources = await loadResourcesForPrompt(
|
|
43
|
+
input.scope === "org" ? SHARED_OWNER : input.ownerEmail,
|
|
44
|
+
compact,
|
|
45
|
+
input.appId,
|
|
46
|
+
input.orgId ?? null,
|
|
47
|
+
);
|
|
48
|
+
const schemaBlock = compact
|
|
49
|
+
? ""
|
|
50
|
+
: await buildSchemaBlock(input.ownerEmail, "read");
|
|
51
|
+
const sections = await buildSystemManifestSections([
|
|
52
|
+
{
|
|
53
|
+
label: "Framework core",
|
|
54
|
+
provenance: "framework-core",
|
|
55
|
+
governance: "required",
|
|
56
|
+
content: compact
|
|
57
|
+
? prompts.PROD_FRAMEWORK_PROMPT_COMPACT
|
|
58
|
+
: prompts.PROD_FRAMEWORK_PROMPT,
|
|
59
|
+
sourceRef: { scope: "framework" },
|
|
60
|
+
},
|
|
61
|
+
...promptResourceManifestSections(resources),
|
|
62
|
+
...(schemaBlock
|
|
63
|
+
? [
|
|
64
|
+
{
|
|
65
|
+
label: "SQL schema",
|
|
66
|
+
provenance: "db-schema" as const,
|
|
67
|
+
governance: "required" as const,
|
|
68
|
+
content: schemaBlock,
|
|
69
|
+
sourceRef: { scope: "sql" },
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
: []),
|
|
73
|
+
]);
|
|
74
|
+
const systemTokens = sections.reduce(
|
|
75
|
+
(total, section) => total + section.tokenCount,
|
|
76
|
+
0,
|
|
77
|
+
);
|
|
78
|
+
const tokenCountMethod = sections.reduce(
|
|
79
|
+
(method, section) => combineMethods(method, section.tokenMethod),
|
|
80
|
+
"exact" as ContextTokenCountMethod,
|
|
81
|
+
);
|
|
82
|
+
return {
|
|
83
|
+
computedAt: Date.now(),
|
|
84
|
+
...(input.model ? { model: input.model } : {}),
|
|
85
|
+
scope: input.scope,
|
|
86
|
+
totalTokens: systemTokens,
|
|
87
|
+
systemTokens,
|
|
88
|
+
tokenCountMethod,
|
|
89
|
+
sections,
|
|
90
|
+
source: "preview",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default defineAction({
|
|
95
|
+
description:
|
|
96
|
+
"Preview the system-prompt context that would be composed for the current user, organization, and app without a live chat thread.",
|
|
97
|
+
schema: z.object({
|
|
98
|
+
scope: z
|
|
99
|
+
.enum(["user", "org"])
|
|
100
|
+
.default("user")
|
|
101
|
+
.describe(
|
|
102
|
+
"Configuration scope to preview: user includes personal context; org includes inherited organization context.",
|
|
103
|
+
),
|
|
104
|
+
appId: z.string().optional().describe("Current app id, when available."),
|
|
105
|
+
compact: z.boolean().optional().describe("Use the compact startup prompt."),
|
|
106
|
+
model: z.string().optional().describe("Model id for display metadata."),
|
|
107
|
+
}),
|
|
108
|
+
http: { method: "GET" },
|
|
109
|
+
readOnly: true,
|
|
110
|
+
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
111
|
+
mcpApp: {
|
|
112
|
+
compactCatalog: true,
|
|
113
|
+
resource: embedApp({
|
|
114
|
+
title: "Context preview",
|
|
115
|
+
description:
|
|
116
|
+
"Preview the system-prompt context before starting a thread.",
|
|
117
|
+
iframeTitle: "Context preview",
|
|
118
|
+
openLabel: "Open context preview",
|
|
119
|
+
height: 720,
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
run: async (args): Promise<ContextPreview> => {
|
|
123
|
+
const ownerEmail = getRequestUserEmail();
|
|
124
|
+
if (!ownerEmail) throw contextXrayAuthError();
|
|
125
|
+
return await buildContextPreview({
|
|
126
|
+
ownerEmail,
|
|
127
|
+
orgId: getRequestOrgId() ?? null,
|
|
128
|
+
scope: args.scope,
|
|
129
|
+
...(args.appId ? { appId: args.appId } : {}),
|
|
130
|
+
...(args.compact !== undefined ? { compact: args.compact } : {}),
|
|
131
|
+
...(args.model ? { model: args.model } : {}),
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -5,11 +5,14 @@ import { getRequestUserEmail } from "../../../server/request-context.js";
|
|
|
5
5
|
import { callerOwnsThread } from "../../run-ownership.js";
|
|
6
6
|
import {
|
|
7
7
|
deactivateContextDirective,
|
|
8
|
+
readContextManifest,
|
|
8
9
|
writeContextManifestStatus,
|
|
9
10
|
} from "../directives-store.js";
|
|
10
11
|
import {
|
|
11
12
|
contextXrayAuthError,
|
|
13
|
+
contextXraySystemSegmentError,
|
|
12
14
|
contextXrayThreadNotFoundError,
|
|
15
|
+
isContextXraySystemSegment,
|
|
13
16
|
} from "./errors.js";
|
|
14
17
|
|
|
15
18
|
export default defineAction({
|
|
@@ -25,6 +28,14 @@ export default defineAction({
|
|
|
25
28
|
if (!(await callerOwnsThread(ownerEmail, args.threadId))) {
|
|
26
29
|
throw contextXrayThreadNotFoundError();
|
|
27
30
|
}
|
|
31
|
+
if (
|
|
32
|
+
isContextXraySystemSegment(
|
|
33
|
+
await readContextManifest(args.threadId),
|
|
34
|
+
args.segmentId,
|
|
35
|
+
)
|
|
36
|
+
) {
|
|
37
|
+
throw contextXraySystemSegmentError();
|
|
38
|
+
}
|
|
28
39
|
const restored = await deactivateContextDirective({
|
|
29
40
|
threadId: args.threadId,
|
|
30
41
|
segmentId: args.segmentId,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ContextManifest } from "../../../shared/context-xray.js";
|
|
2
|
+
|
|
1
3
|
export class ContextXrayActionError extends Error {
|
|
2
4
|
constructor(
|
|
3
5
|
message: string,
|
|
@@ -18,3 +20,21 @@ export function contextXrayAuthError(): ContextXrayActionError {
|
|
|
18
20
|
export function contextXrayThreadNotFoundError(): ContextXrayActionError {
|
|
19
21
|
return new ContextXrayActionError("Thread not found.", 404);
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
export function contextXraySystemSegmentError(): ContextXrayActionError {
|
|
25
|
+
return new ContextXrayActionError(
|
|
26
|
+
"System Context X-Ray sections are required and cannot be pinned, evicted, or restored.",
|
|
27
|
+
400,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isContextXraySystemSegment(
|
|
32
|
+
manifest: ContextManifest | null,
|
|
33
|
+
segmentId: string,
|
|
34
|
+
): boolean {
|
|
35
|
+
return (
|
|
36
|
+
manifest?.systemSections?.some(
|
|
37
|
+
(section) => section.segmentId === segmentId,
|
|
38
|
+
) ?? false
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
1
3
|
import { appStatePut } from "../../application-state/store.js";
|
|
2
4
|
import { buildDeepLink } from "../../server/deep-link.js";
|
|
3
5
|
import {
|
|
@@ -5,9 +7,13 @@ import {
|
|
|
5
7
|
type ContextDirective,
|
|
6
8
|
type ContextManifest,
|
|
7
9
|
type ContextManifestSegment,
|
|
10
|
+
type ContextManifestSourceRef,
|
|
11
|
+
type ContextManifestSystemSection,
|
|
8
12
|
type ContextManifestSource,
|
|
9
13
|
type ContextSegmentStatus,
|
|
10
14
|
type ContextTokenCountMethod,
|
|
15
|
+
type ContextGovernanceTier,
|
|
16
|
+
type ContextSystemProvenance,
|
|
11
17
|
} from "../../shared/context-xray.js";
|
|
12
18
|
import type { EngineMessage } from "../engine/types.js";
|
|
13
19
|
import { computeSegments } from "./segments.js";
|
|
@@ -19,6 +25,85 @@ import {
|
|
|
19
25
|
|
|
20
26
|
export { CONTEXT_XRAY_MANIFEST_KEY };
|
|
21
27
|
|
|
28
|
+
export const CONTEXT_XRAY_REQUEST_SECTIONS_KEY =
|
|
29
|
+
"__agentNativeContextXraySystemSections";
|
|
30
|
+
|
|
31
|
+
export interface SystemManifestSectionInput {
|
|
32
|
+
label: string;
|
|
33
|
+
provenance: ContextSystemProvenance;
|
|
34
|
+
governance: ContextGovernanceTier;
|
|
35
|
+
content: string;
|
|
36
|
+
group?: string;
|
|
37
|
+
sourceRef?: ContextManifestSourceRef;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function sha256(value: string): string {
|
|
41
|
+
return createHash("sha256").update(value).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function previewText(value: string): string {
|
|
45
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
46
|
+
if (normalized.length <= 200) return normalized;
|
|
47
|
+
return `${normalized.slice(0, 197)}...`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function buildSystemManifestSections(
|
|
51
|
+
inputs: SystemManifestSectionInput[],
|
|
52
|
+
): Promise<ContextManifestSystemSection[]> {
|
|
53
|
+
const timestamp = Date.now();
|
|
54
|
+
return await Promise.all(
|
|
55
|
+
inputs
|
|
56
|
+
.filter((input) => input.content.trim().length > 0)
|
|
57
|
+
.map(async (input, index) => {
|
|
58
|
+
const content = input.content.trim();
|
|
59
|
+
const count = await countTextTokens(content);
|
|
60
|
+
const identity = [
|
|
61
|
+
input.provenance,
|
|
62
|
+
input.label,
|
|
63
|
+
input.sourceRef?.resourceId ?? "",
|
|
64
|
+
input.sourceRef?.path ?? "",
|
|
65
|
+
content,
|
|
66
|
+
index,
|
|
67
|
+
].join("\u0000");
|
|
68
|
+
return {
|
|
69
|
+
kind: "system" as const,
|
|
70
|
+
segmentId: `system:${sha256(identity).slice(0, 16)}`,
|
|
71
|
+
group: input.group ?? "System",
|
|
72
|
+
label: input.label,
|
|
73
|
+
provenance: input.provenance,
|
|
74
|
+
governance: input.governance,
|
|
75
|
+
tokenCount: count.tokens,
|
|
76
|
+
tokenMethod: count.method,
|
|
77
|
+
...(input.sourceRef ? { sourceRef: input.sourceRef } : {}),
|
|
78
|
+
contentHash: sha256(content),
|
|
79
|
+
preview: previewText(content),
|
|
80
|
+
timestamp,
|
|
81
|
+
} satisfies ContextManifestSystemSection;
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type ContextXRayEvent = {
|
|
87
|
+
context?: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export function setContextXraySystemSections(
|
|
91
|
+
event: ContextXRayEvent,
|
|
92
|
+
sections: ContextManifestSystemSection[],
|
|
93
|
+
): void {
|
|
94
|
+
event.context = event.context ?? {};
|
|
95
|
+
event.context[CONTEXT_XRAY_REQUEST_SECTIONS_KEY] = sections;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function readContextXraySystemSections(
|
|
99
|
+
event: ContextXRayEvent,
|
|
100
|
+
): ContextManifestSystemSection[] {
|
|
101
|
+
const sections = event.context?.[CONTEXT_XRAY_REQUEST_SECTIONS_KEY];
|
|
102
|
+
return Array.isArray(sections)
|
|
103
|
+
? (sections as ContextManifestSystemSection[])
|
|
104
|
+
: [];
|
|
105
|
+
}
|
|
106
|
+
|
|
22
107
|
export interface BuildManifestInput {
|
|
23
108
|
threadId: string;
|
|
24
109
|
turnId?: string;
|
|
@@ -30,6 +115,7 @@ export interface BuildManifestInput {
|
|
|
30
115
|
protectedSegmentIds?: Set<string>;
|
|
31
116
|
source?: ContextManifestSource;
|
|
32
117
|
enforceable?: boolean;
|
|
118
|
+
systemSections?: ContextManifestSystemSection[];
|
|
33
119
|
}
|
|
34
120
|
|
|
35
121
|
function combineMethods(
|
|
@@ -62,7 +148,7 @@ async function summaryTokenCount(
|
|
|
62
148
|
return (await countTextTokens(text)).tokens;
|
|
63
149
|
}
|
|
64
150
|
|
|
65
|
-
function
|
|
151
|
+
export function contextXrayDeepLink(threadId: string): string {
|
|
66
152
|
const to = `/?contextXray=1&threadId=${encodeURIComponent(threadId)}`;
|
|
67
153
|
return buildDeepLink({
|
|
68
154
|
app: "agent-native",
|
|
@@ -119,8 +205,18 @@ export async function buildManifest(
|
|
|
119
205
|
});
|
|
120
206
|
}
|
|
121
207
|
|
|
122
|
-
const
|
|
123
|
-
const
|
|
208
|
+
const systemSections = input.systemSections ?? [];
|
|
209
|
+
const systemTokenTotals = systemSections.reduce(
|
|
210
|
+
(acc, section) => ({
|
|
211
|
+
tokens: acc.tokens + section.tokenCount,
|
|
212
|
+
method: combineMethods(acc.method, section.tokenMethod),
|
|
213
|
+
}),
|
|
214
|
+
{ tokens: 0, method: "exact" as ContextTokenCountMethod },
|
|
215
|
+
);
|
|
216
|
+
const conversationTokens = sentTokenTotals.tokens;
|
|
217
|
+
const rawConversationTokens = rawTokenTotals.tokens;
|
|
218
|
+
const totalTokens = systemTokenTotals.tokens + conversationTokens;
|
|
219
|
+
const rawTokens = systemTokenTotals.tokens + rawConversationTokens;
|
|
124
220
|
return {
|
|
125
221
|
threadId: input.threadId,
|
|
126
222
|
...(input.turnId ? { turnId: input.turnId } : {}),
|
|
@@ -128,15 +224,18 @@ export async function buildManifest(
|
|
|
128
224
|
...(input.model ? { model: input.model } : {}),
|
|
129
225
|
totalTokens,
|
|
130
226
|
rawTokens,
|
|
131
|
-
reclaimedTokens: Math.max(0,
|
|
227
|
+
reclaimedTokens: Math.max(0, rawConversationTokens - conversationTokens),
|
|
132
228
|
tokenCountMethod: combineMethods(
|
|
133
|
-
rawTokenTotals.method,
|
|
134
|
-
|
|
229
|
+
combineMethods(rawTokenTotals.method, sentTokenTotals.method),
|
|
230
|
+
systemTokenTotals.method,
|
|
135
231
|
),
|
|
232
|
+
conversationTokens,
|
|
233
|
+
systemTokens: systemTokenTotals.tokens,
|
|
136
234
|
source: input.source ?? "structured",
|
|
137
235
|
enforceable: input.enforceable ?? true,
|
|
138
236
|
segments,
|
|
139
|
-
|
|
237
|
+
...(systemSections.length > 0 ? { systemSections } : {}),
|
|
238
|
+
url: contextXrayDeepLink(input.threadId),
|
|
140
239
|
};
|
|
141
240
|
}
|
|
142
241
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContextManifestSystemSection } from "../../shared/context-xray.js";
|
|
1
2
|
import { applyContextDirectives } from "../context-xray/apply-directives.js";
|
|
2
3
|
import { loadContextDirectives } from "../context-xray/directives-store.js";
|
|
3
4
|
import {
|
|
@@ -29,8 +30,10 @@ export async function applyContextXrayTransformForIteration(opts: {
|
|
|
29
30
|
turnId?: string;
|
|
30
31
|
model: string;
|
|
31
32
|
messages: EngineMessage[];
|
|
33
|
+
systemSections?: ContextManifestSystemSection[];
|
|
32
34
|
}): Promise<EngineMessage[]> {
|
|
33
|
-
const { threadId, ownerEmail, turnId, model, messages } =
|
|
35
|
+
const { threadId, ownerEmail, turnId, model, messages, systemSections } =
|
|
36
|
+
opts;
|
|
34
37
|
try {
|
|
35
38
|
const directives = await loadContextDirectives(threadId, {
|
|
36
39
|
ownerEmail: ownerEmail ?? null,
|
|
@@ -49,6 +52,7 @@ export async function applyContextXrayTransformForIteration(opts: {
|
|
|
49
52
|
appliedStatus,
|
|
50
53
|
directives,
|
|
51
54
|
protectedSegmentIds,
|
|
55
|
+
...(systemSections ? { systemSections } : {}),
|
|
52
56
|
source: "structured",
|
|
53
57
|
enforceable: true,
|
|
54
58
|
});
|