@agent-native/core 0.114.16 → 0.115.3
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 +2 -0
- package/corpus/README.md +3 -3
- package/corpus/core/CHANGELOG.md +41 -0
- package/corpus/core/agent-native.eject.json +2 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +16 -0
- package/corpus/core/docs/content/recurring-jobs.mdx +35 -6
- package/corpus/core/export-snapshot.json +4 -0
- package/corpus/core/package.json +5 -1
- package/corpus/core/src/action.ts +22 -1
- package/corpus/core/src/agent/production-agent.ts +122 -3
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +19 -2
- package/corpus/core/src/cli/templates-meta.ts +12 -0
- package/corpus/core/src/client/AssistantChat.tsx +53 -26
- package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +19 -0
- package/corpus/core/src/client/agent-page/use-jobs.ts +1 -0
- package/corpus/core/src/client/blocks/library/wireframe.tsx +3 -1
- package/corpus/core/src/client/chat/message-components.tsx +35 -1
- package/corpus/core/src/client/chat/tool-call-display.tsx +38 -3
- package/corpus/core/src/connections/catalog.ts +20 -1
- package/corpus/core/src/connections/reader.ts +65 -0
- package/corpus/core/src/dashboard-storage/index.ts +27 -0
- package/corpus/core/src/dashboard-storage/panel-source.ts +168 -0
- package/corpus/core/src/dashboard-storage/schema.ts +62 -0
- package/corpus/core/src/dashboard-storage/store.ts +333 -0
- package/corpus/core/src/deploy/build.ts +95 -16
- package/corpus/core/src/eject/provider-api-definitions.ts +1 -0
- package/corpus/core/src/eject/workspace-connections.ts +1 -0
- package/corpus/core/src/extensions/actions.ts +199 -73
- package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +2 -0
- package/corpus/core/src/jobs/scheduler.ts +71 -4
- package/corpus/core/src/jobs/tools.ts +31 -1
- package/corpus/core/src/localization/default-messages.ts +1 -0
- package/corpus/core/src/mcp-client/index.ts +6 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +1 -1
- package/corpus/core/src/provider-api/index.ts +190 -5
- package/corpus/core/src/secrets/register-framework-secrets.ts +8 -0
- package/corpus/core/src/server/agent-chat/context-tools.ts +9 -0
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +2 -2
- package/corpus/core/src/server/agent-chat-plugin.ts +22 -2
- package/corpus/core/src/server/core-routes-plugin.ts +1 -0
- package/corpus/core/src/server/credential-provider.ts +9 -3
- package/corpus/core/src/server/workspace-provider-oauth.ts +181 -4
- package/corpus/core/src/styles/agent-native.css +45 -2
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/corpus/core/src/templates/default/.agents/skills/app-branding/SKILL.md +159 -0
- package/corpus/core/src/templates/default/.agents/skills/app-permissions/SKILL.md +155 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +31 -18
- package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +15 -0
- package/corpus/core/src/triggers/actions.ts +11 -2
- package/corpus/core/src/triggers/dispatcher.ts +20 -1
- package/corpus/core/src/triggers/types.ts +5 -0
- package/corpus/core/src/vite/action-types-plugin.ts +9 -1
- package/corpus/templates/analytics/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/analytics/AGENTS.md +11 -11
- package/corpus/templates/analytics/_gitignore +39 -0
- package/corpus/templates/analytics/actions/query-dashboard-panel.ts +30 -0
- package/corpus/templates/analytics/actions/update-dashboard.ts +2 -1
- package/corpus/templates/analytics/app/lib/sql-query.ts +11 -25
- package/corpus/templates/analytics/changelog/2026-07-21-fixed-extension-updates-failing-before-changes-could-be-appl.md +6 -0
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +1 -0
- package/corpus/templates/analytics/server/lib/dashboard-panel-source-resolver.ts +51 -0
- package/corpus/templates/analytics/server/lib/prometheus.ts +1 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/assets/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/brain/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/calendar/_gitignore +39 -0
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/corpus/templates/chat/AGENTS.md +1 -1
- package/corpus/templates/clips/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/clips/AGENTS.md +7 -0
- package/corpus/templates/clips/actions/prepare-crm-call-evidence.ts +58 -0
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +88 -11
- package/corpus/templates/clips/changelog/2026-07-21-crm-call-evidence-handoff.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-21-recording-retries-and-restarts-keep-their-upload-session-so-.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/background.ts +20 -5
- package/corpus/templates/clips/chrome-extension/src/native-recording-state.ts +19 -0
- package/corpus/templates/clips/chrome-extension/src/offscreen.ts +8 -0
- package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +9 -0
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +54 -28
- package/corpus/templates/clips/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/content/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/content/_gitignore +39 -0
- package/corpus/templates/content/learnings.defaults.md +5 -0
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +133 -0
- package/corpus/templates/crm/.agents/skills/crm/SKILL.md +128 -0
- package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +100 -0
- package/corpus/templates/crm/.env.example +5 -0
- package/corpus/templates/crm/AGENTS.md +120 -0
- package/corpus/templates/crm/CHANGELOG.md +1 -0
- package/corpus/templates/crm/DEVELOPING.md +66 -0
- package/corpus/templates/crm/README.md +106 -0
- package/corpus/templates/crm/_gitignore +12 -0
- package/corpus/templates/crm/actions/_crm-action-utils.ts +87 -0
- package/corpus/templates/crm/actions/_crm-dashboard.ts +69 -0
- package/corpus/templates/crm/actions/_crm-signal-utils.ts +79 -0
- package/corpus/templates/crm/actions/apply-crm-proposals.ts +203 -0
- package/corpus/templates/crm/actions/attach-call-evidence.ts +170 -0
- package/corpus/templates/crm/actions/configure-crm-connection.ts +126 -0
- package/corpus/templates/crm/actions/configure-native-crm.ts +44 -0
- package/corpus/templates/crm/actions/create-crm-record.ts +148 -0
- package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +58 -0
- package/corpus/templates/crm/actions/delete-staged-dataset.ts +14 -0
- package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +36 -0
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +33 -0
- package/corpus/templates/crm/actions/get-crm-dashboard.ts +14 -0
- package/corpus/templates/crm/actions/get-crm-overview.ts +13 -0
- package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +61 -0
- package/corpus/templates/crm/actions/get-crm-record.ts +75 -0
- package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +81 -0
- package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-dashboards.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-proposals.ts +31 -0
- package/corpus/templates/crm/actions/list-crm-records.ts +79 -0
- package/corpus/templates/crm/actions/list-crm-saved-views.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-signal-hits.ts +43 -0
- package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +32 -0
- package/corpus/templates/crm/actions/list-crm-tasks.ts +22 -0
- package/corpus/templates/crm/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/crm/actions/list-workspace-connections.ts +47 -0
- package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +87 -0
- package/corpus/templates/crm/actions/manage-crm-task.ts +132 -0
- package/corpus/templates/crm/actions/navigate.ts +63 -0
- package/corpus/templates/crm/actions/provider-api-catalog.ts +22 -0
- package/corpus/templates/crm/actions/provider-api-docs.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-request.ts +92 -0
- package/corpus/templates/crm/actions/query-staged-dataset.ts +44 -0
- package/corpus/templates/crm/actions/record-crm-call-insight.ts +160 -0
- package/corpus/templates/crm/actions/record-crm-smart-signal.ts +150 -0
- package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +23 -0
- package/corpus/templates/crm/actions/review-crm-signal.ts +31 -0
- package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +103 -0
- package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +275 -0
- package/corpus/templates/crm/actions/run.ts +11 -0
- package/corpus/templates/crm/actions/save-crm-dashboard.ts +51 -0
- package/corpus/templates/crm/actions/save-crm-saved-view.ts +119 -0
- package/corpus/templates/crm/actions/sync-crm.ts +146 -0
- package/corpus/templates/crm/actions/update-crm-record.ts +508 -0
- package/corpus/templates/crm/actions/view-screen.ts +218 -0
- package/corpus/templates/crm/agent-native.app-skill.json +58 -0
- package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +158 -0
- package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +83 -0
- package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +225 -0
- package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +413 -0
- package/corpus/templates/crm/app/components/crm/RecordActions.tsx +510 -0
- package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +134 -0
- package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +367 -0
- package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +92 -0
- package/corpus/templates/crm/app/components/crm/Surface.tsx +96 -0
- package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +180 -0
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +106 -0
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +84 -0
- package/corpus/templates/crm/app/entry.client.tsx +16 -0
- package/corpus/templates/crm/app/entry.server.tsx +10 -0
- package/corpus/templates/crm/app/global.css +167 -0
- package/corpus/templates/crm/app/hooks/use-navigation-state.ts +60 -0
- package/corpus/templates/crm/app/i18n/en-US.ts +89 -0
- package/corpus/templates/crm/app/i18n/index.ts +34 -0
- package/corpus/templates/crm/app/lib/dashboard.ts +13 -0
- package/corpus/templates/crm/app/lib/navigation.ts +54 -0
- package/corpus/templates/crm/app/lib/tab-id.ts +1 -0
- package/corpus/templates/crm/app/lib/types.ts +172 -0
- package/corpus/templates/crm/app/lib/utils.ts +1 -0
- package/corpus/templates/crm/app/root.tsx +88 -0
- package/corpus/templates/crm/app/routes/_index.tsx +26 -0
- package/corpus/templates/crm/app/routes/accounts.tsx +41 -0
- package/corpus/templates/crm/app/routes/agent.tsx +5 -0
- package/corpus/templates/crm/app/routes/ask.tsx +53 -0
- package/corpus/templates/crm/app/routes/dashboard.tsx +118 -0
- package/corpus/templates/crm/app/routes/opportunities.tsx +41 -0
- package/corpus/templates/crm/app/routes/people.tsx +41 -0
- package/corpus/templates/crm/app/routes/proposals.tsx +266 -0
- package/corpus/templates/crm/app/routes/records.$recordId.tsx +35 -0
- package/corpus/templates/crm/app/routes/settings.tsx +63 -0
- package/corpus/templates/crm/app/routes/setup.tsx +308 -0
- package/corpus/templates/crm/app/routes/tasks.tsx +252 -0
- package/corpus/templates/crm/app/routes/views.tsx +333 -0
- package/corpus/templates/crm/app/routes.ts +17 -0
- package/corpus/templates/crm/app/vite-env.d.ts +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-agent-native-crm.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-clips-call-evidence-review-recipe.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-find-and-review-evidence-grounded-call-signals-w.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-manage-keyword-and-smart-call-signal-trackers-fr.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-delegated-local-crm-automation.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-native-sql.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboard.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboards-now-install-correctly-from-the-crm-actio.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-21-salesforce-connection.md +6 -0
- package/corpus/templates/crm/components.json +20 -0
- package/corpus/templates/crm/docs/architecture/crm-contract.md +180 -0
- package/corpus/templates/crm/learnings.defaults.md +5 -0
- package/corpus/templates/crm/package.json +59 -0
- package/corpus/templates/crm/public/favicon.svg +1 -0
- package/corpus/templates/crm/public/icon-180.svg +1 -0
- package/corpus/templates/crm/public/manifest.json +11 -0
- package/corpus/templates/crm/react-router.config.ts +7 -0
- package/corpus/templates/crm/server/crm/adapter.ts +32 -0
- package/corpus/templates/crm/server/crm/crm-field-firewall.ts +64 -0
- package/corpus/templates/crm/server/crm/crm-mirror.ts +711 -0
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +1143 -0
- package/corpus/templates/crm/server/crm/native-adapter.ts +1715 -0
- package/corpus/templates/crm/server/crm/read-through.ts +207 -0
- package/corpus/templates/crm/server/crm/salesforce-adapter.ts +1255 -0
- package/corpus/templates/crm/server/db/crm-store.ts +1170 -0
- package/corpus/templates/crm/server/db/index.ts +169 -0
- package/corpus/templates/crm/server/db/schema.ts +441 -0
- package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +65 -0
- package/corpus/templates/crm/server/lib/intelligence/evidence.ts +105 -0
- package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +100 -0
- package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +144 -0
- package/corpus/templates/crm/server/lib/intelligence/summary.ts +141 -0
- package/corpus/templates/crm/server/lib/provider-api.ts +64 -0
- package/corpus/templates/crm/server/middleware/auth.ts +4 -0
- package/corpus/templates/crm/server/plugins/agent-chat.ts +68 -0
- package/corpus/templates/crm/server/plugins/auth.ts +14 -0
- package/corpus/templates/crm/server/plugins/core-routes.ts +17 -0
- package/corpus/templates/crm/server/plugins/db.ts +454 -0
- package/corpus/templates/crm/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/crm/shared/crm-automation-recipes.ts +132 -0
- package/corpus/templates/crm/shared/crm-contract.ts +254 -0
- package/corpus/templates/crm/shared/crm-sales-config.ts +63 -0
- package/corpus/templates/crm/ssr-entry.ts +11 -0
- package/corpus/templates/crm/tsconfig.json +24 -0
- package/corpus/templates/crm/vite.config.ts +15 -0
- package/corpus/templates/crm/vitest.config.ts +5 -0
- package/corpus/templates/design/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/dispatch/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/forms/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/forms/_gitignore +39 -0
- package/corpus/templates/forms/learnings.defaults.md +5 -0
- package/corpus/templates/macros/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/macros/_gitignore +39 -0
- package/corpus/templates/macros/learnings.defaults.md +5 -0
- package/corpus/templates/mail/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/mail/_gitignore +39 -0
- package/corpus/templates/plan/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +19 -2
- package/corpus/templates/plan/AGENTS.md +10 -0
- package/corpus/templates/plan/actions/create-prototype-plan.ts +27 -3
- package/corpus/templates/plan/actions/get-plan-blocks.ts +1 -1
- package/corpus/templates/plan/actions/update-visual-plan.ts +3 -2
- package/corpus/templates/plan/app/components/plan/PlanContentRenderer.tsx +18 -4
- package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +10 -3
- package/corpus/templates/plan/app/components/plan/wireframe/Wireframe.tsx +3 -1
- package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
- package/corpus/templates/plan/app/lib/create-plan-routing.ts +39 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +31 -107
- package/corpus/templates/plan/changelog/2026-07-22-high-fidelity-mockup-requests-now-preserve-branded-css-use-d.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +110 -2
- package/corpus/templates/slides/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/slides/_gitignore +39 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/corpus/templates/tasks/_gitignore +39 -0
- package/corpus/toolkit/CHANGELOG.md +12 -0
- package/corpus/toolkit/README.md +30 -0
- package/corpus/toolkit/agent-native.eject.json +33 -0
- package/corpus/toolkit/package.json +15 -1
- package/corpus/toolkit/src/dashboard/DataTable.tsx +273 -0
- package/corpus/toolkit/src/dashboard/DateRangePicker.tsx +57 -0
- package/corpus/toolkit/src/dashboard/GenericChartPanel.tsx +461 -0
- package/corpus/toolkit/src/dashboard/MetricCard.tsx +54 -0
- package/corpus/toolkit/src/dashboard/StatsCard.tsx +49 -0
- package/corpus/toolkit/src/dashboard/dashboard-layout.ts +329 -0
- package/corpus/toolkit/src/dashboard/index.ts +6 -0
- package/corpus/toolkit/src/index.ts +1 -0
- package/corpus/toolkit/src/ui/calendar.tsx +8 -8
- package/corpus/toolkit/src/ui/date-picker.tsx +4 -1
- package/dist/action.d.ts +14 -1
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +3 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +97 -3
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/visual-plan-skill.js +19 -2
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +12 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +4 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +30 -17
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.js +3 -1
- package/dist/client/agent-page/AgentJobsTab.js.map +1 -1
- package/dist/client/agent-page/use-jobs.d.ts +1 -0
- package/dist/client/agent-page/use-jobs.d.ts.map +1 -1
- package/dist/client/agent-page/use-jobs.js.map +1 -1
- package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
- package/dist/client/blocks/library/wireframe.js +3 -2
- package/dist/client/blocks/library/wireframe.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +5 -0
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +17 -1
- 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 +17 -7
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/connections/catalog.d.ts +17 -3
- package/dist/connections/catalog.d.ts.map +1 -1
- package/dist/connections/catalog.js +16 -1
- package/dist/connections/catalog.js.map +1 -1
- package/dist/connections/reader.d.ts +18 -0
- package/dist/connections/reader.d.ts.map +1 -1
- package/dist/connections/reader.js +41 -0
- package/dist/connections/reader.js.map +1 -1
- package/dist/dashboard-storage/index.d.ts +4 -0
- package/dist/dashboard-storage/index.d.ts.map +1 -0
- package/dist/dashboard-storage/index.js +4 -0
- package/dist/dashboard-storage/index.js.map +1 -0
- package/dist/dashboard-storage/panel-source.d.ts +68 -0
- package/dist/dashboard-storage/panel-source.d.ts.map +1 -0
- package/dist/dashboard-storage/panel-source.js +76 -0
- package/dist/dashboard-storage/panel-source.js.map +1 -0
- package/dist/dashboard-storage/schema.d.ts +562 -0
- package/dist/dashboard-storage/schema.d.ts.map +1 -0
- package/dist/dashboard-storage/schema.js +32 -0
- package/dist/dashboard-storage/schema.js.map +1 -0
- package/dist/dashboard-storage/store.d.ts +62 -0
- package/dist/dashboard-storage/store.d.ts.map +1 -0
- package/dist/dashboard-storage/store.js +227 -0
- package/dist/dashboard-storage/store.js.map +1 -0
- package/dist/deploy/build.d.ts +7 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +78 -14
- package/dist/deploy/build.js.map +1 -1
- package/dist/eject/provider-api-definitions.d.ts +2 -1
- package/dist/eject/provider-api-definitions.d.ts.map +1 -1
- package/dist/eject/provider-api-definitions.js +1 -0
- package/dist/eject/provider-api-definitions.js.map +1 -1
- package/dist/eject/workspace-connections.d.ts.map +1 -1
- package/dist/eject/workspace-connections.js +1 -0
- package/dist/eject/workspace-connections.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +165 -67
- package/dist/extensions/actions.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/jobs/actions/list-recurring-jobs.d.ts +1 -0
- package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -1
- package/dist/jobs/actions/list-recurring-jobs.js +1 -0
- package/dist/jobs/actions/list-recurring-jobs.js.map +1 -1
- package/dist/jobs/scheduler.d.ts +17 -2
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +51 -2
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +32 -2
- package/dist/jobs/tools.js.map +1 -1
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +1 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp-client/index.d.ts +2 -0
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +5 -0
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
- package/dist/provider-api/actions/provider-api.d.ts +8 -6
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
- package/dist/provider-api/actions/provider-api.js +1 -1
- package/dist/provider-api/actions/provider-api.js.map +1 -1
- package/dist/provider-api/index.d.ts +11 -7
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +143 -5
- package/dist/provider-api/index.js.map +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +7 -0
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +9 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/framework-prompts.js +2 -2
- package/dist/server/agent-chat/framework-prompts.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +18 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +1 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +4 -3
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +9 -3
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/workspace-provider-oauth.d.ts +6 -1
- package/dist/server/workspace-provider-oauth.d.ts.map +1 -1
- package/dist/server/workspace-provider-oauth.js +141 -4
- package/dist/server/workspace-provider-oauth.js.map +1 -1
- package/dist/styles/agent-native.css +45 -2
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/dist/templates/chat/AGENTS.md +1 -1
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/dist/templates/default/.agents/skills/app-branding/SKILL.md +159 -0
- package/dist/templates/default/.agents/skills/app-permissions/SKILL.md +155 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +31 -18
- package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +15 -0
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +10 -2
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +15 -0
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/triggers/types.d.ts +5 -0
- package/dist/triggers/types.d.ts.map +1 -1
- package/dist/triggers/types.js.map +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +4 -1
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +16 -0
- package/docs/content/recurring-jobs.mdx +35 -6
- package/package.json +7 -3
- package/src/action.ts +22 -1
- package/src/agent/production-agent.ts +122 -3
- package/src/cli/skills-content/visual-plan-skill.ts +19 -2
- package/src/cli/templates-meta.ts +12 -0
- package/src/client/AssistantChat.tsx +53 -26
- package/src/client/agent-page/AgentJobsTab.tsx +19 -0
- package/src/client/agent-page/use-jobs.ts +1 -0
- package/src/client/blocks/library/wireframe.tsx +3 -1
- package/src/client/chat/message-components.tsx +35 -1
- package/src/client/chat/tool-call-display.tsx +38 -3
- package/src/connections/catalog.ts +20 -1
- package/src/connections/reader.ts +65 -0
- package/src/dashboard-storage/index.ts +27 -0
- package/src/dashboard-storage/panel-source.ts +168 -0
- package/src/dashboard-storage/schema.ts +62 -0
- package/src/dashboard-storage/store.ts +333 -0
- package/src/deploy/build.ts +95 -16
- package/src/eject/provider-api-definitions.ts +1 -0
- package/src/eject/workspace-connections.ts +1 -0
- package/src/extensions/actions.ts +199 -73
- package/src/jobs/actions/list-recurring-jobs.ts +2 -0
- package/src/jobs/scheduler.ts +71 -4
- package/src/jobs/tools.ts +31 -1
- package/src/localization/default-messages.ts +1 -0
- package/src/mcp-client/index.ts +6 -0
- package/src/provider-api/actions/provider-api.ts +1 -1
- package/src/provider-api/index.ts +190 -5
- package/src/secrets/register-framework-secrets.ts +8 -0
- package/src/server/agent-chat/context-tools.ts +9 -0
- package/src/server/agent-chat/framework-prompts.ts +2 -2
- package/src/server/agent-chat-plugin.ts +22 -2
- package/src/server/core-routes-plugin.ts +1 -0
- package/src/server/credential-provider.ts +9 -3
- package/src/server/workspace-provider-oauth.ts +181 -4
- package/src/styles/agent-native.css +45 -2
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/src/templates/chat/AGENTS.md +1 -1
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/src/templates/default/.agents/skills/app-branding/SKILL.md +159 -0
- package/src/templates/default/.agents/skills/app-permissions/SKILL.md +155 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +27 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +31 -18
- package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +15 -0
- package/src/triggers/actions.ts +11 -2
- package/src/triggers/dispatcher.ts +20 -1
- package/src/triggers/types.ts +5 -0
- package/src/vite/action-types-plugin.ts +9 -1
- package/corpus/templates/analytics/server/handlers/sql-query.ts +0 -36
- package/corpus/templates/analytics/server/routes/api/sql-query.post.ts +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { defineAction } 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 { isSafeCrmEvidenceExcerpt } from "../server/crm/crm-field-firewall.js";
|
|
7
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
+
import {
|
|
9
|
+
crmSignalIdempotencyKey,
|
|
10
|
+
signalTupleError,
|
|
11
|
+
} from "./_crm-signal-utils.js";
|
|
12
|
+
|
|
13
|
+
export default defineAction({
|
|
14
|
+
description:
|
|
15
|
+
"Record one delegated-agent detector hit only after grounding it to an access-scoped evidence excerpt and queued smart run.",
|
|
16
|
+
schema: z.object({
|
|
17
|
+
runId: z.string().trim().min(1).max(128),
|
|
18
|
+
trackerId: z.string().trim().min(1).max(128),
|
|
19
|
+
recordId: z.string().trim().min(1).max(128),
|
|
20
|
+
evidenceId: z.string().trim().min(1).max(128),
|
|
21
|
+
quote: z.string().trim().min(1).max(1_200).refine(isSafeCrmEvidenceExcerpt),
|
|
22
|
+
confidence: z.coerce.number().finite().min(0).max(100),
|
|
23
|
+
model: z.string().trim().min(1).max(120),
|
|
24
|
+
modelVersion: z.string().trim().max(120).optional(),
|
|
25
|
+
idempotencyKey: z.string().trim().min(1).max(180),
|
|
26
|
+
}),
|
|
27
|
+
run: async (args, ctx) => {
|
|
28
|
+
await Promise.all([
|
|
29
|
+
assertAccess("crm-record", args.recordId, "editor"),
|
|
30
|
+
assertAccess("crm-signal-run", args.runId, "editor"),
|
|
31
|
+
assertAccess("crm-signal-tracker", args.trackerId, "viewer"),
|
|
32
|
+
assertAccess("crm-call-evidence", args.evidenceId, "viewer"),
|
|
33
|
+
]);
|
|
34
|
+
const db = getDb();
|
|
35
|
+
const [[run], [tracker], [evidence]] = await Promise.all([
|
|
36
|
+
db
|
|
37
|
+
.select()
|
|
38
|
+
.from(schema.crmSignalRuns)
|
|
39
|
+
.where(
|
|
40
|
+
and(
|
|
41
|
+
eq(schema.crmSignalRuns.id, args.runId),
|
|
42
|
+
accessFilter(schema.crmSignalRuns, schema.crmSignalRunShares),
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
.limit(1),
|
|
46
|
+
db
|
|
47
|
+
.select()
|
|
48
|
+
.from(schema.crmSignalTrackers)
|
|
49
|
+
.where(
|
|
50
|
+
and(
|
|
51
|
+
eq(schema.crmSignalTrackers.id, args.trackerId),
|
|
52
|
+
accessFilter(
|
|
53
|
+
schema.crmSignalTrackers,
|
|
54
|
+
schema.crmSignalTrackerShares,
|
|
55
|
+
),
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
.limit(1),
|
|
59
|
+
db
|
|
60
|
+
.select()
|
|
61
|
+
.from(schema.crmCallEvidence)
|
|
62
|
+
.where(
|
|
63
|
+
and(
|
|
64
|
+
eq(schema.crmCallEvidence.id, args.evidenceId),
|
|
65
|
+
accessFilter(schema.crmCallEvidence, schema.crmCallEvidenceShares),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
.limit(1),
|
|
69
|
+
]);
|
|
70
|
+
if (
|
|
71
|
+
!run ||
|
|
72
|
+
!tracker ||
|
|
73
|
+
!evidence ||
|
|
74
|
+
run.kind !== "smart" ||
|
|
75
|
+
run.recordId !== args.recordId ||
|
|
76
|
+
run.trackerId !== args.trackerId ||
|
|
77
|
+
tracker.kind !== "smart" ||
|
|
78
|
+
evidence.recordId !== args.recordId
|
|
79
|
+
)
|
|
80
|
+
signalTupleError(
|
|
81
|
+
"The signal run, tracker, evidence, and record do not form an accessible tuple.",
|
|
82
|
+
);
|
|
83
|
+
const source = evidence.quote.trim() || evidence.summary.trim();
|
|
84
|
+
if (!source.includes(args.quote))
|
|
85
|
+
throw new Error(
|
|
86
|
+
"The signal quote must be an exact substring of the stored bounded evidence excerpt.",
|
|
87
|
+
);
|
|
88
|
+
const idem = await crmSignalIdempotencyKey(
|
|
89
|
+
ctx,
|
|
90
|
+
args.recordId,
|
|
91
|
+
args.idempotencyKey,
|
|
92
|
+
);
|
|
93
|
+
const [existing] = await db
|
|
94
|
+
.select()
|
|
95
|
+
.from(schema.crmSignals)
|
|
96
|
+
.where(
|
|
97
|
+
and(
|
|
98
|
+
eq(schema.crmSignals.idempotencyKey, idem.key),
|
|
99
|
+
accessFilter(schema.crmSignals, schema.crmSignalShares),
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
.limit(1);
|
|
103
|
+
if (existing) return existing;
|
|
104
|
+
const now = new Date().toISOString();
|
|
105
|
+
const id = crypto.randomUUID();
|
|
106
|
+
await db.transaction(async (tx) => {
|
|
107
|
+
await tx.insert(schema.crmSignals).values({
|
|
108
|
+
id,
|
|
109
|
+
runId: args.runId,
|
|
110
|
+
trackerId: args.trackerId,
|
|
111
|
+
recordId: args.recordId,
|
|
112
|
+
evidenceId: args.evidenceId,
|
|
113
|
+
kind: "moment",
|
|
114
|
+
label: tracker.name,
|
|
115
|
+
quote: args.quote,
|
|
116
|
+
speaker: evidence.speaker,
|
|
117
|
+
startSeconds: evidence.startSeconds,
|
|
118
|
+
endSeconds: evidence.endSeconds,
|
|
119
|
+
summary: "",
|
|
120
|
+
confidence: args.confidence,
|
|
121
|
+
detector: "agent",
|
|
122
|
+
model: args.model,
|
|
123
|
+
modelVersion: args.modelVersion ?? null,
|
|
124
|
+
reviewStatus: "unreviewed",
|
|
125
|
+
idempotencyKey: idem.key,
|
|
126
|
+
...idem.scope,
|
|
127
|
+
createdAt: now,
|
|
128
|
+
updatedAt: now,
|
|
129
|
+
});
|
|
130
|
+
await tx
|
|
131
|
+
.update(schema.crmSignalRuns)
|
|
132
|
+
.set({
|
|
133
|
+
status: "completed",
|
|
134
|
+
model: args.model,
|
|
135
|
+
modelVersion: args.modelVersion ?? null,
|
|
136
|
+
completedAt: now,
|
|
137
|
+
updatedAt: now,
|
|
138
|
+
})
|
|
139
|
+
.where(eq(schema.crmSignalRuns.id, args.runId));
|
|
140
|
+
});
|
|
141
|
+
const [saved] = await db
|
|
142
|
+
.select()
|
|
143
|
+
.from(schema.crmSignals)
|
|
144
|
+
.where(eq(schema.crmSignals.id, id))
|
|
145
|
+
.limit(1);
|
|
146
|
+
if (!saved)
|
|
147
|
+
throw new Error("CRM signal could not be verified after saving.");
|
|
148
|
+
return saved;
|
|
149
|
+
},
|
|
150
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineAction, type ActionRunContext } from "@agent-native/core/action";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
import { crmDashboardStore } from "../server/db/index.js";
|
|
5
|
+
import { requireDashboardAccess } from "./_crm-dashboard.js";
|
|
6
|
+
|
|
7
|
+
export default defineAction({
|
|
8
|
+
description:
|
|
9
|
+
"Restore one revision of an access-scoped CRM dashboard. The restore is revision-aware and fails if the dashboard changed concurrently.",
|
|
10
|
+
schema: z.object({
|
|
11
|
+
id: z.string().trim().min(1).max(200),
|
|
12
|
+
revisionId: z.string().trim().min(1).max(200),
|
|
13
|
+
}),
|
|
14
|
+
run: async ({ id, revisionId }, ctx?: ActionRunContext) => {
|
|
15
|
+
const dashboard = await crmDashboardStore.restore(
|
|
16
|
+
id,
|
|
17
|
+
revisionId,
|
|
18
|
+
requireDashboardAccess(ctx),
|
|
19
|
+
);
|
|
20
|
+
if (!dashboard) throw new Error("CRM dashboard revision was not found.");
|
|
21
|
+
return dashboard;
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core/action";
|
|
2
|
+
import { assertAccess } from "@agent-native/core/sharing";
|
|
3
|
+
import { eq } from "drizzle-orm";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
7
|
+
|
|
8
|
+
export default defineAction({
|
|
9
|
+
description:
|
|
10
|
+
"Confirm, dismiss, or return one access-scoped CRM signal to the unreviewed queue.",
|
|
11
|
+
schema: z.object({
|
|
12
|
+
signalId: z.string().trim().min(1).max(128),
|
|
13
|
+
reviewStatus: z.enum(["unreviewed", "confirmed", "dismissed"]),
|
|
14
|
+
}),
|
|
15
|
+
run: async (args) => {
|
|
16
|
+
await assertAccess("crm-signal", args.signalId, "editor");
|
|
17
|
+
const now = new Date().toISOString();
|
|
18
|
+
await getDb()
|
|
19
|
+
.update(schema.crmSignals)
|
|
20
|
+
.set({ reviewStatus: args.reviewStatus, updatedAt: now })
|
|
21
|
+
.where(eq(schema.crmSignals.id, args.signalId));
|
|
22
|
+
const [saved] = await getDb()
|
|
23
|
+
.select()
|
|
24
|
+
.from(schema.crmSignals)
|
|
25
|
+
.where(eq(schema.crmSignals.id, args.signalId))
|
|
26
|
+
.limit(1);
|
|
27
|
+
if (!saved)
|
|
28
|
+
throw new Error("CRM signal could not be verified after review.");
|
|
29
|
+
return saved;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { defineAction, type ActionRunContext } from "@agent-native/core/action";
|
|
2
|
+
import { runDataProgram } from "@agent-native/core/data-programs";
|
|
3
|
+
import { accessFilter } from "@agent-native/core/sharing";
|
|
4
|
+
import { and, eq } from "drizzle-orm";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
+
import { CRM_APP_ID } from "../server/lib/provider-api.js";
|
|
9
|
+
import { isSafeCrmMutationFields } from "./_crm-action-utils.js";
|
|
10
|
+
|
|
11
|
+
export default defineAction({
|
|
12
|
+
description:
|
|
13
|
+
"Run the data program linked to one access-scoped CRM saved view and return a bounded, sanitized preview.",
|
|
14
|
+
schema: z.object({
|
|
15
|
+
viewId: z.string().trim().min(1).max(128),
|
|
16
|
+
}),
|
|
17
|
+
agentTool: false,
|
|
18
|
+
toolCallable: false,
|
|
19
|
+
run: async ({ viewId }, ctx?: ActionRunContext) => {
|
|
20
|
+
if (!ctx?.userEmail) {
|
|
21
|
+
throw new Error("CRM data programs require an authenticated user.");
|
|
22
|
+
}
|
|
23
|
+
const [view] = await getDb()
|
|
24
|
+
.select({ dataProgramId: schema.crmSavedViews.dataProgramId })
|
|
25
|
+
.from(schema.crmSavedViews)
|
|
26
|
+
.where(
|
|
27
|
+
and(
|
|
28
|
+
eq(schema.crmSavedViews.id, viewId),
|
|
29
|
+
accessFilter(schema.crmSavedViews, schema.crmSavedViewShares),
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
.limit(1);
|
|
33
|
+
if (!view?.dataProgramId) {
|
|
34
|
+
throw new Error("This CRM saved view has no data program.");
|
|
35
|
+
}
|
|
36
|
+
const result = await runDataProgram({
|
|
37
|
+
programId: view.dataProgramId,
|
|
38
|
+
appId: CRM_APP_ID,
|
|
39
|
+
params: {},
|
|
40
|
+
ctx: { userEmail: ctx.userEmail, orgId: ctx.orgId ?? null },
|
|
41
|
+
triggeredBy: "agent",
|
|
42
|
+
});
|
|
43
|
+
if (!result.ok) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false as const,
|
|
46
|
+
code: result.error.code,
|
|
47
|
+
message: "The saved view data program could not run.",
|
|
48
|
+
...(result.lastGoodRun
|
|
49
|
+
? {
|
|
50
|
+
lastGoodRun: {
|
|
51
|
+
rowCount: result.lastGoodRun.rows.length,
|
|
52
|
+
columns: safeColumns(result.lastGoodRun.schema),
|
|
53
|
+
sampleRows: safeSampleRows(result.lastGoodRun.rows),
|
|
54
|
+
truncated: result.lastGoodRun.truncated,
|
|
55
|
+
asOfMs: result.lastGoodRun.asOfMs,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
: {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
ok: true as const,
|
|
63
|
+
rowCount: result.rows.length,
|
|
64
|
+
columns: safeColumns(result.schema),
|
|
65
|
+
sampleRows: safeSampleRows(result.rows),
|
|
66
|
+
asOfMs: result.asOfMs,
|
|
67
|
+
cacheHit: result.cacheHit,
|
|
68
|
+
stale: result.stale,
|
|
69
|
+
truncated: result.truncated,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function safeColumns(columns: Array<{ name: string; type: string }>) {
|
|
75
|
+
return columns
|
|
76
|
+
.filter(
|
|
77
|
+
(column) =>
|
|
78
|
+
column.name.length <= 120 &&
|
|
79
|
+
isSafeCrmMutationFields({ [column.name]: "preview" }),
|
|
80
|
+
)
|
|
81
|
+
.slice(0, 12);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function safeSampleRows(rows: Array<Record<string, unknown>>) {
|
|
85
|
+
return rows.slice(0, 5).map((row) =>
|
|
86
|
+
Object.fromEntries(
|
|
87
|
+
Object.entries(row)
|
|
88
|
+
.filter(
|
|
89
|
+
([fieldName, value]) =>
|
|
90
|
+
isSafeCrmMutationFields({ [fieldName]: value }) &&
|
|
91
|
+
(value === null ||
|
|
92
|
+
typeof value === "string" ||
|
|
93
|
+
typeof value === "number" ||
|
|
94
|
+
typeof value === "boolean"),
|
|
95
|
+
)
|
|
96
|
+
.slice(0, 12)
|
|
97
|
+
.map(([fieldName, value]) => [
|
|
98
|
+
fieldName,
|
|
99
|
+
typeof value === "string" ? value.slice(0, 500) : value,
|
|
100
|
+
]),
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { initDataPrograms } from "@agent-native/core/data-programs";
|
|
2
|
+
import { runScript } from "@agent-native/core/scripts";
|
|
3
|
+
|
|
4
|
+
import getCrmPipelineData from "./get-crm-pipeline-data.js";
|
|
5
|
+
|
|
6
|
+
initDataPrograms({
|
|
7
|
+
appId: "crm",
|
|
8
|
+
getActions: () => ({ "get-crm-pipeline-data": getCrmPipelineData }),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
runScript();
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
});
|