@agent-native/core 0.123.0 → 0.123.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +24 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/cli/templates-meta.ts +12 -0
  5. package/corpus/core/src/deploy/build.ts +8 -0
  6. package/corpus/core/src/server/builder-browser.ts +76 -0
  7. package/corpus/core/src/server/core-routes-plugin.ts +15 -5
  8. package/corpus/templates/assets/app/global.css +0 -4
  9. package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +195 -167
  10. package/corpus/templates/assets/changelog/2026-07-23-drafts-preview-panel-now-fills-the-full-width-with-a-large-p.md +6 -0
  11. package/corpus/templates/content/actions/_builder-cms-source-adapter.ts +1 -0
  12. package/corpus/templates/content/actions/_builder-cms-write-client.ts +55 -9
  13. package/corpus/templates/content/actions/_database-source-utils.ts +756 -182
  14. package/corpus/templates/content/actions/change-content-database-source-role.ts +21 -20
  15. package/corpus/templates/content/actions/execute-builder-source-execution.ts +49 -8
  16. package/corpus/templates/content/actions/materialize-builder-required-fields.ts +42 -9
  17. package/corpus/templates/content/actions/prepare-builder-source-review.ts +88 -90
  18. package/corpus/templates/content/actions/preview-builder-source-review.ts +4 -3
  19. package/corpus/templates/content/actions/refresh-content-database-source.ts +36 -9
  20. package/corpus/templates/content/actions/set-content-database-source-write-mode.ts +28 -24
  21. package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +62 -12
  22. package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +91 -16
  23. package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +15 -1
  24. package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +234 -44
  25. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +194 -16
  26. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +95 -42
  27. package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +4 -2
  28. package/corpus/templates/content/app/components/editor/extensions/CodeBlockNode.tsx +10 -166
  29. package/corpus/templates/content/app/components/editor/extensions/VideoBlock.tsx +32 -8
  30. package/corpus/templates/content/app/components/editor/extensions/VideoNode.ts +14 -0
  31. package/corpus/templates/content/app/components/editor/registrySlashItems.ts +5 -1
  32. package/corpus/templates/content/app/hooks/use-content-database.ts +59 -2
  33. package/corpus/templates/content/app/hooks/use-documents.ts +18 -26
  34. package/corpus/templates/content/app/root.tsx +1 -6
  35. package/corpus/templates/content/changelog/2026-07-24-builder-can-now-publish-approved-updates-to-entries-that-are.md +6 -0
  36. package/corpus/templates/content/changelog/2026-07-24-builder-collection-loading-no-longer-restarts-from-the-begin.md +6 -0
  37. package/corpus/templates/content/changelog/2026-07-24-builder-connections-now-complete-securely-from-netlify-deplo.md +6 -0
  38. package/corpus/templates/content/changelog/2026-07-24-builder-draft-creation-now-scopes-execution-to-the-selected-.md +6 -0
  39. package/corpus/templates/content/changelog/2026-07-24-builder-review-now-distinguishes-preparing-a-safe-dry-run-from.md +6 -0
  40. package/corpus/templates/content/changelog/2026-07-24-builder-source-imports-now-recover-from-a-transient-paginati.md +6 -0
  41. package/corpus/templates/content/changelog/2026-07-24-builder-source-refresh-now-preserves-the-provider-bound-fiel.md +6 -0
  42. package/corpus/templates/content/changelog/2026-07-24-builder-update-reviews-now-open-reliably-on-large-collection.md +6 -0
  43. package/corpus/templates/content/changelog/2026-07-24-builder-write-policy-controls-now-reflect-successful-changes.md +6 -0
  44. package/corpus/templates/content/changelog/2026-07-24-date-properties-now-save-reliably-when-selected-with-the-nat.md +6 -0
  45. package/corpus/templates/content/changelog/2026-07-24-editor-slash-search-now-keeps-multi-word-block-names-open.md +6 -0
  46. package/corpus/templates/content/changelog/2026-07-24-exact-editor-slash-commands-now-execute-on-enter-even-if-the.md +6 -0
  47. package/corpus/templates/content/changelog/2026-07-24-new-collaborative-pages-now-save-their-first-edits.md +6 -0
  48. package/corpus/templates/content/changelog/2026-07-24-new-local-builder-rows-no-longer-remain-locked-behind-a-none.md +6 -0
  49. package/corpus/templates/content/changelog/2026-07-24-opening-or-closing-a-collaborative-document-no-longer-lets-u.md +6 -0
  50. package/corpus/templates/content/changelog/2026-07-24-selected-text-now-opens-the-link-editor-with-command-k-or-co.md +6 -0
  51. package/corpus/templates/content/changelog/2026-07-24-slash-menu-block-choices-no-longer-stall-pointer-interaction.md +6 -0
  52. package/corpus/templates/content/changelog/2026-07-24-uploaded-and-embedded-media-now-stay-intact-while-collaborative-document-drafts-save.md +6 -0
  53. package/corpus/templates/content/changelog/2026-07-24-video-link-insertion-now-keeps-its-source-panel-open-while-t.md +6 -0
  54. package/corpus/templates/content/changelog/2026-07-26-builder-publishing-now-shows-safe-validation-details-instead.md +6 -0
  55. package/corpus/templates/content/changelog/2026-07-26-builder-reviews-stay-responsive-on-large-collections-and-pre.md +6 -0
  56. package/corpus/templates/content/changelog/2026-07-26-collaborative-documents-no-longer-flash-duplicated-recent-bl.md +6 -0
  57. package/corpus/templates/content/changelog/2026-07-26-corrected-builder-updates-are-now-reviewed-separately-from-f.md +6 -0
  58. package/corpus/templates/content/changelog/2026-07-26-documents-now-remain-read-only-until-their-live-collaborativ.md +6 -0
  59. package/corpus/templates/content/changelog/2026-07-26-slash-command-menus-now-stay-reachable-when-editing-near-the.md +6 -0
  60. package/corpus/templates/content/changelog/2026-07-26-the-slash-menu-now-shows-one-clear-callout-choice-instead-of.md +6 -0
  61. package/corpus/templates/content/shared/api.ts +1 -0
  62. package/corpus/templates/content/shared/builder-mdx.ts +73 -16
  63. package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +115 -0
  64. package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
  65. package/corpus/templates/crm/.agents/skills/crm/SKILL.md +205 -0
  66. package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +220 -0
  67. package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +169 -0
  68. package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +228 -0
  69. package/corpus/templates/crm/.agents/skills/storing-data/SKILL.md +178 -0
  70. package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +122 -0
  71. package/corpus/templates/crm/.env.example +5 -0
  72. package/corpus/templates/crm/AGENTS.md +82 -0
  73. package/corpus/templates/crm/CHANGELOG.md +25 -0
  74. package/corpus/templates/crm/DEVELOPING.md +66 -0
  75. package/corpus/templates/crm/README.md +122 -0
  76. package/corpus/templates/crm/_gitignore +12 -0
  77. package/corpus/templates/crm/actions/_crm-action-utils.ts +98 -0
  78. package/corpus/templates/crm/actions/_crm-attribute-utils.ts +219 -0
  79. package/corpus/templates/crm/actions/_crm-dashboard.ts +69 -0
  80. package/corpus/templates/crm/actions/_crm-data-program-actions.ts +15 -0
  81. package/corpus/templates/crm/actions/_crm-list-utils.ts +775 -0
  82. package/corpus/templates/crm/actions/_crm-signal-utils.ts +79 -0
  83. package/corpus/templates/crm/actions/add-crm-record-to-list.ts +164 -0
  84. package/corpus/templates/crm/actions/apply-crm-proposals.ts +291 -0
  85. package/corpus/templates/crm/actions/archive-crm-attribute.ts +69 -0
  86. package/corpus/templates/crm/actions/attach-call-evidence.ts +170 -0
  87. package/corpus/templates/crm/actions/configure-crm-connection.ts +126 -0
  88. package/corpus/templates/crm/actions/configure-native-crm.ts +44 -0
  89. package/corpus/templates/crm/actions/create-crm-attribute.ts +350 -0
  90. package/corpus/templates/crm/actions/create-crm-list.ts +194 -0
  91. package/corpus/templates/crm/actions/create-crm-record.ts +148 -0
  92. package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +58 -0
  93. package/corpus/templates/crm/actions/delete-crm-saved-view.ts +68 -0
  94. package/corpus/templates/crm/actions/delete-staged-dataset.ts +14 -0
  95. package/corpus/templates/crm/actions/estimate-crm-enrichment.ts +229 -0
  96. package/corpus/templates/crm/actions/find-crm-duplicates.ts +87 -0
  97. package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +36 -0
  98. package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +35 -0
  99. package/corpus/templates/crm/actions/get-crm-dashboard.ts +14 -0
  100. package/corpus/templates/crm/actions/get-crm-overview.ts +13 -0
  101. package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +61 -0
  102. package/corpus/templates/crm/actions/get-crm-record-page.ts +287 -0
  103. package/corpus/templates/crm/actions/get-crm-record.ts +75 -0
  104. package/corpus/templates/crm/actions/get-crm-workspace.ts +364 -0
  105. package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +81 -0
  106. package/corpus/templates/crm/actions/list-crm-attributes.ts +71 -0
  107. package/corpus/templates/crm/actions/list-crm-connections.ts +68 -0
  108. package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +15 -0
  109. package/corpus/templates/crm/actions/list-crm-dashboards.ts +15 -0
  110. package/corpus/templates/crm/actions/list-crm-enrichment-slots.ts +28 -0
  111. package/corpus/templates/crm/actions/list-crm-list-entries.ts +192 -0
  112. package/corpus/templates/crm/actions/list-crm-lists.ts +80 -0
  113. package/corpus/templates/crm/actions/list-crm-proposals.ts +55 -0
  114. package/corpus/templates/crm/actions/list-crm-record-field-history.ts +201 -0
  115. package/corpus/templates/crm/actions/list-crm-record-values.ts +200 -0
  116. package/corpus/templates/crm/actions/list-crm-records.ts +103 -0
  117. package/corpus/templates/crm/actions/list-crm-saved-views.ts +66 -0
  118. package/corpus/templates/crm/actions/list-crm-signal-hits.ts +43 -0
  119. package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +32 -0
  120. package/corpus/templates/crm/actions/list-crm-tasks.ts +22 -0
  121. package/corpus/templates/crm/actions/list-staged-datasets.ts +14 -0
  122. package/corpus/templates/crm/actions/list-workspace-connections.ts +47 -0
  123. package/corpus/templates/crm/actions/manage-crm-attribute-option.ts +272 -0
  124. package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +87 -0
  125. package/corpus/templates/crm/actions/manage-crm-task.ts +132 -0
  126. package/corpus/templates/crm/actions/merge-crm-records.ts +691 -0
  127. package/corpus/templates/crm/actions/navigate.ts +54 -0
  128. package/corpus/templates/crm/actions/provider-api-catalog.ts +22 -0
  129. package/corpus/templates/crm/actions/provider-api-docs.ts +54 -0
  130. package/corpus/templates/crm/actions/provider-api-request.ts +92 -0
  131. package/corpus/templates/crm/actions/query-staged-dataset.ts +44 -0
  132. package/corpus/templates/crm/actions/record-crm-call-insight.ts +160 -0
  133. package/corpus/templates/crm/actions/record-crm-smart-signal.ts +150 -0
  134. package/corpus/templates/crm/actions/remove-crm-list-entry.ts +79 -0
  135. package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +23 -0
  136. package/corpus/templates/crm/actions/review-crm-signal.ts +31 -0
  137. package/corpus/templates/crm/actions/run-crm-attribute-fill.ts +443 -0
  138. package/corpus/templates/crm/actions/run-crm-enrichment.ts +647 -0
  139. package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +103 -0
  140. package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +265 -0
  141. package/corpus/templates/crm/actions/run.ts +7 -0
  142. package/corpus/templates/crm/actions/save-crm-dashboard.ts +51 -0
  143. package/corpus/templates/crm/actions/save-crm-saved-view.ts +296 -0
  144. package/corpus/templates/crm/actions/sync-crm.ts +146 -0
  145. package/corpus/templates/crm/actions/update-crm-attribute.ts +111 -0
  146. package/corpus/templates/crm/actions/update-crm-list-entry.ts +102 -0
  147. package/corpus/templates/crm/actions/update-crm-list.ts +97 -0
  148. package/corpus/templates/crm/actions/update-crm-record.ts +543 -0
  149. package/corpus/templates/crm/actions/view-screen.ts +324 -0
  150. package/corpus/templates/crm/agent-native.app-skill.json +69 -0
  151. package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +158 -0
  152. package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +78 -0
  153. package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +220 -0
  154. package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +414 -0
  155. package/corpus/templates/crm/app/components/crm/RecordActions.tsx +648 -0
  156. package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +488 -0
  157. package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +232 -0
  158. package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +93 -0
  159. package/corpus/templates/crm/app/components/crm/Surface.tsx +97 -0
  160. package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +180 -0
  161. package/corpus/templates/crm/app/components/crm/board/CrmBoard.tsx +988 -0
  162. package/corpus/templates/crm/app/components/crm/board/board-model.ts +399 -0
  163. package/corpus/templates/crm/app/components/crm/board/entry-filter.ts +150 -0
  164. package/corpus/templates/crm/app/components/crm/board/view-draft.ts +227 -0
  165. package/corpus/templates/crm/app/components/crm/grid/CrmGrid.tsx +1033 -0
  166. package/corpus/templates/crm/app/components/crm/grid/GridCell.tsx +620 -0
  167. package/corpus/templates/crm/app/components/crm/grid/clipboard.ts +84 -0
  168. package/corpus/templates/crm/app/components/crm/grid/model.ts +304 -0
  169. package/corpus/templates/crm/app/components/crm/grid/navigation.ts +220 -0
  170. package/corpus/templates/crm/app/components/crm/grid/query.ts +214 -0
  171. package/corpus/templates/crm/app/components/crm/record/AttributePanel.tsx +192 -0
  172. package/corpus/templates/crm/app/components/crm/record/FieldHistory.tsx +179 -0
  173. package/corpus/templates/crm/app/components/crm/record/RecordHeader.tsx +103 -0
  174. package/corpus/templates/crm/app/components/crm/record/RecordLists.tsx +235 -0
  175. package/corpus/templates/crm/app/components/crm/record/RecordTabs.tsx +206 -0
  176. package/corpus/templates/crm/app/components/crm/record/field-editors.tsx +245 -0
  177. package/corpus/templates/crm/app/components/crm/record/record-data.ts +603 -0
  178. package/corpus/templates/crm/app/components/crm/settings/AdvancedSettings.tsx +49 -0
  179. package/corpus/templates/crm/app/components/crm/settings/AttributeOptionsEditor.tsx +441 -0
  180. package/corpus/templates/crm/app/components/crm/settings/ConnectionSettings.tsx +169 -0
  181. package/corpus/templates/crm/app/components/crm/settings/FieldsSettings.tsx +935 -0
  182. package/corpus/templates/crm/app/components/crm/settings/ListsSettings.tsx +339 -0
  183. package/corpus/templates/crm/app/components/crm/settings/settings-admin.ts +377 -0
  184. package/corpus/templates/crm/app/components/crm/shared/AttributeValueParts.tsx +69 -0
  185. package/corpus/templates/crm/app/components/crm/shared/attribute-value.ts +591 -0
  186. package/corpus/templates/crm/app/components/layout/CrmCommandMenu.tsx +556 -0
  187. package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +130 -0
  188. package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +407 -0
  189. package/corpus/templates/crm/app/components/layout/command-palette-search.ts +126 -0
  190. package/corpus/templates/crm/app/components/layout/crm-ui-intents.ts +41 -0
  191. package/corpus/templates/crm/app/components/layout/sidebar-collapse.ts +40 -0
  192. package/corpus/templates/crm/app/components/layout/sidebar-lists.ts +109 -0
  193. package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +1 -0
  194. package/corpus/templates/crm/app/components/ui/badge.tsx +1 -0
  195. package/corpus/templates/crm/app/components/ui/button.tsx +1 -0
  196. package/corpus/templates/crm/app/components/ui/card.tsx +1 -0
  197. package/corpus/templates/crm/app/components/ui/checkbox.tsx +1 -0
  198. package/corpus/templates/crm/app/components/ui/dialog.tsx +1 -0
  199. package/corpus/templates/crm/app/components/ui/dropdown-menu.tsx +1 -0
  200. package/corpus/templates/crm/app/components/ui/hover-card.tsx +1 -0
  201. package/corpus/templates/crm/app/components/ui/input.tsx +1 -0
  202. package/corpus/templates/crm/app/components/ui/label.tsx +1 -0
  203. package/corpus/templates/crm/app/components/ui/popover.tsx +1 -0
  204. package/corpus/templates/crm/app/components/ui/select.tsx +1 -0
  205. package/corpus/templates/crm/app/components/ui/sheet.tsx +1 -0
  206. package/corpus/templates/crm/app/components/ui/skeleton.tsx +1 -0
  207. package/corpus/templates/crm/app/components/ui/switch.tsx +1 -0
  208. package/corpus/templates/crm/app/components/ui/table.tsx +1 -0
  209. package/corpus/templates/crm/app/components/ui/tabs.tsx +1 -0
  210. package/corpus/templates/crm/app/components/ui/textarea.tsx +1 -0
  211. package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +17 -0
  212. package/corpus/templates/crm/app/components/ui/tooltip.tsx +1 -0
  213. package/corpus/templates/crm/app/design-system.ts +3 -0
  214. package/corpus/templates/crm/app/entry.client.tsx +19 -0
  215. package/corpus/templates/crm/app/entry.server.tsx +10 -0
  216. package/corpus/templates/crm/app/global.css +167 -0
  217. package/corpus/templates/crm/app/hooks/use-keyboard-shortcuts.ts +206 -0
  218. package/corpus/templates/crm/app/hooks/use-navigation-state.ts +48 -0
  219. package/corpus/templates/crm/app/i18n/en-US.ts +684 -0
  220. package/corpus/templates/crm/app/i18n/index.ts +34 -0
  221. package/corpus/templates/crm/app/lib/dashboard.ts +13 -0
  222. package/corpus/templates/crm/app/lib/navigation.ts +17 -0
  223. package/corpus/templates/crm/app/lib/tab-id.ts +1 -0
  224. package/corpus/templates/crm/app/lib/types.ts +172 -0
  225. package/corpus/templates/crm/app/lib/utils.ts +1 -0
  226. package/corpus/templates/crm/app/root.tsx +93 -0
  227. package/corpus/templates/crm/app/routes/_index.tsx +26 -0
  228. package/corpus/templates/crm/app/routes/accounts.tsx +41 -0
  229. package/corpus/templates/crm/app/routes/agent.tsx +5 -0
  230. package/corpus/templates/crm/app/routes/ask.tsx +53 -0
  231. package/corpus/templates/crm/app/routes/dashboard.tsx +118 -0
  232. package/corpus/templates/crm/app/routes/lists.tsx +228 -0
  233. package/corpus/templates/crm/app/routes/opportunities.tsx +41 -0
  234. package/corpus/templates/crm/app/routes/people.tsx +41 -0
  235. package/corpus/templates/crm/app/routes/proposals.tsx +388 -0
  236. package/corpus/templates/crm/app/routes/records.$recordId.tsx +53 -0
  237. package/corpus/templates/crm/app/routes/records.tsx +64 -0
  238. package/corpus/templates/crm/app/routes/settings.tsx +118 -0
  239. package/corpus/templates/crm/app/routes/setup.tsx +308 -0
  240. package/corpus/templates/crm/app/routes/tasks.tsx +252 -0
  241. package/corpus/templates/crm/app/routes/views.tsx +683 -0
  242. package/corpus/templates/crm/app/routes.ts +19 -0
  243. package/corpus/templates/crm/app/vite-env.d.ts +6 -0
  244. package/corpus/templates/crm/changelog/2026-07-26-any-list-or-view-can-be-shown-as-a-board-grouped-by-stage-so.md +6 -0
  245. package/corpus/templates/crm/changelog/2026-07-26-crm-now-finds-likely-duplicate-records-and-tells-you-exactly.md +6 -0
  246. package/corpus/templates/crm/changelog/2026-07-26-enrichment-now-shows-what-a-run-will-cost-before-it-starts-g.md +6 -0
  247. package/corpus/templates/crm/changelog/2026-07-26-lists-turn-any-set-of-records-into-a-pipeline-with-its-own-s.md +6 -0
  248. package/corpus/templates/crm/changelog/2026-07-26-moving-a-record-or-list-entry-into-a-stage-that-was-retired-.md +6 -0
  249. package/corpus/templates/crm/changelog/2026-07-26-opening-a-record-now-shows-one-page-with-its-fields-the-list.md +6 -0
  250. package/corpus/templates/crm/changelog/2026-07-26-press-cmd-k-to-jump-to-any-record-list-view-or-setting-and-u.md +6 -0
  251. package/corpus/templates/crm/changelog/2026-07-26-provider-record-edits-now-show-an-exact-before-after-diff-an.md +6 -0
  252. package/corpus/templates/crm/changelog/2026-07-26-record-page-attribute-labels-now-read-in-full-instead-of-bei.md +6 -0
  253. package/corpus/templates/crm/changelog/2026-07-26-records-now-use-typed-fields-currency-dates-ratings-status-s.md +6 -0
  254. package/corpus/templates/crm/changelog/2026-07-26-retyping-a-value-on-the-record-page-now-replaces-it-instead-.md +6 -0
  255. package/corpus/templates/crm/changelog/2026-07-26-settings-now-has-fields-and-lists-tabs-for-adding-fields-edi.md +6 -0
  256. package/corpus/templates/crm/changelog/2026-07-26-the-proposal-review-now-shows-the-field-that-actually-change.md +6 -0
  257. package/corpus/templates/crm/changelog/2026-07-26-the-record-grid-is-now-a-real-spreadsheet-filter-sort-and-pa.md +6 -0
  258. package/corpus/templates/crm/components.json +20 -0
  259. package/corpus/templates/crm/docs/architecture/crm-contract.md +214 -0
  260. package/corpus/templates/crm/docs/features/README.md +55 -0
  261. package/corpus/templates/crm/docs/features/f1-records-and-fields.mdx +52 -0
  262. package/corpus/templates/crm/docs/features/f2-lists-pipelines-and-views.mdx +48 -0
  263. package/corpus/templates/crm/docs/features/f3-work-and-record-quality.mdx +40 -0
  264. package/corpus/templates/crm/docs/features/f4-evidence-and-chat.mdx +47 -0
  265. package/corpus/templates/crm/learnings.defaults.md +5 -0
  266. package/corpus/templates/crm/netlify.toml +11 -0
  267. package/corpus/templates/crm/package.json +61 -0
  268. package/corpus/templates/crm/public/favicon.svg +1 -0
  269. package/corpus/templates/crm/public/icon-180.svg +1 -0
  270. package/corpus/templates/crm/public/manifest.json +11 -0
  271. package/corpus/templates/crm/react-router.config.ts +7 -0
  272. package/corpus/templates/crm/server/crm/adapter.ts +32 -0
  273. package/corpus/templates/crm/server/crm/crm-field-firewall.ts +64 -0
  274. package/corpus/templates/crm/server/crm/crm-mirror.ts +721 -0
  275. package/corpus/templates/crm/server/crm/field-policy-attributes.ts +48 -0
  276. package/corpus/templates/crm/server/crm/hubspot-adapter.ts +1146 -0
  277. package/corpus/templates/crm/server/crm/native-adapter.ts +1810 -0
  278. package/corpus/templates/crm/server/crm/provider-record-link.ts +264 -0
  279. package/corpus/templates/crm/server/crm/read-through.ts +207 -0
  280. package/corpus/templates/crm/server/crm/salesforce-adapter.ts +1255 -0
  281. package/corpus/templates/crm/server/db/crm-store.ts +1112 -0
  282. package/corpus/templates/crm/server/db/index.ts +191 -0
  283. package/corpus/templates/crm/server/db/schema.ts +647 -0
  284. package/corpus/templates/crm/server/lib/crm-query.ts +1558 -0
  285. package/corpus/templates/crm/server/lib/dedupe.ts +714 -0
  286. package/corpus/templates/crm/server/lib/enrichment-cost.ts +381 -0
  287. package/corpus/templates/crm/server/lib/enrichment-slots.ts +519 -0
  288. package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +65 -0
  289. package/corpus/templates/crm/server/lib/intelligence/evidence.ts +105 -0
  290. package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +94 -0
  291. package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +39 -0
  292. package/corpus/templates/crm/server/lib/intelligence/summary.ts +19 -0
  293. package/corpus/templates/crm/server/lib/lifecycle.ts +634 -0
  294. package/corpus/templates/crm/server/lib/provider-api.ts +64 -0
  295. package/corpus/templates/crm/server/middleware/auth.ts +4 -0
  296. package/corpus/templates/crm/server/plugins/agent-chat.ts +65 -0
  297. package/corpus/templates/crm/server/plugins/auth.ts +14 -0
  298. package/corpus/templates/crm/server/plugins/core-routes.ts +17 -0
  299. package/corpus/templates/crm/server/plugins/db.ts +738 -0
  300. package/corpus/templates/crm/server/routes/[...page].get.ts +5 -0
  301. package/corpus/templates/crm/shared/crm-attributes.ts +469 -0
  302. package/corpus/templates/crm/shared/crm-automation-recipes.ts +132 -0
  303. package/corpus/templates/crm/shared/crm-contract.ts +417 -0
  304. package/corpus/templates/crm/shared/crm-navigation.ts +190 -0
  305. package/corpus/templates/crm/shared/crm-sales-config.ts +63 -0
  306. package/corpus/templates/crm/ssr-entry.ts +11 -0
  307. package/corpus/templates/crm/tsconfig.json +24 -0
  308. package/corpus/templates/crm/vite.config.ts +15 -0
  309. package/corpus/templates/crm/vitest.config.ts +5 -0
  310. package/corpus/templates/design/app/i18n-data.ts +12 -12
  311. package/corpus/templates/design/changelog/2026-07-26-apply-design-updates-from-a-centered-top-toolbar-without-cov.md +6 -0
  312. package/corpus/toolkit/CHANGELOG.md +6 -0
  313. package/corpus/toolkit/package.json +1 -1
  314. package/corpus/toolkit/src/editor/useCollabReconcile.ts +14 -1
  315. package/dist/cli/templates-meta.d.ts.map +1 -1
  316. package/dist/cli/templates-meta.js +12 -0
  317. package/dist/cli/templates-meta.js.map +1 -1
  318. package/dist/collab/routes.d.ts +2 -2
  319. package/dist/deploy/build.js +6 -0
  320. package/dist/deploy/build.js.map +1 -1
  321. package/dist/observability/routes.d.ts +3 -3
  322. package/dist/server/builder-browser.d.ts +13 -0
  323. package/dist/server/builder-browser.d.ts.map +1 -1
  324. package/dist/server/builder-browser.js +59 -0
  325. package/dist/server/builder-browser.js.map +1 -1
  326. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  327. package/dist/server/core-routes-plugin.js +10 -5
  328. package/dist/server/core-routes-plugin.js.map +1 -1
  329. package/dist/server/transcribe-voice.d.ts +1 -1
  330. package/package.json +2 -2
  331. package/src/cli/templates-meta.ts +12 -0
  332. package/src/deploy/build.ts +8 -0
  333. package/src/server/builder-browser.ts +76 -0
  334. package/src/server/core-routes-plugin.ts +15 -5
