@agent-native/core 0.115.4 → 0.116.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/agent-native.eject.json +1 -0
- package/corpus/README.md +3 -3
- package/corpus/core/CHANGELOG.md +28 -0
- package/corpus/core/agent-native.eject.json +1 -0
- package/corpus/core/docs/AGENTS.md +1 -1
- package/corpus/core/docs/content/agent-mentions.mdx +2 -2
- package/corpus/core/docs/content/{workspace.mdx → agent-resources.mdx} +1 -7
- package/corpus/core/docs/content/agent-teams.mdx +4 -4
- package/corpus/core/docs/content/dispatch.mdx +10 -10
- package/corpus/core/docs/content/drop-in-agent.mdx +4 -4
- package/corpus/core/docs/content/external-agents.mdx +1 -1
- package/corpus/core/docs/content/frames.mdx +1 -1
- package/corpus/core/docs/content/integrations.mdx +13 -2
- package/corpus/core/docs/content/key-concepts.mdx +2 -2
- package/corpus/core/docs/content/mcp-clients.mdx +7 -1
- package/corpus/core/docs/content/multi-app-workspace.mdx +3 -3
- package/corpus/core/docs/content/real-time-collaboration.mdx +33 -15
- package/corpus/core/docs/content/recurring-jobs.mdx +7 -7
- package/corpus/core/docs/content/skills-guide.mdx +4 -4
- package/corpus/core/docs/content/template-brain.mdx +1 -1
- package/corpus/core/docs/content/toolkit-collaboration.mdx +1 -1
- package/corpus/core/docs/content/using-your-agent.mdx +1 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +4 -4
- package/corpus/core/docs/content/workspace-management.mdx +4 -4
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/production-agent.ts +13 -3
- package/corpus/core/src/cli/doctor.ts +6 -1
- package/corpus/core/src/client/AgentPanel.tsx +79 -41
- package/corpus/core/src/client/AssistantChat.tsx +71 -25
- package/corpus/core/src/client/FeedbackButton.tsx +33 -7
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +6 -8
- package/corpus/core/src/client/agent-chat-adapter.ts +11 -2
- package/corpus/core/src/client/agent-page/AgentTabFrame.tsx +22 -3
- package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +34 -19
- package/corpus/core/src/client/chat/message-components.tsx +43 -16
- package/corpus/core/src/client/chat/tool-call-display.tsx +30 -18
- package/corpus/core/src/client/chat/tool-render-registry.tsx +2 -0
- package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +19 -2
- package/corpus/core/src/client/resources/ResourceTree.tsx +7 -10
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +33 -70
- package/corpus/core/src/client/resources/mcp-connection-resume.ts +107 -0
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +65 -12
- package/corpus/core/src/client/resources/mcp-integration-logos.ts +4 -0
- package/corpus/core/src/client/sse-event-processor.ts +50 -14
- package/corpus/core/src/client/use-db-sync.ts +16 -6
- package/corpus/core/src/connections/catalog.ts +7 -1
- package/corpus/core/src/eject/remote-mcp-presets.ts +37 -5
- package/corpus/core/src/guards/explicit-collab-access.ts +229 -0
- package/corpus/core/src/guards/index.ts +1 -0
- package/corpus/core/src/localization/default-messages.ts +54 -5
- package/corpus/core/src/mcp/connect-route.ts +34 -51
- package/corpus/core/src/provider-api/index.ts +1 -1
- package/corpus/core/src/server/collab-plugin.ts +137 -18
- package/corpus/core/src/server/index.ts +2 -0
- package/corpus/core/src/styles/agent-native.css +40 -0
- package/corpus/core/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/core/src/templates/default/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/corpus/core/src/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/corpus/core/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +12 -8
- package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/analytics/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/analytics/AGENTS.md +7 -2
- package/corpus/templates/analytics/actions/export-dashboard-panel-to-google-sheet.ts +144 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +7 -88
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +34 -37
- package/corpus/templates/analytics/app/global.css +0 -4
- package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +2 -7
- package/corpus/templates/analytics/app/i18n-data.ts +107 -0
- package/corpus/templates/analytics/app/lib/data-source-status.ts +9 -0
- package/corpus/templates/analytics/app/lib/sql-query.ts +1 -2
- package/corpus/templates/analytics/app/pages/Ask.tsx +2 -7
- package/corpus/templates/analytics/app/pages/DataSources.tsx +48 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +59 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +2 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/report-panel-window.ts +3 -1
- package/corpus/templates/analytics/changelog/2026-07-22-clear-background-chat-progress.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-22-daily-dashboard-email-query-batches.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-22-export-table-panels-directly-to-google-sheets.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-22-recent-chats-can-expand-in-the-sidebar.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +8 -8
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +31 -0
- package/corpus/templates/analytics/server/lib/dashboard-report-subscriptions.ts +3 -5
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +12 -0
- package/corpus/templates/analytics/server/lib/first-party-dashboard-repair.ts +3 -5
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +150 -21
- package/corpus/templates/analytics/server/lib/google-sheets-export.ts +188 -0
- package/corpus/templates/analytics/server/lib/provider-api.ts +7 -2
- package/corpus/templates/analytics/server/plugins/collab.ts +6 -3
- package/corpus/templates/analytics/shared/sql-query-limits.ts +1 -0
- package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/assets/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/corpus/templates/assets/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/assets/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +54 -62
- package/corpus/templates/assets/app/hooks/use-navigation-state.ts +2 -6
- package/corpus/templates/assets/app/routes/_index.tsx +8 -5
- package/corpus/templates/assets/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-22-recent-chats-expand-from-a-compact-list.md +6 -0
- package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/brain/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/brain/actions/rotate-source-ingest-token.ts +77 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +5 -1
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +38 -51
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +2 -9
- package/corpus/templates/brain/app/i18n-data.ts +120 -0
- package/corpus/templates/brain/app/routes/sources.tsx +156 -5
- package/corpus/templates/brain/changelog/2026-07-22-chat-runs-always-end-with-an-answer.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-22-clear-background-chat-progress.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-22-long-chat-titles-stay-inside-the-sidebar.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-22-new-clips-and-webhook-sources-now-show-their-secure-connecti.md +6 -0
- package/corpus/templates/brain/jobs/emit-netlify-brain-queue-cron.ts +125 -0
- package/corpus/templates/brain/netlify.toml +5 -1
- package/corpus/templates/brain/scripts/configure-prod-clips-source.ts +50 -0
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +64 -6
- package/corpus/templates/brain/server/plugins/agent-chat.ts +4 -0
- package/corpus/templates/brain/server/plugins/brain-jobs.ts +1 -0
- package/corpus/templates/brain/server/routes/api/brain/queue/run.post.ts +55 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/calendar/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/chat/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +43 -67
- package/corpus/templates/chat/app/hooks/use-navigation-state.ts +2 -7
- package/corpus/templates/chat/app/routes/_index.tsx +8 -5
- package/corpus/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
- package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/clips/AGENTS.md +9 -1
- package/corpus/templates/clips/actions/export-to-brain.ts +82 -6
- package/corpus/templates/clips/actions/request-transcript.ts +25 -14
- package/corpus/templates/clips/changelog/2026-07-22-clips-transcripts-now-retry-brain-export.md +5 -0
- package/corpus/templates/clips/changelog/2026-07-22-german-umlauts-and-other-non-ascii-characters-now-paste-corr.md +6 -0
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +26 -3
- package/corpus/templates/clips/jobs/emit-netlify-brain-export-cron.ts +118 -0
- package/corpus/templates/clips/netlify.toml +4 -1
- package/corpus/templates/clips/scripts/configure-prod-brain-export.ts +92 -0
- package/corpus/templates/clips/server/jobs/brain-export.ts +182 -0
- package/corpus/templates/clips/server/lib/brain-export-state.ts +42 -0
- package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +5 -1
- package/corpus/templates/clips/server/plugins/calendar-jobs.ts +2 -0
- package/corpus/templates/clips/server/register-secrets.ts +42 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +10 -1
- package/corpus/templates/clips/server/routes/api/clips/brain-export/run.post.ts +45 -0
- package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/content/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -1
- package/corpus/templates/content/server/plugins/collab.ts +1 -1
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/crm/actions/_crm-data-program-actions.ts +15 -0
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +2 -0
- package/corpus/templates/crm/actions/run.ts +2 -6
- package/corpus/templates/crm/actions/update-crm-record.ts +4 -2
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +6 -0
- package/corpus/templates/crm/changelog/2026-07-22-crm-field-validation-now-explains-which-fields-cannot-be-edi.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-22-fixed-hubspot-contact-syncs-missing-records-updated-after-th.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-22-fixed-pipeline-dashboard-panels-so-their-opportunity-data-lo.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +4 -1
- package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/design/server/plugins/collab.ts +11 -8
- package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/forms/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/forms/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/forms/app/hooks/use-navigation-state.ts +2 -9
- package/corpus/templates/forms/app/root.tsx +1 -6
- package/corpus/templates/forms/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/mail/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +2 -2
- package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/plan/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/plan/app/components/layout/Layout.tsx +5 -1
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +57 -72
- package/corpus/templates/plan/app/hooks/use-navigation-state.ts +2 -9
- package/corpus/templates/plan/app/lib/create-plan-routing.ts +2 -2
- package/corpus/templates/plan/app/pages/PlanChatPage.tsx +0 -1
- package/corpus/templates/plan/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-22-recent-chats-and-sidebar-controls-are-more-compact.md +6 -0
- package/corpus/templates/plan/server/plugins/collab.ts +5 -2
- package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/slides/server/plugins/collab.ts +11 -8
- package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/corpus/templates/tasks/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +5 -22
- package/corpus/templates/tasks/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +7 -0
- package/corpus/toolkit/README.md +12 -3
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/chat-history/ChatHistoryRail.tsx +89 -0
- package/corpus/toolkit/src/chat-history/index.ts +5 -0
- package/corpus/toolkit/src/chat-history.css +59 -0
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +106 -36
- package/corpus/toolkit/src/composer/VoiceButton.tsx +49 -0
- package/corpus/toolkit/src/composer/realtime-voice-audio-level.ts +2 -1
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +5 -3
- package/corpus/toolkit/src/styles.css +35 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +13 -3
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/doctor.d.ts +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +5 -2
- package/dist/cli/doctor.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +1 -0
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +38 -18
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +55 -20
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/FeedbackButton.d.ts +4 -2
- package/dist/client/FeedbackButton.d.ts.map +1 -1
- package/dist/client/FeedbackButton.js +18 -2
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +2 -3
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +11 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-page/AgentTabFrame.d.ts +3 -1
- package/dist/client/agent-page/AgentTabFrame.d.ts.map +1 -1
- package/dist/client/agent-page/AgentTabFrame.js +3 -2
- package/dist/client/agent-page/AgentTabFrame.js.map +1 -1
- package/dist/client/agent-page/AgentTabsPage.d.ts +2 -0
- package/dist/client/agent-page/AgentTabsPage.d.ts.map +1 -1
- package/dist/client/agent-page/AgentTabsPage.js +26 -15
- package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +6 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +17 -11
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +11 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +16 -17
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/tool-render-registry.d.ts +2 -0
- package/dist/client/chat/tool-render-registry.d.ts.map +1 -1
- package/dist/client/chat/tool-render-registry.js.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.js +15 -1
- package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +3 -3
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts +1 -0
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +34 -20
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/mcp-connection-resume.d.ts +11 -0
- package/dist/client/resources/mcp-connection-resume.d.ts.map +1 -0
- package/dist/client/resources/mcp-connection-resume.js +95 -0
- package/dist/client/resources/mcp-connection-resume.js.map +1 -0
- package/dist/client/resources/mcp-integration-catalog.d.ts +1 -0
- package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.js +63 -8
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/mcp-integration-logos.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-logos.js +4 -0
- package/dist/client/resources/mcp-integration-logos.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +5 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +39 -13
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-db-sync.d.ts +3 -2
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +17 -6
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/connections/catalog.d.ts +1 -1
- package/dist/connections/catalog.d.ts.map +1 -1
- package/dist/connections/catalog.js +7 -1
- package/dist/connections/catalog.js.map +1 -1
- package/dist/eject/remote-mcp-presets.d.ts.map +1 -1
- package/dist/eject/remote-mcp-presets.js +33 -3
- package/dist/eject/remote-mcp-presets.js.map +1 -1
- package/dist/guards/explicit-collab-access.d.ts +8 -0
- package/dist/guards/explicit-collab-access.d.ts.map +1 -0
- package/dist/guards/explicit-collab-access.js +214 -0
- package/dist/guards/explicit-collab-access.js.map +1 -0
- package/dist/guards/index.d.ts +1 -0
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +1 -0
- package/dist/guards/index.js.map +1 -1
- package/dist/localization/default-messages.d.ts +43 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +48 -5
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/connect-route.d.ts.map +1 -1
- package/dist/mcp/connect-route.js +34 -48
- package/dist/mcp/connect-route.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +11 -11
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/provider-api/index.js +1 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/server/collab-plugin.d.ts +34 -3
- package/dist/server/collab-plugin.d.ts.map +1 -1
- package/dist/server/collab-plugin.js +65 -12
- package/dist/server/collab-plugin.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/styles/agent-native.css +40 -0
- package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/dist/templates/chat/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/dist/templates/chat/app/components/layout/Layout.tsx +1 -0
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +43 -67
- package/dist/templates/chat/app/hooks/use-navigation-state.ts +2 -7
- package/dist/templates/chat/app/routes/_index.tsx +8 -5
- package/dist/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/dist/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/dist/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
- package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/dist/templates/default/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/dist/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +12 -8
- package/docs/AGENTS.md +1 -1
- package/docs/content/agent-mentions.mdx +2 -2
- package/docs/content/{workspace.mdx → agent-resources.mdx} +1 -7
- package/docs/content/agent-teams.mdx +4 -4
- package/docs/content/dispatch.mdx +10 -10
- package/docs/content/drop-in-agent.mdx +4 -4
- package/docs/content/external-agents.mdx +1 -1
- package/docs/content/frames.mdx +1 -1
- package/docs/content/integrations.mdx +13 -2
- package/docs/content/key-concepts.mdx +2 -2
- package/docs/content/mcp-clients.mdx +7 -1
- package/docs/content/multi-app-workspace.mdx +3 -3
- package/docs/content/real-time-collaboration.mdx +33 -15
- package/docs/content/recurring-jobs.mdx +7 -7
- package/docs/content/skills-guide.mdx +4 -4
- package/docs/content/template-brain.mdx +1 -1
- package/docs/content/toolkit-collaboration.mdx +1 -1
- package/docs/content/using-your-agent.mdx +1 -1
- package/docs/content/what-is-agent-native.mdx +4 -4
- package/docs/content/workspace-management.mdx +4 -4
- package/package.json +3 -3
- package/src/agent/production-agent.ts +13 -3
- package/src/cli/doctor.ts +6 -1
- package/src/client/AgentPanel.tsx +79 -41
- package/src/client/AssistantChat.tsx +71 -25
- package/src/client/FeedbackButton.tsx +33 -7
- package/src/client/MultiTabAssistantChat.tsx +6 -8
- package/src/client/agent-chat-adapter.ts +11 -2
- package/src/client/agent-page/AgentTabFrame.tsx +22 -3
- package/src/client/agent-page/AgentTabsPage.tsx +34 -19
- package/src/client/chat/message-components.tsx +43 -16
- package/src/client/chat/tool-call-display.tsx +30 -18
- package/src/client/chat/tool-render-registry.tsx +2 -0
- package/src/client/resources/McpConnectionSuggestion.tsx +19 -2
- package/src/client/resources/ResourceTree.tsx +7 -10
- package/src/client/resources/ResourcesPanel.tsx +33 -70
- package/src/client/resources/mcp-connection-resume.ts +107 -0
- package/src/client/resources/mcp-integration-catalog.ts +65 -12
- package/src/client/resources/mcp-integration-logos.ts +4 -0
- package/src/client/sse-event-processor.ts +50 -14
- package/src/client/use-db-sync.ts +16 -6
- package/src/connections/catalog.ts +7 -1
- package/src/eject/remote-mcp-presets.ts +37 -5
- package/src/guards/explicit-collab-access.ts +229 -0
- package/src/guards/index.ts +1 -0
- package/src/localization/default-messages.ts +54 -5
- package/src/mcp/connect-route.ts +34 -51
- package/src/provider-api/index.ts +1 -1
- package/src/server/collab-plugin.ts +137 -18
- package/src/server/index.ts +2 -0
- package/src/styles/agent-native.css +40 -0
- package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/src/templates/chat/app/components/layout/Layout.tsx +1 -0
- package/src/templates/chat/app/components/layout/Sidebar.tsx +43 -67
- package/src/templates/chat/app/hooks/use-navigation-state.ts +2 -7
- package/src/templates/chat/app/routes/_index.tsx +8 -5
- package/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
- package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/src/templates/default/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -1
- package/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +35 -13
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +12 -8
package/dist/cli/doctor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MigrationManifest } from "../package-lifecycle/index.js";
|
|
2
|
-
export type GuardName = "no-drizzle-push" | "no-unscoped-credentials" | "no-unscoped-queries" | "no-env-credentials" | "db-tool-scoping" | "no-env-mutation" | "no-localhost-fallback" | "migration-manifest";
|
|
2
|
+
export type GuardName = "no-drizzle-push" | "no-unscoped-credentials" | "no-unscoped-queries" | "no-env-credentials" | "db-tool-scoping" | "no-env-mutation" | "no-localhost-fallback" | "explicit-collab-access" | "migration-manifest";
|
|
3
3
|
export declare const ALL_GUARD_NAMES: GuardName[];
|
|
4
4
|
export interface DoctorConfig {
|
|
5
5
|
disabledGuards: string[];
|
package/dist/cli/doctor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAoCA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,MAAM,SAAS,GACjB,iBAAiB,GACjB,yBAAyB,GACzB,qBAAqB,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,uBAAuB,GACvB,wBAAwB,GACxB,oBAAoB,CAAC;AAEzB,eAAO,MAAM,eAAe,EAAE,SAAS,EAUtC,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,WAAW,EAAE,OAAO,CAAC;CACtB;AAQD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,EAA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;AAC/D,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAE,QAAoB,GACvB,OAAO,CAAC,MAAM,CAAC,CAyDjB;AAED,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC;8DAC0D;IAC1D,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,sBAAsB,EAC/B,EAAE,GAAE,QAAoB,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAmChC"}
|
package/dist/cli/doctor.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* itself via `scripts/guard-*.mjs` (see
|
|
5
5
|
* `advisor-plans/reports/005-doctor-design.md` for the full design and
|
|
6
6
|
* `advisor-plans/015-doctor-v1-implementation.md` for the implementation
|
|
7
|
-
* plan). v1 ships
|
|
7
|
+
* plan). v1 ships 9 of those guards, ported to work against a single
|
|
8
8
|
* generated app root instead of this monorepo's multi-template layout —
|
|
9
9
|
* see `../guards/index.ts`.
|
|
10
10
|
*
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import fs from "node:fs";
|
|
24
24
|
import path from "node:path";
|
|
25
|
-
import { scanDbToolScoping, scanDrizzlePush, scanEnvCredentials, scanEnvMutation, scanLocalhostFallback, scanUnscopedCredentials, scanUnscopedQueries, } from "../guards/index.js";
|
|
25
|
+
import { scanDbToolScoping, scanDrizzlePush, scanEnvCredentials, scanEnvMutation, scanExplicitCollabAccess, scanLocalhostFallback, scanUnscopedCredentials, scanUnscopedQueries, } from "../guards/index.js";
|
|
26
26
|
import { AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND, scanDeprecatedImports, } from "../package-lifecycle/index.js";
|
|
27
27
|
export const ALL_GUARD_NAMES = [
|
|
28
28
|
"no-drizzle-push",
|
|
@@ -32,6 +32,7 @@ export const ALL_GUARD_NAMES = [
|
|
|
32
32
|
"db-tool-scoping",
|
|
33
33
|
"no-env-mutation",
|
|
34
34
|
"no-localhost-fallback",
|
|
35
|
+
"explicit-collab-access",
|
|
35
36
|
"migration-manifest",
|
|
36
37
|
];
|
|
37
38
|
const DEFAULT_DOCTOR_CONFIG = {
|
|
@@ -86,6 +87,8 @@ function runGuard(name, root, config, migrationManifests) {
|
|
|
86
87
|
return scanEnvMutation({ root });
|
|
87
88
|
case "no-localhost-fallback":
|
|
88
89
|
return scanLocalhostFallback({ root, extraExemptPaths: [] });
|
|
90
|
+
case "explicit-collab-access":
|
|
91
|
+
return scanExplicitCollabAccess({ root });
|
|
89
92
|
case "migration-manifest": {
|
|
90
93
|
const imports = scanDeprecatedImports({
|
|
91
94
|
root,
|
package/dist/cli/doctor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAYvC,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,iBAAiB;IACjB,yBAAyB;IACzB,qBAAqB;IACrB,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,uBAAuB;IACvB,oBAAoB;CACrB,CAAC;AAQF,MAAM,qBAAqB,GAAiB;IAC1C,cAAc,EAAE,EAAE;IAClB,qBAA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AAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAChC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,EAAE,CAAC,GAAG,CACJ,cAAc,MAAM,CAAC,QAAQ,CAAC,MAAM,8DAA8D,CACnG,CAAC;QACF,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,EAAE,CAAC,GAAG,CACJ,MAAM,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IACH,IAAI,IAAI,EAAE,CAAC;QACT,EAAE,CAAC,GAAG,CACJ,6BAA6B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gDAAgD,GAAG,CAC1H,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["/**\n * `agent-native doctor` — scan an app's source tree for the security-\n * critical code-safety invariants this monorepo already enforces on\n * itself via `scripts/guard-*.mjs` (see\n * `advisor-plans/reports/005-doctor-design.md` for the full design and\n * `advisor-plans/015-doctor-v1-implementation.md` for the implementation\n * plan). v1 ships 8 of those guards, ported to work against a single\n * generated app root instead of this monorepo's multi-template layout —\n * see `../guards/index.ts`.\n *\n * This is a NEW top-level command, deliberately kept separate from the two\n * existing \"doctor\" precedents in this CLI:\n * - `agent-native upgrade check` (`upgrade.ts`) — dependency-pin health.\n * - `agent-native recap doctor` (`recap.ts`) — PR Visual Recap config health.\n * Each diagnoses a different domain; none are folded into a shared\n * mega-doctor (see report 005, \"Relationship to upgrade doctor and recap\n * doctor\").\n *\n * `--fix` is reserved, not implemented in v1 — it prints a message and\n * exits 2 rather than silently no-op, so a future implementation doesn't\n * collide with a script already passing the flag.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n scanDbToolScoping,\n scanDrizzlePush,\n scanEnvCredentials,\n scanEnvMutation,\n scanLocalhostFallback,\n scanUnscopedCredentials,\n scanUnscopedQueries,\n} from \"../guards/index.js\";\nimport type { GuardFinding, GuardResult } from \"../guards/index.js\";\nimport {\n AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND,\n scanDeprecatedImports,\n type MigrationManifest,\n} from \"../package-lifecycle/index.js\";\n\nexport type GuardName =\n | \"no-drizzle-push\"\n | \"no-unscoped-credentials\"\n | \"no-unscoped-queries\"\n | \"no-env-credentials\"\n | \"db-tool-scoping\"\n | \"no-env-mutation\"\n | \"no-localhost-fallback\"\n | \"migration-manifest\";\n\nexport const ALL_GUARD_NAMES: GuardName[] = [\n \"no-drizzle-push\",\n \"no-unscoped-credentials\",\n \"no-unscoped-queries\",\n \"no-env-credentials\",\n \"db-tool-scoping\",\n \"no-env-mutation\",\n \"no-localhost-fallback\",\n \"migration-manifest\",\n];\n\nexport interface DoctorConfig {\n disabledGuards: string[];\n dbToolScopingDenylist: Record<string, string>;\n failOnBuild: boolean;\n}\n\nconst DEFAULT_DOCTOR_CONFIG: DoctorConfig = {\n disabledGuards: [],\n dbToolScopingDenylist: {},\n failOnBuild: false,\n};\n\nexport interface DoctorFinding {\n guard: string;\n file: string;\n line: number;\n message: string;\n}\n\nexport interface DoctorReport {\n ok: boolean;\n findings: DoctorFinding[];\n warnings: DoctorFinding[];\n guardsRun: string[];\n}\n\ninterface DoctorGuardResult extends GuardResult {\n warnings?: GuardFinding[];\n}\n\n/**\n * Reads the optional `\"doctor\"` key from `<root>/agent-native.json`. All\n * fields are optional with sane empty defaults — an app needs zero config\n * to run `agent-native doctor` with every v1 guard enabled.\n */\nexport function readDoctorConfig(root: string): DoctorConfig {\n const manifestPath = path.join(root, \"agent-native.json\");\n if (!fs.existsSync(manifestPath)) {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n try {\n const raw = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(raw) as { doctor?: Record<string, unknown> };\n const doctor = parsed.doctor ?? {};\n const disabledGuards = Array.isArray(doctor.disabledGuards)\n ? doctor.disabledGuards.filter((v): v is string => typeof v === \"string\")\n : [];\n const dbToolScopingDenylist =\n doctor.dbToolScopingDenylist &&\n typeof doctor.dbToolScopingDenylist === \"object\"\n ? (Object.fromEntries(\n Object.entries(\n doctor.dbToolScopingDenylist as Record<string, unknown>,\n ).filter(\n (entry): entry is [string, string] =>\n typeof entry[1] === \"string\",\n ),\n ) as Record<string, string>)\n : {};\n const failOnBuild = doctor.failOnBuild === true;\n return { disabledGuards, dbToolScopingDenylist, failOnBuild };\n } catch {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n}\n\nfunction runGuard(\n name: GuardName,\n root: string,\n config: DoctorConfig,\n migrationManifests?: MigrationManifest[],\n): DoctorGuardResult {\n switch (name) {\n case \"no-drizzle-push\":\n return scanDrizzlePush({ root });\n case \"no-unscoped-credentials\":\n return scanUnscopedCredentials({ root });\n case \"no-unscoped-queries\":\n return scanUnscopedQueries({ root, extraExemptPaths: [] });\n case \"no-env-credentials\":\n return scanEnvCredentials({ root });\n case \"db-tool-scoping\":\n return scanDbToolScoping({\n root,\n denylist: config.dbToolScopingDenylist,\n });\n case \"no-env-mutation\":\n return scanEnvMutation({ root });\n case \"no-localhost-fallback\":\n return scanLocalhostFallback({ root, extraExemptPaths: [] });\n case \"migration-manifest\": {\n const imports = scanDeprecatedImports({\n root,\n manifests: migrationManifests,\n });\n return {\n name,\n findings: imports\n .filter((finding) => finding.status === \"active\")\n .map((finding) => ({\n file: path.relative(root, finding.file),\n line: finding.line,\n message: `${finding.from} moves to ${finding.to.join(\", \")}. Run: ${AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND}`,\n })),\n warnings: imports\n .filter((finding) => finding.status === \"planned\")\n .map((finding) => ({\n file: path.relative(root, finding.file),\n line: finding.line,\n message: `${finding.from} is planned to move to ${finding.to.join(\", \")} in a future release. No rewrite is available yet.`,\n })),\n };\n }\n }\n}\n\nexport interface RunDoctorScanOptions {\n root: string;\n /** Restrict to these guard names. When omitted, runs every guard not\n * listed in `agent-native.json`'s `doctor.disabledGuards`. Unknown names\n * are silently ignored here — the CLI layer (`runDoctor`) validates\n * `--only` and reports a usage error before calling this. */\n only?: string[];\n migrationManifests?: MigrationManifest[];\n}\n\n/** Pure scan orchestrator: runs the selected guards against `root` and\n * returns a flat report. No I/O beyond reading `agent-native.json` and the\n * app source tree — no printing, no process.exit. */\nexport function runDoctorScan(options: RunDoctorScanOptions): DoctorReport {\n const root = options.root;\n const config = readDoctorConfig(root);\n\n let names: GuardName[];\n if (options.only && options.only.length > 0) {\n const knownOnly = options.only.filter((n): n is GuardName =>\n (ALL_GUARD_NAMES as string[]).includes(n),\n );\n names = knownOnly;\n } else {\n names = ALL_GUARD_NAMES.filter((n) => !config.disabledGuards.includes(n));\n }\n\n const findings: DoctorFinding[] = [];\n const warnings: DoctorFinding[] = [];\n for (const name of names) {\n const result = runGuard(name, root, config, options.migrationManifests);\n for (const f of result.findings) {\n findings.push({\n guard: name,\n file: f.file,\n line: f.line,\n message: f.message,\n });\n }\n for (const warning of result.warnings ?? []) {\n warnings.push({\n guard: name,\n file: warning.file,\n line: warning.line,\n message: warning.message,\n });\n }\n }\n\n return {\n ok: findings.length === 0,\n findings,\n warnings,\n guardsRun: names,\n };\n}\n\n/** Pure escalation rule shared by the CLI (`--strict`) and the `build`\n * pre-step (`--strict` / `agent-native.json` `doctor.failOnBuild`). Doctor\n * findings never fail anything on their own — only `strict` or\n * `failOnBuild` turn findings into a hard failure. */\nexport function shouldFailBuild(\n hasFindings: boolean,\n opts: { strict?: boolean; failOnBuild?: boolean },\n): boolean {\n return hasFindings && Boolean(opts.strict || opts.failOnBuild);\n}\n\nexport interface DoctorIo {\n log: (message: string) => void;\n err: (message: string) => void;\n}\n\nconst defaultIo: DoctorIo = {\n log: (message) => console.log(message),\n err: (message) => console.error(message),\n};\n\nfunction formatDoctorHuman(report: DoctorReport, root: string): string {\n const lines: string[] = [];\n lines.push(`agent-native doctor: ${root}`);\n lines.push(`Guards run: ${report.guardsRun.join(\", \") || \"(none)\"}`);\n if (report.findings.length === 0) {\n lines.push(\"Clean — no findings.\");\n } else {\n lines.push(`${report.findings.length} finding(s):`);\n for (const f of report.findings) {\n lines.push(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n if (report.warnings.length > 0) {\n lines.push(`${report.warnings.length} warning(s):`);\n for (const warning of report.warnings) {\n lines.push(\n ` [${warning.guard}] ${warning.file}:${warning.line} — ${warning.message}`,\n );\n }\n }\n return lines.join(\"\\n\");\n}\n\nexport interface DoctorCliOptions {\n json?: boolean;\n cwd?: string;\n only?: string[];\n strict?: boolean;\n help?: boolean;\n fix?: boolean;\n}\n\nexport function parseDoctorArgs(argv: string[]): DoctorCliOptions {\n const opts: DoctorCliOptions = {};\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--help\" || arg === \"-h\") {\n opts.help = true;\n } else if (arg === \"--json\") {\n opts.json = true;\n } else if (arg === \"--strict\") {\n opts.strict = true;\n } else if (arg === \"--fix\") {\n opts.fix = true;\n } else if (arg === \"--cwd\" && argv[i + 1] !== undefined) {\n opts.cwd = argv[++i];\n } else if (arg.startsWith(\"--cwd=\")) {\n opts.cwd = arg.slice(\"--cwd=\".length);\n } else if (arg === \"--only\" && argv[i + 1] !== undefined) {\n opts.only = splitGuardList(argv[++i]);\n } else if (arg.startsWith(\"--only=\")) {\n opts.only = splitGuardList(arg.slice(\"--only=\".length));\n }\n }\n return opts;\n}\n\nfunction splitGuardList(value: string): string[] {\n return value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\nexport function printDoctorHelp(io: Pick<DoctorIo, \"log\"> = defaultIo): void {\n io.log(\n [\n \"Usage:\",\n \" agent-native doctor Scan app source for security-critical guard violations\",\n \" agent-native doctor --json Machine-readable report: { ok, findings, warnings, guardsRun, strict }\",\n \" agent-native doctor --only <guard,guard> Run only the named guard(s)\",\n \" agent-native doctor --strict Escalate findings to a hard failure when used by `agent-native build --strict`\",\n \" agent-native doctor --cwd <dir> Run against a project root other than the current directory\",\n \" agent-native doctor --fix Not implemented in this version\",\n \" agent-native doctor --help Show this help\",\n \"\",\n `Guards: ${ALL_GUARD_NAMES.join(\", \")}`,\n \"\",\n \"Exit codes: 0 clean, 1 findings present, 2 usage/execution error.\",\n \"\",\n \"`agent-native build` runs doctor as a warn-only pre-step by default — it\",\n \"never fails the build unless `agent-native build --strict` is passed or\",\n 'agent-native.json sets { \"doctor\": { \"failOnBuild\": true } }.',\n \"\",\n \"For dependency-pin health (framework overrides/patches, stale\",\n \"@agent-native/* pins), run `agent-native upgrade check` instead.\",\n `For import migrations, run \\`${AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND}\\`.`,\n ].join(\"\\n\"),\n );\n}\n\n/** `agent-native doctor` CLI entrypoint. Returns the process exit code —\n * callers are responsible for calling `process.exit(code)`. */\nexport async function runDoctor(\n argv: string[],\n io: DoctorIo = defaultIo,\n): Promise<number> {\n const opts = parseDoctorArgs(argv);\n\n if (opts.help) {\n printDoctorHelp(io);\n return 0;\n }\n\n if (opts.fix) {\n io.err(\n \"agent-native doctor --fix is not implemented in this version. Fix findings manually and re-run `agent-native doctor`.\",\n );\n return 2;\n }\n\n const root = path.resolve(opts.cwd ?? process.cwd());\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n const message = `--cwd path does not exist or is not a directory: ${root}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n\n if (opts.only) {\n const unknown = opts.only.filter(\n (n) => !(ALL_GUARD_NAMES as string[]).includes(n),\n );\n if (unknown.length > 0) {\n const message = `Unknown guard name(s) in --only: ${unknown.join(\", \")}. Known guards: ${ALL_GUARD_NAMES.join(\", \")}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n }\n\n const report = runDoctorScan({ root, only: opts.only });\n\n if (opts.json) {\n // The machine-readable report always goes to stdout (io.log), whether\n // or not findings are present, so `agent-native doctor --json >\n // report.json` in CI always captures the report. Only the usage/\n // execution error payloads above (bad --cwd, unknown --only) go to\n // stderr — those are diagnostics for exit code 2, not the report.\n io.log(\n JSON.stringify({ ...report, strict: Boolean(opts.strict) }, null, 2),\n );\n } else {\n io.log(formatDoctorHuman(report, root));\n if (!report.ok) {\n io.err(\"\");\n io.err(\n \"agent-native doctor found issues above. Fix them, or add a `// guard:allow-<check> — reason` opt-out with reviewer approval.\",\n );\n }\n }\n\n return report.ok ? 0 : 1;\n}\n\nexport interface DoctorBuildHookOptions {\n cwd: string;\n /** Set when the caller passed `agent-native build --strict`. */\n strict?: boolean;\n}\n\nexport interface DoctorBuildHookResult {\n /** False only when findings are present AND (`strict` was requested OR\n * `agent-native.json`'s `doctor.failOnBuild` is true). */\n ok: boolean;\n report: DoctorReport;\n}\n\n/**\n * `agent-native build`'s doctor pre-step. Always runs every enabled guard\n * and always prints findings (as warnings) to `io.err` — never silent.\n * Never causes the build to fail unless `strict` was passed or\n * `agent-native.json` sets `doctor.failOnBuild: true` (see report 005,\n * \"Where it runs\" — the v1 doctor has zero field mileage against arbitrary\n * app layouts, so shipping fail-by-default would risk breaking a first\n * deploy on a false positive).\n */\nexport async function runDoctorBuildHook(\n options: DoctorBuildHookOptions,\n io: DoctorIo = defaultIo,\n): Promise<DoctorBuildHookResult> {\n const root = path.resolve(options.cwd);\n const config = readDoctorConfig(root);\n const report = runDoctorScan({ root });\n\n if (report.findings.length > 0) {\n io.err(\n `\\n[doctor] ${report.findings.length} finding(s) from \\`agent-native doctor\\` — run it directly for details. This does not fail the build unless --strict was passed or agent-native.json's doctor.failOnBuild is true.`,\n );\n for (const f of report.findings) {\n io.err(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n if (report.warnings.length > 0) {\n io.err(\n `\\n[doctor] ${report.warnings.length} planned migration warning(s) — no rewrite is available yet.`,\n );\n for (const warning of report.warnings) {\n io.err(\n ` [${warning.guard}] ${warning.file}:${warning.line} — ${warning.message}`,\n );\n }\n }\n\n const fail = shouldFailBuild(report.findings.length > 0, {\n strict: options.strict,\n failOnBuild: config.failOnBuild,\n });\n if (fail) {\n io.err(\n `\\n[doctor] Failing build: ${options.strict ? \"--strict was passed\" : \"agent-native.json's doctor.failOnBuild is true\"}.`,\n );\n }\n\n return { ok: !fail, report };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,oCAAoC,EACpC,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAavC,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,iBAAiB;IACjB,yBAAyB;IACzB,qBAAqB;IACrB,oBAAoB;IACpB,iBAAi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":["/**\n * `agent-native doctor` — scan an app's source tree for the security-\n * critical code-safety invariants this monorepo already enforces on\n * itself via `scripts/guard-*.mjs` (see\n * `advisor-plans/reports/005-doctor-design.md` for the full design and\n * `advisor-plans/015-doctor-v1-implementation.md` for the implementation\n * plan). v1 ships 9 of those guards, ported to work against a single\n * generated app root instead of this monorepo's multi-template layout —\n * see `../guards/index.ts`.\n *\n * This is a NEW top-level command, deliberately kept separate from the two\n * existing \"doctor\" precedents in this CLI:\n * - `agent-native upgrade check` (`upgrade.ts`) — dependency-pin health.\n * - `agent-native recap doctor` (`recap.ts`) — PR Visual Recap config health.\n * Each diagnoses a different domain; none are folded into a shared\n * mega-doctor (see report 005, \"Relationship to upgrade doctor and recap\n * doctor\").\n *\n * `--fix` is reserved, not implemented in v1 — it prints a message and\n * exits 2 rather than silently no-op, so a future implementation doesn't\n * collide with a script already passing the flag.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n scanDbToolScoping,\n scanDrizzlePush,\n scanEnvCredentials,\n scanEnvMutation,\n scanExplicitCollabAccess,\n scanLocalhostFallback,\n scanUnscopedCredentials,\n scanUnscopedQueries,\n} from \"../guards/index.js\";\nimport type { GuardFinding, GuardResult } from \"../guards/index.js\";\nimport {\n AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND,\n scanDeprecatedImports,\n type MigrationManifest,\n} from \"../package-lifecycle/index.js\";\n\nexport type GuardName =\n | \"no-drizzle-push\"\n | \"no-unscoped-credentials\"\n | \"no-unscoped-queries\"\n | \"no-env-credentials\"\n | \"db-tool-scoping\"\n | \"no-env-mutation\"\n | \"no-localhost-fallback\"\n | \"explicit-collab-access\"\n | \"migration-manifest\";\n\nexport const ALL_GUARD_NAMES: GuardName[] = [\n \"no-drizzle-push\",\n \"no-unscoped-credentials\",\n \"no-unscoped-queries\",\n \"no-env-credentials\",\n \"db-tool-scoping\",\n \"no-env-mutation\",\n \"no-localhost-fallback\",\n \"explicit-collab-access\",\n \"migration-manifest\",\n];\n\nexport interface DoctorConfig {\n disabledGuards: string[];\n dbToolScopingDenylist: Record<string, string>;\n failOnBuild: boolean;\n}\n\nconst DEFAULT_DOCTOR_CONFIG: DoctorConfig = {\n disabledGuards: [],\n dbToolScopingDenylist: {},\n failOnBuild: false,\n};\n\nexport interface DoctorFinding {\n guard: string;\n file: string;\n line: number;\n message: string;\n}\n\nexport interface DoctorReport {\n ok: boolean;\n findings: DoctorFinding[];\n warnings: DoctorFinding[];\n guardsRun: string[];\n}\n\ninterface DoctorGuardResult extends GuardResult {\n warnings?: GuardFinding[];\n}\n\n/**\n * Reads the optional `\"doctor\"` key from `<root>/agent-native.json`. All\n * fields are optional with sane empty defaults — an app needs zero config\n * to run `agent-native doctor` with every v1 guard enabled.\n */\nexport function readDoctorConfig(root: string): DoctorConfig {\n const manifestPath = path.join(root, \"agent-native.json\");\n if (!fs.existsSync(manifestPath)) {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n try {\n const raw = fs.readFileSync(manifestPath, \"utf-8\");\n const parsed = JSON.parse(raw) as { doctor?: Record<string, unknown> };\n const doctor = parsed.doctor ?? {};\n const disabledGuards = Array.isArray(doctor.disabledGuards)\n ? doctor.disabledGuards.filter((v): v is string => typeof v === \"string\")\n : [];\n const dbToolScopingDenylist =\n doctor.dbToolScopingDenylist &&\n typeof doctor.dbToolScopingDenylist === \"object\"\n ? (Object.fromEntries(\n Object.entries(\n doctor.dbToolScopingDenylist as Record<string, unknown>,\n ).filter(\n (entry): entry is [string, string] =>\n typeof entry[1] === \"string\",\n ),\n ) as Record<string, string>)\n : {};\n const failOnBuild = doctor.failOnBuild === true;\n return { disabledGuards, dbToolScopingDenylist, failOnBuild };\n } catch {\n return { ...DEFAULT_DOCTOR_CONFIG, dbToolScopingDenylist: {} };\n }\n}\n\nfunction runGuard(\n name: GuardName,\n root: string,\n config: DoctorConfig,\n migrationManifests?: MigrationManifest[],\n): DoctorGuardResult {\n switch (name) {\n case \"no-drizzle-push\":\n return scanDrizzlePush({ root });\n case \"no-unscoped-credentials\":\n return scanUnscopedCredentials({ root });\n case \"no-unscoped-queries\":\n return scanUnscopedQueries({ root, extraExemptPaths: [] });\n case \"no-env-credentials\":\n return scanEnvCredentials({ root });\n case \"db-tool-scoping\":\n return scanDbToolScoping({\n root,\n denylist: config.dbToolScopingDenylist,\n });\n case \"no-env-mutation\":\n return scanEnvMutation({ root });\n case \"no-localhost-fallback\":\n return scanLocalhostFallback({ root, extraExemptPaths: [] });\n case \"explicit-collab-access\":\n return scanExplicitCollabAccess({ root });\n case \"migration-manifest\": {\n const imports = scanDeprecatedImports({\n root,\n manifests: migrationManifests,\n });\n return {\n name,\n findings: imports\n .filter((finding) => finding.status === \"active\")\n .map((finding) => ({\n file: path.relative(root, finding.file),\n line: finding.line,\n message: `${finding.from} moves to ${finding.to.join(\", \")}. Run: ${AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND}`,\n })),\n warnings: imports\n .filter((finding) => finding.status === \"planned\")\n .map((finding) => ({\n file: path.relative(root, finding.file),\n line: finding.line,\n message: `${finding.from} is planned to move to ${finding.to.join(\", \")} in a future release. No rewrite is available yet.`,\n })),\n };\n }\n }\n}\n\nexport interface RunDoctorScanOptions {\n root: string;\n /** Restrict to these guard names. When omitted, runs every guard not\n * listed in `agent-native.json`'s `doctor.disabledGuards`. Unknown names\n * are silently ignored here — the CLI layer (`runDoctor`) validates\n * `--only` and reports a usage error before calling this. */\n only?: string[];\n migrationManifests?: MigrationManifest[];\n}\n\n/** Pure scan orchestrator: runs the selected guards against `root` and\n * returns a flat report. No I/O beyond reading `agent-native.json` and the\n * app source tree — no printing, no process.exit. */\nexport function runDoctorScan(options: RunDoctorScanOptions): DoctorReport {\n const root = options.root;\n const config = readDoctorConfig(root);\n\n let names: GuardName[];\n if (options.only && options.only.length > 0) {\n const knownOnly = options.only.filter((n): n is GuardName =>\n (ALL_GUARD_NAMES as string[]).includes(n),\n );\n names = knownOnly;\n } else {\n names = ALL_GUARD_NAMES.filter((n) => !config.disabledGuards.includes(n));\n }\n\n const findings: DoctorFinding[] = [];\n const warnings: DoctorFinding[] = [];\n for (const name of names) {\n const result = runGuard(name, root, config, options.migrationManifests);\n for (const f of result.findings) {\n findings.push({\n guard: name,\n file: f.file,\n line: f.line,\n message: f.message,\n });\n }\n for (const warning of result.warnings ?? []) {\n warnings.push({\n guard: name,\n file: warning.file,\n line: warning.line,\n message: warning.message,\n });\n }\n }\n\n return {\n ok: findings.length === 0,\n findings,\n warnings,\n guardsRun: names,\n };\n}\n\n/** Pure escalation rule shared by the CLI (`--strict`) and the `build`\n * pre-step (`--strict` / `agent-native.json` `doctor.failOnBuild`). Doctor\n * findings never fail anything on their own — only `strict` or\n * `failOnBuild` turn findings into a hard failure. */\nexport function shouldFailBuild(\n hasFindings: boolean,\n opts: { strict?: boolean; failOnBuild?: boolean },\n): boolean {\n return hasFindings && Boolean(opts.strict || opts.failOnBuild);\n}\n\nexport interface DoctorIo {\n log: (message: string) => void;\n err: (message: string) => void;\n}\n\nconst defaultIo: DoctorIo = {\n log: (message) => console.log(message),\n err: (message) => console.error(message),\n};\n\nfunction formatDoctorHuman(report: DoctorReport, root: string): string {\n const lines: string[] = [];\n lines.push(`agent-native doctor: ${root}`);\n lines.push(`Guards run: ${report.guardsRun.join(\", \") || \"(none)\"}`);\n if (report.findings.length === 0) {\n lines.push(\"Clean — no findings.\");\n } else {\n lines.push(`${report.findings.length} finding(s):`);\n for (const f of report.findings) {\n lines.push(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n if (report.warnings.length > 0) {\n lines.push(`${report.warnings.length} warning(s):`);\n for (const warning of report.warnings) {\n lines.push(\n ` [${warning.guard}] ${warning.file}:${warning.line} — ${warning.message}`,\n );\n }\n }\n return lines.join(\"\\n\");\n}\n\nexport interface DoctorCliOptions {\n json?: boolean;\n cwd?: string;\n only?: string[];\n strict?: boolean;\n help?: boolean;\n fix?: boolean;\n}\n\nexport function parseDoctorArgs(argv: string[]): DoctorCliOptions {\n const opts: DoctorCliOptions = {};\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--help\" || arg === \"-h\") {\n opts.help = true;\n } else if (arg === \"--json\") {\n opts.json = true;\n } else if (arg === \"--strict\") {\n opts.strict = true;\n } else if (arg === \"--fix\") {\n opts.fix = true;\n } else if (arg === \"--cwd\" && argv[i + 1] !== undefined) {\n opts.cwd = argv[++i];\n } else if (arg.startsWith(\"--cwd=\")) {\n opts.cwd = arg.slice(\"--cwd=\".length);\n } else if (arg === \"--only\" && argv[i + 1] !== undefined) {\n opts.only = splitGuardList(argv[++i]);\n } else if (arg.startsWith(\"--only=\")) {\n opts.only = splitGuardList(arg.slice(\"--only=\".length));\n }\n }\n return opts;\n}\n\nfunction splitGuardList(value: string): string[] {\n return value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n}\n\nexport function printDoctorHelp(io: Pick<DoctorIo, \"log\"> = defaultIo): void {\n io.log(\n [\n \"Usage:\",\n \" agent-native doctor Scan app source for security-critical guard violations\",\n \" agent-native doctor --json Machine-readable report: { ok, findings, warnings, guardsRun, strict }\",\n \" agent-native doctor --only <guard,guard> Run only the named guard(s)\",\n \" agent-native doctor --strict Escalate findings to a hard failure when used by `agent-native build --strict`\",\n \" agent-native doctor --cwd <dir> Run against a project root other than the current directory\",\n \" agent-native doctor --fix Not implemented in this version\",\n \" agent-native doctor --help Show this help\",\n \"\",\n `Guards: ${ALL_GUARD_NAMES.join(\", \")}`,\n \"\",\n \"Exit codes: 0 clean, 1 findings present, 2 usage/execution error.\",\n \"\",\n \"`agent-native build` runs doctor as a warn-only pre-step by default — it\",\n \"never fails the build unless `agent-native build --strict` is passed or\",\n 'agent-native.json sets { \"doctor\": { \"failOnBuild\": true } }.',\n \"\",\n \"For dependency-pin health (framework overrides/patches, stale\",\n \"@agent-native/* pins), run `agent-native upgrade check` instead.\",\n `For import migrations, run \\`${AGENT_NATIVE_UPGRADE_CODEMOD_COMMAND}\\`.`,\n ].join(\"\\n\"),\n );\n}\n\n/** `agent-native doctor` CLI entrypoint. Returns the process exit code —\n * callers are responsible for calling `process.exit(code)`. */\nexport async function runDoctor(\n argv: string[],\n io: DoctorIo = defaultIo,\n): Promise<number> {\n const opts = parseDoctorArgs(argv);\n\n if (opts.help) {\n printDoctorHelp(io);\n return 0;\n }\n\n if (opts.fix) {\n io.err(\n \"agent-native doctor --fix is not implemented in this version. Fix findings manually and re-run `agent-native doctor`.\",\n );\n return 2;\n }\n\n const root = path.resolve(opts.cwd ?? process.cwd());\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n const message = `--cwd path does not exist or is not a directory: ${root}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n\n if (opts.only) {\n const unknown = opts.only.filter(\n (n) => !(ALL_GUARD_NAMES as string[]).includes(n),\n );\n if (unknown.length > 0) {\n const message = `Unknown guard name(s) in --only: ${unknown.join(\", \")}. Known guards: ${ALL_GUARD_NAMES.join(\", \")}`;\n if (opts.json) io.err(JSON.stringify({ ok: false, message }, null, 2));\n else io.err(message);\n return 2;\n }\n }\n\n const report = runDoctorScan({ root, only: opts.only });\n\n if (opts.json) {\n // The machine-readable report always goes to stdout (io.log), whether\n // or not findings are present, so `agent-native doctor --json >\n // report.json` in CI always captures the report. Only the usage/\n // execution error payloads above (bad --cwd, unknown --only) go to\n // stderr — those are diagnostics for exit code 2, not the report.\n io.log(\n JSON.stringify({ ...report, strict: Boolean(opts.strict) }, null, 2),\n );\n } else {\n io.log(formatDoctorHuman(report, root));\n if (!report.ok) {\n io.err(\"\");\n io.err(\n \"agent-native doctor found issues above. Fix them, or add a `// guard:allow-<check> — reason` opt-out with reviewer approval.\",\n );\n }\n }\n\n return report.ok ? 0 : 1;\n}\n\nexport interface DoctorBuildHookOptions {\n cwd: string;\n /** Set when the caller passed `agent-native build --strict`. */\n strict?: boolean;\n}\n\nexport interface DoctorBuildHookResult {\n /** False only when findings are present AND (`strict` was requested OR\n * `agent-native.json`'s `doctor.failOnBuild` is true). */\n ok: boolean;\n report: DoctorReport;\n}\n\n/**\n * `agent-native build`'s doctor pre-step. Always runs every enabled guard\n * and always prints findings (as warnings) to `io.err` — never silent.\n * Never causes the build to fail unless `strict` was passed or\n * `agent-native.json` sets `doctor.failOnBuild: true` (see report 005,\n * \"Where it runs\" — the v1 doctor has zero field mileage against arbitrary\n * app layouts, so shipping fail-by-default would risk breaking a first\n * deploy on a false positive).\n */\nexport async function runDoctorBuildHook(\n options: DoctorBuildHookOptions,\n io: DoctorIo = defaultIo,\n): Promise<DoctorBuildHookResult> {\n const root = path.resolve(options.cwd);\n const config = readDoctorConfig(root);\n const report = runDoctorScan({ root });\n\n if (report.findings.length > 0) {\n io.err(\n `\\n[doctor] ${report.findings.length} finding(s) from \\`agent-native doctor\\` — run it directly for details. This does not fail the build unless --strict was passed or agent-native.json's doctor.failOnBuild is true.`,\n );\n for (const f of report.findings) {\n io.err(` [${f.guard}] ${f.file}:${f.line} — ${f.message}`);\n }\n }\n if (report.warnings.length > 0) {\n io.err(\n `\\n[doctor] ${report.warnings.length} planned migration warning(s) — no rewrite is available yet.`,\n );\n for (const warning of report.warnings) {\n io.err(\n ` [${warning.guard}] ${warning.file}:${warning.line} — ${warning.message}`,\n );\n }\n }\n\n const fail = shouldFailBuild(report.findings.length > 0, {\n strict: options.strict,\n failOnBuild: config.failOnBuild,\n });\n if (fail) {\n io.err(\n `\\n[doctor] Failing build: ${options.strict ? \"--strict was passed\" : \"agent-native.json's doctor.failOnBuild is true\"}.`,\n );\n }\n\n return { ok: !fail, report };\n}\n"]}
|
|
@@ -98,6 +98,7 @@ export interface AgentPanelProps extends Omit<AssistantChatProps, "onSwitchToCli
|
|
|
98
98
|
codeAccess?: AgentPanelCodeAccess;
|
|
99
99
|
}
|
|
100
100
|
export declare function resolveAgentPanelChatSurface(explicitSurface: AgentChatSurfaceKind | undefined, desktopCodeSurfaceRequested: boolean): AgentChatSurfaceKind;
|
|
101
|
+
export declare function getActiveTabScrollDelta(containerRect: Pick<DOMRect, "left" | "right">, tabRect: Pick<DOMRect, "left" | "right">, margin?: number): number;
|
|
101
102
|
export declare function AgentPanel(props: AgentPanelProps): React.JSX.Element;
|
|
102
103
|
export type AgentChatSurfaceMode = "panel" | "page";
|
|
103
104
|
export interface AgentChatSurfaceProps extends AgentPanelProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentPanel.d.ts","sourceRoot":"","sources":["../../src/client/AgentPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAmBH,OAAO,KASN,MAAM,OAAO,CAAC;AAmCf,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAapE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAY7D,OAAO,KAAK,EACV,gCAAgC,EAChC,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AA0FpC,KAAK,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,CAAC;AAC3D,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,OAAO,GACzB,SAAS,CAEX;AA4LD,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,gCAAgC,CAAC,MAAM,CAAC,EAC9C,WAAW,EAAE,MAAM;;;;;;EAcpB;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gCAAgC,CAAC,MAAM,CAAC,EAC9C,WAAW,EAAE,MAAM,WAOpB;AAED,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,gCAAgC,CAAC,MAAM,CAAC,WAG/C;AAED,wBAAgB,qCAAqC,CACnD,IAAI,EAAE,gCAAgC,CAAC,MAAM,CAAC,EAC9C,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,WAO9B;AAED,wBAAgB,6BAA6B,C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AAmB,EACnB,YAAY,EACZ,QAAkB,EAClB,WAAmB,EACnB,aAAoB,EACpB,cAAqB,EACrB,kBAA0B,EAC1B,UAAU,EACV,iBAAyB,EACzB,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,GACd,EAAE,iBAAiB,qBAkmBnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,SAqB7B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,4BAqCtE"}
|
|
@@ -27,7 +27,7 @@ import React, { useState, useEffect, useRef, useCallback, useMemo, lazy, Suspens
|
|
|
27
27
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "./components/ui/dropdown-menu.js";
|
|
28
28
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, normalizeTooltipText, } from "./components/ui/tooltip.js";
|
|
29
29
|
import { ErrorReportActions } from "./ErrorReportActions.js";
|
|
30
|
-
import { FeedbackButton } from "./FeedbackButton.js";
|
|
30
|
+
import { FeedbackButton, resolveFeedbackUrl } from "./FeedbackButton.js";
|
|
31
31
|
import { RunsTrayMenuItem } from "./progress/RunsTray.js";
|
|
32
32
|
import { ShareButton } from "./sharing/ShareButton.js";
|
|
33
33
|
// Lazy-load the full assistant-ui chat stack (tiptap composer + react-markdown +
|
|
@@ -378,6 +378,7 @@ function CodeAccessUnavailablePanel({ title, description, ctaLabel, ctaHref, sec
|
|
|
378
378
|
}
|
|
379
379
|
function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, emptyStateText, emptyStateAddon, suggestions, dynamicSuggestions, showHeader = true, onCollapse, isFullscreen, onToggleFullscreen, devAppUrl, storageKey, restoreActiveThread = true, scope, showScopeBadge, browserTabId, threadUrlSync, chatNotice, showTabBar = true, showPageNewChatButton = false, allowSettingsMode = true, agentPageHref, codeAccess, ...assistantChatProps }) {
|
|
380
380
|
const t = useT();
|
|
381
|
+
const feedbackEnabled = resolveFeedbackUrl() !== null;
|
|
381
382
|
const navigate = useNavigate();
|
|
382
383
|
const mounted = useClientOnly();
|
|
383
384
|
const keyPrefix = storageKey ? `:${storageKey}` : "";
|
|
@@ -639,18 +640,18 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
639
640
|
return null;
|
|
640
641
|
}
|
|
641
642
|
return (_jsx(ShareButton, { resourceType: "chat_thread", resourceId: activeTab.id, resourceTitle: activeTab.label || "Chat", shareUrl: getChatThreadShareUrl(activeTab.id), trigger: "icon", triggerClassName: "h-7 w-7" }));
|
|
642
|
-
})(), _jsx(FeedbackButton, { variant: "icon", side: "bottom", align: "end", chatSessionId: activeChatSessionId, chatStorageKey: storageKey, open: feedbackOpen, onOpenChange: setFeedbackOpen, trigger: _jsx("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "pointer-events-none absolute end-0 top-full h-px w-px opacity-0" }) }), mode === "chat" && (_jsx(IconTooltip, { content: t("agentPanel.newChat"), children: _jsx("button", { onClick: addTab, "aria-label": t("agentPanel.newChat"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) })), !onCollapse && mode === "cli" && canUseCodeTools && (_jsx(IconTooltip, { content: t("agentPanel.newTerminal"), children: _jsx("button", { onClick: addCliTab, "aria-label": t("agentPanel.newTerminal"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) })), agentPageHref &&
|
|
643
|
+
})(), feedbackEnabled ? (_jsx(FeedbackButton, { variant: "icon", side: "bottom", align: "end", chatSessionId: activeChatSessionId, chatStorageKey: storageKey, open: feedbackOpen, onOpenChange: setFeedbackOpen, trigger: _jsx("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "pointer-events-none absolute end-0 top-full h-px w-px opacity-0" }) })) : null, mode === "chat" && (_jsx(IconTooltip, { content: t("agentPanel.newChat"), children: _jsx("button", { onClick: addTab, "aria-label": t("agentPanel.newChat"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) })), !onCollapse && mode === "cli" && canUseCodeTools && (_jsx(IconTooltip, { content: t("agentPanel.newTerminal"), children: _jsx("button", { onClick: addCliTab, "aria-label": t("agentPanel.newTerminal"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconPlus, { size: 14 }) }) })), agentPageHref &&
|
|
643
644
|
shouldShowAgentPanelFullViewAction(agentPageHref, mode) && (_jsx(IconTooltip, { content: t("agentPanel.openFullView"), children: _jsx(Link, { to: agentPageHref, "aria-label": t("agentPanel.openFullView"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-accent/50 hover:text-foreground", children: _jsx(IconArrowsMaximize, { size: 14 }) }) })), _jsxs(DropdownMenu, { open: headerMenuOpen, onOpenChange: setHeaderMenuOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { className: cn("flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", (headerMenuOpen || mode === "settings") &&
|
|
644
645
|
"bg-accent text-foreground"), "aria-label": t("agentPanel.panelOptions"), children: _jsx(IconDotsVertical, { size: 14 }) }) }), _jsxs(DropdownMenuContent, { align: "end", sideOffset: 6, className: "w-48", children: [onCollapse && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onSelect: onCollapse, children: [_jsx(IconLayoutSidebarRightCollapse, { size: 14, className: "shrink-0" }), t("agentPanel.collapseSidebar"), _jsx(DropdownMenuShortcut, { children: toggleSidebarHint })] }), _jsx(DropdownMenuSeparator, {})] })), onCollapse && mode === "chat" && (_jsxs(DropdownMenuItem, { onSelect: addTab, children: [_jsx(IconPlus, { size: 14, className: "shrink-0" }), t("agentPanel.newChat")] })), mode === "chat" && toggleHistory && (_jsxs(DropdownMenuItem, { onSelect: toggleHistory, children: [_jsx(IconHistory, { size: 14, className: "shrink-0" }), showHistory
|
|
645
646
|
? t("agentPanel.hideChats")
|
|
646
647
|
: t("agentPanel.allChats")] })), mode === "chat" && (_jsx(RunsTrayMenuItem, { pollMs: 0, limit: 12, showRecent: true, onOpenThread: openRunThread })), mode === "chat" && _jsx(DropdownMenuSeparator, {}), mode === "cli" && availableClis.length > 0 && (_jsxs(_Fragment, { children: [availableClis.map((cli) => (_jsxs(DropdownMenuItem, { onSelect: () => selectCli(cli.command), className: cn(cli.command === selectedCli
|
|
647
648
|
? "font-medium"
|
|
648
|
-
: "text-muted-foreground"), children: [cli.command === selectedCli ? (_jsx(IconCheck, { size: 12, className: "shrink-0" })) : (_jsx("span", { className: "w-3" })), cli.label] }, cli.command))), _jsx(DropdownMenuSeparator, {})] })), allowSettingsMode && (_jsxs(DropdownMenuItem, { onSelect: () => switchMode("settings"), className: cn(mode === "settings" ? "font-medium" : "text-muted-foreground"), children: [_jsx(IconSettings, { size: 14, className: "shrink-0" }), t("agentPanel.settings")] })), _jsxs(DropdownMenuItem, { onSelect: () => {
|
|
649
|
+
: "text-muted-foreground"), children: [cli.command === selectedCli ? (_jsx(IconCheck, { size: 12, className: "shrink-0" })) : (_jsx("span", { className: "w-3" })), cli.label] }, cli.command))), _jsx(DropdownMenuSeparator, {})] })), allowSettingsMode && (_jsxs(DropdownMenuItem, { onSelect: () => switchMode("settings"), className: cn(mode === "settings" ? "font-medium" : "text-muted-foreground"), children: [_jsx(IconSettings, { size: 14, className: "shrink-0" }), t("agentPanel.settings")] })), feedbackEnabled ? (_jsxs(DropdownMenuItem, { onSelect: () => {
|
|
649
650
|
// Defer past the closing DropdownMenu's focus-restore/dismiss-layer
|
|
650
651
|
// teardown, otherwise it can immediately dismiss the Popover we're
|
|
651
652
|
// opening in the same tick (Radix nested-overlay race).
|
|
652
653
|
setTimeout(() => setFeedbackOpen(true), 0);
|
|
653
|
-
}, children: [_jsx(IconMessageDots, { size: 14, className: "shrink-0" }), t("agentPanel.feedback")] }), onToggleFullscreen && (_jsxs(DropdownMenuItem, { onSelect: onToggleFullscreen, children: [isFullscreen ? (_jsx(IconArrowsMinimize, { size: 14, className: "shrink-0" })) : (_jsx(IconArrowsMaximize, { size: 14, className: "shrink-0" })), isFullscreen
|
|
654
|
+
}, children: [_jsx(IconMessageDots, { size: 14, className: "shrink-0" }), t("agentPanel.feedback")] })) : null, onToggleFullscreen && (_jsxs(DropdownMenuItem, { onSelect: onToggleFullscreen, children: [isFullscreen ? (_jsx(IconArrowsMinimize, { size: 14, className: "shrink-0" })) : (_jsx(IconArrowsMaximize, { size: 14, className: "shrink-0" })), isFullscreen
|
|
654
655
|
? t("agentPanel.exitFullscreen")
|
|
655
656
|
: t("agentPanel.fullscreen")] })), ((mode === "chat" && activeTabId) ||
|
|
656
657
|
(mode === "cli" && canUseCodeTools && activeCliTab)) && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), mode === "chat" ? (shouldShowAgentPanelChatTabBar(tabs, activeTabId) ? (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onSelect: () => closeTab(activeTabId), children: [_jsx(IconX, { size: 14, className: "shrink-0" }), t("agentPanel.closeTab"), _jsx(DropdownMenuShortcut, { children: closeTabHint })] }), _jsx(DropdownMenuItem, { onSelect: () => closeOtherTabs(activeTabId), children: t("agentPanel.closeOtherTabs") }), _jsxs(DropdownMenuItem, { onSelect: () => closeAllTabs(), children: [t("agentPanel.closeAllTabs"), _jsx(DropdownMenuShortcut, { children: closeAllTabsHint })] })] })) : (_jsxs(DropdownMenuItem, { onSelect: clearActiveTab, children: [_jsx(IconX, { size: 14, className: "shrink-0" }), t("agentPanel.clearChat")] }))) : (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onSelect: () => closeCliTab(activeCliTab), children: [_jsx(IconX, { size: 14, className: "shrink-0" }), t("agentPanel.closeTab"), _jsx(DropdownMenuShortcut, { children: closeTabHint })] }), _jsx(DropdownMenuItem, { onSelect: () => closeOtherCliTabs(activeCliTab), children: t("agentPanel.closeOtherTabs") }), _jsxs(DropdownMenuItem, { onSelect: () => closeAllCliTabs(), children: [t("agentPanel.closeAllTabs"), _jsx(DropdownMenuShortcut, { children: closeAllTabsHint })] })] }))] }))] })] }), onCollapse && (_jsx(IconTooltip, { content: t("agentPanel.collapseSidebar"), children: _jsx("button", { type: "button", onClick: onCollapse, "aria-label": t("agentPanel.collapseSidebar"), className: "flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-accent/50", children: _jsx(IconX, { size: 14 }) }) }))] })), [
|
|
@@ -665,6 +666,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
665
666
|
closeOtherCliTabs,
|
|
666
667
|
closeTabHint,
|
|
667
668
|
feedbackOpen,
|
|
669
|
+
feedbackEnabled,
|
|
668
670
|
getChatThreadShareUrl,
|
|
669
671
|
headerMenuOpen,
|
|
670
672
|
isFullscreen,
|
|
@@ -691,26 +693,35 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
691
693
|
addTab();
|
|
692
694
|
}, className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-border bg-background/95 px-2.5 text-xs font-medium text-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(IconPlus, { size: 14 }), _jsx("span", { children: t("agentPanel.newChat") })] })] }) })] }));
|
|
693
695
|
}, [getChatThreadShareUrl, t]);
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
const activeTabRefCb = useCallback((el) => {
|
|
697
|
-
if (!el)
|
|
698
|
-
return;
|
|
696
|
+
const activeTabResizeObserverRef = useRef(null);
|
|
697
|
+
const scrollActiveTabIntoView = useCallback((el) => {
|
|
699
698
|
const container = el.parentElement;
|
|
700
699
|
if (!container)
|
|
701
700
|
return;
|
|
702
|
-
// Use rAF so layout is settled after React commit
|
|
703
701
|
requestAnimationFrame(() => {
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
container.scrollLeft += tabRect.left - containerRect.left;
|
|
708
|
-
}
|
|
709
|
-
else if (tabRect.right > containerRect.right) {
|
|
710
|
-
container.scrollLeft += tabRect.right - containerRect.right;
|
|
711
|
-
}
|
|
702
|
+
const delta = getActiveTabScrollDelta(container.getBoundingClientRect(), el.getBoundingClientRect());
|
|
703
|
+
if (delta !== 0)
|
|
704
|
+
container.scrollLeft += delta;
|
|
712
705
|
});
|
|
713
706
|
}, []);
|
|
707
|
+
// The sidebar stays mounted while closed and animates its width on open, so
|
|
708
|
+
// the active tab ref alone can run before the overflow container is usable.
|
|
709
|
+
const activeTabRefCb = useCallback((el) => {
|
|
710
|
+
activeTabResizeObserverRef.current?.disconnect();
|
|
711
|
+
activeTabResizeObserverRef.current = null;
|
|
712
|
+
if (!el)
|
|
713
|
+
return;
|
|
714
|
+
const container = el.parentElement;
|
|
715
|
+
if (!container)
|
|
716
|
+
return;
|
|
717
|
+
const observer = typeof ResizeObserver === "undefined"
|
|
718
|
+
? null
|
|
719
|
+
: new ResizeObserver(() => scrollActiveTabIntoView(el));
|
|
720
|
+
observer?.observe(container);
|
|
721
|
+
activeTabResizeObserverRef.current = observer;
|
|
722
|
+
scrollActiveTabIntoView(el);
|
|
723
|
+
}, [scrollActiveTabIntoView]);
|
|
724
|
+
useEffect(() => () => activeTabResizeObserverRef.current?.disconnect(), []);
|
|
714
725
|
const renderChatHeader = useCallback(({ tabs, activeTabId, activeTabMessageCount, setActiveTabId, addTab, clearActiveTab, closeTab, closeOtherTabs, closeAllTabs, showHistory, toggleHistory, }) => {
|
|
715
726
|
const { activeTab, childTabs, focusParentId, hasSubTabs, mainTabs } = getAgentPanelChatTabGroups(tabs, activeTabId);
|
|
716
727
|
const showSidebarChatTabs = Boolean(onCollapse) &&
|
|
@@ -870,6 +881,15 @@ const SIDEBAR_OVERLAY_Z_INDEX = 70;
|
|
|
870
881
|
const SIDEBAR_FULLSCREEN_Z_INDEX = 90;
|
|
871
882
|
/** Shared max width of the centered fullscreen chat column and composer. */
|
|
872
883
|
const FULLSCREEN_CHAT_COLUMN_MAX_PX = 684;
|
|
884
|
+
export function getActiveTabScrollDelta(containerRect, tabRect, margin = 24) {
|
|
885
|
+
if (tabRect.left < containerRect.left + margin) {
|
|
886
|
+
return tabRect.left - containerRect.left - margin;
|
|
887
|
+
}
|
|
888
|
+
if (tabRect.right > containerRect.right - margin) {
|
|
889
|
+
return tabRect.right - containerRect.right + margin;
|
|
890
|
+
}
|
|
891
|
+
return 0;
|
|
892
|
+
}
|
|
873
893
|
function ResizeHandle({ position, onDrag, onResizeStart, onResizeEnd, }) {
|
|
874
894
|
const ref = useRef(null);
|
|
875
895
|
const dragging = useRef(false);
|