@agent-native/core 0.62.1 → 0.63.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.
Files changed (110) hide show
  1. package/dist/cli/code-agent-executor.js +1 -1
  2. package/dist/cli/code-agent-executor.js.map +1 -1
  3. package/dist/cli/create.js +1 -1
  4. package/dist/cli/create.js.map +1 -1
  5. package/dist/client/NewWorkspaceAppFlow.js +1 -1
  6. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  7. package/dist/client/chat/index.d.ts +2 -1
  8. package/dist/client/chat/index.d.ts.map +1 -1
  9. package/dist/client/chat/index.js +2 -1
  10. package/dist/client/chat/index.js.map +1 -1
  11. package/dist/client/chat-view-transition.d.ts +17 -0
  12. package/dist/client/chat-view-transition.d.ts.map +1 -1
  13. package/dist/client/chat-view-transition.js +46 -0
  14. package/dist/client/chat-view-transition.js.map +1 -1
  15. package/dist/client/index.d.ts +2 -1
  16. package/dist/client/index.d.ts.map +1 -1
  17. package/dist/client/index.js +2 -1
  18. package/dist/client/index.js.map +1 -1
  19. package/dist/client/use-agent-chat-home-handoff.d.ts +27 -0
  20. package/dist/client/use-agent-chat-home-handoff.d.ts.map +1 -0
  21. package/dist/client/use-agent-chat-home-handoff.js +120 -0
  22. package/dist/client/use-agent-chat-home-handoff.js.map +1 -0
  23. package/dist/index.d.ts +1 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +20 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/styles/agent-native.css +2 -6
  28. package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +3 -3
  29. package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
  30. package/dist/templates/default/DEVELOPING.md +1 -1
  31. package/dist/templates/default/app/lib/utils.ts +1 -1
  32. package/dist/templates/default/app/root.tsx +1 -1
  33. package/dist/templates/headless/actions/hello.ts +1 -1
  34. package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +3 -3
  35. package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
  36. package/dist/templates/workspace-root/README.md +4 -4
  37. package/docs/content/actions.md +32 -42
  38. package/docs/content/agent-surfaces.md +105 -84
  39. package/docs/content/agent-teams.md +2 -14
  40. package/docs/content/agent-web-surfaces.md +4 -4
  41. package/docs/content/authentication.md +40 -24
  42. package/docs/content/automations.md +18 -36
  43. package/docs/content/blueprint-installer.md +3 -0
  44. package/docs/content/cli-adapters.md +24 -168
  45. package/docs/content/client.md +11 -77
  46. package/docs/content/cloneable-saas.md +1 -1
  47. package/docs/content/code-agents-ui.md +43 -0
  48. package/docs/content/components.md +10 -23
  49. package/docs/content/context-awareness.md +3 -3
  50. package/docs/content/creating-templates.md +20 -18
  51. package/docs/content/database.md +1 -1
  52. package/docs/content/deployment.md +5 -37
  53. package/docs/content/dispatch.md +17 -28
  54. package/docs/content/drop-in-agent.md +24 -111
  55. package/docs/content/durable-resume.md +4 -0
  56. package/docs/content/embedding-sdk.md +141 -135
  57. package/docs/content/evals.md +3 -3
  58. package/docs/content/extensions.md +1 -1
  59. package/docs/content/external-agents.md +34 -60
  60. package/docs/content/faq.md +5 -5
  61. package/docs/content/frames.md +13 -4
  62. package/docs/content/getting-started.md +96 -142
  63. package/docs/content/harness-agents.md +24 -7
  64. package/docs/content/human-approval.md +1 -1
  65. package/docs/content/key-concepts.md +14 -99
  66. package/docs/content/local-file-mode.md +2 -2
  67. package/docs/content/mcp-apps.md +9 -2
  68. package/docs/content/mcp-clients.md +8 -3
  69. package/docs/content/mcp-protocol.md +11 -29
  70. package/docs/content/messaging.md +1 -1
  71. package/docs/content/migration-workbench.md +14 -175
  72. package/docs/content/multi-app-workspace.md +1 -1
  73. package/docs/content/multi-tenancy.md +18 -47
  74. package/docs/content/native-chat-ui.md +15 -12
  75. package/docs/content/observability.md +16 -4
  76. package/docs/content/observational-memory.md +1 -1
  77. package/docs/content/pure-agent-apps.md +17 -124
  78. package/docs/content/real-time-collaboration.md +14 -14
  79. package/docs/content/routing.md +71 -0
  80. package/docs/content/sandbox-adapters.md +78 -4
  81. package/docs/content/security.md +59 -39
  82. package/docs/content/server.md +16 -8
  83. package/docs/content/sharing.md +1 -6
  84. package/docs/content/skills-guide.md +3 -1
  85. package/docs/content/template-analytics.md +1 -1
  86. package/docs/content/template-assets.md +12 -3
  87. package/docs/content/template-brain.md +64 -72
  88. package/docs/content/template-chat.md +32 -4
  89. package/docs/content/template-clips.md +35 -4
  90. package/docs/content/template-design.md +19 -3
  91. package/docs/content/template-dispatch.md +9 -0
  92. package/docs/content/template-forms.md +15 -10
  93. package/docs/content/template-plan.md +7 -0
  94. package/docs/content/template-slides.md +14 -14
  95. package/docs/content/template-videos.md +10 -12
  96. package/docs/content/tracking.md +66 -55
  97. package/docs/content/using-your-agent.md +6 -16
  98. package/docs/content/what-is-agent-native.md +5 -11
  99. package/docs/content/workspace-management.md +2 -2
  100. package/docs/content/workspace.md +20 -160
  101. package/package.json +1 -1
  102. package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +3 -3
  103. package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +1 -1
  104. package/src/templates/default/DEVELOPING.md +1 -1
  105. package/src/templates/default/app/lib/utils.ts +1 -1
  106. package/src/templates/default/app/root.tsx +1 -1
  107. package/src/templates/headless/actions/hello.ts +1 -1
  108. package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +3 -3
  109. package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +1 -1
  110. package/src/templates/workspace-root/README.md +4 -4
