@agent-native/core 0.123.0 → 0.123.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +16 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/templates-meta.ts +12 -0
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
- package/corpus/templates/crm/.agents/skills/crm/SKILL.md +205 -0
- package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +220 -0
- package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +228 -0
- package/corpus/templates/crm/.agents/skills/storing-data/SKILL.md +178 -0
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +122 -0
- package/corpus/templates/crm/.env.example +5 -0
- package/corpus/templates/crm/AGENTS.md +82 -0
- package/corpus/templates/crm/CHANGELOG.md +25 -0
- package/corpus/templates/crm/DEVELOPING.md +66 -0
- package/corpus/templates/crm/README.md +122 -0
- package/corpus/templates/crm/_gitignore +12 -0
- package/corpus/templates/crm/actions/_crm-action-utils.ts +98 -0
- package/corpus/templates/crm/actions/_crm-attribute-utils.ts +219 -0
- package/corpus/templates/crm/actions/_crm-dashboard.ts +69 -0
- package/corpus/templates/crm/actions/_crm-data-program-actions.ts +15 -0
- package/corpus/templates/crm/actions/_crm-list-utils.ts +775 -0
- package/corpus/templates/crm/actions/_crm-signal-utils.ts +79 -0
- package/corpus/templates/crm/actions/add-crm-record-to-list.ts +164 -0
- package/corpus/templates/crm/actions/apply-crm-proposals.ts +291 -0
- package/corpus/templates/crm/actions/archive-crm-attribute.ts +69 -0
- package/corpus/templates/crm/actions/attach-call-evidence.ts +170 -0
- package/corpus/templates/crm/actions/configure-crm-connection.ts +126 -0
- package/corpus/templates/crm/actions/configure-native-crm.ts +44 -0
- package/corpus/templates/crm/actions/create-crm-attribute.ts +350 -0
- package/corpus/templates/crm/actions/create-crm-list.ts +194 -0
- package/corpus/templates/crm/actions/create-crm-record.ts +148 -0
- package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +58 -0
- package/corpus/templates/crm/actions/delete-crm-saved-view.ts +68 -0
- package/corpus/templates/crm/actions/delete-staged-dataset.ts +14 -0
- package/corpus/templates/crm/actions/estimate-crm-enrichment.ts +229 -0
- package/corpus/templates/crm/actions/find-crm-duplicates.ts +87 -0
- package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +36 -0
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +35 -0
- package/corpus/templates/crm/actions/get-crm-dashboard.ts +14 -0
- package/corpus/templates/crm/actions/get-crm-overview.ts +13 -0
- package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +61 -0
- package/corpus/templates/crm/actions/get-crm-record-page.ts +287 -0
- package/corpus/templates/crm/actions/get-crm-record.ts +75 -0
- package/corpus/templates/crm/actions/get-crm-workspace.ts +364 -0
- package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +81 -0
- package/corpus/templates/crm/actions/list-crm-attributes.ts +71 -0
- package/corpus/templates/crm/actions/list-crm-connections.ts +68 -0
- package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-dashboards.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-enrichment-slots.ts +28 -0
- package/corpus/templates/crm/actions/list-crm-list-entries.ts +192 -0
- package/corpus/templates/crm/actions/list-crm-lists.ts +80 -0
- package/corpus/templates/crm/actions/list-crm-proposals.ts +55 -0
- package/corpus/templates/crm/actions/list-crm-record-field-history.ts +201 -0
- package/corpus/templates/crm/actions/list-crm-record-values.ts +200 -0
- package/corpus/templates/crm/actions/list-crm-records.ts +103 -0
- package/corpus/templates/crm/actions/list-crm-saved-views.ts +66 -0
- package/corpus/templates/crm/actions/list-crm-signal-hits.ts +43 -0
- package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +32 -0
- package/corpus/templates/crm/actions/list-crm-tasks.ts +22 -0
- package/corpus/templates/crm/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/crm/actions/list-workspace-connections.ts +47 -0
- package/corpus/templates/crm/actions/manage-crm-attribute-option.ts +272 -0
- package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +87 -0
- package/corpus/templates/crm/actions/manage-crm-task.ts +132 -0
- package/corpus/templates/crm/actions/merge-crm-records.ts +691 -0
- package/corpus/templates/crm/actions/navigate.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-catalog.ts +22 -0
- package/corpus/templates/crm/actions/provider-api-docs.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-request.ts +92 -0
- package/corpus/templates/crm/actions/query-staged-dataset.ts +44 -0
- package/corpus/templates/crm/actions/record-crm-call-insight.ts +160 -0
- package/corpus/templates/crm/actions/record-crm-smart-signal.ts +150 -0
- package/corpus/templates/crm/actions/remove-crm-list-entry.ts +79 -0
- package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +23 -0
- package/corpus/templates/crm/actions/review-crm-signal.ts +31 -0
- package/corpus/templates/crm/actions/run-crm-attribute-fill.ts +443 -0
- package/corpus/templates/crm/actions/run-crm-enrichment.ts +647 -0
- package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +103 -0
- package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +265 -0
- package/corpus/templates/crm/actions/run.ts +7 -0
- package/corpus/templates/crm/actions/save-crm-dashboard.ts +51 -0
- package/corpus/templates/crm/actions/save-crm-saved-view.ts +296 -0
- package/corpus/templates/crm/actions/sync-crm.ts +146 -0
- package/corpus/templates/crm/actions/update-crm-attribute.ts +111 -0
- package/corpus/templates/crm/actions/update-crm-list-entry.ts +102 -0
- package/corpus/templates/crm/actions/update-crm-list.ts +97 -0
- package/corpus/templates/crm/actions/update-crm-record.ts +543 -0
- package/corpus/templates/crm/actions/view-screen.ts +324 -0
- package/corpus/templates/crm/agent-native.app-skill.json +69 -0
- package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +158 -0
- package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +78 -0
- package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +220 -0
- package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +414 -0
- package/corpus/templates/crm/app/components/crm/RecordActions.tsx +648 -0
- package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +488 -0
- package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +232 -0
- package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +93 -0
- package/corpus/templates/crm/app/components/crm/Surface.tsx +97 -0
- package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +180 -0
- package/corpus/templates/crm/app/components/crm/board/CrmBoard.tsx +988 -0
- package/corpus/templates/crm/app/components/crm/board/board-model.ts +399 -0
- package/corpus/templates/crm/app/components/crm/board/entry-filter.ts +150 -0
- package/corpus/templates/crm/app/components/crm/board/view-draft.ts +227 -0
- package/corpus/templates/crm/app/components/crm/grid/CrmGrid.tsx +1033 -0
- package/corpus/templates/crm/app/components/crm/grid/GridCell.tsx +620 -0
- package/corpus/templates/crm/app/components/crm/grid/clipboard.ts +84 -0
- package/corpus/templates/crm/app/components/crm/grid/model.ts +304 -0
- package/corpus/templates/crm/app/components/crm/grid/navigation.ts +220 -0
- package/corpus/templates/crm/app/components/crm/grid/query.ts +214 -0
- package/corpus/templates/crm/app/components/crm/record/AttributePanel.tsx +192 -0
- package/corpus/templates/crm/app/components/crm/record/FieldHistory.tsx +179 -0
- package/corpus/templates/crm/app/components/crm/record/RecordHeader.tsx +103 -0
- package/corpus/templates/crm/app/components/crm/record/RecordLists.tsx +235 -0
- package/corpus/templates/crm/app/components/crm/record/RecordTabs.tsx +206 -0
- package/corpus/templates/crm/app/components/crm/record/field-editors.tsx +245 -0
- package/corpus/templates/crm/app/components/crm/record/record-data.ts +603 -0
- package/corpus/templates/crm/app/components/crm/settings/AdvancedSettings.tsx +49 -0
- package/corpus/templates/crm/app/components/crm/settings/AttributeOptionsEditor.tsx +441 -0
- package/corpus/templates/crm/app/components/crm/settings/ConnectionSettings.tsx +169 -0
- package/corpus/templates/crm/app/components/crm/settings/FieldsSettings.tsx +935 -0
- package/corpus/templates/crm/app/components/crm/settings/ListsSettings.tsx +339 -0
- package/corpus/templates/crm/app/components/crm/settings/settings-admin.ts +377 -0
- package/corpus/templates/crm/app/components/crm/shared/AttributeValueParts.tsx +69 -0
- package/corpus/templates/crm/app/components/crm/shared/attribute-value.ts +591 -0
- package/corpus/templates/crm/app/components/layout/CrmCommandMenu.tsx +556 -0
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +130 -0
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +407 -0
- package/corpus/templates/crm/app/components/layout/command-palette-search.ts +126 -0
- package/corpus/templates/crm/app/components/layout/crm-ui-intents.ts +41 -0
- package/corpus/templates/crm/app/components/layout/sidebar-collapse.ts +40 -0
- package/corpus/templates/crm/app/components/layout/sidebar-lists.ts +109 -0
- package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/badge.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/button.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/checkbox.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/hover-card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/input.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/label.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/select.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/table.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/tabs.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/crm/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/crm/app/design-system.ts +3 -0
- package/corpus/templates/crm/app/entry.client.tsx +19 -0
- package/corpus/templates/crm/app/entry.server.tsx +10 -0
- package/corpus/templates/crm/app/global.css +167 -0
- package/corpus/templates/crm/app/hooks/use-keyboard-shortcuts.ts +206 -0
- package/corpus/templates/crm/app/hooks/use-navigation-state.ts +48 -0
- package/corpus/templates/crm/app/i18n/en-US.ts +684 -0
- package/corpus/templates/crm/app/i18n/index.ts +34 -0
- package/corpus/templates/crm/app/lib/dashboard.ts +13 -0
- package/corpus/templates/crm/app/lib/navigation.ts +17 -0
- package/corpus/templates/crm/app/lib/tab-id.ts +1 -0
- package/corpus/templates/crm/app/lib/types.ts +172 -0
- package/corpus/templates/crm/app/lib/utils.ts +1 -0
- package/corpus/templates/crm/app/root.tsx +93 -0
- package/corpus/templates/crm/app/routes/_index.tsx +26 -0
- package/corpus/templates/crm/app/routes/accounts.tsx +41 -0
- package/corpus/templates/crm/app/routes/agent.tsx +5 -0
- package/corpus/templates/crm/app/routes/ask.tsx +53 -0
- package/corpus/templates/crm/app/routes/dashboard.tsx +118 -0
- package/corpus/templates/crm/app/routes/lists.tsx +228 -0
- package/corpus/templates/crm/app/routes/opportunities.tsx +41 -0
- package/corpus/templates/crm/app/routes/people.tsx +41 -0
- package/corpus/templates/crm/app/routes/proposals.tsx +388 -0
- package/corpus/templates/crm/app/routes/records.$recordId.tsx +53 -0
- package/corpus/templates/crm/app/routes/records.tsx +64 -0
- package/corpus/templates/crm/app/routes/settings.tsx +118 -0
- package/corpus/templates/crm/app/routes/setup.tsx +308 -0
- package/corpus/templates/crm/app/routes/tasks.tsx +252 -0
- package/corpus/templates/crm/app/routes/views.tsx +683 -0
- package/corpus/templates/crm/app/routes.ts +19 -0
- package/corpus/templates/crm/app/vite-env.d.ts +6 -0
- 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
- package/corpus/templates/crm/changelog/2026-07-26-crm-now-finds-likely-duplicate-records-and-tells-you-exactly.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-enrichment-now-shows-what-a-run-will-cost-before-it-starts-g.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-lists-turn-any-set-of-records-into-a-pipeline-with-its-own-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-moving-a-record-or-list-entry-into-a-stage-that-was-retired-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-opening-a-record-now-shows-one-page-with-its-fields-the-list.md +6 -0
- 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
- package/corpus/templates/crm/changelog/2026-07-26-provider-record-edits-now-show-an-exact-before-after-diff-an.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-record-page-attribute-labels-now-read-in-full-instead-of-bei.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-records-now-use-typed-fields-currency-dates-ratings-status-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-retyping-a-value-on-the-record-page-now-replaces-it-instead-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-settings-now-has-fields-and-lists-tabs-for-adding-fields-edi.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-proposal-review-now-shows-the-field-that-actually-change.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-record-grid-is-now-a-real-spreadsheet-filter-sort-and-pa.md +6 -0
- package/corpus/templates/crm/components.json +20 -0
- package/corpus/templates/crm/docs/architecture/crm-contract.md +214 -0
- package/corpus/templates/crm/docs/features/README.md +55 -0
- package/corpus/templates/crm/docs/features/f1-records-and-fields.mdx +52 -0
- package/corpus/templates/crm/docs/features/f2-lists-pipelines-and-views.mdx +48 -0
- package/corpus/templates/crm/docs/features/f3-work-and-record-quality.mdx +40 -0
- package/corpus/templates/crm/docs/features/f4-evidence-and-chat.mdx +47 -0
- package/corpus/templates/crm/learnings.defaults.md +5 -0
- package/corpus/templates/crm/netlify.toml +11 -0
- package/corpus/templates/crm/package.json +61 -0
- package/corpus/templates/crm/public/favicon.svg +1 -0
- package/corpus/templates/crm/public/icon-180.svg +1 -0
- package/corpus/templates/crm/public/manifest.json +11 -0
- package/corpus/templates/crm/react-router.config.ts +7 -0
- package/corpus/templates/crm/server/crm/adapter.ts +32 -0
- package/corpus/templates/crm/server/crm/crm-field-firewall.ts +64 -0
- package/corpus/templates/crm/server/crm/crm-mirror.ts +721 -0
- package/corpus/templates/crm/server/crm/field-policy-attributes.ts +48 -0
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +1146 -0
- package/corpus/templates/crm/server/crm/native-adapter.ts +1810 -0
- package/corpus/templates/crm/server/crm/provider-record-link.ts +264 -0
- package/corpus/templates/crm/server/crm/read-through.ts +207 -0
- package/corpus/templates/crm/server/crm/salesforce-adapter.ts +1255 -0
- package/corpus/templates/crm/server/db/crm-store.ts +1112 -0
- package/corpus/templates/crm/server/db/index.ts +191 -0
- package/corpus/templates/crm/server/db/schema.ts +647 -0
- package/corpus/templates/crm/server/lib/crm-query.ts +1558 -0
- package/corpus/templates/crm/server/lib/dedupe.ts +714 -0
- package/corpus/templates/crm/server/lib/enrichment-cost.ts +381 -0
- package/corpus/templates/crm/server/lib/enrichment-slots.ts +519 -0
- package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +65 -0
- package/corpus/templates/crm/server/lib/intelligence/evidence.ts +105 -0
- package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +94 -0
- package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +39 -0
- package/corpus/templates/crm/server/lib/intelligence/summary.ts +19 -0
- package/corpus/templates/crm/server/lib/lifecycle.ts +634 -0
- package/corpus/templates/crm/server/lib/provider-api.ts +64 -0
- package/corpus/templates/crm/server/middleware/auth.ts +4 -0
- package/corpus/templates/crm/server/plugins/agent-chat.ts +65 -0
- package/corpus/templates/crm/server/plugins/auth.ts +14 -0
- package/corpus/templates/crm/server/plugins/core-routes.ts +17 -0
- package/corpus/templates/crm/server/plugins/db.ts +738 -0
- package/corpus/templates/crm/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/crm/shared/crm-attributes.ts +469 -0
- package/corpus/templates/crm/shared/crm-automation-recipes.ts +132 -0
- package/corpus/templates/crm/shared/crm-contract.ts +417 -0
- package/corpus/templates/crm/shared/crm-navigation.ts +190 -0
- package/corpus/templates/crm/shared/crm-sales-config.ts +63 -0
- package/corpus/templates/crm/ssr-entry.ts +11 -0
- package/corpus/templates/crm/tsconfig.json +24 -0
- package/corpus/templates/crm/vite.config.ts +15 -0
- package/corpus/templates/crm/vitest.config.ts +5 -0
- package/corpus/templates/design/app/i18n-data.ts +12 -12
- package/corpus/templates/design/changelog/2026-07-26-apply-design-updates-from-a-centered-top-toolbar-without-cov.md +6 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +12 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/templates-meta.ts +12 -0
|
@@ -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,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
|
+
}
|