@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,109 @@
1
+ /**
2
+ * Shapes the sidebar and command menu need from `list-crm-lists` and
3
+ * `list-crm-saved-views`. Both actions are read defensively because the wave-1
4
+ * contract widened saved views (`viewKind`/`targetKind`/`targetId`) while the
5
+ * older `kind` field is still in flight.
6
+ */
7
+
8
+ export interface CrmSidebarList {
9
+ id: string;
10
+ name: string;
11
+ parentObjectType?: string;
12
+ }
13
+
14
+ export interface CrmSidebarSavedView {
15
+ id: string;
16
+ name: string;
17
+ viewKind: "table" | "board";
18
+ targetKind: "object" | "list";
19
+ targetId?: string;
20
+ pinned: boolean;
21
+ }
22
+
23
+ const OBJECT_ROUTES: Record<string, string> = {
24
+ account: "/accounts",
25
+ accounts: "/accounts",
26
+ person: "/people",
27
+ people: "/people",
28
+ contact: "/people",
29
+ opportunity: "/opportunities",
30
+ opportunities: "/opportunities",
31
+ deal: "/opportunities",
32
+ };
33
+
34
+ function rowsOf(payload: unknown, ...keys: string[]): unknown[] {
35
+ if (Array.isArray(payload)) return payload;
36
+ if (!payload || typeof payload !== "object") return [];
37
+ for (const key of keys) {
38
+ const value = (payload as Record<string, unknown>)[key];
39
+ if (Array.isArray(value)) return value;
40
+ }
41
+ return [];
42
+ }
43
+
44
+ function text(value: unknown): string | undefined {
45
+ return typeof value === "string" && value.trim().length > 0
46
+ ? value.trim()
47
+ : undefined;
48
+ }
49
+
50
+ export function normalizeCrmLists(payload: unknown): CrmSidebarList[] {
51
+ return rowsOf(payload, "lists", "items", "rows").flatMap((row) => {
52
+ if (!row || typeof row !== "object") return [];
53
+ const record = row as Record<string, unknown>;
54
+ const id = text(record.id);
55
+ const name = text(record.name);
56
+ if (!id || !name) return [];
57
+ if (record.archived === true) return [];
58
+ return [
59
+ {
60
+ id,
61
+ name,
62
+ ...(text(record.parentObjectType)
63
+ ? { parentObjectType: text(record.parentObjectType) as string }
64
+ : {}),
65
+ },
66
+ ];
67
+ });
68
+ }
69
+
70
+ export function normalizeCrmSavedViews(
71
+ payload: unknown,
72
+ ): CrmSidebarSavedView[] {
73
+ return rowsOf(payload, "views", "savedViews", "items", "rows").flatMap(
74
+ (row) => {
75
+ if (!row || typeof row !== "object") return [];
76
+ const record = row as Record<string, unknown>;
77
+ const id = text(record.id);
78
+ const name = text(record.name);
79
+ if (!id || !name) return [];
80
+
81
+ const targetKind = record.targetKind === "list" ? "list" : "object";
82
+ const targetId =
83
+ text(record.targetId) ??
84
+ (targetKind === "object" ? text(record.kind) : undefined);
85
+
86
+ return [
87
+ {
88
+ id,
89
+ name,
90
+ viewKind: record.viewKind === "board" ? "board" : "table",
91
+ targetKind,
92
+ ...(targetId ? { targetId } : {}),
93
+ pinned: record.pinned === true,
94
+ } satisfies CrmSidebarSavedView,
95
+ ];
96
+ },
97
+ );
98
+ }
99
+
100
+ export function savedViewHref(view: CrmSidebarSavedView): string {
101
+ const query = `?view=${encodeURIComponent(view.id)}`;
102
+ if (view.targetKind === "list" && view.targetId) {
103
+ return `/lists/${encodeURIComponent(view.targetId)}${query}`;
104
+ }
105
+ const objectRoute = view.targetId
106
+ ? OBJECT_ROUTES[view.targetId.toLowerCase()]
107
+ : undefined;
108
+ return `${objectRoute ?? "/views"}${query}`;
109
+ }
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/alert-dialog";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/badge";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/button";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/card";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/checkbox";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/dialog";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/dropdown-menu";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/hover-card";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/input";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/label";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/popover";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/select";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/sheet";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/skeleton";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/switch";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/table";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/tabs";
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/textarea";
@@ -0,0 +1,17 @@
1
+ import { ToolkitProvider, type ToolkitComponents } from "@agent-native/toolkit";
2
+ import type { ReactNode } from "react";
3
+
4
+ import { Button } from "@/components/ui/button";
5
+ import { designSystem } from "@/design-system";
6
+
7
+ const components: ToolkitComponents = {
8
+ Button: Button as ToolkitComponents["Button"],
9
+ };
10
+
11
+ export function AppToolkitProvider({ children }: { children: ReactNode }) {
12
+ return (
13
+ <ToolkitProvider components={components} designSystem={designSystem}>
14
+ {children}
15
+ </ToolkitProvider>
16
+ );
17
+ }
@@ -0,0 +1 @@
1
+ export * from "@agent-native/toolkit/ui/tooltip";
@@ -0,0 +1,3 @@
1
+ import { defineDesignSystem } from "@agent-native/toolkit/design-system";
2
+
3
+ export const designSystem = defineDesignSystem({});
@@ -0,0 +1,19 @@
1
+ import { appBasePath } from "@agent-native/core/client/api-path";
2
+ import { installRouteChunkRecovery } from "@agent-native/core/client/route-chunk-recovery";
3
+ import { hydrateRoot } from "react-dom/client";
4
+ import { HydratedRouter } from "react-router/dom";
5
+
6
+ installRouteChunkRecovery();
7
+
8
+ const basePath = appBasePath();
9
+ const pathname = window.location.pathname;
10
+ const routerBasePath =
11
+ basePath && (pathname === basePath || pathname.startsWith(`${basePath}/`))
12
+ ? basePath
13
+ : "";
14
+ const context = (
15
+ window as Window & { __reactRouterContext?: { basename?: string } }
16
+ ).__reactRouterContext;
17
+ if (context) context.basename = routerBasePath;
18
+
19
+ hydrateRoot(document, <HydratedRouter />);
@@ -0,0 +1,10 @@
1
+ import {
2
+ createDocumentRequestHandler,
3
+ streamTimeout,
4
+ } from "@agent-native/core/server/entry-server";
5
+ import { ServerRouter } from "react-router";
6
+
7
+ const handleDocumentRequest = createDocumentRequestHandler(ServerRouter);
8
+
9
+ export { streamTimeout };
10
+ export default handleDocumentRequest;
@@ -0,0 +1,167 @@
1
+ @import "@fontsource-variable/inter";
2
+ @import "tailwindcss";
3
+ @import "@agent-native/core/styles/agent-native.css";
4
+ @import "@agent-native/toolkit/styles.css";
5
+
6
+ @source "./**/*.{ts,tsx}";
7
+
8
+ :root {
9
+ --background: 0 0% 100%;
10
+ --foreground: 0 0% 10%;
11
+ --card: 0 0% 100%;
12
+ --card-foreground: 0 0% 10%;
13
+ --popover: 0 0% 100%;
14
+ --popover-foreground: 0 0% 10%;
15
+ --primary: 0 0% 15%;
16
+ --primary-foreground: 0 0% 100%;
17
+ --secondary: 0 0% 95%;
18
+ --secondary-foreground: 0 0% 15%;
19
+ --muted: 0 0% 95%;
20
+ --muted-foreground: 0 0% 45%;
21
+ --accent: 0 0% 95%;
22
+ --accent-foreground: 0 0% 15%;
23
+ --destructive: 0 84% 60%;
24
+ --destructive-foreground: 0 0% 98%;
25
+ --border: 0 0% 90%;
26
+ --input: 0 0% 90%;
27
+ --ring: 0 0% 40%;
28
+ --chart-1: 0 0% 20%;
29
+ --chart-2: 155 36% 42%;
30
+ --chart-3: 32 55% 50%;
31
+ --chart-4: 270 25% 55%;
32
+ --chart-5: 350 38% 55%;
33
+ --chart-6: 190 25% 48%;
34
+ --radius: 0.5rem;
35
+ --sidebar-background: 0 0% 97%;
36
+ --sidebar-foreground: 0 0% 45%;
37
+ --sidebar-primary: 0 0% 15%;
38
+ --sidebar-primary-foreground: 0 0% 100%;
39
+ --sidebar-accent: 0 0% 95%;
40
+ --sidebar-accent-foreground: 0 0% 15%;
41
+ --sidebar-border: 0 0% 90%;
42
+ --sidebar-ring: 0 0% 40%;
43
+ }
44
+
45
+ .dark {
46
+ --background: 0 0% 13%;
47
+ --foreground: 0 0% 90%;
48
+ --card: 0 0% 15%;
49
+ --card-foreground: 0 0% 90%;
50
+ --popover: 0 0% 15%;
51
+ --popover-foreground: 0 0% 90%;
52
+ --primary: 0 0% 75%;
53
+ --primary-foreground: 0 0% 10%;
54
+ --secondary: 0 0% 18%;
55
+ --secondary-foreground: 0 0% 90%;
56
+ --muted: 0 0% 16%;
57
+ --muted-foreground: 0 0% 60%;
58
+ --accent: 0 0% 18%;
59
+ --accent-foreground: 0 0% 96%;
60
+ --destructive: 0 84% 60%;
61
+ --destructive-foreground: 0 0% 98%;
62
+ --border: 0 0% 24%;
63
+ --input: 0 0% 24%;
64
+ --ring: 0 0% 60%;
65
+ --chart-1: 0 0% 78%;
66
+ --chart-2: 155 32% 58%;
67
+ --chart-3: 32 50% 62%;
68
+ --chart-4: 270 28% 68%;
69
+ --chart-5: 350 38% 66%;
70
+ --chart-6: 190 28% 62%;
71
+ --sidebar-background: 0 0% 10%;
72
+ --sidebar-foreground: 0 0% 60%;
73
+ --sidebar-primary: 0 0% 75%;
74
+ --sidebar-primary-foreground: 0 0% 10%;
75
+ --sidebar-accent: 0 0% 16%;
76
+ --sidebar-accent-foreground: 0 0% 90%;
77
+ --sidebar-border: 0 0% 20%;
78
+ --sidebar-ring: 0 0% 60%;
79
+ }
80
+
81
+ @layer base {
82
+ * {
83
+ @apply border-border;
84
+ }
85
+ html,
86
+ body {
87
+ @apply bg-background text-foreground;
88
+ font-family: "Inter Variable", Inter, sans-serif;
89
+ font-feature-settings: "cv02", "cv03", "cv04", "cv11";
90
+ }
91
+ }
92
+
93
+ ::-webkit-scrollbar {
94
+ width: 5px;
95
+ height: 5px;
96
+ }
97
+ ::-webkit-scrollbar-track {
98
+ background: transparent;
99
+ }
100
+ ::-webkit-scrollbar-thumb {
101
+ border-radius: 3px;
102
+ background: hsl(var(--border));
103
+ }
104
+
105
+ .crm-chat-intro {
106
+ display: none;
107
+ }
108
+ .crm-chat-panel [data-agent-empty-state="centered"] {
109
+ justify-content: center;
110
+ padding-bottom: clamp(4rem, 12vh, 8rem);
111
+ }
112
+ .crm-chat-panel [data-agent-empty-state="centered"] .crm-chat-intro {
113
+ display: grid;
114
+ width: 100%;
115
+ max-width: min(670px, 90%);
116
+ gap: 0.5rem;
117
+ margin: 0 auto 1rem;
118
+ text-align: center;
119
+ }
120
+ .crm-chat-intro h1 {
121
+ margin: 0;
122
+ font-size: clamp(1.75rem, 2.5vw, 2.5rem);
123
+ font-weight: 600;
124
+ letter-spacing: -0.03em;
125
+ line-height: 1.1;
126
+ }
127
+ .crm-chat-intro p {
128
+ margin: 0;
129
+ color: hsl(var(--muted-foreground));
130
+ font-size: 0.9375rem;
131
+ line-height: 1.5;
132
+ }
133
+ .crm-chat-panel [data-agent-empty-state="centered"] .agent-chat-scroll {
134
+ flex: 0 0 auto;
135
+ min-height: 0;
136
+ overflow: visible;
137
+ }
138
+ .crm-chat-panel [data-agent-empty-state="centered"] .agent-composer-area {
139
+ width: 100%;
140
+ max-width: min(670px, 90%);
141
+ padding: 0;
142
+ }
143
+ .crm-chat-panel [data-agent-empty-state="centered"] .agent-composer-root {
144
+ min-height: 7.5rem;
145
+ border-color: hsl(var(--border));
146
+ border-radius: 1rem;
147
+ background: hsl(var(--card));
148
+ box-shadow: none;
149
+ }
150
+ .crm-chat-panel
151
+ [data-agent-empty-state="centered"]
152
+ .agent-composer-prosemirror {
153
+ min-height: 4.75rem;
154
+ font-size: 1rem;
155
+ line-height: 1.625rem;
156
+ }
157
+
158
+ @media (max-width: 767px) {
159
+ .crm-chat-panel [data-agent-empty-state="centered"] {
160
+ padding: 1rem;
161
+ padding-bottom: 5rem;
162
+ }
163
+ .crm-chat-panel [data-agent-empty-state="centered"] .agent-composer-area,
164
+ .crm-chat-panel [data-agent-empty-state="centered"] .crm-chat-intro {
165
+ max-width: 100%;
166
+ }
167
+ }
@@ -0,0 +1,206 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ export interface KeyboardShortcut {
4
+ /** Single key, compared case-insensitively against `KeyboardEvent.key`. */
5
+ key: string;
6
+ /** Requires Cmd (macOS) or Ctrl. */
7
+ meta?: boolean;
8
+ shift?: boolean;
9
+ handler: (event: KeyboardEvent) => void;
10
+ }
11
+
12
+ export interface SequenceShortcut {
13
+ /** Lower-case keys in order, e.g. `["g", "a"]`. */
14
+ keys: string[];
15
+ handler: () => void;
16
+ }
17
+
18
+ /** The parts of an event target the shortcut layer inspects. */
19
+ export interface ShortcutEventTarget {
20
+ tagName?: string;
21
+ isContentEditable?: boolean;
22
+ closest?: (selector: string) => unknown;
23
+ }
24
+
25
+ /** The parts of a keyboard event the shortcut layer inspects. */
26
+ export interface ShortcutKeyEvent {
27
+ key: string;
28
+ metaKey?: boolean;
29
+ ctrlKey?: boolean;
30
+ altKey?: boolean;
31
+ shiftKey?: boolean;
32
+ target?: ShortcutEventTarget | null;
33
+ }
34
+
35
+ export const SEQUENCE_SHORTCUT_TIMEOUT_MS = 1000;
36
+
37
+ export function shouldIgnoreShortcutTarget(
38
+ target: ShortcutEventTarget | null | undefined,
39
+ ): boolean {
40
+ if (!target) return false;
41
+ const tag = target.tagName?.toLowerCase();
42
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
43
+ if (target.isContentEditable) return true;
44
+ return Boolean(target.closest?.("[contenteditable]"));
45
+ }
46
+
47
+ export function resolveShortcut<T extends KeyboardShortcut>(
48
+ event: ShortcutKeyEvent,
49
+ shortcuts: readonly T[],
50
+ ): T | null {
51
+ if (shouldIgnoreShortcutTarget(event.target)) return null;
52
+ if (event.altKey) return null;
53
+
54
+ const key = event.key.toLowerCase();
55
+ const modified = Boolean(event.metaKey || event.ctrlKey);
56
+
57
+ for (const shortcut of shortcuts) {
58
+ if (key !== shortcut.key.toLowerCase()) continue;
59
+ if (Boolean(shortcut.meta) !== modified) continue;
60
+ if (Boolean(shortcut.shift) !== Boolean(event.shiftKey)) continue;
61
+ return shortcut;
62
+ }
63
+
64
+ return null;
65
+ }
66
+
67
+ export type SequenceMatch<T extends SequenceShortcut> =
68
+ /** The keystroke completed a chord. */
69
+ | { status: "matched"; sequence: T }
70
+ /** The keystroke started or extended a chord; nothing else may claim it. */
71
+ | { status: "pending" }
72
+ /** The keystroke is not part of any chord and is free for a plain binding. */
73
+ | { status: "none" };
74
+
75
+ export interface SequenceMatcher<T extends SequenceShortcut> {
76
+ push(event: ShortcutKeyEvent, now: number): SequenceMatch<T>;
77
+ reset(): void;
78
+ }
79
+
80
+ function startsWith(keys: readonly string[], prefix: readonly string[]) {
81
+ return prefix.every((key, index) => keys[index] === key);
82
+ }
83
+
84
+ /**
85
+ * Chord matcher with an explicit clock instead of a timer, so the buffer
86
+ * expires deterministically and no timeout outlives an unmounted component.
87
+ * The buffer only ever holds a live prefix, which is what lets a caller tell a
88
+ * pending chord (`g` before `g t`) apart from a free key (a bare `t`).
89
+ */
90
+ export function createSequenceMatcher<T extends SequenceShortcut>(
91
+ sequences: readonly T[],
92
+ timeoutMs: number = SEQUENCE_SHORTCUT_TIMEOUT_MS,
93
+ ): SequenceMatcher<T> {
94
+ let buffer: string[] = [];
95
+ let lastKeyAt: number | null = null;
96
+
97
+ const clear = () => {
98
+ buffer = [];
99
+ lastKeyAt = null;
100
+ };
101
+
102
+ return {
103
+ push(event, now) {
104
+ if (shouldIgnoreShortcutTarget(event.target)) {
105
+ clear();
106
+ return { status: "none" };
107
+ }
108
+ if (event.metaKey || event.ctrlKey || event.altKey) {
109
+ return { status: "none" };
110
+ }
111
+
112
+ if (lastKeyAt !== null && now - lastKeyAt > timeoutMs) clear();
113
+ const candidate = [...buffer, event.key.toLowerCase()];
114
+
115
+ const matched = sequences.find(
116
+ (sequence) =>
117
+ sequence.keys.length === candidate.length &&
118
+ startsWith(sequence.keys, candidate),
119
+ );
120
+ if (matched) {
121
+ clear();
122
+ return { status: "matched", sequence: matched };
123
+ }
124
+
125
+ const pending = sequences.some(
126
+ (sequence) =>
127
+ sequence.keys.length > candidate.length &&
128
+ startsWith(sequence.keys, candidate),
129
+ );
130
+ if (pending) {
131
+ buffer = candidate;
132
+ lastKeyAt = now;
133
+ return { status: "pending" };
134
+ }
135
+
136
+ clear();
137
+ return { status: "none" };
138
+ },
139
+ reset: clear,
140
+ };
141
+ }
142
+
143
+ export interface UseShortcutsOptions {
144
+ shortcuts?: readonly KeyboardShortcut[];
145
+ sequences?: readonly SequenceShortcut[];
146
+ enabled?: boolean;
147
+ timeoutMs?: number;
148
+ }
149
+
150
+ /**
151
+ * One window listener for both plain keys and chords. Chords are resolved
152
+ * first: without that, pressing `g` then `t` would run the `g t` chord *and*
153
+ * the bare `t` binding.
154
+ */
155
+ export function useKeyboardShortcuts({
156
+ shortcuts = [],
157
+ sequences = [],
158
+ enabled = true,
159
+ timeoutMs = SEQUENCE_SHORTCUT_TIMEOUT_MS,
160
+ }: UseShortcutsOptions) {
161
+ const shortcutsRef = useRef(shortcuts);
162
+ const sequencesRef = useRef(sequences);
163
+ shortcutsRef.current = shortcuts;
164
+ sequencesRef.current = sequences;
165
+
166
+ // Resubscribing rebuilds the matcher and drops an in-flight chord, so the
167
+ // effect keys on the chord shape only — handlers stay live through the ref.
168
+ const chordSignature = sequences
169
+ .map((sequence) => sequence.keys.join("+"))
170
+ .join("|");
171
+
172
+ useEffect(() => {
173
+ if (!enabled) return;
174
+
175
+ const matcher = createSequenceMatcher(
176
+ sequencesRef.current.map((sequence, index) => ({
177
+ keys: sequence.keys,
178
+ handler: () => sequencesRef.current[index]?.handler(),
179
+ })),
180
+ timeoutMs,
181
+ );
182
+
183
+ const onKeyDown = (event: KeyboardEvent) => {
184
+ const shortcutEvent = event as unknown as ShortcutKeyEvent;
185
+ const chord = matcher.push(shortcutEvent, Date.now());
186
+
187
+ if (chord.status === "matched") {
188
+ event.preventDefault();
189
+ chord.sequence.handler();
190
+ return;
191
+ }
192
+ if (chord.status === "pending") {
193
+ event.preventDefault();
194
+ return;
195
+ }
196
+
197
+ const shortcut = resolveShortcut(shortcutEvent, shortcutsRef.current);
198
+ if (!shortcut) return;
199
+ event.preventDefault();
200
+ shortcut.handler(event);
201
+ };
202
+
203
+ window.addEventListener("keydown", onKeyDown);
204
+ return () => window.removeEventListener("keydown", onKeyDown);
205
+ }, [enabled, timeoutMs, chordSignature]);
206
+ }
@@ -0,0 +1,48 @@
1
+ import { appPath } from "@agent-native/core/client/api-path";
2
+ import { useAgentRouteState } from "@agent-native/core/client/navigation";
3
+
4
+ import {
5
+ crmNavigationPath,
6
+ viewFromPath,
7
+ type CrmNavigationTarget,
8
+ type CrmView,
9
+ } from "@/lib/navigation";
10
+ import { TAB_ID } from "@/lib/tab-id";
11
+
12
+ export interface CrmNavigationState {
13
+ view: CrmView;
14
+ path: string;
15
+ recordId?: string;
16
+ viewId?: string;
17
+ query?: string;
18
+ settingsSection?: "intelligence";
19
+ dashboardId?: string;
20
+ }
21
+
22
+ /** Exactly what `navigate` accepts, so no destination is dropped in between. */
23
+ export type CrmNavigateCommand = CrmNavigationTarget;
24
+
25
+ export function useNavigationState() {
26
+ useAgentRouteState<CrmNavigationState, CrmNavigateCommand>({
27
+ browserTabId: TAB_ID,
28
+ requestSource: TAB_ID,
29
+ getNavigationState: ({ pathname, search }) => {
30
+ const params = new URLSearchParams(search);
31
+ const recordMatch = pathname.match(/^\/records\/([^/?#]+)/);
32
+ const settingsMatch = pathname.match(/^\/settings\/([^/?#]+)/);
33
+ return {
34
+ view: viewFromPath(pathname),
35
+ path: appPath(`${pathname}${search}`),
36
+ recordId: recordMatch?.[1]
37
+ ? decodeURIComponent(recordMatch[1])
38
+ : undefined,
39
+ viewId: params.get("view") ?? undefined,
40
+ dashboardId: params.get("id") ?? undefined,
41
+ query: params.get("q") ?? undefined,
42
+ settingsSection:
43
+ settingsMatch?.[1] === "intelligence" ? "intelligence" : undefined,
44
+ };
45
+ },
46
+ getCommandPath: (command) => crmNavigationPath(command),
47
+ });
48
+ }