@agent-native/core 0.118.0 → 0.118.1
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/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +32 -10
- package/corpus/core/src/cli/index.ts +18 -10
- package/corpus/core/src/cli/multi-frontier-runs.ts +5 -3
- package/corpus/core/src/cli/templates-meta.ts +0 -12
- package/corpus/core/src/cli/workspace-dev.ts +1 -1
- package/corpus/core/src/client/AgentPanel.tsx +9 -1
- package/corpus/core/src/client/RunStuckBanner.tsx +39 -47
- package/corpus/core/src/client/chat/action-chat-ui-surface.tsx +32 -0
- package/corpus/core/src/client/chat/message-components.tsx +53 -8
- package/corpus/core/src/client/chat/tool-call-display.tsx +24 -9
- package/corpus/core/src/client/chat/widgets/InlineExtensionWidget.tsx +0 -1
- package/corpus/core/src/client/chat/widgets/builtin-tool-renderers.tsx +7 -3
- package/corpus/core/src/client/conversation/AgentConversation.tsx +12 -1
- package/corpus/core/src/client/error-capture.ts +2 -6
- package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +20 -14
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +5 -1
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +7 -17
- package/corpus/core/src/client/resources/mcp-integration-logos.ts +2 -2
- package/corpus/core/src/client/route-chunk-recovery.ts +5 -3
- package/corpus/core/src/client/session-replay.ts +3 -3
- package/corpus/core/src/client/settings/SettingsPanel.tsx +15 -6
- package/corpus/core/src/client/transcription/use-live-transcription.ts +64 -45
- package/corpus/core/src/deploy/build.ts +2 -1
- package/corpus/core/src/guards/db-tool-scoping.ts +1 -1
- package/corpus/core/src/integrations/adapters/slack.ts +84 -5
- package/corpus/core/src/integrations/index.ts +5 -1
- package/corpus/core/src/localization/default-messages.ts +1 -1
- package/corpus/core/src/mcp-client/oauth-routes.ts +45 -12
- package/corpus/core/src/server/realtime-voice.ts +4 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
- package/corpus/core/src/terminal/cli-registry.ts +1 -1
- package/corpus/core/src/vite/client.ts +166 -1
- package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +13 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +10 -0
- package/corpus/templates/analytics/changelog/2026-07-22-show-a-useful-error-when-saving-a-dashboard-view-fails.md +6 -0
- package/corpus/templates/brain/app/routes/sources.tsx +181 -114
- package/corpus/templates/clips/AGENTS.md +8 -6
- package/corpus/templates/clips/actions/request-transcript.ts +90 -420
- package/corpus/templates/clips/actions/save-browser-transcript.ts +11 -28
- package/corpus/templates/clips/app/components/capture-install-options.tsx +5 -3
- package/corpus/templates/clips/app/components/player/transcript-panel.tsx +3 -136
- package/corpus/templates/clips/app/lib/capture-install-options.ts +15 -4
- package/corpus/templates/clips/app/routes/download.tsx +3 -2
- package/corpus/templates/clips/changelog/2026-07-22-fixed-an-intermittent-hydration-error-on-the-download-page.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-22-fixed-transcript-generation-when-native-speech-capture-retur.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-22-transcript-generation-now-retries-with-backup-speech-recogni.md +6 -0
- package/corpus/templates/clips/server/lib/public-agent-context.ts +2 -2
- package/corpus/templates/clips/server/register-secrets.ts +7 -6
- package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +16 -84
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +13 -7
- package/corpus/templates/content/app/components/editor/extensions/ImageBlock.tsx +2 -2
- package/corpus/templates/content/app/i18n-data.ts +10 -0
- package/corpus/templates/design/server/lib/fig-file-decoder.ts +1 -0
- package/corpus/templates/plan/app/entry.client.tsx +3 -0
- package/corpus/templates/plan/changelog/2026-07-22-recover-stale-pages-after-a-deployment-refresh-automatically.md +6 -0
- package/corpus/templates/slides/app/hooks/use-agent-generating.ts +10 -3
- package/corpus/templates/slides/app/pages/Index.tsx +1 -0
- package/corpus/templates/slides/changelog/2026-07-22-new-deck-prompts-now-open-in-their-own-visible-chat-thread.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +9 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/composer/PromptComposer.tsx +5 -1
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +119 -31
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +30 -0
- package/corpus/toolkit/src/conformance/runner.tsx +153 -1
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +13 -2
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +20 -0
- package/corpus/toolkit/src/editor/index.ts +2 -0
- package/corpus/toolkit/src/styles.css +52 -23
- package/dist/a2a/client.d.ts +3 -1
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +17 -12
- package/dist/a2a/client.js.map +1 -1
- package/dist/cli/index.js +18 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/multi-frontier-runs.js +3 -3
- package/dist/cli/multi-frontier-runs.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +0 -12
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspace-dev.js +1 -1
- package/dist/cli/workspace-dev.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +4 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/RunStuckBanner.d.ts +3 -5
- package/dist/client/RunStuckBanner.d.ts.map +1 -1
- package/dist/client/RunStuckBanner.js +17 -18
- package/dist/client/RunStuckBanner.js.map +1 -1
- package/dist/client/chat/action-chat-ui-surface.d.ts +8 -0
- package/dist/client/chat/action-chat-ui-surface.d.ts.map +1 -0
- package/dist/client/chat/action-chat-ui-surface.js +10 -0
- package/dist/client/chat/action-chat-ui-surface.js.map +1 -0
- package/dist/client/chat/message-components.d.ts +3 -0
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +40 -7
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +3 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +13 -9
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/widgets/InlineExtensionWidget.d.ts.map +1 -1
- package/dist/client/chat/widgets/InlineExtensionWidget.js +1 -1
- package/dist/client/chat/widgets/InlineExtensionWidget.js.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.js +5 -3
- package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
- package/dist/client/conversation/AgentConversation.js +3 -2
- package/dist/client/conversation/AgentConversation.js.map +1 -1
- package/dist/client/error-capture.d.ts.map +1 -1
- package/dist/client/error-capture.js +2 -2
- package/dist/client/error-capture.js.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.d.ts +1 -0
- package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.js +9 -8
- package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +3 -1
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- 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 +4 -17
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/mcp-integration-logos.js +2 -2
- package/dist/client/resources/mcp-integration-logos.js.map +1 -1
- package/dist/client/route-chunk-recovery.d.ts.map +1 -1
- package/dist/client/route-chunk-recovery.js +5 -3
- package/dist/client/route-chunk-recovery.js.map +1 -1
- package/dist/client/session-replay.js +3 -3
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +2 -2
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/transcription/use-live-transcription.d.ts +3 -3
- package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
- package/dist/client/transcription/use-live-transcription.js +22 -11
- package/dist/client/transcription/use-live-transcription.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +1 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/guards/db-tool-scoping.js +1 -1
- package/dist/guards/db-tool-scoping.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts +1 -0
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +61 -5
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/index.d.ts +1 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/localization/default-messages.js +1 -1
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp-client/oauth-routes.d.ts +3 -0
- package/dist/mcp-client/oauth-routes.d.ts.map +1 -1
- package/dist/mcp-client/oauth-routes.js +41 -12
- package/dist/mcp-client/oauth-routes.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
- package/dist/provider-api/actions/provider-api.d.ts +11 -11
- package/dist/secrets/routes.d.ts +6 -6
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +1 -1
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
- package/dist/terminal/cli-registry.js +1 -1
- package/dist/terminal/cli-registry.js.map +1 -1
- package/dist/vite/client.d.ts +8 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +113 -2
- package/dist/vite/client.js.map +1 -1
- package/package.json +2 -2
- package/src/a2a/client.ts +32 -10
- package/src/cli/index.ts +18 -10
- package/src/cli/multi-frontier-runs.ts +5 -3
- package/src/cli/templates-meta.ts +0 -12
- package/src/cli/workspace-dev.ts +1 -1
- package/src/client/AgentPanel.tsx +9 -1
- package/src/client/RunStuckBanner.tsx +39 -47
- package/src/client/chat/action-chat-ui-surface.tsx +32 -0
- package/src/client/chat/message-components.tsx +53 -8
- package/src/client/chat/tool-call-display.tsx +24 -9
- package/src/client/chat/widgets/InlineExtensionWidget.tsx +0 -1
- package/src/client/chat/widgets/builtin-tool-renderers.tsx +7 -3
- package/src/client/conversation/AgentConversation.tsx +12 -1
- package/src/client/error-capture.ts +2 -6
- package/src/client/resources/McpConnectionSuggestion.tsx +20 -14
- package/src/client/resources/ResourcesPanel.tsx +5 -1
- package/src/client/resources/mcp-integration-catalog.ts +7 -17
- package/src/client/resources/mcp-integration-logos.ts +2 -2
- package/src/client/route-chunk-recovery.ts +5 -3
- package/src/client/session-replay.ts +3 -3
- package/src/client/settings/SettingsPanel.tsx +15 -6
- package/src/client/transcription/use-live-transcription.ts +64 -45
- package/src/deploy/build.ts +2 -1
- package/src/guards/db-tool-scoping.ts +1 -1
- package/src/integrations/adapters/slack.ts +84 -5
- package/src/integrations/index.ts +5 -1
- package/src/localization/default-messages.ts +1 -1
- package/src/mcp-client/oauth-routes.ts +45 -12
- package/src/server/realtime-voice.ts +4 -1
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
- package/src/terminal/cli-registry.ts +1 -1
- package/src/vite/client.ts +166 -1
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +0 -115
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
- package/corpus/templates/crm/.agents/skills/crm/SKILL.md +0 -128
- package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +0 -220
- package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +0 -169
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +0 -100
- package/corpus/templates/crm/.env.example +0 -5
- package/corpus/templates/crm/AGENTS.md +0 -120
- package/corpus/templates/crm/CHANGELOG.md +0 -1
- package/corpus/templates/crm/DEVELOPING.md +0 -66
- package/corpus/templates/crm/README.md +0 -106
- package/corpus/templates/crm/_gitignore +0 -12
- package/corpus/templates/crm/actions/_crm-action-utils.ts +0 -87
- package/corpus/templates/crm/actions/_crm-dashboard.ts +0 -69
- package/corpus/templates/crm/actions/_crm-data-program-actions.ts +0 -15
- package/corpus/templates/crm/actions/_crm-signal-utils.ts +0 -79
- package/corpus/templates/crm/actions/apply-crm-proposals.ts +0 -203
- package/corpus/templates/crm/actions/attach-call-evidence.ts +0 -170
- package/corpus/templates/crm/actions/configure-crm-connection.ts +0 -126
- package/corpus/templates/crm/actions/configure-native-crm.ts +0 -44
- package/corpus/templates/crm/actions/create-crm-record.ts +0 -148
- package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +0 -58
- package/corpus/templates/crm/actions/delete-staged-dataset.ts +0 -14
- package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +0 -36
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +0 -35
- package/corpus/templates/crm/actions/get-crm-dashboard.ts +0 -14
- package/corpus/templates/crm/actions/get-crm-overview.ts +0 -13
- package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +0 -61
- package/corpus/templates/crm/actions/get-crm-record.ts +0 -75
- package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +0 -81
- package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +0 -15
- package/corpus/templates/crm/actions/list-crm-dashboards.ts +0 -15
- package/corpus/templates/crm/actions/list-crm-proposals.ts +0 -31
- package/corpus/templates/crm/actions/list-crm-records.ts +0 -79
- package/corpus/templates/crm/actions/list-crm-saved-views.ts +0 -15
- package/corpus/templates/crm/actions/list-crm-signal-hits.ts +0 -43
- package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +0 -32
- package/corpus/templates/crm/actions/list-crm-tasks.ts +0 -22
- package/corpus/templates/crm/actions/list-staged-datasets.ts +0 -14
- package/corpus/templates/crm/actions/list-workspace-connections.ts +0 -47
- package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +0 -87
- package/corpus/templates/crm/actions/manage-crm-task.ts +0 -132
- package/corpus/templates/crm/actions/navigate.ts +0 -63
- package/corpus/templates/crm/actions/provider-api-catalog.ts +0 -22
- package/corpus/templates/crm/actions/provider-api-docs.ts +0 -54
- package/corpus/templates/crm/actions/provider-api-request.ts +0 -92
- package/corpus/templates/crm/actions/query-staged-dataset.ts +0 -44
- package/corpus/templates/crm/actions/record-crm-call-insight.ts +0 -160
- package/corpus/templates/crm/actions/record-crm-smart-signal.ts +0 -150
- package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +0 -23
- package/corpus/templates/crm/actions/review-crm-signal.ts +0 -31
- package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +0 -103
- package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +0 -275
- package/corpus/templates/crm/actions/run.ts +0 -7
- package/corpus/templates/crm/actions/save-crm-dashboard.ts +0 -51
- package/corpus/templates/crm/actions/save-crm-saved-view.ts +0 -119
- package/corpus/templates/crm/actions/sync-crm.ts +0 -146
- package/corpus/templates/crm/actions/update-crm-record.ts +0 -510
- package/corpus/templates/crm/actions/view-screen.ts +0 -218
- package/corpus/templates/crm/agent-native.app-skill.json +0 -58
- package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +0 -158
- package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +0 -78
- package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +0 -226
- package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +0 -414
- package/corpus/templates/crm/app/components/crm/RecordActions.tsx +0 -510
- package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +0 -134
- package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +0 -362
- package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +0 -93
- package/corpus/templates/crm/app/components/crm/Surface.tsx +0 -97
- package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +0 -180
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +0 -112
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +0 -84
- package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/badge.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/button.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/card.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/dialog.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/input.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/label.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/select.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/sheet.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/skeleton.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/switch.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/table.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/tabs.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/textarea.tsx +0 -1
- package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +0 -17
- package/corpus/templates/crm/app/design-system.ts +0 -3
- package/corpus/templates/crm/app/entry.client.tsx +0 -16
- package/corpus/templates/crm/app/entry.server.tsx +0 -10
- package/corpus/templates/crm/app/global.css +0 -167
- package/corpus/templates/crm/app/hooks/use-navigation-state.ts +0 -60
- package/corpus/templates/crm/app/i18n/en-US.ts +0 -89
- package/corpus/templates/crm/app/i18n/index.ts +0 -34
- package/corpus/templates/crm/app/lib/dashboard.ts +0 -13
- package/corpus/templates/crm/app/lib/navigation.ts +0 -54
- package/corpus/templates/crm/app/lib/tab-id.ts +0 -1
- package/corpus/templates/crm/app/lib/types.ts +0 -172
- package/corpus/templates/crm/app/lib/utils.ts +0 -1
- package/corpus/templates/crm/app/root.tsx +0 -91
- package/corpus/templates/crm/app/routes/_index.tsx +0 -26
- package/corpus/templates/crm/app/routes/accounts.tsx +0 -41
- package/corpus/templates/crm/app/routes/agent.tsx +0 -5
- package/corpus/templates/crm/app/routes/ask.tsx +0 -53
- package/corpus/templates/crm/app/routes/dashboard.tsx +0 -118
- package/corpus/templates/crm/app/routes/opportunities.tsx +0 -41
- package/corpus/templates/crm/app/routes/people.tsx +0 -41
- package/corpus/templates/crm/app/routes/proposals.tsx +0 -266
- package/corpus/templates/crm/app/routes/records.$recordId.tsx +0 -35
- package/corpus/templates/crm/app/routes/settings.tsx +0 -63
- package/corpus/templates/crm/app/routes/setup.tsx +0 -308
- package/corpus/templates/crm/app/routes/tasks.tsx +0 -252
- package/corpus/templates/crm/app/routes/views.tsx +0 -333
- package/corpus/templates/crm/app/routes.ts +0 -17
- package/corpus/templates/crm/app/vite-env.d.ts +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-agent-native-crm.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-clips-call-evidence-review-recipe.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-find-and-review-evidence-grounded-call-signals-w.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-manage-keyword-and-smart-call-signal-trackers-fr.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-delegated-local-crm-automation.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-native-sql.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboard.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboards-now-install-correctly-from-the-crm-actio.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-21-salesforce-connection.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-22-crm-field-validation-now-explains-which-fields-cannot-be-edi.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-22-fixed-hubspot-contact-syncs-missing-records-updated-after-th.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-22-fixed-pipeline-dashboard-panels-so-their-opportunity-data-lo.md +0 -6
- package/corpus/templates/crm/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
- package/corpus/templates/crm/components.json +0 -20
- package/corpus/templates/crm/docs/architecture/crm-contract.md +0 -180
- package/corpus/templates/crm/learnings.defaults.md +0 -5
- package/corpus/templates/crm/package.json +0 -59
- package/corpus/templates/crm/public/favicon.svg +0 -1
- package/corpus/templates/crm/public/icon-180.svg +0 -1
- package/corpus/templates/crm/public/manifest.json +0 -11
- package/corpus/templates/crm/react-router.config.ts +0 -7
- package/corpus/templates/crm/server/crm/adapter.ts +0 -32
- package/corpus/templates/crm/server/crm/crm-field-firewall.ts +0 -64
- package/corpus/templates/crm/server/crm/crm-mirror.ts +0 -711
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +0 -1146
- package/corpus/templates/crm/server/crm/native-adapter.ts +0 -1715
- package/corpus/templates/crm/server/crm/read-through.ts +0 -207
- package/corpus/templates/crm/server/crm/salesforce-adapter.ts +0 -1255
- package/corpus/templates/crm/server/db/crm-store.ts +0 -1170
- package/corpus/templates/crm/server/db/index.ts +0 -169
- package/corpus/templates/crm/server/db/schema.ts +0 -441
- package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +0 -65
- package/corpus/templates/crm/server/lib/intelligence/evidence.ts +0 -105
- package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +0 -100
- package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +0 -144
- package/corpus/templates/crm/server/lib/intelligence/summary.ts +0 -141
- package/corpus/templates/crm/server/lib/provider-api.ts +0 -64
- package/corpus/templates/crm/server/middleware/auth.ts +0 -4
- package/corpus/templates/crm/server/plugins/agent-chat.ts +0 -68
- package/corpus/templates/crm/server/plugins/auth.ts +0 -14
- package/corpus/templates/crm/server/plugins/core-routes.ts +0 -17
- package/corpus/templates/crm/server/plugins/db.ts +0 -454
- package/corpus/templates/crm/server/routes/[...page].get.ts +0 -5
- package/corpus/templates/crm/shared/crm-automation-recipes.ts +0 -132
- package/corpus/templates/crm/shared/crm-contract.ts +0 -254
- package/corpus/templates/crm/shared/crm-sales-config.ts +0 -63
- package/corpus/templates/crm/ssr-entry.ts +0 -11
- package/corpus/templates/crm/tsconfig.json +0 -24
- package/corpus/templates/crm/vite.config.ts +0 -15
- package/corpus/templates/crm/vitest.config.ts +0 -5
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { defineAction } from "@agent-native/core/action";
|
|
2
|
-
import { writeAppState } from "@agent-native/core/application-state";
|
|
3
|
-
import { accessFilter } from "@agent-native/core/sharing";
|
|
4
|
-
import { and, eq, inArray } from "drizzle-orm";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
|
|
7
|
-
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
-
import { DEFAULT_CRM_DETECTORS } from "../server/lib/intelligence/default-detectors.js";
|
|
9
|
-
import { runKeywordDetector } from "../server/lib/intelligence/keyword-detector.js";
|
|
10
|
-
import { buildSmartDetectorPrompt } from "../server/lib/intelligence/smart-detector.js";
|
|
11
|
-
import { buildCallEvidenceSummaryPrompt } from "../server/lib/intelligence/summary.js";
|
|
12
|
-
import {
|
|
13
|
-
crmSignalIdempotencyKey,
|
|
14
|
-
evidenceExcerpts,
|
|
15
|
-
loadCrmSignalEvidence,
|
|
16
|
-
} from "./_crm-signal-utils.js";
|
|
17
|
-
|
|
18
|
-
export default defineAction({
|
|
19
|
-
description:
|
|
20
|
-
"Run deterministic keyword detectors and prepare bounded smart/summary requests for delegation through agent chat. Never calls an LLM or stores transcript bodies.",
|
|
21
|
-
schema: z.object({
|
|
22
|
-
recordId: z.string().trim().min(1).max(128),
|
|
23
|
-
evidenceIds: z.array(z.string().trim().min(1).max(128)).max(20).optional(),
|
|
24
|
-
trackerIds: z.array(z.string().trim().min(1).max(128)).max(20).optional(),
|
|
25
|
-
includeSummary: z.boolean().default(true),
|
|
26
|
-
idempotencyKey: z.string().trim().min(1).max(180),
|
|
27
|
-
}),
|
|
28
|
-
run: async (args, ctx) => {
|
|
29
|
-
const evidence = await loadCrmSignalEvidence({
|
|
30
|
-
recordId: args.recordId,
|
|
31
|
-
evidenceIds: args.evidenceIds,
|
|
32
|
-
role: "editor",
|
|
33
|
-
});
|
|
34
|
-
if (!evidence.length)
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Attach bounded Clips call evidence before running signal detectors.",
|
|
37
|
-
);
|
|
38
|
-
const excerpts = evidenceExcerpts(evidence);
|
|
39
|
-
if (!excerpts.length)
|
|
40
|
-
throw new Error(
|
|
41
|
-
"The attached evidence has no bounded excerpt to analyze.",
|
|
42
|
-
);
|
|
43
|
-
await ensureDefaultTrackers(ctx);
|
|
44
|
-
const filters = [
|
|
45
|
-
eq(schema.crmSignalTrackers.enabled, true),
|
|
46
|
-
accessFilter(schema.crmSignalTrackers, schema.crmSignalTrackerShares),
|
|
47
|
-
];
|
|
48
|
-
if (args.trackerIds?.length)
|
|
49
|
-
filters.push(inArray(schema.crmSignalTrackers.id, args.trackerIds));
|
|
50
|
-
const trackers = await getDb()
|
|
51
|
-
.select()
|
|
52
|
-
.from(schema.crmSignalTrackers)
|
|
53
|
-
.where(and(...filters))
|
|
54
|
-
.limit(20);
|
|
55
|
-
const now = new Date().toISOString();
|
|
56
|
-
const keywordRows: Array<typeof schema.crmSignals.$inferInsert> = [];
|
|
57
|
-
const delegated: Array<{
|
|
58
|
-
runId: string;
|
|
59
|
-
trackerId?: string;
|
|
60
|
-
kind: "smart" | "summary";
|
|
61
|
-
prompt: string;
|
|
62
|
-
}> = [];
|
|
63
|
-
|
|
64
|
-
for (const tracker of trackers) {
|
|
65
|
-
const runKey = await crmSignalIdempotencyKey(
|
|
66
|
-
ctx,
|
|
67
|
-
args.recordId,
|
|
68
|
-
`${args.idempotencyKey}:run:${tracker.id}`,
|
|
69
|
-
);
|
|
70
|
-
const [existingRun] = await getDb()
|
|
71
|
-
.select()
|
|
72
|
-
.from(schema.crmSignalRuns)
|
|
73
|
-
.where(
|
|
74
|
-
and(
|
|
75
|
-
eq(schema.crmSignalRuns.idempotencyKey, runKey.key),
|
|
76
|
-
accessFilter(schema.crmSignalRuns, schema.crmSignalRunShares),
|
|
77
|
-
),
|
|
78
|
-
)
|
|
79
|
-
.limit(1);
|
|
80
|
-
if (existingRun) continue;
|
|
81
|
-
const runId = crypto.randomUUID();
|
|
82
|
-
if (tracker.kind === "keyword") {
|
|
83
|
-
const candidates = runKeywordDetector(
|
|
84
|
-
{
|
|
85
|
-
id: tracker.id,
|
|
86
|
-
name: tracker.name,
|
|
87
|
-
kind: "keyword",
|
|
88
|
-
keywords: safeKeywords(tracker.keywordsJson),
|
|
89
|
-
},
|
|
90
|
-
excerpts,
|
|
91
|
-
);
|
|
92
|
-
for (const candidate of candidates) {
|
|
93
|
-
const signalKey = await crmSignalIdempotencyKey(
|
|
94
|
-
ctx,
|
|
95
|
-
args.recordId,
|
|
96
|
-
`${args.idempotencyKey}:signal:${tracker.id}:${candidate.evidenceRef}:${candidate.quote}`,
|
|
97
|
-
);
|
|
98
|
-
keywordRows.push({
|
|
99
|
-
id: crypto.randomUUID(),
|
|
100
|
-
runId,
|
|
101
|
-
trackerId: tracker.id,
|
|
102
|
-
recordId: args.recordId,
|
|
103
|
-
evidenceId: candidate.evidenceRef,
|
|
104
|
-
kind: "moment",
|
|
105
|
-
label: tracker.name,
|
|
106
|
-
quote: candidate.quote,
|
|
107
|
-
speaker: candidate.speaker ?? null,
|
|
108
|
-
startSeconds: candidate.startSeconds,
|
|
109
|
-
endSeconds: candidate.endSeconds ?? null,
|
|
110
|
-
summary: "",
|
|
111
|
-
confidence: candidate.confidence,
|
|
112
|
-
detector: "keyword",
|
|
113
|
-
model: null,
|
|
114
|
-
modelVersion: null,
|
|
115
|
-
reviewStatus: "unreviewed",
|
|
116
|
-
idempotencyKey: signalKey.key,
|
|
117
|
-
...signalKey.scope,
|
|
118
|
-
createdAt: now,
|
|
119
|
-
updatedAt: now,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
await getDb().transaction(async (tx) => {
|
|
123
|
-
await tx.insert(schema.crmSignalRuns).values({
|
|
124
|
-
id: runId,
|
|
125
|
-
trackerId: tracker.id,
|
|
126
|
-
recordId: args.recordId,
|
|
127
|
-
kind: "keyword",
|
|
128
|
-
status: "completed",
|
|
129
|
-
evidenceCount: evidence.length,
|
|
130
|
-
idempotencyKey: runKey.key,
|
|
131
|
-
completedAt: now,
|
|
132
|
-
...runKey.scope,
|
|
133
|
-
createdAt: now,
|
|
134
|
-
updatedAt: now,
|
|
135
|
-
});
|
|
136
|
-
const rows = keywordRows.filter((row) => row.runId === runId);
|
|
137
|
-
if (rows.length) await tx.insert(schema.crmSignals).values(rows);
|
|
138
|
-
});
|
|
139
|
-
} else {
|
|
140
|
-
const prompt = buildSmartDetectorPrompt(
|
|
141
|
-
{
|
|
142
|
-
id: tracker.id,
|
|
143
|
-
name: tracker.name,
|
|
144
|
-
description: tracker.description,
|
|
145
|
-
classifierPrompt: tracker.classifierPrompt,
|
|
146
|
-
},
|
|
147
|
-
excerpts,
|
|
148
|
-
);
|
|
149
|
-
if (!prompt) continue;
|
|
150
|
-
await getDb()
|
|
151
|
-
.insert(schema.crmSignalRuns)
|
|
152
|
-
.values({
|
|
153
|
-
id: runId,
|
|
154
|
-
trackerId: tracker.id,
|
|
155
|
-
recordId: args.recordId,
|
|
156
|
-
kind: "smart",
|
|
157
|
-
status: "queued",
|
|
158
|
-
evidenceCount: evidence.length,
|
|
159
|
-
idempotencyKey: runKey.key,
|
|
160
|
-
...runKey.scope,
|
|
161
|
-
createdAt: now,
|
|
162
|
-
updatedAt: now,
|
|
163
|
-
});
|
|
164
|
-
delegated.push({ runId, trackerId: tracker.id, kind: "smart", prompt });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (args.includeSummary) {
|
|
169
|
-
const runKey = await crmSignalIdempotencyKey(
|
|
170
|
-
ctx,
|
|
171
|
-
args.recordId,
|
|
172
|
-
`${args.idempotencyKey}:run:summary`,
|
|
173
|
-
);
|
|
174
|
-
const [existing] = await getDb()
|
|
175
|
-
.select({ id: schema.crmSignalRuns.id })
|
|
176
|
-
.from(schema.crmSignalRuns)
|
|
177
|
-
.where(
|
|
178
|
-
and(
|
|
179
|
-
eq(schema.crmSignalRuns.idempotencyKey, runKey.key),
|
|
180
|
-
accessFilter(schema.crmSignalRuns, schema.crmSignalRunShares),
|
|
181
|
-
),
|
|
182
|
-
)
|
|
183
|
-
.limit(1);
|
|
184
|
-
if (!existing) {
|
|
185
|
-
const runId = crypto.randomUUID();
|
|
186
|
-
const prompt = buildCallEvidenceSummaryPrompt(
|
|
187
|
-
`CRM record ${args.recordId}`,
|
|
188
|
-
excerpts,
|
|
189
|
-
);
|
|
190
|
-
if (prompt) {
|
|
191
|
-
await getDb()
|
|
192
|
-
.insert(schema.crmSignalRuns)
|
|
193
|
-
.values({
|
|
194
|
-
id: runId,
|
|
195
|
-
trackerId: null,
|
|
196
|
-
recordId: args.recordId,
|
|
197
|
-
kind: "summary",
|
|
198
|
-
status: "queued",
|
|
199
|
-
evidenceCount: evidence.length,
|
|
200
|
-
idempotencyKey: runKey.key,
|
|
201
|
-
...runKey.scope,
|
|
202
|
-
createdAt: now,
|
|
203
|
-
updatedAt: now,
|
|
204
|
-
});
|
|
205
|
-
delegated.push({ runId, kind: "summary", prompt });
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
for (const request of delegated) {
|
|
211
|
-
await writeAppState(`crm-signal-agent-request-${request.runId}`, {
|
|
212
|
-
runId: request.runId,
|
|
213
|
-
recordId: args.recordId,
|
|
214
|
-
trackerId: request.trackerId,
|
|
215
|
-
kind: request.kind,
|
|
216
|
-
evidenceIds: evidence.map((item) => item.id),
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
keywordSignalsCreated: keywordRows.length,
|
|
221
|
-
delegatedRequests: delegated,
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
function safeKeywords(value: string): string[] {
|
|
227
|
-
try {
|
|
228
|
-
const parsed = JSON.parse(value) as unknown;
|
|
229
|
-
return Array.isArray(parsed)
|
|
230
|
-
? parsed
|
|
231
|
-
.filter((item): item is string => typeof item === "string")
|
|
232
|
-
.slice(0, 40)
|
|
233
|
-
: [];
|
|
234
|
-
} catch {
|
|
235
|
-
return [];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async function ensureDefaultTrackers(
|
|
240
|
-
ctx: Parameters<typeof crmSignalIdempotencyKey>[0],
|
|
241
|
-
) {
|
|
242
|
-
const db = getDb();
|
|
243
|
-
const [existing] = await db
|
|
244
|
-
.select({ id: schema.crmSignalTrackers.id })
|
|
245
|
-
.from(schema.crmSignalTrackers)
|
|
246
|
-
.where(
|
|
247
|
-
accessFilter(schema.crmSignalTrackers, schema.crmSignalTrackerShares),
|
|
248
|
-
)
|
|
249
|
-
.limit(1);
|
|
250
|
-
if (existing) return;
|
|
251
|
-
const now = new Date().toISOString();
|
|
252
|
-
for (const detector of DEFAULT_CRM_DETECTORS) {
|
|
253
|
-
const identity = await crmSignalIdempotencyKey(
|
|
254
|
-
ctx,
|
|
255
|
-
"defaults",
|
|
256
|
-
detector.id,
|
|
257
|
-
);
|
|
258
|
-
await db
|
|
259
|
-
.insert(schema.crmSignalTrackers)
|
|
260
|
-
.values({
|
|
261
|
-
id: `default-${identity.key.slice(-32)}`,
|
|
262
|
-
name: detector.name,
|
|
263
|
-
description: detector.description,
|
|
264
|
-
kind: detector.kind,
|
|
265
|
-
keywordsJson: JSON.stringify(detector.keywords ?? []),
|
|
266
|
-
classifierPrompt: detector.classifierPrompt ?? "",
|
|
267
|
-
enabled: true,
|
|
268
|
-
isDefault: true,
|
|
269
|
-
...identity.scope,
|
|
270
|
-
createdAt: now,
|
|
271
|
-
updatedAt: now,
|
|
272
|
-
})
|
|
273
|
-
.onConflictDoNothing();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { defineAction, type ActionRunContext } from "@agent-native/core/action";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
crmDashboardStore,
|
|
6
|
-
type CrmDashboardConfig,
|
|
7
|
-
} from "../server/db/index.js";
|
|
8
|
-
import { requireDashboardAccess } from "./_crm-dashboard.js";
|
|
9
|
-
|
|
10
|
-
const configSchema = z.object({
|
|
11
|
-
version: z.literal(1),
|
|
12
|
-
panels: z
|
|
13
|
-
.array(
|
|
14
|
-
z.object({
|
|
15
|
-
id: z.string().trim().min(1).max(120),
|
|
16
|
-
title: z.string().trim().min(1).max(160),
|
|
17
|
-
source: z.literal("program"),
|
|
18
|
-
query: z.string().trim().min(1).max(2_000),
|
|
19
|
-
chartType: z.enum(["metric", "bar", "table"]),
|
|
20
|
-
}),
|
|
21
|
-
)
|
|
22
|
-
.min(1)
|
|
23
|
-
.max(12)
|
|
24
|
-
.refine(
|
|
25
|
-
(panels) =>
|
|
26
|
-
new Set(panels.map((panel) => panel.id)).size === panels.length,
|
|
27
|
-
"Dashboard panel IDs must be unique.",
|
|
28
|
-
),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default defineAction({
|
|
32
|
-
description:
|
|
33
|
-
"Create or update an access-scoped CRM pipeline dashboard. Pass expectedUpdatedAt to reject an overwrite when the dashboard changed since it was read.",
|
|
34
|
-
schema: z.object({
|
|
35
|
-
id: z.string().trim().min(1).max(200),
|
|
36
|
-
title: z.string().trim().min(1).max(160),
|
|
37
|
-
config: configSchema,
|
|
38
|
-
expectedUpdatedAt: z.string().datetime().optional(),
|
|
39
|
-
}),
|
|
40
|
-
run: ({ id, title, config, expectedUpdatedAt }, ctx?: ActionRunContext) =>
|
|
41
|
-
crmDashboardStore.write(
|
|
42
|
-
{
|
|
43
|
-
id,
|
|
44
|
-
kind: "pipeline",
|
|
45
|
-
title,
|
|
46
|
-
config: config as CrmDashboardConfig,
|
|
47
|
-
expectedUpdatedAt,
|
|
48
|
-
},
|
|
49
|
-
requireDashboardAccess(ctx),
|
|
50
|
-
),
|
|
51
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { defineAction } from "@agent-native/core/action";
|
|
2
|
-
import { assertAccess } from "@agent-native/core/sharing";
|
|
3
|
-
import { and, eq } from "drizzle-orm";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
import { getDb, schema } from "../server/db/index.js";
|
|
7
|
-
import { requireCrmScope, toJson } from "./_crm-action-utils.js";
|
|
8
|
-
|
|
9
|
-
const filterSchema = z.record(z.string().max(120), z.unknown());
|
|
10
|
-
|
|
11
|
-
export default defineAction({
|
|
12
|
-
description:
|
|
13
|
-
"Create or update a bounded, access-scoped CRM saved view. A saved view stores filters and presentation settings, never provider rows.",
|
|
14
|
-
schema: z.object({
|
|
15
|
-
id: z.string().min(1).max(128).optional(),
|
|
16
|
-
name: z.string().trim().min(1).max(120),
|
|
17
|
-
description: z.string().trim().max(500).optional(),
|
|
18
|
-
kind: z.enum(["account", "person", "opportunity"]).optional(),
|
|
19
|
-
filters: filterSchema.optional(),
|
|
20
|
-
columns: z.array(z.string().trim().min(1).max(120)).max(40).optional(),
|
|
21
|
-
sort: z
|
|
22
|
-
.array(
|
|
23
|
-
z.object({
|
|
24
|
-
field: z.string().trim().min(1).max(120),
|
|
25
|
-
direction: z.enum(["asc", "desc"]),
|
|
26
|
-
}),
|
|
27
|
-
)
|
|
28
|
-
.max(4)
|
|
29
|
-
.optional(),
|
|
30
|
-
dataProgramId: z.string().trim().min(1).max(128).optional(),
|
|
31
|
-
pinned: z.boolean().optional(),
|
|
32
|
-
}),
|
|
33
|
-
audit: {
|
|
34
|
-
target: (_args, result) => {
|
|
35
|
-
const view = result as {
|
|
36
|
-
id: string;
|
|
37
|
-
ownerEmail: string;
|
|
38
|
-
orgId: string | null;
|
|
39
|
-
visibility: "private" | "org";
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
type: "crm-saved-view",
|
|
43
|
-
id: view.id,
|
|
44
|
-
ownerEmail: view.ownerEmail,
|
|
45
|
-
orgId: view.orgId,
|
|
46
|
-
visibility: view.visibility,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
summary: (args) => `Saved CRM view ${args.name}`,
|
|
50
|
-
},
|
|
51
|
-
run: async (args, ctx) => {
|
|
52
|
-
const db = getDb();
|
|
53
|
-
const now = new Date().toISOString();
|
|
54
|
-
if (args.id) {
|
|
55
|
-
await assertAccess("crm-saved-view", args.id, "editor");
|
|
56
|
-
await db
|
|
57
|
-
.update(schema.crmSavedViews)
|
|
58
|
-
.set({
|
|
59
|
-
name: args.name,
|
|
60
|
-
...(args.description !== undefined
|
|
61
|
-
? { description: args.description }
|
|
62
|
-
: {}),
|
|
63
|
-
...(args.kind !== undefined ? { kind: args.kind } : {}),
|
|
64
|
-
...(args.filters !== undefined
|
|
65
|
-
? { filtersJson: toJson(args.filters, 8_000) }
|
|
66
|
-
: {}),
|
|
67
|
-
...(args.columns !== undefined
|
|
68
|
-
? { columnsJson: toJson(args.columns, 4_000) }
|
|
69
|
-
: {}),
|
|
70
|
-
...(args.sort !== undefined
|
|
71
|
-
? { sortJson: toJson(args.sort, 2_000) }
|
|
72
|
-
: {}),
|
|
73
|
-
...(args.dataProgramId !== undefined
|
|
74
|
-
? { dataProgramId: args.dataProgramId }
|
|
75
|
-
: {}),
|
|
76
|
-
...(args.pinned !== undefined ? { pinned: args.pinned } : {}),
|
|
77
|
-
updatedAt: now,
|
|
78
|
-
})
|
|
79
|
-
.where(eq(schema.crmSavedViews.id, args.id));
|
|
80
|
-
const [view] = await db
|
|
81
|
-
.select()
|
|
82
|
-
.from(schema.crmSavedViews)
|
|
83
|
-
.where(eq(schema.crmSavedViews.id, args.id))
|
|
84
|
-
.limit(1);
|
|
85
|
-
if (!view) throw new Error("CRM saved view was not found.");
|
|
86
|
-
return view;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const scope = requireCrmScope(ctx);
|
|
90
|
-
const id = crypto.randomUUID();
|
|
91
|
-
await db.insert(schema.crmSavedViews).values({
|
|
92
|
-
id,
|
|
93
|
-
name: args.name,
|
|
94
|
-
description: args.description ?? "",
|
|
95
|
-
kind: args.kind ?? null,
|
|
96
|
-
filtersJson: toJson(args.filters ?? {}, 8_000),
|
|
97
|
-
columnsJson: toJson(args.columns ?? [], 4_000),
|
|
98
|
-
sortJson: toJson(args.sort ?? [], 2_000),
|
|
99
|
-
dataProgramId: args.dataProgramId ?? null,
|
|
100
|
-
pinned: args.pinned ?? false,
|
|
101
|
-
...scope,
|
|
102
|
-
createdAt: now,
|
|
103
|
-
updatedAt: now,
|
|
104
|
-
});
|
|
105
|
-
const [view] = await db
|
|
106
|
-
.select()
|
|
107
|
-
.from(schema.crmSavedViews)
|
|
108
|
-
.where(
|
|
109
|
-
and(
|
|
110
|
-
eq(schema.crmSavedViews.id, id),
|
|
111
|
-
eq(schema.crmSavedViews.ownerEmail, scope.ownerEmail),
|
|
112
|
-
),
|
|
113
|
-
)
|
|
114
|
-
.limit(1);
|
|
115
|
-
if (!view)
|
|
116
|
-
throw new Error("CRM saved view could not be verified after saving.");
|
|
117
|
-
return view;
|
|
118
|
-
},
|
|
119
|
-
});
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { defineAction, type ActionRunContext } from "@agent-native/core/action";
|
|
2
|
-
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
3
|
-
import { and, eq } from "drizzle-orm";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
createConnectedCrmAdapter,
|
|
8
|
-
isConnectedCrmProvider,
|
|
9
|
-
} from "../server/crm/adapter.js";
|
|
10
|
-
import {
|
|
11
|
-
MAX_SYNC_PAGE_SIZE,
|
|
12
|
-
MAX_SYNC_PAGES,
|
|
13
|
-
syncCrmMirror,
|
|
14
|
-
} from "../server/crm/crm-mirror.js";
|
|
15
|
-
import { getDb, schema } from "../server/db/index.js";
|
|
16
|
-
import { requireCrmScope } from "./_crm-action-utils.js";
|
|
17
|
-
|
|
18
|
-
const idList = z
|
|
19
|
-
.array(z.string().trim().min(1).max(160))
|
|
20
|
-
.min(1)
|
|
21
|
-
.max(50)
|
|
22
|
-
.optional();
|
|
23
|
-
const syncScopeSchema = z
|
|
24
|
-
.object({
|
|
25
|
-
pipelineIds: idList,
|
|
26
|
-
ownerIds: idList,
|
|
27
|
-
recordIds: idList,
|
|
28
|
-
associatedRecordIds: idList,
|
|
29
|
-
updatedAfter: z.string().datetime({ offset: true }).optional(),
|
|
30
|
-
includeDeleted: z.boolean().default(false),
|
|
31
|
-
})
|
|
32
|
-
.superRefine((scope, issue) => {
|
|
33
|
-
if (
|
|
34
|
-
!scope.pipelineIds &&
|
|
35
|
-
!scope.ownerIds &&
|
|
36
|
-
!scope.recordIds &&
|
|
37
|
-
!scope.associatedRecordIds &&
|
|
38
|
-
!scope.updatedAfter
|
|
39
|
-
) {
|
|
40
|
-
issue.addIssue({
|
|
41
|
-
code: "custom",
|
|
42
|
-
message:
|
|
43
|
-
"A sync requires a bounded cohort selector: pipelineIds, ownerIds, recordIds, associatedRecordIds, or updatedAfter.",
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export default defineAction({
|
|
49
|
-
description:
|
|
50
|
-
"Thinly mirror one bounded HubSpot or Salesforce CRM object cohort. It discovers field policy first, mirrors only explicit safe fields, and returns a continuation cursor instead of claiming an exhaustive sync.",
|
|
51
|
-
schema: z.object({
|
|
52
|
-
connectionId: z.string().trim().min(1).max(128),
|
|
53
|
-
objectType: z.string().trim().min(1).max(120),
|
|
54
|
-
scope: syncScopeSchema,
|
|
55
|
-
fieldAllowList: z
|
|
56
|
-
.array(z.string().trim().min(1).max(120))
|
|
57
|
-
.min(1)
|
|
58
|
-
.max(80)
|
|
59
|
-
.optional(),
|
|
60
|
-
allowCustomObject: z.boolean().default(false),
|
|
61
|
-
cursor: z.string().trim().min(1).max(2_000).optional(),
|
|
62
|
-
pageSize: z.coerce
|
|
63
|
-
.number()
|
|
64
|
-
.int()
|
|
65
|
-
.min(1)
|
|
66
|
-
.max(MAX_SYNC_PAGE_SIZE)
|
|
67
|
-
.default(MAX_SYNC_PAGE_SIZE),
|
|
68
|
-
maxPages: z.coerce
|
|
69
|
-
.number()
|
|
70
|
-
.int()
|
|
71
|
-
.min(1)
|
|
72
|
-
.max(MAX_SYNC_PAGES)
|
|
73
|
-
.default(MAX_SYNC_PAGES),
|
|
74
|
-
}),
|
|
75
|
-
audit: {
|
|
76
|
-
target: (args, result) => {
|
|
77
|
-
const response = result as {
|
|
78
|
-
ownerEmail: string;
|
|
79
|
-
orgId: string | null;
|
|
80
|
-
visibility: "private" | "org";
|
|
81
|
-
};
|
|
82
|
-
return {
|
|
83
|
-
type: "crm-connection",
|
|
84
|
-
id: args.connectionId,
|
|
85
|
-
ownerEmail: response.ownerEmail,
|
|
86
|
-
orgId: response.orgId,
|
|
87
|
-
visibility: response.visibility,
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
summary: (args) => `Synced bounded CRM ${args.objectType} cohort`,
|
|
91
|
-
recordInputs: false,
|
|
92
|
-
},
|
|
93
|
-
run: async (args, ctx?: ActionRunContext) => {
|
|
94
|
-
await assertAccess("crm-connection", args.connectionId, "editor");
|
|
95
|
-
const db = getDb();
|
|
96
|
-
const [connection] = await db
|
|
97
|
-
.select()
|
|
98
|
-
.from(schema.crmConnections)
|
|
99
|
-
.where(
|
|
100
|
-
and(
|
|
101
|
-
eq(schema.crmConnections.id, args.connectionId),
|
|
102
|
-
accessFilter(
|
|
103
|
-
schema.crmConnections,
|
|
104
|
-
schema.crmConnectionShares,
|
|
105
|
-
undefined,
|
|
106
|
-
"editor",
|
|
107
|
-
),
|
|
108
|
-
),
|
|
109
|
-
)
|
|
110
|
-
.limit(1);
|
|
111
|
-
if (!connection || connection.status === "disconnected")
|
|
112
|
-
throw new Error("CRM connection is unavailable.");
|
|
113
|
-
if (
|
|
114
|
-
!isConnectedCrmProvider(connection.provider) ||
|
|
115
|
-
!connection.workspaceConnectionId
|
|
116
|
-
)
|
|
117
|
-
throw new Error(
|
|
118
|
-
"CRM sync requires a connected HubSpot or Salesforce workspace connection.",
|
|
119
|
-
);
|
|
120
|
-
const ownership = requireCrmScope(ctx);
|
|
121
|
-
const adapter = await createConnectedCrmAdapter({
|
|
122
|
-
provider: connection.provider,
|
|
123
|
-
connectionId: connection.workspaceConnectionId,
|
|
124
|
-
userEmail: ownership.ownerEmail,
|
|
125
|
-
orgId: ownership.orgId,
|
|
126
|
-
});
|
|
127
|
-
const result = await syncCrmMirror({
|
|
128
|
-
connectionId: connection.id,
|
|
129
|
-
objectType: args.objectType,
|
|
130
|
-
scope: { objectType: args.objectType, ...args.scope },
|
|
131
|
-
fieldAllowList: args.fieldAllowList,
|
|
132
|
-
allowCustomObject: args.allowCustomObject,
|
|
133
|
-
cursor: args.cursor,
|
|
134
|
-
pageSize: args.pageSize,
|
|
135
|
-
maxPages: args.maxPages,
|
|
136
|
-
ownership,
|
|
137
|
-
adapter,
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
...result,
|
|
141
|
-
ownerEmail: ownership.ownerEmail,
|
|
142
|
-
orgId: ownership.orgId,
|
|
143
|
-
visibility: ownership.visibility,
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
});
|