@@ -0,0 +1,324 @@
1
+ import { defineAction, type ActionRunContext } from "@agent-native/core/action";
2
+ import { readAppStateForCurrentTab } from "@agent-native/core/application-state";
3
+ import { getRequestUserEmail } from "@agent-native/core/server";
4
+ import { accessFilter } from "@agent-native/core/sharing";
5
+ import { and, asc, desc, eq } from "drizzle-orm";
6
+ import { z } from "zod";
7
+
8
+ import {
9
+ createConnectedCrmAdapter,
10
+ isConnectedCrmProvider,
11
+ } from "../server/crm/adapter.js";
12
+ import { createNativeCrmAdapter } from "../server/crm/native-adapter.js";
13
+ import { loadVerifiedReadThroughRecord } from "../server/crm/read-through.js";
14
+ import {
15
+ getCrmOverview,
16
+ getCrmRecord,
17
+ getCrmRecordReadContext,
18
+ getReadThroughRelationshipSummaries,
19
+ listCrmProposals,
20
+ listCrmSavedViews,
21
+ listCrmSignals,
22
+ listCrmTasks,
23
+ } from "../server/db/crm-store.js";
24
+ import { crmDashboardStore, getDb, schema } from "../server/db/index.js";
25
+ import { loadCrmSavedView, queryCrmRecords } from "../server/lib/crm-query.js";
26
+ import {
27
+ parseCrmNavigationSelection,
28
+ type CrmNavigationSelection,
29
+ type CrmView,
30
+ } from "../shared/crm-navigation.js";
31
+
32
+ export default defineAction({
33
+ description:
34
+ "Return an access-scoped snapshot of the visible CRM screen: the current selection plus the relevant records, lists, saved view and its board grouping, tasks, proposals, or setup state.",
35
+ schema: z.object({}),
36
+ http: false,
37
+ readOnly: true,
38
+ run: async (_args, ctx?: ActionRunContext) => {
39
+ const navigation = (await readAppStateForCurrentTab("navigation")) as {
40
+ view?: CrmView;
41
+ path?: string;
42
+ recordId?: string;
43
+ viewId?: string;
44
+ dashboardId?: string;
45
+ query?: string;
46
+ settingsSection?: string;
47
+ } | null;
48
+ const url = await readAppStateForCurrentTab("__url__");
49
+ // The route hook publishes the visited path with its search string, and for
50
+ // the list/board surfaces the search params ARE the selection. Reading them
51
+ // back here beats maintaining a second copy of that state.
52
+ const parsed = parseCrmNavigationSelection(
53
+ navigation?.path ?? (typeof url === "string" ? url : null),
54
+ );
55
+ const selection = resolveSelection(navigation, parsed);
56
+ const actorEmail = ctx?.userEmail ?? getRequestUserEmail() ?? null;
57
+ const screen: Record<string, unknown> = { navigation, url, selection };
58
+
59
+ switch (navigation?.view) {
60
+ case "record":
61
+ if (selection.recordId) {
62
+ [screen.record, screen.signals] = await Promise.all([
63
+ readVisibleRecord(selection.recordId, ctx),
64
+ listCrmSignals({ recordId: selection.recordId, limit: 50 }),
65
+ ]);
66
+ } else {
67
+ screen.record = null;
68
+ screen.signals = [];
69
+ }
70
+ break;
71
+ case "account":
72
+ case "person":
73
+ case "opportunity":
74
+ case "records":
75
+ screen.records = await queryCrmRecords(
76
+ {
77
+ // /records defaults to the accounts tab when the URL names no kind.
78
+ kind:
79
+ navigation.view === "records"
80
+ ? (selection.kind ?? "account")
81
+ : navigation.view,
82
+ ...(selection.query ? { query: selection.query } : {}),
83
+ ...(selection.viewId ? { viewId: selection.viewId } : {}),
84
+ limit: 50,
85
+ },
86
+ { actorEmail },
87
+ );
88
+ break;
89
+ case "lists":
90
+ screen.lists = await visibleLists();
91
+ break;
92
+ case "views":
93
+ case "board":
94
+ screen.savedViews = await listCrmSavedViews({ limit: 50 });
95
+ if (selection.viewId) {
96
+ const view = await loadCrmSavedView(selection.viewId);
97
+ screen.activeView = view;
98
+ screen.records = await queryCrmRecords(
99
+ { viewId: view.id, limit: 50 },
100
+ { actorEmail },
101
+ );
102
+ } else if (selection.listId) {
103
+ // null distinguishes "a list is selected but not visible to you"
104
+ // from "no list is selected", which `selection.listId` still shows.
105
+ screen.activeList = await visibleList(selection.listId);
106
+ }
107
+ break;
108
+ case "tasks":
109
+ screen.tasks = await listCrmTasks({ limit: 50 });
110
+ break;
111
+ case "proposals":
112
+ screen.proposals = await listCrmProposals({ limit: 50 });
113
+ break;
114
+ case "dashboard":
115
+ {
116
+ const dashboards = await crmDashboardStore.list({
117
+ userEmail: ctx?.userEmail,
118
+ orgId: ctx?.orgId ?? undefined,
119
+ });
120
+ screen.dashboards = dashboards;
121
+ screen.dashboard = selection.dashboardId
122
+ ? (dashboards.find(
123
+ (dashboard: { id: string }) =>
124
+ dashboard.id === selection.dashboardId,
125
+ ) ?? null)
126
+ : (dashboards[0] ?? null);
127
+ }
128
+ break;
129
+ case "ask":
130
+ [screen.overview, screen.savedViews] = await Promise.all([
131
+ getCrmOverview(),
132
+ listCrmSavedViews({ limit: 20 }),
133
+ ]);
134
+ break;
135
+ case "setup":
136
+ screen.connections = await visibleConnections();
137
+ break;
138
+ case "settings":
139
+ screen.connections = await visibleConnections();
140
+ screen.signalTrackers = await visibleSignalTrackers();
141
+ break;
142
+ case "work":
143
+ case undefined:
144
+ screen.overview = await getCrmOverview();
145
+ break;
146
+ }
147
+
148
+ return screen;
149
+ },
150
+ });
151
+
152
+ interface ResolvedSelection extends CrmNavigationSelection {
153
+ recordId?: string;
154
+ /** False when the UI published no path, so an absent field is unknown. */
155
+ pathReadable: boolean;
156
+ }
157
+
158
+ /**
159
+ * The fields the route hook publishes explicitly win; the rest come from the
160
+ * visited path. `pathReadable` keeps "nothing selected" distinguishable from
161
+ * "the UI never told us what is selected".
162
+ */
163
+ function resolveSelection(
164
+ navigation: {
165
+ recordId?: string;
166
+ viewId?: string;
167
+ dashboardId?: string;
168
+ query?: string;
169
+ settingsSection?: string;
170
+ } | null,
171
+ parsed: CrmNavigationSelection | null,
172
+ ): ResolvedSelection {
173
+ const viewId = navigation?.viewId ?? parsed?.viewId;
174
+ const dashboardId = navigation?.dashboardId ?? parsed?.dashboardId;
175
+ const query = navigation?.query ?? parsed?.query;
176
+ const settingsSection =
177
+ (navigation?.settingsSection as CrmNavigationSelection["settingsSection"]) ??
178
+ parsed?.settingsSection;
179
+ return {
180
+ pathReadable: parsed !== null,
181
+ ...(navigation?.recordId ? { recordId: navigation.recordId } : {}),
182
+ ...(viewId ? { viewId } : {}),
183
+ ...(parsed?.listId ? { listId: parsed.listId } : {}),
184
+ ...(dashboardId ? { dashboardId } : {}),
185
+ ...(parsed?.kind ? { kind: parsed.kind } : {}),
186
+ ...(parsed?.mode ? { mode: parsed.mode } : {}),
187
+ ...(query ? { query } : {}),
188
+ ...(settingsSection ? { settingsSection } : {}),
189
+ };
190
+ }
191
+
192
+ const LIST_COLUMNS = {
193
+ id: schema.crmLists.id,
194
+ connectionId: schema.crmLists.connectionId,
195
+ name: schema.crmLists.name,
196
+ apiSlug: schema.crmLists.apiSlug,
197
+ description: schema.crmLists.description,
198
+ parentObjectType: schema.crmLists.parentObjectType,
199
+ defaultViewId: schema.crmLists.defaultViewId,
200
+ archived: schema.crmLists.archived,
201
+ position: schema.crmLists.position,
202
+ };
203
+
204
+ async function visibleLists() {
205
+ return getDb()
206
+ .select(LIST_COLUMNS)
207
+ .from(schema.crmLists)
208
+ .where(
209
+ and(
210
+ eq(schema.crmLists.archived, false),
211
+ accessFilter(schema.crmLists, schema.crmListShares),
212
+ ),
213
+ )
214
+ .orderBy(asc(schema.crmLists.position), asc(schema.crmLists.createdAt))
215
+ .limit(50);
216
+ }
217
+
218
+ async function visibleList(listId: string) {
219
+ const [list] = await getDb()
220
+ .select(LIST_COLUMNS)
221
+ .from(schema.crmLists)
222
+ .where(
223
+ and(
224
+ eq(schema.crmLists.id, listId),
225
+ accessFilter(schema.crmLists, schema.crmListShares),
226
+ ),
227
+ )
228
+ .limit(1);
229
+ return list ?? null;
230
+ }
231
+
232
+ async function readVisibleRecord(recordId: string, ctx?: ActionRunContext) {
233
+ const context = await getCrmRecordReadContext(recordId);
234
+ if (!context) return null;
235
+ const adapter =
236
+ context.provider === "native"
237
+ ? await createNativeCrmAdapter({
238
+ connectionId: context.connectionId,
239
+ accessTier: "viewer",
240
+ })
241
+ : isConnectedCrmProvider(context.provider) &&
242
+ context.workspaceConnectionId
243
+ ? await createConnectedCrmAdapter({
244
+ provider: context.provider,
245
+ connectionId: context.workspaceConnectionId,
246
+ ...(ctx?.userEmail ? { userEmail: ctx.userEmail } : {}),
247
+ ...(ctx?.orgId !== undefined ? { orgId: ctx.orgId } : {}),
248
+ })
249
+ : null;
250
+ if (!adapter) return null;
251
+ let readThrough;
252
+ try {
253
+ readThrough = await loadVerifiedReadThroughRecord({ adapter, context });
254
+ } catch {
255
+ return null;
256
+ }
257
+ const relatedRecords = await getReadThroughRelationshipSummaries({
258
+ context,
259
+ relationships: readThrough.relationships,
260
+ currentScopes: readThrough.currentScopes,
261
+ });
262
+ return getCrmRecord(recordId, {
263
+ displayName: readThrough.remote.displayName,
264
+ fields: readThrough.remote.fields,
265
+ remoteRevision: readThrough.remote.remoteRevision,
266
+ remoteUpdatedAt: readThrough.remote.remoteUpdatedAt,
267
+ relatedRecords,
268
+ accessScope: readThrough.currentScope,
269
+ });
270
+ }
271
+
272
+ async function visibleConnections() {
273
+ return getDb()
274
+ .select({
275
+ id: schema.crmConnections.id,
276
+ provider: schema.crmConnections.provider,
277
+ label: schema.crmConnections.label,
278
+ mode: schema.crmConnections.mode,
279
+ status: schema.crmConnections.status,
280
+ lastSyncedAt: schema.crmConnections.lastSyncedAt,
281
+ updatedAt: schema.crmConnections.updatedAt,
282
+ })
283
+ .from(schema.crmConnections)
284
+ .where(accessFilter(schema.crmConnections, schema.crmConnectionShares))
285
+ .orderBy(desc(schema.crmConnections.updatedAt))
286
+ .limit(20);
287
+ }
288
+
289
+ async function visibleSignalTrackers() {
290
+ const trackers = await getDb()
291
+ .select({
292
+ id: schema.crmSignalTrackers.id,
293
+ name: schema.crmSignalTrackers.name,
294
+ description: schema.crmSignalTrackers.description,
295
+ kind: schema.crmSignalTrackers.kind,
296
+ keywordsJson: schema.crmSignalTrackers.keywordsJson,
297
+ classifierPrompt: schema.crmSignalTrackers.classifierPrompt,
298
+ enabled: schema.crmSignalTrackers.enabled,
299
+ isDefault: schema.crmSignalTrackers.isDefault,
300
+ })
301
+ .from(schema.crmSignalTrackers)
302
+ .where(
303
+ accessFilter(schema.crmSignalTrackers, schema.crmSignalTrackerShares),
304
+ )
305
+ .orderBy(asc(schema.crmSignalTrackers.name));
306
+ return trackers.map((tracker) => ({
307
+ ...tracker,
308
+ keywords: safeKeywords(tracker.keywordsJson),
309
+ keywordsJson: undefined,
310
+ }));
311
+ }
312
+
313
+ function safeKeywords(value: string): string[] {
314
+ try {
315
+ const parsed = JSON.parse(value) as unknown;
316
+ return Array.isArray(parsed)
317
+ ? parsed.filter(
318
+ (keyword): keyword is string => typeof keyword === "string",
319
+ )
320
+ : [];
321
+ } catch {
322
+ return [];
323
+ }
324
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "crm",
4
+ "displayName": "CRM",
5
+ "description": "A typed, bitemporal CRM grid with lists, pipelines, and saved board views — running on its own SQL or as a field-policy-aware HubSpot and Salesforce companion.",
6
+ "mcp": { "serverName": "agent-native-crm" },
7
+ "local": {
8
+ "template": "crm",
9
+ "sourcePath": ".",
10
+ "defaultUrl": "http://127.0.0.1:8107",
11
+ "commands": {
12
+ "install": "pnpm install",
13
+ "dev": "pnpm dev",
14
+ "start": "pnpm start"
15
+ }
16
+ },
17
+ "auth": {
18
+ "mode": "oauth",
19
+ "setup": "Start with Native SQL without an external connection, or connect HubSpot or Salesforce through workspace Connections. CRM never accepts or stores provider credentials."
20
+ },
21
+ "surfaces": [
22
+ { "id": "crm-workspace", "action": "get-crm-workspace", "path": "/" },
23
+ { "id": "crm-records", "action": "list-crm-records", "path": "/records" },
24
+ { "id": "crm-lists", "action": "list-crm-lists", "path": "/lists" },
25
+ {
26
+ "id": "crm-saved-views",
27
+ "action": "list-crm-saved-views",
28
+ "path": "/views"
29
+ },
30
+ { "id": "crm-tasks", "action": "list-crm-tasks", "path": "/tasks" },
31
+ {
32
+ "id": "crm-proposals",
33
+ "action": "list-crm-proposals",
34
+ "path": "/proposals"
35
+ },
36
+ {
37
+ "id": "crm-pipeline",
38
+ "action": "get-crm-dashboard",
39
+ "path": "/dashboard"
40
+ },
41
+ {
42
+ "id": "crm-attributes",
43
+ "action": "list-crm-attributes",
44
+ "path": "/settings/fields"
45
+ },
46
+ {
47
+ "id": "crm-signals",
48
+ "action": "list-crm-signal-hits",
49
+ "path": "/records"
50
+ },
51
+ {
52
+ "id": "crm-clips-review-recipe",
53
+ "action": "get-crm-automation-recipe",
54
+ "path": "/records"
55
+ }
56
+ ],
57
+ "skills": [
58
+ { "path": ".agents/skills/crm", "visibility": "both", "exportAs": "crm" }
59
+ ],
60
+ "hostAdapters": [
61
+ "codex-plugin",
62
+ "claude-marketplace",
63
+ "vercel-skills",
64
+ "plain-skill",
65
+ "claude-skill",
66
+ "chatgpt-mcp",
67
+ "generic-mcp"
68
+ ]
69
+ }
@@ -0,0 +1,158 @@
1
+ import { useActionMutation } from "@agent-native/core/client/hooks";
2
+ import { IconPlus } from "@tabler/icons-react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { useState } from "react";
5
+ import { useNavigate } from "react-router";
6
+ import { toast } from "sonner";
7
+
8
+ import { Button } from "@/components/ui/button";
9
+ import {
10
+ Dialog,
11
+ DialogContent,
12
+ DialogDescription,
13
+ DialogFooter,
14
+ DialogHeader,
15
+ DialogTitle,
16
+ DialogTrigger,
17
+ } from "@/components/ui/dialog";
18
+ import { Input } from "@/components/ui/input";
19
+ import { Label } from "@/components/ui/label";
20
+ import type { CrmKind } from "@/lib/types";
21
+
22
+ import type { CrmValue } from "../../../shared/crm-contract";
23
+
24
+ const recordCopy: Record<
25
+ CrmKind,
26
+ {
27
+ noun: string;
28
+ fieldName: string;
29
+ fieldLabel: string;
30
+ fieldPlaceholder: string;
31
+ }
32
+ > = {
33
+ account: {
34
+ noun: "account",
35
+ fieldName: "domain",
36
+ fieldLabel: "Website",
37
+ fieldPlaceholder: "example.com",
38
+ },
39
+ person: {
40
+ noun: "person",
41
+ fieldName: "email",
42
+ fieldLabel: "Email",
43
+ fieldPlaceholder: "name@example.com",
44
+ },
45
+ opportunity: {
46
+ noun: "opportunity",
47
+ fieldName: "stage",
48
+ fieldLabel: "Stage",
49
+ fieldPlaceholder: "Discovery",
50
+ },
51
+ };
52
+
53
+ export function CreateCrmRecordDialog({ kind }: { kind: CrmKind }) {
54
+ const navigate = useNavigate();
55
+ const queryClient = useQueryClient();
56
+ const copy = recordCopy[kind];
57
+ const [open, setOpen] = useState(false);
58
+ const [displayName, setDisplayName] = useState("");
59
+ const [fieldValue, setFieldValue] = useState("");
60
+ const create = useActionMutation<
61
+ { recordId: string },
62
+ {
63
+ connectionId?: string;
64
+ kind: CrmKind;
65
+ displayName: string;
66
+ fields?: Record<string, CrmValue>;
67
+ idempotencyKey?: string;
68
+ }
69
+ >("create-crm-record" as never);
70
+
71
+ function reset() {
72
+ setDisplayName("");
73
+ setFieldValue("");
74
+ }
75
+
76
+ function setDialogOpen(nextOpen: boolean) {
77
+ setOpen(nextOpen);
78
+ if (!nextOpen) reset();
79
+ }
80
+
81
+ async function submit() {
82
+ const fields = fieldValue.trim()
83
+ ? { [copy.fieldName]: fieldValue.trim() }
84
+ : undefined;
85
+ try {
86
+ const result = await create.mutateAsync({
87
+ kind,
88
+ displayName: displayName.trim(),
89
+ fields,
90
+ });
91
+ setDialogOpen(false);
92
+ void queryClient.invalidateQueries({
93
+ queryKey: ["action", "list-crm-records"],
94
+ });
95
+ toast.success(`Native ${copy.noun} created.`);
96
+ navigate(`/records/${encodeURIComponent(result.recordId)}`);
97
+ } catch (error) {
98
+ toast.error(
99
+ error instanceof Error
100
+ ? error.message
101
+ : `Could not create ${copy.noun}.`,
102
+ );
103
+ }
104
+ }
105
+
106
+ return (
107
+ <Dialog open={open} onOpenChange={setDialogOpen}>
108
+ <DialogTrigger asChild>
109
+ <Button size="sm" className="gap-2">
110
+ <IconPlus className="size-4" /> New {copy.noun}
111
+ </Button>
112
+ </DialogTrigger>
113
+ <DialogContent className="sm:max-w-md">
114
+ <DialogHeader>
115
+ <DialogTitle>Create {copy.noun}</DialogTitle>
116
+ <DialogDescription>
117
+ This record lives in the local-authoritative Native SQL CRM. You can
118
+ connect or mirror another CRM separately.
119
+ </DialogDescription>
120
+ </DialogHeader>
121
+ <div className="grid gap-4 py-2">
122
+ <div className="grid gap-2">
123
+ <Label htmlFor={`new-${kind}-name`}>Name</Label>
124
+ <Input
125
+ id={`new-${kind}-name`}
126
+ value={displayName}
127
+ maxLength={300}
128
+ autoFocus
129
+ onChange={(event) => setDisplayName(event.target.value)}
130
+ />
131
+ </div>
132
+ <div className="grid gap-2">
133
+ <Label htmlFor={`new-${kind}-${copy.fieldName}`}>
134
+ {copy.fieldLabel}{" "}
135
+ <span className="text-muted-foreground">(optional)</span>
136
+ </Label>
137
+ <Input
138
+ id={`new-${kind}-${copy.fieldName}`}
139
+ value={fieldValue}
140
+ maxLength={500}
141
+ placeholder={copy.fieldPlaceholder}
142
+ type={copy.fieldName === "email" ? "email" : "text"}
143
+ onChange={(event) => setFieldValue(event.target.value)}
144
+ />
145
+ </div>
146
+ </div>
147
+ <DialogFooter>
148
+ <Button
149
+ disabled={!displayName.trim() || create.isPending}
150
+ onClick={() => void submit()}
151
+ >
152
+ {create.isPending ? "Creating…" : `Create ${copy.noun}`}
153
+ </Button>
154
+ </DialogFooter>
155
+ </DialogContent>
156
+ </Dialog>
157
+ );
158
+ }
@@ -0,0 +1,78 @@
1
+ import { useActionQuery } from "@agent-native/core/client/hooks";
2
+ import {
3
+ GenericChartPanel,
4
+ MetricCard,
5
+ type GenericChartConfig,
6
+ } from "@agent-native/toolkit/dashboard";
7
+
8
+ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
9
+ import type { CrmDashboardPanelConfig } from "@/lib/types";
10
+
11
+ type PanelResult = {
12
+ rows: Record<string, unknown>[];
13
+ schema?: Array<{ name: string; type: string }>;
14
+ truncated?: boolean;
15
+ };
16
+
17
+ export function CrmDashboardPanel({
18
+ dashboardId,
19
+ panel,
20
+ dataPanelId = panel.id,
21
+ }: {
22
+ dashboardId: string;
23
+ panel: CrmDashboardPanelConfig;
24
+ dataPanelId?: string;
25
+ }) {
26
+ const query = useActionQuery<PanelResult>(
27
+ "get-crm-dashboard-panel" as never,
28
+ { dashboardId, panelId: dataPanelId } as never,
29
+ );
30
+ const error = query.error instanceof Error ? query.error.message : undefined;
31
+ const rows = query.data?.rows ?? [];
32
+
33
+ if (panel.chartType === "metric") {
34
+ return (
35
+ <MetricCard
36
+ title={panel.title}
37
+ value={metricValue(rows)}
38
+ description={query.data?.truncated ? "Source is bounded" : undefined}
39
+ loading={query.isLoading}
40
+ error={error}
41
+ />
42
+ );
43
+ }
44
+
45
+ const chart: GenericChartConfig = {
46
+ chartType: panel.chartType,
47
+ xKey: "stage",
48
+ yKeys: ["pipelineValue", "opportunities"],
49
+ ...(panel.chartType === "table"
50
+ ? { columns: ["stage", "pipelineValue", "opportunities"] }
51
+ : {}),
52
+ };
53
+ return (
54
+ <Card className="border-border/70 bg-card">
55
+ <CardHeader className="pb-3">
56
+ <CardTitle className="text-base">{panel.title}</CardTitle>
57
+ </CardHeader>
58
+ <CardContent>
59
+ <GenericChartPanel
60
+ data={query.data?.rows}
61
+ config={panel}
62
+ chart={chart}
63
+ loading={query.isLoading}
64
+ error={error}
65
+ emptyMessage="No opportunities are available in this pipeline yet."
66
+ />
67
+ </CardContent>
68
+ </Card>
69
+ );
70
+ }
71
+
72
+ function metricValue(rows: Record<string, unknown>[]) {
73
+ return rows.reduce(
74
+ (total, row) =>
75
+ total + (typeof row.pipelineValue === "number" ? row.pipelineValue : 0),
76
+ 0,
77
+ );
78
+ }