@@ -5,19 +5,16 @@ description: "Expose your agent-native app as a remote MCP server so Claude, Cha
5
5
 
6
6
  # MCP Protocol
7
7
 
8
- Every agent-native app automatically exposes a remote MCP (Model Context Protocol) server. This lets external AI tools like Claude, ChatGPT custom MCP apps, Claude Code, Cursor, Codex, VS Code GitHub Copilot, and Windsurf discover and call your app's actions directly no extra code needed.
8
+ **This page: the lower-level MCP server reference.** How every agent-native app exposes its actions over MCP the auto-mounted endpoint, auth modes, the `tools/call` / `ask-agent` surface, and custom mounting. Reach for it when you need server internals; for connecting a host, start with [External Agents](/docs/external-agents).
9
9
 
10
- **Which page do I need?**
10
+ | If you want to… | Read |
11
+ | ------------------------------------------------------------ | ---------------------------------------- |
12
+ | Connect an external agent/host to your app | [External Agents](/docs/external-agents) |
13
+ | Give your agent more tools (consume other MCP servers) | [MCP Clients](/docs/mcp-clients) |
14
+ | Build inline UIs that render in Claude/ChatGPT | [MCP Apps](/docs/mcp-apps) |
15
+ | Lower-level MCP server reference (auth, tools, custom mount) | **This page** — MCP Protocol |
11
16
 
12
- | Goal | Page |
13
- | ----------------------------------------------------------- | ---------------------------------------- |
14
- | Connect Claude / ChatGPT / Codex / Cursor to a hosted app | [External Agents](/docs/external-agents) |
15
- | Make your app callable over MCP (server setup, auth, tools) | This page |
16
- | Give your app's agent more tools from external MCP servers | [MCP Clients](/docs/mcp-clients) |
17
- | App-to-app delegation via JSON-RPC | [A2A Protocol](/docs/a2a-protocol) |
18
- | Build or embed interactive MCP App resources | [MCP Apps](/docs/mcp-apps) |
19
-
20
- If your goal is to connect Claude, ChatGPT, Claude Code, Codex, Cursor, or Claude Cowork to hosted agent-native apps, start with [External Agents](/docs/external-agents). It documents the recommended single Dispatch connector at `https://dispatch.agent-native.com/_agent-native/mcp`, direct per-app URLs for isolated app access, standard remote MCP OAuth, fallback config for older clients, MCP Apps inline UIs, and deep links back into the UI. This page is the lower-level MCP server reference.
17
+ Every agent-native app automatically exposes a remote MCP (Model Context Protocol) server, so external AI tools like Claude, ChatGPT custom MCP apps, Claude Code, Cursor, Codex, and VS Code GitHub Copilot can discover and call your app's actions directly — no extra code needed. If your goal is to _connect_ one of those hosts to a hosted app, [External Agents](/docs/external-agents) covers the recommended single Dispatch connector, per-app URLs, OAuth, MCP Apps inline UIs, and deep links. This page documents what sits underneath that.
21
18
 
22
19
  ## Overview {#overview}
23
20
 
