@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,220 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: customizing-agent-native
|
|
3
|
+
description: >-
|
|
4
|
+
How to configure, compose, or eject Agent Native features into app-owned
|
|
5
|
+
code. Use when overriding shared components or integrations, customizing a
|
|
6
|
+
template, adding UI to chat or headless apps, or inspecting package source.
|
|
7
|
+
scope: dev
|
|
8
|
+
metadata:
|
|
9
|
+
internal: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Customizing Agent Native
|
|
13
|
+
|
|
14
|
+
## Rule
|
|
15
|
+
|
|
16
|
+
Start with the app's registered design system and local UI adapters, then use
|
|
17
|
+
the public feature's props, semantic components, controller, product slots,
|
|
18
|
+
and callbacks. If those seams are not enough, use the eject CLI to transfer
|
|
19
|
+
the smallest supported feature into the app and make that copy app-owned.
|
|
20
|
+
Never edit `node_modules`, deep-import a private source file at runtime, or
|
|
21
|
+
patch an `@agent-native/*` package.
|
|
22
|
+
|
|
23
|
+
Use this order:
|
|
24
|
+
|
|
25
|
+
1. Set brand tokens with the build-time theme configuration when tokens are
|
|
26
|
+
enough.
|
|
27
|
+
2. Register company components in `app/design-system.ts` with
|
|
28
|
+
`defineDesignSystem`, then pass that definition to `ToolkitProvider`.
|
|
29
|
+
3. Configure a public feature through its semantic components, headless
|
|
30
|
+
controller, and product-level render slots.
|
|
31
|
+
4. Compose app primitives behind the app's local UI adapter layer.
|
|
32
|
+
5. Eject the smallest feature into app-owned source.
|
|
33
|
+
6. Propose a new Toolkit seam when the same override is useful in two apps.
|
|
34
|
+
|
|
35
|
+
Ejection is for intentional product customization, not for hiding an upgrade
|
|
36
|
+
failure or replacing Core runtime behavior.
|
|
37
|
+
|
|
38
|
+
## Use A Company Design System
|
|
39
|
+
|
|
40
|
+
Keep the explicit, typed registration seam in `app/design-system.ts`:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { defineDesignSystem } from "@agent-native/toolkit/design-system";
|
|
44
|
+
import {
|
|
45
|
+
AcmeActionButtonAdapter,
|
|
46
|
+
AcmeDialogAdapter,
|
|
47
|
+
} from "./design-system/acme-adapter";
|
|
48
|
+
|
|
49
|
+
export const designSystem = defineDesignSystem({
|
|
50
|
+
name: "Acme",
|
|
51
|
+
components: {
|
|
52
|
+
ActionButton: AcmeActionButtonAdapter,
|
|
53
|
+
Dialog: AcmeDialogAdapter,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Adapters translate the semantic Toolkit contract into company component props.
|
|
59
|
+
They are ordinary React components and may use MUI-style providers, React Aria,
|
|
60
|
+
CSS modules, CSS-in-JS, or another styling runtime. `className` and `style` are
|
|
61
|
+
optional interoperability hooks, not Tailwind or CVA requirements.
|
|
62
|
+
|
|
63
|
+
The contract has nine leaf components (`ActionButton`, `IconButton`,
|
|
64
|
+
`TextField`, `TextArea`, `Spinner`, `Skeleton`, `Status`, `Surface`, `Avatar`)
|
|
65
|
+
and eight behavior components (`Tooltip`, `Menu`, `Popover`, `Dialog`,
|
|
66
|
+
`Picker`, `Checkbox`, `Switch`, `Tabs`). `Picker` covers select and combobox
|
|
67
|
+
behavior, not date picking. Behavior adapters own their portal, focus,
|
|
68
|
+
keyboard, dismissal, and stacking implementation while honoring the semantic
|
|
69
|
+
props and `portalContainer` interop contract.
|
|
70
|
+
|
|
71
|
+
App product code imports standard controls from its local adapter path, usually
|
|
72
|
+
`@/components/ui/*`. Do not import `@agent-native/toolkit/ui/*` directly from
|
|
73
|
+
pages, routes, or domain components. That bypasses the app seam and makes a
|
|
74
|
+
future design-system replacement incomplete. Toolkit feature packages remain
|
|
75
|
+
valid imports; configure their presentation through the registered semantic
|
|
76
|
+
components, controller, and product slots.
|
|
77
|
+
|
|
78
|
+
Run the published conformance kit against a complete adapter in its own CI:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { assertDesignSystemConformance } from "@agent-native/toolkit/conformance";
|
|
82
|
+
import { DESIGN_SYSTEM_CONTRACT_VERSION } from "@agent-native/toolkit/design-system";
|
|
83
|
+
|
|
84
|
+
await assertDesignSystemConformance({
|
|
85
|
+
adapterName: "Acme",
|
|
86
|
+
components,
|
|
87
|
+
contractVersion: DESIGN_SYSTEM_CONTRACT_VERSION,
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
New components and optional props are minor contract changes. Required props,
|
|
92
|
+
removed APIs, or behavioral changes require a new contract major.
|
|
93
|
+
|
|
94
|
+
## Customize A Shared Feature
|
|
95
|
+
|
|
96
|
+
Prefer feature-level headless controllers over rebuilding individual widgets.
|
|
97
|
+
One controller must power both the Toolkit default view and every custom render
|
|
98
|
+
path so behavior, actions, analytics, accessibility state, and error handling
|
|
99
|
+
cannot drift. Use a product-level render slot to replace the view while keeping
|
|
100
|
+
that controller. Eject only when the controller and slots cannot express the
|
|
101
|
+
required product behavior.
|
|
102
|
+
|
|
103
|
+
## Eject A Feature
|
|
104
|
+
|
|
105
|
+
Discover and inspect the ejection units published by installed first-party
|
|
106
|
+
packages before changing source:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
agent-native eject --list
|
|
110
|
+
agent-native eject inspect <unit>
|
|
111
|
+
agent-native eject <unit> --app <app>
|
|
112
|
+
agent-native eject <unit> --app <app> --apply
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The command is dry-run by default. It prints the file closure, consumer import
|
|
116
|
+
rewrites, protected package contracts, and verification commands before
|
|
117
|
+
writing. `--apply` copies the package-version-matched source into the app and
|
|
118
|
+
rewrites only imports covered by the unit manifest.
|
|
119
|
+
|
|
120
|
+
Every first-party public ejection unit must have a complete manifest. If one is
|
|
121
|
+
missing, treat that as a framework coverage bug instead of inventing a copy
|
|
122
|
+
recipe. For an unknown third-party package, use the emitted add-style blueprint
|
|
123
|
+
as a starting point. Protected runtime behavior is never copied; follow the
|
|
124
|
+
reported configuration, adapter, or extension seam instead.
|
|
125
|
+
|
|
126
|
+
Applied ejections are recorded in the committed
|
|
127
|
+
`agent-native.ejections.json`, including package version, manifest digest,
|
|
128
|
+
target hashes, and import rewrites. Use the recorded state to review drift or
|
|
129
|
+
undo an unchanged ejection:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
agent-native eject diff <unit> --app <app>
|
|
133
|
+
agent-native eject restore <unit> --app <app>
|
|
134
|
+
agent-native eject restore <unit> --app <app> --apply
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Restore is hash-gated. It refuses to remove locally edited files or reverse
|
|
138
|
+
changed imports and prints their diff instead. Keep an edited ejection as
|
|
139
|
+
app-owned code, or reconcile those edits before restoring it.
|
|
140
|
+
|
|
141
|
+
## Find The Installed Implementation
|
|
142
|
+
|
|
143
|
+
Use the source that matches the installed package version:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pnpm action docs-search --query "<component or feature>"
|
|
147
|
+
pnpm action source-search --query "<component or symbol>"
|
|
148
|
+
rg -n "<component or symbol>" node_modules/@agent-native/toolkit/src
|
|
149
|
+
rg -n "<component or symbol>" node_modules/@agent-native/core/corpus
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- Toolkit publishes readable TypeScript under
|
|
153
|
+
`node_modules/@agent-native/toolkit/src/` for selective UI adoption.
|
|
154
|
+
- Core and first-party template source lives under
|
|
155
|
+
`node_modules/@agent-native/core/corpus/core/` and
|
|
156
|
+
`node_modules/@agent-native/core/corpus/templates/`.
|
|
157
|
+
- Treat those trees as read-only references. Prefer `agent-native eject` so the
|
|
158
|
+
package manifest selects the complete source closure and rewrites imports.
|
|
159
|
+
Manual inspection is still useful for deciding whether to configure,
|
|
160
|
+
compose, eject, or propose a shared seam.
|
|
161
|
+
|
|
162
|
+
Do not manually guess at sibling dependencies. The ejection manifest owns the
|
|
163
|
+
required file closure and keeps protected contracts on public package imports.
|
|
164
|
+
|
|
165
|
+
## Preserve The Agent-Native Contract
|
|
166
|
+
|
|
167
|
+
UI ownership may change; product contracts should not:
|
|
168
|
+
|
|
169
|
+
- Keep app operations in `defineAction` actions and call them through
|
|
170
|
+
`useActionQuery`, `useActionMutation`, or another named client helper.
|
|
171
|
+
- Keep navigation, selection, and focused-object state visible through the
|
|
172
|
+
existing application-state keys.
|
|
173
|
+
- Keep AI work in the shared agent chat instead of adding direct LLM calls.
|
|
174
|
+
- Keep auth, access checks, persistence, chat transport, and agent execution in
|
|
175
|
+
Core. Do not copy those runtimes into the app.
|
|
176
|
+
- Keep local adapters narrow so package upgrades still improve every surface
|
|
177
|
+
the app has not intentionally taken ownership of.
|
|
178
|
+
- Keep page, route, and domain code on local UI adapter imports. Never reach
|
|
179
|
+
around the registered design system with direct Toolkit UI primitive imports.
|
|
180
|
+
|
|
181
|
+
## App Shapes
|
|
182
|
+
|
|
183
|
+
- **Template app:** begin with `app/design-system.ts`, its local UI adapters,
|
|
184
|
+
and domain UI. Use Toolkit features for repeated workspace behavior; eject
|
|
185
|
+
only the unit being customized.
|
|
186
|
+
- **Chat app:** keep `AgentChatSurface`, thread state, and chat transport in
|
|
187
|
+
Core. Compose or eject Toolkit presentation such as chat-history UI around it.
|
|
188
|
+
- **Headless app:** stay action-first while no UI is needed. When adding a UI,
|
|
189
|
+
use the Chat template as the on-ramp or add Toolkit components without
|
|
190
|
+
replacing the existing actions.
|
|
191
|
+
- **Workspace:** put one-app overrides in that app. Promote a local component
|
|
192
|
+
to `packages/shared` only when multiple workspace apps use it.
|
|
193
|
+
|
|
194
|
+
## After Ejecting
|
|
195
|
+
|
|
196
|
+
- Commit `agent-native.ejections.json` with the app-owned files and rewrites.
|
|
197
|
+
- Remove unused dependencies and imports from the ejected files.
|
|
198
|
+
- Keep visible text in the app's localization catalogs.
|
|
199
|
+
- Run the manifest verification commands plus the app's formatter, typecheck,
|
|
200
|
+
and focused tests.
|
|
201
|
+
- Re-check the installed source during future package upgrades; the app-owned
|
|
202
|
+
ejection does not receive upstream fixes automatically. Use `eject diff` to
|
|
203
|
+
distinguish recorded output from subsequent local edits.
|
|
204
|
+
|
|
205
|
+
## Don't
|
|
206
|
+
|
|
207
|
+
- Don't edit or import from `node_modules/@agent-native/*/src` at runtime.
|
|
208
|
+
- Don't add `pnpm.overrides`, patches, or resolutions for Agent Native packages.
|
|
209
|
+
- Don't copy Core auth, DB, action, agent-loop, or transport internals.
|
|
210
|
+
- Don't manually copy a first-party unit with a missing recipe; fix its manifest.
|
|
211
|
+
- Don't eject a full package when a prop, slot, wrapper, or smaller unit works.
|
|
212
|
+
- Don't fork feature state into a custom view; consume the feature's controller.
|
|
213
|
+
|
|
214
|
+
## Related Skills
|
|
215
|
+
|
|
216
|
+
- `agent-native-docs` — version-matched docs and source lookup
|
|
217
|
+
- `agent-native-toolkit` — shared-vs-app-owned architecture boundary
|
|
218
|
+
- `self-modifying-code` — safe app source edits
|
|
219
|
+
- `upgrade-agent-native` — supported package upgrade path
|
|
220
|
+
- `adding-a-feature` — UI/action/instructions/application-state parity
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feature-flags
|
|
3
|
+
description: >-
|
|
4
|
+
Declare, evaluate, manage, and remove framework feature flags. Use when
|
|
5
|
+
shipping a capability gradually, targeting users or organizations, or
|
|
6
|
+
replacing a compile-time rollout switch with a production-safe runtime flag.
|
|
7
|
+
scope: dev
|
|
8
|
+
metadata:
|
|
9
|
+
internal: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Feature Flags
|
|
13
|
+
|
|
14
|
+
A feature flag is a boolean declared in app code, evaluated locally by Core,
|
|
15
|
+
and managed from the Analytics fleet control plane. Code owns whether a flag
|
|
16
|
+
exists. Runtime settings own only its rollout state.
|
|
17
|
+
|
|
18
|
+
Flags let an app deploy dormant code and turn it on in the real environment
|
|
19
|
+
without another deployment. They are not experiments: do not add variants,
|
|
20
|
+
hypotheses, conversion metrics, exposure tracking, or lifecycle states.
|
|
21
|
+
|
|
22
|
+
## When to use one
|
|
23
|
+
|
|
24
|
+
Use a flag for a reversible rollout of a user-facing capability whose dormant
|
|
25
|
+
code is safe to deploy. Flags are useful for production dogfooding, exact-user
|
|
26
|
+
or organization pilots, and deterministic percentage rollouts.
|
|
27
|
+
|
|
28
|
+
Do not use a flag for authentication, authorization, secrets, audit enablement,
|
|
29
|
+
SSR cache behavior, or another security boundary. Client hiding is presentation
|
|
30
|
+
only; every guarded server action must evaluate the same registered flag.
|
|
31
|
+
|
|
32
|
+
## Agent workflow
|
|
33
|
+
|
|
34
|
+
### 1. Declare
|
|
35
|
+
|
|
36
|
+
Keep definitions in a shared TypeScript module so server and client code use the
|
|
37
|
+
same stable key. Flags are boolean and default-off.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags/registry";
|
|
41
|
+
|
|
42
|
+
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
|
+
key: "full-app-building",
|
|
44
|
+
displayName: "Full app building",
|
|
45
|
+
description: "Create and edit Fusion-backed applications.",
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Keys are immutable, never reused, and contain only letters, numbers, dots,
|
|
50
|
+
underscores, or hyphens. Prefer a concise app-owned name. Do not create flag
|
|
51
|
+
definitions or rollout rows from Analytics.
|
|
52
|
+
|
|
53
|
+
### 2. Register
|
|
54
|
+
|
|
55
|
+
Register app definitions from a Nitro plugin before actions are discovered.
|
|
56
|
+
Do not add app-specific flags to a Core registry.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { createFeatureFlagsPlugin } from "@agent-native/core/server";
|
|
60
|
+
|
|
61
|
+
import { FULL_APP_BUILDING } from "../../shared/feature-flags.js";
|
|
62
|
+
|
|
63
|
+
export default createFeatureFlagsPlugin({ flags: [FULL_APP_BUILDING] });
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Guard server and client
|
|
67
|
+
|
|
68
|
+
The server action is the enforcement boundary:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { isFeatureFlagEnabled } from "@agent-native/core/feature-flags";
|
|
72
|
+
|
|
73
|
+
run: async (args, ctx) => {
|
|
74
|
+
if (!(await isFeatureFlagEnabled(FULL_APP_BUILDING, ctx))) {
|
|
75
|
+
throw new Error("Full app building is not enabled for this account.");
|
|
76
|
+
}
|
|
77
|
+
// guarded operation
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use the client hook only to hide or reveal hydrated UI:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useFeatureFlag } from "@agent-native/core/client/feature-flags";
|
|
85
|
+
|
|
86
|
+
const enabled = useFeatureFlag(FULL_APP_BUILDING.key);
|
|
87
|
+
return enabled ? <FullAppOption /> : null;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The client hook intentionally returns false while loading or for an unknown
|
|
91
|
+
flag. Never replace that fail-closed behavior with app-local bucketing or a
|
|
92
|
+
compile-time fallback. Never evaluate personalized flags in the public SSR
|
|
93
|
+
shell; it is shared and cached for every visitor.
|
|
94
|
+
|
|
95
|
+
### 4. Verify and roll out
|
|
96
|
+
|
|
97
|
+
1. Verify the off path before changing rollout state.
|
|
98
|
+
2. Confirm the registered flag appears in **Analytics → Feature flags** for the
|
|
99
|
+
app and is Off by default.
|
|
100
|
+
3. Use **Enable for me** for initial production dogfood.
|
|
101
|
+
4. Expand to exact emails, organization IDs, or a percentage only from
|
|
102
|
+
Analytics.
|
|
103
|
+
5. Confirm the client presentation and authoritative server action agree.
|
|
104
|
+
|
|
105
|
+
## Management contract
|
|
106
|
+
|
|
107
|
+
Core mounts three actions in registered apps:
|
|
108
|
+
|
|
109
|
+
| Action | Purpose |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `get-feature-flags` | Return the current caller's evaluated boolean values. |
|
|
112
|
+
| `list-feature-flags` | Return definitions and rollout metadata to an authorized operator. |
|
|
113
|
+
| `set-feature-flag` | Atomically turn a flag off, enable it for the operator, or replace targeting rules. |
|
|
114
|
+
|
|
115
|
+
Analytics calls the app-local operator actions through narrowly scoped A2A
|
|
116
|
+
delegation. Tokens require an exact audience, organization, scope, operator
|
|
117
|
+
role, and audit correlation id. Management is permission-checked and audited
|
|
118
|
+
by the target app. Never manage flags through generic settings routes, raw SQL,
|
|
119
|
+
or per-app toggle UIs.
|
|
120
|
+
|
|
121
|
+
## Rollout semantics
|
|
122
|
+
|
|
123
|
+
The operator modes are **Off**, **Targeted**, and **Everyone**. Core stores them
|
|
124
|
+
as `off`, `rules`, and `on`.
|
|
125
|
+
|
|
126
|
+
Targeted rules combine exact normalized emails, exact organization IDs, and a
|
|
127
|
+
percentage with OR semantics. Exact matches are checked first. Percentage
|
|
128
|
+
buckets use Core's stable hash of the flag key and authenticated user identity;
|
|
129
|
+
anonymous callers fail closed. Raising a percentage preserves the users already
|
|
130
|
+
included at a lower percentage. Do not implement bucketing in app code.
|
|
131
|
+
|
|
132
|
+
Unknown definitions, missing state, malformed state, storage errors, and
|
|
133
|
+
evaluation errors all return the code default (`false` in v1). Explicit Off
|
|
134
|
+
wins over every target; Everyone enables every authenticated caller.
|
|
135
|
+
|
|
136
|
+
## Remove a flag
|
|
137
|
+
|
|
138
|
+
After a rollout is permanent:
|
|
139
|
+
|
|
140
|
+
1. Replace guarded branches with the chosen behavior.
|
|
141
|
+
2. Delete the server and client gates.
|
|
142
|
+
3. Delete the definition and registration entry.
|
|
143
|
+
4. Verify the flag disappears from the Analytics fleet.
|
|
144
|
+
5. Remove stale tests and rollout instructions.
|
|
145
|
+
|
|
146
|
+
A permanent flag is just an if statement with a pension plan.
|
|
147
|
+
|
|
148
|
+
## Verification checklist
|
|
149
|
+
|
|
150
|
+
- Unknown and unregistered keys evaluate false.
|
|
151
|
+
- UI hiding and server enforcement use the same registered key.
|
|
152
|
+
- Exact-user, organization, deterministic percentage, Everyone, and Off paths
|
|
153
|
+
have focused tests.
|
|
154
|
+
- Increasing a percentage is monotonic; anonymous percentage evaluation is off.
|
|
155
|
+
- Unauthorized callers cannot list targeting details or mutate flags.
|
|
156
|
+
- Mutations are atomic, read back stored state, emit refresh, and appear in the
|
|
157
|
+
audit log with the flag key.
|
|
158
|
+
- Analytics represents ready, no-definition, unsupported, forbidden, legacy,
|
|
159
|
+
and unreachable directory apps honestly.
|
|
160
|
+
- Future agents can find this skill from root `AGENTS.md`, and
|
|
161
|
+
`pnpm guard:workspace-skills` passes after syncing generated copies.
|
|
162
|
+
|
|
163
|
+
## Related skills
|
|
164
|
+
|
|
165
|
+
- **adding-a-feature** — preserve UI/action/instruction/application-state parity
|
|
166
|
+
- **actions** — define and call guarded app operations
|
|
167
|
+
- **audit-log** — inspect automatic action mutation history
|
|
168
|
+
- **reliable-mutations** — make rollout changes atomic and provable
|
|
169
|
+
- **security** — keep security controls out of feature flags
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sharing
|
|
3
|
+
description: >-
|
|
4
|
+
Framework-level sharing and privacy for user-authored resources
|
|
5
|
+
(dashboards, documents, forms, decks, etc.). Use when making a resource
|
|
6
|
+
table ownable, wiring list/read/update access checks, or dropping the
|
|
7
|
+
standard share dialog into a template.
|
|
8
|
+
scope: dev
|
|
9
|
+
metadata:
|
|
10
|
+
internal: true
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Sharing — Private by Default, Explicit Share
|
|
14
|
+
|
|
15
|
+
## Rule
|
|
16
|
+
|
|
17
|
+
Any resource a user **creates** (dashboards, documents, forms, decks, compositions, booking links, issues, analyses) is **private to the creator** by default and visible to others only when they have been **explicitly shared** with or when the creator changes visibility to `org` or `public`.
|
|
18
|
+
|
|
19
|
+
This is the framework-level primitive. Every ownable resource gets it for free — same API, same UI, same skill.
|
|
20
|
+
|
|
21
|
+
## Concepts
|
|
22
|
+
|
|
23
|
+
### Three visibility levels
|
|
24
|
+
|
|
25
|
+
- **`private`** — owner + explicit share grants only. Default.
|
|
26
|
+
- **`org`** — owner + explicit grants + anyone in the same org (read-only).
|
|
27
|
+
- **`public`** — owner + explicit grants + **anyone with the link** (read-only). Public docs do NOT appear in other users' list/sidebar/search results — `accessFilter` omits them by default. They're reachable by id (`resolveAccess` admits them) so direct links and SSR routes like `/p/:id` keep working. If a list endpoint legitimately needs cross-user public discovery (a template gallery, etc.), pass `accessFilter(table, shares, ctx, minRole, { includePublic: true })`.
|
|
28
|
+
|
|
29
|
+
Visibility is coarse. Explicit share grants are fine-grained (per user or per org).
|
|
30
|
+
|
|
31
|
+
### Roles on a share grant
|
|
32
|
+
|
|
33
|
+
- **`viewer`** — read only.
|
|
34
|
+
- **`editor`** — read + write.
|
|
35
|
+
- **`admin`** — read + write + manage shares. Does NOT replace the single `owner_email` on the resource.
|
|
36
|
+
|
|
37
|
+
### Anonymous public URLs stay separate
|
|
38
|
+
|
|
39
|
+
Form "publish" slugs, booking-link slugs, any feature that exposes a URL to unauthenticated users — these are a different axis and are NOT controlled by the sharing system. Keep them alongside it.
|
|
40
|
+
|
|
41
|
+
## Make a resource ownable
|
|
42
|
+
|
|
43
|
+
In your template's `server/db/schema.ts`:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import {
|
|
47
|
+
table,
|
|
48
|
+
text,
|
|
49
|
+
integer,
|
|
50
|
+
now,
|
|
51
|
+
ownableColumns,
|
|
52
|
+
createSharesTable,
|
|
53
|
+
} from "@agent-native/core/db/schema";
|
|
54
|
+
|
|
55
|
+
export const decks = table("decks", {
|
|
56
|
+
id: text("id").primaryKey(),
|
|
57
|
+
title: text("title").notNull(),
|
|
58
|
+
data: text("data").notNull(),
|
|
59
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
60
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
61
|
+
...ownableColumns(), // adds owner_email, org_id, visibility
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const deckShares = createSharesTable("deck_shares");
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then register it **in `server/db/index.ts`** (not the schema file — keeps the schema file free of the `getDb` closure and avoids circular imports):
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// server/db/index.ts
|
|
71
|
+
import * as schema from "./schema.js";
|
|
72
|
+
import { createGetDb } from "@agent-native/core/db";
|
|
73
|
+
import { registerShareableResource } from "@agent-native/core/sharing";
|
|
74
|
+
|
|
75
|
+
export const getDb = createGetDb(schema);
|
|
76
|
+
export { schema };
|
|
77
|
+
|
|
78
|
+
registerShareableResource({
|
|
79
|
+
type: "deck",
|
|
80
|
+
resourceTable: schema.decks,
|
|
81
|
+
sharesTable: schema.deckShares,
|
|
82
|
+
displayName: "Deck",
|
|
83
|
+
titleColumn: "title",
|
|
84
|
+
getResourcePath: (deck) => `/deck/${deck.id}`,
|
|
85
|
+
getDb,
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The `type` string is the stable id the UI and actions use. `getDb` is required — the framework-level share actions use it to reach your template's DB.
|
|
90
|
+
|
|
91
|
+
### Restricting public visibility and cross-org user shares
|
|
92
|
+
|
|
93
|
+
Some resources should NOT be reachable by an arbitrary authenticated user even with the link, and should NOT be shareable to an email outside the org. Two optional registration flags lock these axes down:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
registerShareableResource({
|
|
97
|
+
type: "extension",
|
|
98
|
+
// ...
|
|
99
|
+
allowPublic: false, // hides "Public" in the share dialog and rejects it server-side
|
|
100
|
+
requireOrgMemberForUserShares: true, // user shares must target an org member or pending invitee
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- **`allowPublic: false`** — `set-resource-visibility('public')` throws `ForbiddenError`, `accessFilter` / `resolveAccess` treat any stored `'public'` row as private (defense in depth against bad data), and the share popover hides the "Public" option. `list-resource-shares` returns `policy.allowPublic: false` so the UI follows the server.
|
|
105
|
+
- **`requireOrgMemberForUserShares: true`** — `share-resource` looks up `principalId` in `org_members` and `org_invitations` (pending) for the resource's `orgId` and rejects user shares to anyone else. The same flag also pins `principalType: "org"` shares to the resource's own org — sharing to a *different* org would let that org's members run code in the viewer's auth context (same threat model as a public extension). (The flag name is kept for backward compatibility; treat it as "lock both user and org shares to the resource's org".)
|
|
106
|
+
|
|
107
|
+
Use both for resources that execute code or expose privileged data with the *viewer's* credentials. Extensions ship with both set: an extension's HTML calls actions / SQL / the secrets-injecting proxy as the viewer, so a public or cross-org-shared extension would let a stranger run arbitrary code with someone else's auth context. `scripts/guard-extension-no-public.mjs` (CI + `pnpm prep`) statically enforces that the extension registration keeps both flags set.
|
|
108
|
+
|
|
109
|
+
Defaults match historical behaviour: `allowPublic: true`, `requireOrgMemberForUserShares: false`. Resources that don't set the flags work as before.
|
|
110
|
+
|
|
111
|
+
## Filter list/read queries
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { accessFilter } from "@agent-native/core/sharing";
|
|
115
|
+
|
|
116
|
+
const rows = await db
|
|
117
|
+
.select()
|
|
118
|
+
.from(schema.decks)
|
|
119
|
+
.where(accessFilter(schema.decks, schema.deckShares));
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`accessFilter` admits rows the current user owns, has been shared on, or that the user can reach via `org` visibility. `public` rows are NOT admitted by default — see the visibility section above for why and how to opt in.
|
|
123
|
+
|
|
124
|
+
## Guard write actions
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { assertAccess } from "@agent-native/core/sharing";
|
|
128
|
+
|
|
129
|
+
export default defineAction({
|
|
130
|
+
schema: z.object({ id: z.string(), title: z.string() }),
|
|
131
|
+
run: async (args) => {
|
|
132
|
+
await assertAccess("deck", args.id, "editor");
|
|
133
|
+
// ...proceed
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
For delete actions use `"admin"` (or fold in `"owner"` to require the real owner).
|
|
139
|
+
|
|
140
|
+
## Create actions must set owner
|
|
141
|
+
|
|
142
|
+
When inserting a new row, fill `ownerEmail` and `orgId` from the request context:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import {
|
|
146
|
+
getRequestUserEmail,
|
|
147
|
+
getRequestOrgId,
|
|
148
|
+
} from "@agent-native/core/server/request-context";
|
|
149
|
+
|
|
150
|
+
const ownerEmail = getRequestUserEmail();
|
|
151
|
+
// Never fall back to a sentinel like "local@localhost" — that pools every
|
|
152
|
+
// unauthenticated write into one shared tenant (see the 2026-04-29 leak and
|
|
153
|
+
// guard-no-localhost-fallback). Throw / 401 when there is no session instead.
|
|
154
|
+
if (!ownerEmail) throw new Error("Not authenticated");
|
|
155
|
+
|
|
156
|
+
await db.insert(schema.decks).values({
|
|
157
|
+
id: nanoid(),
|
|
158
|
+
title,
|
|
159
|
+
data,
|
|
160
|
+
ownerEmail,
|
|
161
|
+
orgId: getRequestOrgId(),
|
|
162
|
+
// visibility defaults to 'private'
|
|
163
|
+
// ...
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Drop in the share UI
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { ShareButton } from "@agent-native/core/client/sharing";
|
|
171
|
+
|
|
172
|
+
// In the resource's header/toolbar:
|
|
173
|
+
<ShareButton
|
|
174
|
+
resourceType="deck"
|
|
175
|
+
resourceId={deck.id}
|
|
176
|
+
resourceTitle={deck.title}
|
|
177
|
+
/>;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
For list views, show `<VisibilityBadge visibility={row.visibility} />` next to each resource.
|
|
181
|
+
|
|
182
|
+
## Actions available everywhere
|
|
183
|
+
|
|
184
|
+
The framework auto-mounts these actions in every template — no per-template boilerplate:
|
|
185
|
+
|
|
186
|
+
| Action | Args | Purpose |
|
|
187
|
+
| -------------------------- | ------------------------------------------------------------------------------ | ----------------------------------------- |
|
|
188
|
+
| `share-resource` | `resourceType, resourceId, principalType, principalId, role, notify?, resourceUrl?` | Grant a user or org access. `notify` defaults to true for individual user shares; `resourceUrl` can provide the direct app link used in the notification email. |
|
|
189
|
+
| `unshare-resource` | `resourceType, resourceId, principalType, principalId` | Revoke access. |
|
|
190
|
+
| `list-resource-shares` | `resourceType, resourceId` | Current visibility + all share grants. |
|
|
191
|
+
| `set-resource-visibility` | `resourceType, resourceId, visibility` | Change to `private` / `org` / `public`. |
|
|
192
|
+
|
|
193
|
+
Both the agent and the UI use these same actions. The agent calls them as tools;
|
|
194
|
+
UI code should use `ShareButton` / `ShareDialog` or the action client hooks
|
|
195
|
+
instead of hand-writing route calls.
|
|
196
|
+
|
|
197
|
+
## Migration pattern for existing tables
|
|
198
|
+
|
|
199
|
+
When retrofitting an existing resource table:
|
|
200
|
+
|
|
201
|
+
1. Add `owner_email`, `org_id`, `visibility` columns (defaults `'local@localhost'`, `NULL`, `'private'`).
|
|
202
|
+
2. Backfill `owner_email` from any prior creator trail; otherwise leave the default.
|
|
203
|
+
3. Add the companion `{type}_shares` table.
|
|
204
|
+
4. Register via `registerShareableResource`.
|
|
205
|
+
5. Update list/read actions to use `accessFilter`.
|
|
206
|
+
6. Update update/delete actions to `assertAccess` with the correct role.
|
|
207
|
+
7. Add `<ShareButton>` to the resource header.
|
|
208
|
+
8. Add `getResourcePath` in the registration so agent-triggered shares can email a direct link even when no UI supplied `resourceUrl`.
|
|
209
|
+
|
|
210
|
+
## Templates that opt out
|
|
211
|
+
|
|
212
|
+
Sharing doesn't apply to:
|
|
213
|
+
|
|
214
|
+
- **Personal-data apps** (mail, macros) — user-scoped by design.
|
|
215
|
+
- **External source-of-truth apps** (issues → Jira, recruiting → Greenhouse) — ACL lives in the upstream system.
|
|
216
|
+
- **Demo/boilerplate** (starter) — no resources.
|
|
217
|
+
|
|
218
|
+
For these, add a short note to the template's `AGENTS.md` explaining why.
|
|
219
|
+
|
|
220
|
+
## Analytics (follow-up)
|
|
221
|
+
|
|
222
|
+
Dashboards and analyses in the `analytics` template currently live in the settings KV store (`u:<email>:dashboard-*` keys), not SQL. Sharing requires either migrating them to SQL tables (then applying this skill) or extending the settings store with a parallel share overlay. This is a tracked follow-up — see the analytics template's `AGENTS.md`.
|
|
223
|
+
|
|
224
|
+
## Debugging
|
|
225
|
+
|
|
226
|
+
- `ForbiddenError` from an action means the current user isn't owner / hasn't been shared / can't meet the role bar.
|
|
227
|
+
- If the agent can't see a resource it just created, check that the insert actually set `owner_email` from the request context.
|
|
228
|
+
- If a share doesn't take effect in the UI, confirm the template's `list-*` action uses `accessFilter` — the share rows are there but nothing is reading them yet.
|