@@ -103,24 +100,9 @@ See [MCP Apps](/docs/mcp-apps#mcp-app-bridge) for the full embed bridge details
103
100
 
104
101
  ## Tools {#tools}
105
102
 
106
- Every caller gets a compact app-host catalog by default — chat-style app hosts
107
- (OAuth callers that request `mcp:apps` and generic authenticated remote
108
- HTTP/static-token callers), code/stdio developer clients, and the local CLI
109
- proxy alike: app-facing builtins (`list_apps`, `open_app`, `ask_app`, and
110
- app-only `create_embed_session`), the template-declared app actions, and rare
111
- actions marked `mcpApp.compactCatalog: true`. Their `resources/list` is compact
112
- too, normally advertising only the generic `open_app` embed resource. The
113
- catalog is never inferred from the client name or user-agent. The full action
114
- surface is served only on explicit opt-in — a token minted with `--full-catalog`
115
- (`catalog_scope: "full"`) or the deployment-wide `AGENT_NATIVE_MCP_FULL_CATALOG=1`
116
- override. `tool-search` is always available, including in the compact catalog:
117
- call it with no query for the full menu of tool names and one-line descriptions,
118
- or with a query for ranked matches with parameter summaries, to reach any tool
119
- on demand. `publicAgent.expose` remains the opt-in for safe read/ingest tools
120
- outside that compact app catalog. This keeps ChatGPT/Claude app-host discovery
121
- small while keeping every tool reachable.
122
-
123
- The mapping is direct:
103
+ Every caller gets a **compact catalog by default** (template-declared app actions plus the cross-app builtins), with the full action surface served only on explicit opt-in and `tool-search` always available to reach the rest. See [External Agents → Catalog tiers](/docs/external-agents#catalog-tiers) for the full explanation.
104
+
105
+ Each action maps directly to one MCP tool:
124
106
 
125
107
  | Action property | MCP tool property |
126
108
  | ------------------ | ----------------- |
@@ -291,7 +291,7 @@ Every incoming webhook is signature-verified before processing:
291
291
  The email adapter also enforces:
292
292
 
293
293
  - **Allowed domains** — optional `allowedDomains` array in the integration's `integration_configs` row; senders outside the list are dropped.
294
- - **Rate limit** — in-memory limiter at 20 inbound messages per sender per hour.
294
+ - **Rate limit** — SQL-queue-backed rate limit of 20 inbound messages per sender per hour.
295
295
 
296
296
  ### Proactive sends {#proactive-sends}
297
297
 
@@ -1,187 +1,26 @@
1
1
  ---
2
2
  title: "Migrating to Agent-Native (/migrate)"
3
- description: "Use the open-source Agent-Native Code workspace for coding sessions, including the built-in /migrate capability."
3
+ description: "Migration is a built-in /migrate goal in the Agent-Native Code workspace not a separate app. See Agent-Native Code UI for the full guide."
4
4
  ---
5
5
 
6
6
  # Migrating to Agent-Native (/migrate)
7
7
 
8
- Start from **Agent-Native Code**:
8
+ Migration is **not a separate product or template** — it is the built-in
9
+ `/migrate` goal inside the [Agent-Native Code](/docs/code-agents-ui) workspace.
10
+ It runs as a normal Code session you can resume, attach to, inspect, and stop.
9
11
 
10
12
  ```bash
11
- npx @agent-native/core@latest
12
- npx @agent-native/core@latest "fix the failing auth tests"
13
- npx @agent-native/core@latest code
14
- npx @agent-native/core@latest code "fix the failing auth tests"
15
- npx @agent-native/core@latest code attach --last
16
13
  npx @agent-native/core@latest code /migrate ./my-next-app --out ../migrated-app
14
+ npx @agent-native/core@latest code /migrate https://example.com --describe "marketing site plus dashboard"
15
+ npx @agent-native/core@latest migrate ./my-next-app --out ../migrated-app # shortcut into the same goal
17
16
  ```
18
17
 
19
- **Agent-Native Code** is the open-source Claude Code/Codex-like workspace for coding work in Agent-Native. `npx @agent-native/core@latest` or `npx @agent-native/core@latest code` launches it with no prompt required, and a bare prompt starts a generic coding task directly. `/migrate` is one built-in capability for moving an existing app, URL, or described product into agent-native. It uses the same session store, transcript, and desktop hub as the CLI `code` command, so migration behaves like a goal you can resume, attach to, inspect, and stop rather than a separate one-off product.
18
+ The full guide input shapes (path / URL / description), `--emit` dossiers,
19
+ Plan vs Auto mode, run controls, credentials, Desktop deep links, and the
20
+ `@agent-native/migrate` package exports — lives in
21
+ [Agent-Native Code UI → Migrating to Agent-Native](/docs/code-agents-ui#migrate).
20
22
 
21
- See [Agent-Native Code UI](/docs/code-agents-ui) for the shared CLI run controls (`list`/`attach`/`logs`/`resume`/`status`/`stop`/`ui`) and the file-backed, long-running background-run model that `/migrate` sessions use.
22
-
23
- By default `/migrate` creates a generic Agent-Native Code session plus a portable migration dossier. Migration is a slash command in the Code workspace, not a normal template to scaffold. The legacy hidden `migration` detail app has been removed; use the Code workspace, Desktop Code tab, or emitted dossier as the supported surfaces.
24
-
25
- The direct `migrate` command remains a shortcut into the same goal:
26
-
27
- ```bash
28
- npx @agent-native/core@latest migrate ./my-next-app --out ../migrated-app
29
- ```
30
-
31
- Both forms print the same handoff: run id, source, output, dossier directory,
32
- important artifact files, and the exact Agent-Native Code commands to inspect or
33
- resume the session (see [Agent-Native Code UI](/docs/code-agents-ui) for the
34
- full run-control command set).
35
-
36
- ## Code Workspace
37
-
38
- `npx @agent-native/core@latest code` opens the interactive Agent-Native Code shell. Inside the shell, `/migrate` is a slash goal alongside `/audit` and other built-in commands. Projects can also define custom migration variants in `.agents/commands/*.md`. The CLI and Desktop hub share the same run store — start in one and continue in the other using the standard `list`/`attach`/`logs`/`resume`/`approve`/`stop` controls.
39
-
40
- See [Agent-Native Code UI](/docs/code-agents-ui) for the full shell, run controls, Plan/Auto modes, slash-goal discovery, and Desktop hub integration.
41
-
42
- ## Input Shapes
43
-
44
- Use a local source path when you have code:
45
-
46
- ```bash
47
- npx @agent-native/core@latest code /migrate ./my-next-app --out ../migrated-app
48
- ```
49
-
50
- Use a URL when the first artifact is a live site or product surface:
51
-
52
- ```bash
53
- npx @agent-native/core@latest code /migrate https://example.com --describe "marketing site plus logged-in dashboard"
54
- ```
55
-
56
- Use a description when the migration starts from requirements, screenshots, or a handoff brief:
57
-
58
- ```bash
59
- npx @agent-native/core@latest code /migrate --describe "A Rails admin app with reports, approvals, and CSV imports" --emit
60
- ```
61
-
62
- For local paths, the source is read-only. Generated output must live outside the source tree.
63
-
64
- ## Internal Run Flow
65
-
66
- The normal command creates a generic Agent-Native Code session and writes artifacts under the Agent-Native Code run store. It does **not** scaffold an app/template. The flow is:
67
-
68
- 1. **Discover** reads the source and creates `01-assessment.md`.
69
- 2. **Plan** creates recipe tasks and writes `02-plan.md` plus `03-tasks.md`.
70
- 3. **Approve** unlocks generated output writes.
71
- 4. **Sweep** runs migration tasks against the generated output project.
72
- 5. **Verify** runs deterministic checks and writes `04-report.md`.
73
-
74
- Drive the session with the standard run controls (`status`/`list`/`attach`/`logs`/`approve`/`resume`/`ui`/`stop`, plus `--continue "prompt"` to record and run a follow-up). See [Agent-Native Code UI](/docs/code-agents-ui) for what each control does and how stop/approve behave.
75
-
76
- ## Long-Running Goals
77
-
78
- The `/migrate` goal advances a run in bounded iterations:
79
-
80
- - before approval, it can assess and plan but cannot write generated output
81
- - after approval, it scaffolds once, advances pending tasks, verifies, and records verifier results
82
- - if verification fails, the critic policy returns `retry-with-more-context`, `tune-recipe`, `manual-decision-needed`, `rollback-generated-output`, or `accept`
83
-
84
- That gives the flow Claude Code `/goal`-style semantics without making migration a one-shot rewrite. The app state and disk artifacts let you resume after restarts, long pauses, or manual decisions.
85
-
86
- ## Credentials
87
-
88
- The `/migrate` goal reuses the same credentials system as agent-native. There is no migration-specific key store and no `MIGRATION_*` secret namespace.
89
-
90
- In Agent-Native Code, Desktop, or the internal run surface, connect providers through the normal settings and onboarding surfaces. For headless CLI use, existing provider environment variables are detected, including `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, and other provider env vars supported by the framework. Secret values are never copied into migration artifacts.
91
-
92
- ## Desktop Deep Links
93
-
94
- `/migrate` runs appear in the Desktop Agent-Native Code hub alongside any other Code session and use the same hub run controls and approval gate ([Agent-Native Code UI](/docs/code-agents-ui) covers the Desktop host and run controls). Browser/Desktop approval remains the trust gate for generated output writes.
95
-
96
- The hub handles a `/migrate` goal deep link:
97
-
98
- ```text
99
- agentnative://open?goal=migrate&run=<runId>
100
- ```
101
-
102
- The legacy app-style deep link still works and opens the internal run detail surface:
103
-
104
- ```text
105
- agentnative://open?app=migration&run=<runId>
106
- ```
107
-
108
- ## Emit Mode
109
-
110
- Use `--emit` when you want Codex, Claude Code, another code agent, or Agent-Native Desktop to do the next phase without opening the internal run surface:
111
-
112
- ```bash
113
- npx @agent-native/core@latest code /migrate ./my-next-app --emit ../migration-dossier
114
- ```
115
-
116
- The dossier is always written outside `sourceRoot`. It includes:
117
-
118
- - `AGENTS.md` with migration-specific instructions
119
- - `.agents/skills/migration*/SKILL.md` when migration skills are available from the template
120
- - `MIGRATION_PLAYBOOK.md`
121
- - `01-assessment.md`
122
- - `ir.json` when file-level inventory is available
123
-
124
- Hand the dossier to your preferred coding agent with a prompt like:
125
-
126
- ```text
127
- Use this migration dossier. Follow AGENTS.md and MIGRATION_PLAYBOOK.md, keep the source read-only, write the agent-native output outside the source tree, and record verification evidence before calling the migration complete.
128
- ```
129
-
130
- When `@agent-native/migrate` helpers are installed, `--emit` uses them for Next.js assessment and IR. If they are not available, the CLI falls back to a safe local inventory pass. URL-only and description-only dossiers still include the playbook and assessment, but they do not claim file-level IR until an agent inspects source.
131
-
132
- ## Instruction Packs
133
-
134
- The `/migrate` goal is driven by instruction packs instead of one source-specific path.
135
-
136
- | Pack | What it tells the agent to do |
137
- | ---------------- | ------------------------------------------------------------------- |
138
- | Source intake | Normalize path, URL, or prose input into an assessment |
139
- | Agent-native map | Convert operations to actions, SQL, app state, sharing, and SSR |
140
- | Output safety | Keep generated code outside sourceRoot and require approval gates |
141
- | Verification | Use deterministic checks and record manual gaps |
142
- | Platform exits | Add source-specific guidance for systems such as AEM or CMS exports |
143
-
144
- Builder.io, AEM, crawls, package exports, and CMS APIs are optional instruction-pack concerns, not top-level assumptions. Builder Publish can be a target for marketing, docs, landing, and content surfaces. Transactional SaaS state, dashboards, app-owned data, and workflows stay in agent-native SQL/actions.
145
-
146
- ## Agent-Native Mapping
147
-
148
- The recipes are named after the framework contracts they enforce:
149
-
150
- | Source pattern | Agent-native target |
151
- | --------------------------- | ----------------------------------------------------------------- |
152
- | API routes / server actions | `actions/`, except uploads, webhooks, OAuth, and streaming routes |
153
- | app-owned data | Drizzle SQL tables plus actions |
154
- | direct LLM calls | agent chat delegation |
155
- | important client state | `application_state` navigation and selection |
156
- | UI mutations | optimistic action mutations |
157
- | shared resources | ownership, sharing, and access helpers |
158
- | public pages | server rendering |
159
- | logged-in workflows | persistent client app shell |
160
-
161
- This is the difference between porting React code and actually migrating to agent-native.
162
-
163
- ## Package Exports
164
-
165
- `@agent-native/migrate` exposes a reusable engine for adapters and custom workflows:
166
-
167
- ```ts
168
- import {
169
- createMigrationRun,
170
- discoverMigration,
171
- planMigration,
172
- selectSourceAdapter,
173
- createSkeletonProjectIR,
174
- createBrowserVerifier,
175
- nextjsSourceAdapter,
176
- agentNativeTargetAdapter,
177
- } from "@agent-native/migrate";
178
- ```
179
-
180
- Subpath exports are available for first-party V1 adapters:
181
-
182
- ```ts
183
- import { nextjsSourceAdapter } from "@agent-native/migrate/source-nextjs";
184
- import { agentNativeTargetAdapter } from "@agent-native/migrate/target-agent-native";
185
- ```
186
-
187
- The intermediate representation is split into four graphs: site, components, content, and behavior. Verification starts with deterministic checks and can grow to Playwright, visual, accessibility, Lighthouse, SEO, and redirect checks.
23
+ > [!NOTE]
24
+ > The legacy hidden `migration` detail app has been removed. Use the Code
25
+ > workspace, the Desktop Code tab, or an emitted dossier as the supported
26
+ > surfaces.
@@ -5,7 +5,7 @@ description: "Host many agent-native apps in one monorepo with shared auth, RBAC
5
5
 
6
6
  # Multi-App Workspaces
7
7
 
8
- > For what a workspace _is_ the customization layer, `AGENTS.md`, `LEARNINGS.md`, personal memory, skills, and custom agents see [Workspace](/docs/workspace). This page is about the **deployment shape**: hosting many agent-native apps in one monorepo with shared auth, components, and a unified deploy.
8
+ > **Which workspace doc?** This page covers the **deployment shape** — one monorepo, many apps, shared auth and a unified deploy. For what a workspace _is_ (the customization layer: `AGENTS.md`, `LEARNINGS.md`, personal memory, skills, custom agents) see [Workspace](/docs/workspace); for governance (who reviews, approves, and owns what) see [Workspace Governance](/docs/workspace-management).
9
9
 
10
10
  When vibe-coding an internal tool takes an afternoon, you don't stop at one. A team ends up with a CRM, a support inbox, a dashboard, an ops console — ten small apps, each scaffolded independently. That's great until you need to change something in all of them.
11
11
 
@@ -1,67 +1,38 @@
1
1
  ---
2
2
  title: "Multi-Tenancy"
3
- description: "Every agent-native app is multi-tenant out of the box — organizations, team members, roles, and per-org data isolation with zero configuration."
3
+ description: "Every agent-native app is multi-tenant out of the box — organizations, team members, roles, and per-org data isolation, with zero configuration."
4
4
  ---
5
5
 
6
6
  # Multi-Tenancy
7
7
 
8
- Every agent-native app is multi-tenant by default. Organizations, team members, role-based access, and per-org data isolation are built into the framework there is nothing to configure or opt into.
8
+ Every agent-native app is multi-tenant out of the box. Organizations, team members, role-based access, and per-org data isolation are built into the framework with zero configuration.
9
9
 
10
- ## How it works {#how-it-works}
10
+ ## What you get for free {#free}
11
11
 
12
- The framework provides full multi-tenancy through its own built-in organization system — the core `org/` module backed by the `organizations` and `org_members` tables. (This is the framework's own system, not [Better Auth](https://better-auth.com)'s organization plugin, which is intentionally not registered.)
12
+ A fresh `npx @agent-native/core@latest create` scaffold already ships with:
13
13
 
14
- - **Organizations** users create organizations and invite team members. Each org is a fully isolated tenant.
15
- - **Roles** — every member has a role: `owner`, `admin`, or `member`. Actions can check roles for authorization.
16
- - **Active organization** — the session tracks which org the user is currently working in (`session.orgId`). Switching orgs changes the data they see.
17
- - **Data isolation** — SQL queries are automatically scoped to the active org via `org_id` columns. Data tagged with one org is invisible to users in another org, including the agent.
14
+ - **User registration and login** see [Authentication](/docs/authentication).
15
+ - **Organizations** — users create orgs and invite members by email. Each org is a fully isolated tenant.
16
+ - **Roles** — every member is an `owner`, `admin`, or `member`; actions can check the role for authorization.
17
+ - **Org switching** — the session tracks the active org (`session.orgId`), and switching it changes the data the user and agent see.
18
+ - **Per-org data isolation** — every query is automatically scoped to the active org.
18
19
 
19
- All first-party templates are multi-tenant out of the box. See [Cloneable SaaS templates](/docs/cloneable-saas) for the full list.
20
+ If you're evaluating agent-native for a CRM, project tracker, support inbox, or any team tool, the multi-tenant foundation is already there. All first-party templates are multi-tenant see [Cloneable SaaS templates](/docs/cloneable-saas) for the list.
20
21
 
21
- ## Organizations and members {#organizations-and-members}
22
+ ## The org switcher UI {#org-switcher}
22
23
 
23
- Users can create organizations, invite members by email, and assign roles. The org-switcher and members UI drive this through the core org REST routes (no template code required):
24
+ The org-switcher and members UI render in every template with no extra code. They drive the core org REST routes under `/_agent-native/org/*` (create org, switch org, list/invite/remove members, change roles, set allowed email domain). Users pick the active org from the switcher; the members panel handles invitations and role changes.
24
25
 
25
- ```text
26
- POST /_agent-native/org # create an organization
27
- POST /_agent-native/org/invitations # invite a member by email
28
- ```
26
+ This is the framework's own `org/` module, not Better Auth's organization plugin (which is intentionally not registered). The full org-management surface — `createOrganization`, the REST routes, and template-authored `defineAction` wrappers like `invite-member` — is documented in [Authentication → Organizations](/docs/authentication#organizations).
29
27
 
30
- Server code can call the same surface directly through the `org/` module. `createOrganization(name, email, role?)` creates an org and adds the caller as a member; membership and roles live in the `org_members` table:
28
+ ## How isolation works {#isolation}
31
29
 
32
- ```typescript
33
- import { createOrganization } from "@agent-native/core/org";
30
+ Tenant data is isolated by an `org_id` column (added by `ownableColumns()`), and the framework scopes every query to the active org automatically: `session.orgId → AGENT_ORG_ID → SQL`. When a user switches organizations, the UI, actions, and agent all see only that org's data — the agent cannot reach data for an org the user isn't a member of.
34
31
 
35
- // Creating an org adds the caller (email) as a member with the given role
36
- const org = await createOrganization(
37
- "Acme Inc",
38
- "alice@acme.com",
39
- "owner", // "owner" | "admin" | "member", defaults to "owner"
40
- );
41
- ```
42
-
43
- Org management is a **framework built-in**: the core org plugin auto-mounts REST routes under `/_agent-native/org/*` (create org, switch org, list/invite/remove members, change roles, set allowed email domain), and these back the org-switcher and members UI in every template with no extra code. Agent-callable actions with names like `create-organization` or `invite-member` are **template-authored** on top of this surface, not built-in tools — a template wires its own `defineAction` wrappers when it wants the agent to manage its specific membership model.
44
-
45
- ## Data scoping {#data-scoping}
46
-
47
- Tenant data is isolated by an `org_id` column (added by `ownableColumns()`), and the framework scopes every query to the active org automatically — `session.orgId → AGENT_ORG_ID → SQL`. When a user switches organizations, the UI, actions, and agent all see only that org's data; the agent cannot reach data for an org the user isn't a member of.
48
-
49
- This is the same pipeline used for per-user scoping. For the SQL-level mechanics, the `ownableColumns()` contract, and the `accessFilter` / `resolveAccess` / `assertAccess` guards, see [Security & Data Scoping](/docs/security#data-scoping).
50
-
51
- ## No configuration needed {#zero-config}
52
-
53
- Multi-tenancy is not a feature you enable — it's the default architecture. A fresh `npx @agent-native/core@latest create` scaffold already has:
54
-
55
- - User registration and login
56
- - Organization creation and management
57
- - Member invitations with role assignment
58
- - Per-org data isolation
59
- - Org switching in the UI
60
-
61
- If you're evaluating agent-native for a product like a CRM, project tracker, support inbox, or any team tool — the multi-tenant foundation is already there.
32
+ This is the same pipeline used for per-user scoping. For the SQL-level mechanics, the `ownableColumns()` contract, and the `accessFilter` / `resolveAccess` / `assertAccess` guards, see [Security → Data Scoping](/docs/security#data-scoping) — the single source of truth for the scoping pipeline.
62
33
 
63
34
  ## Related docs {#related}
64
35
 
65
- - [Authentication](/docs/authentication) — auth modes, social providers, session API
66
- - [Security & Data Scoping](/docs/security) — SQL-level isolation, input validation, access guards
36
+ - [Authentication](/docs/authentication#organizations) — sessions, social providers, and the org-management surface
37
+ - [Security Data Scoping](/docs/security#data-scoping) — SQL-level isolation, the `ownableColumns()` contract, and access guards
67
38
  - [Multi-App Workspace](/docs/multi-app-workspace) — hosting multiple agent-native apps in one monorepo with shared auth and RBAC
@@ -190,15 +190,18 @@ arbitrary query execution behind typed read actions rather than raw SQL in chat.
190
190
 
191
191
  ## BYO agent runtimes {#byo-agent-runtimes}
192
192
 
193
- `AgentChatRuntime` is the bring-your-own-agent contract for the chat shell. It
194
- lets an agent you built elsewhere stream normalized events into Agent-Native's
195
- conversation UI while keeping the shared composer, transcript rendering, tool
196
- cards, approvals, native widgets, and surrounding app layout. For how this fits
197
- with headless actions, embedded sidecars, and full applications, see
198
- [Agent Surfaces](/docs/agent-surfaces).
199
-
200
- Use the generic HTTP runtime when your agent can expose a POST endpoint that
201
- returns SSE or NDJSON runtime events:
193
+ `AgentChatRuntime` is the bring-your-own-agent contract for the chat shell, and
194
+ this section is its canonical reference. It lets an agent you built elsewhere
195
+ stream normalized events into Agent-Native's conversation UI while keeping the
196
+ shared composer, transcript rendering, tool cards, approvals, native widgets,
197
+ and surrounding app layout. The [Drop-in Agent](/docs/drop-in-agent#custom-chat-ui)
198
+ tutorial points here for the runtime story, and [Component API](/docs/components#agent-chat-ui)
199
+ lists each connector and adapter with its import path; the contract itself is
200
+ described below.
201
+
202
+ All connectors are exported from `@agent-native/core/client/chat` (and the root
203
+ `@agent-native/core/client` entry). Use the generic HTTP runtime when your agent
204
+ can expose a POST endpoint that returns SSE or NDJSON runtime events:
202
205
 
203
206
  ```tsx
204
207
  import {
@@ -255,7 +258,7 @@ const agUiRuntime = createAgUiChatRuntime({
255
258
 
256
259
  The endpoint may stream the normalized event shape directly:
257
260
 
258
- ```txt
261
+ ```text
259
262
  data: {"type":"message-start","message":{"id":"m1","role":"assistant","content":[]}}
260
263
  data: {"type":"message-delta","messageId":"m1","delta":{"type":"text","text":"Hello"}}
261
264
  data: {"type":"tool-start","toolCall":{"id":"t1","name":"query","input":{"q":"forms"}}}
@@ -295,7 +298,7 @@ if it matures, it should adapt into this same explicit runtime/widget contract.
295
298
 
296
299
  - [Actions](/docs/actions) — define the operations that return native widget data.
297
300
  - [Agent Surfaces](/docs/agent-surfaces) — decide whether you need headless, chat, sidecar, or full app.
298
- - [Drop-in Agent](/docs/drop-in-agent) — mount the standard chat runtime.
299
- - [Component API](/docs/components) — custom chat layers and tool renderers.
301
+ - [Drop-in Agent](/docs/drop-in-agent) — the tutorial for mounting the standard chat runtime.
302
+ - [Component API](/docs/components) — the per-export API map for chat layers, runtimes, and tool renderers.
300
303
  - [MCP Apps](/docs/mcp-apps) — inline UI for external MCP hosts.
301
304
  - [Key Concepts](/docs/key-concepts#protocols) — protocol status and positioning.
@@ -9,6 +9,18 @@ Every agent-native app gets observability out of the box. Traces, automated eval
9
9
 
10
10
  This page covers _agent quality_ metrics: traces, cost, evals, and feedback stored in your database. For _product_ analytics (your app's events flowing to PostHog/Mixpanel/Amplitude), see [Tracking](/docs/tracking).
11
11
 
12
+ ## Three things called "evals"/"observability" — which do I want? {#which}
13
+
14
+ These three pages are easy to confuse. Pick by the question you're asking:
15
+
16
+ | Page | The question it answers | When it runs | Concern |
17
+ | ------------------------------------------------------ | ---------------------------------------------------------- | -------------------------------------------- | -------------- |
18
+ | **Observability evals** (this page, the _Evals_ tab) | "How did my real production runs do?" | Passive, after every run (LLM-judge sampled) | Quality |
19
+ | **[CI Eval Gate](/docs/evals)** (`*.eval.ts`) | "Does the agent do the right thing on this fixed input?" | Active, deterministic, a CI/deploy gate | Quality |
20
+ | **[Observational Memory](/docs/observational-memory)** | "Is this long thread staying cheap and inside the window?" | Background compaction on long threads | Cost / context |
21
+
22
+ Observability and the CI Eval Gate both score _quality_ but from opposite ends — passive post-hoc scoring of real traffic vs. active pass/fail checks on fixed inputs. Observational Memory is unrelated to quality; it's about token cost and context-window pressure.
23
+
12
24
  ## What's captured automatically {#captured}
13
25
 
14
26
  When a user sends a message, the framework automatically records:
@@ -113,10 +125,10 @@ Test different models, temperatures, or agent configurations:
113
125
  // Create via API
114
126
  POST /_agent-native/observability/experiments
115
127
  {
116
- "name": "sonnet-vs-haiku",
128
+ "name": "model-a-vs-b",
117
129
  "variants": [
118
- { "id": "control", "weight": 50, "config": { "model": "claude-sonnet-4-6" } },
119
- { "id": "treatment", "weight": 50, "config": { "model": "claude-haiku-4-5-20251001" } }
130
+ { "id": "control", "weight": 50, "config": { "model": "<your-model-id>" } },
131
+ { "id": "treatment", "weight": 50, "config": { "model": "<other-model-id>" } }
120
132
  ],
121
133
  "metrics": ["cost", "latency", "satisfaction"]
122
134
  }
@@ -126,7 +138,7 @@ PUT /_agent-native/observability/experiments/:id
126
138
  { "status": "running" }
127
139
  ```
128
140
 
129
- The agent loop automatically resolves the user's variant and applies the config override. Assignment uses consistent hashing — same user always gets the same variant.
141
+ Use the real model identifiers your engine accepts in place of `<your-model-id>` / `<other-model-id>` (model names change often — check your provider/engine for the current ids). The agent loop automatically resolves the user's variant and applies the config override. Assignment uses consistent hashing — same user always gets the same variant.
130
142
 
131
143
  ## Configuration {#config}
132
144
 
@@ -58,6 +58,6 @@ The injection is best-effort and boundary-safe — if a safe trim point can't be
58
58
 
59
59
  ## Related
60
60
 
61
- - [**Context X-Ray**](/docs/using-your-agent) — inspect what's actually in the live context window.
61
+ - [**Using Your Agent**](/docs/using-your-agent) — the day-to-day loop of working with the agent docked next to your app.
62
62
  - [**Observability**](/docs/observability) — token and cost metrics per run, where OM's savings show up.
63
63
  - [**Custom Agents & Teams**](/docs/agent-teams) — long sub-agent runs benefit from the same compaction.