@agent-native/core 0.49.0 → 0.49.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -210,13 +210,14 @@ export default defineConfig({
210
210
 
211
211
  ### Build / Runtime {#env-runtime}
212
212
 
213
- | Variable | Description |
214
- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
215
- | `PORT` | Server port (Node.js only) |
216
- | `NITRO_PRESET` | Override build preset at build time |
217
- | `APP_BASE_PATH` | Mount the app under a prefix (e.g. `/mail`). Set automatically by `npx @agent-native/core@latest deploy`; leave unset for standalone. |
218
- | `DATABASE_URL` | Persistent SQL connection string. Required in production. See [Database](/docs/database#production) for adapter and dialect details. |
219
- | `DATABASE_AUTH_TOKEN` | Auth token for providers that require a separate token, such as Turso/libSQL. |
213
+ | Variable | Description |
214
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
215
+ | `PORT` | Server port (Node.js only) |
216
+ | `NITRO_PRESET` | Override build preset at build time |
217
+ | `APP_BASE_PATH` | Mount the app under a prefix (e.g. `/mail`). Set automatically by `npx @agent-native/core@latest deploy`; leave unset for standalone. |
218
+ | `DATABASE_URL` | Persistent SQL connection string. Required in production. See [Database](/docs/database#production) for adapter and dialect details. |
219
+ | `DATABASE_AUTH_TOKEN` | Auth token for providers that require a separate token, such as Turso/libSQL. |
220
+ | `AGENT_PROD_CODE_EXECUTION` | Optional production code-execution mode: `off` (default), `sandboxed`, or `trusted`. See [Production Code Execution](#production-code-execution). |
220
221
 
221
222
  ### Required in Production {#env-required-prod}
222
223
 
@@ -289,11 +290,34 @@ openssl rand -hex 32
289
290
 
290
291
  Rotate them by replacing the env var on every instance and redeploying — sessions / OAuth state envelopes signed under the old key become invalid, so users may need to sign in again.
291
292
 
293
+ ## Production Code Execution {#production-code-execution}
294
+
295
+ By default, production agents run without code-execution tools. They can call app actions, database tools, MCP tools, browser/session tools, and other registered framework tools, but they do not get shell or filesystem access.
296
+
297
+ Node-compatible deployments can opt into production code execution through the agent chat plugin or an environment override:
298
+
299
+ ```ts
300
+ // server/plugins/agent-chat.ts
301
+ export default createAgentChatPlugin({
302
+ codeExecution: { production: "sandboxed" },
303
+ });
304
+ ```
305
+
306
+ The available modes are:
307
+
308
+ - `off` — the default. No code-execution tools are registered in production.
309
+ - `sandboxed` — registers `run-code`, an isolated Node.js JavaScript runner with a scrubbed environment, a fresh temp directory, output/time limits, and a localhost bridge to allowlisted registered tools such as `provider-api-request`, `provider-api-docs`, `provider-api-catalog`, `web-request`, and `workspace-files`.
310
+ - `trusted` — registers `run-code` plus the full coding tool registry (`bash`, `read`, `edit`, `write`). Use this only for single-tenant or operator-controlled deployments where full shell access to the host is intentional.
311
+
312
+ Set `AGENT_PROD_CODE_EXECUTION=sandboxed` or `AGENT_PROD_CODE_EXECUTION=trusted` to override the plugin option for a specific deployment without a code change. `AGENT_PROD_CODE_EXECUTION=off` forces code execution off even when the plugin option enables it.
313
+
314
+ The `run-code` sandbox is process-level isolation, not an OS container. It strips app secrets from the child process environment and uses the Node permission model when available, but outbound network is not blocked by Node itself; authenticated calls should go through the bridge helpers the tool exposes.
315
+
292
316
  ## Updating UI in Production {#updating-ui-in-production}
293
317
 
294
318
  One of agent-native's core features is that the agent can modify your app's source code — components, routes, styles, actions. During local development this works seamlessly because the agent has full filesystem access.
295
319
 
296
- In a standard production deployment, however, the agent runs in **production mode** with access to app tools (actions, database, MCP) but **not** the filesystem. This means the agent can read and write data, run actions, and interact with external services — but it can't edit your React components or add new routes on a deployed instance.
320
+ In a standard production deployment with [production code execution](#production-code-execution) left off, the agent has access to app tools (actions, database, MCP) but not the filesystem. This means the agent can read and write data, run actions, and interact with external services — but it can't edit your React components or add new routes on a deployed instance.
297
321
 
298
322
  ### Builder.io: Visual Editing in Production {#builderio}
299
323
 
@@ -15,24 +15,27 @@ You don't need to build agent-native from scratch. The agent chat, workspace tab
15
15
 
16
16
  ## The components at a glance {#components}
17
17
 
18
- | Component | What it is | Use it when |
19
- | --------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------- |
20
- | `<AgentSidebar>` | Wraps your app, adds a toggleable side panel containing the full agent | You want the agent available alongside your app on every screen |
21
- | `<AgentToggleButton>` | Opens/closes `<AgentSidebar>` (put it in your header) | Pair with `<AgentSidebar>` |
22
- | `<AgentPanel>` | The raw panel itself — chat + CLI + workspace tabs | You want full control over layout, or a dedicated agent page |
23
- | `<AgentChatSurface>` | A pre-wired panel/page chat surface | You want chat without the sidebar wrapper |
24
- | `<AssistantChat>` | Lower-level chat renderer with composer/history hooks | You need custom chrome around the standard conversation UI |
25
- | `sendToAgentChat()` | Programmatically send a message to the chat | A button that hands work to the agent instead of running inline |
26
- | `useActionMutation()` | Typesafe frontend wrapper around an action | The UI needs to run the same operation an agent tool would run |
18
+ | Component | What it is | Use it when |
19
+ | --------------------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
20
+ | `<AgentSidebar>` | Wraps your root app layout and adds a toggleable side panel containing the full agent | You want the agent available alongside your app on every screen |
21
+ | `<AgentToggleButton>` | Opens/closes `<AgentSidebar>` (put it in your header) | Pair with `<AgentSidebar>` |
22
+ | `<AgentPanel>` | The raw panel itself — chat + CLI + workspace tabs | You want full control over layout, or a dedicated agent page |
23
+ | `<AgentChatSurface>` | A pre-wired panel/page chat surface | You want chat without the sidebar wrapper |
24
+ | `<AssistantChat>` | Lower-level chat renderer with composer/history hooks | You need custom chrome around the standard conversation UI |
25
+ | `sendToAgentChat()` | Programmatically send a message to the chat | A button that hands work to the agent instead of running inline |
26
+ | `useActionMutation()` | Typesafe frontend wrapper around an action | The UI needs to run the same operation an agent tool would run |
27
27
 
28
28
  All of these are exported from `@agent-native/core/client`.
29
29
 
30
30
  ## The 80% case: `<AgentSidebar>` {#sidebar}
31
31
 
32
- The most common setup is a sidebar that slides in from the right on any screen. Two pieces — the wrapper and a header button:
32
+ The most common setup is a sidebar that opens from the right on any screen.
33
+ Wrap your existing root layout with `<AgentSidebar>`; whatever you pass as
34
+ children stays in the main app area. The agent chat is the side panel.
33
35
 
34
36
  ```tsx
35
37
  // app/root.tsx
38
+ import { Outlet } from "react-router";
36
39
  import { AgentSidebar, AgentToggleButton } from "@agent-native/core/client";
37
40
 
38
41
  export default function Root() {
@@ -48,20 +51,23 @@ export default function Root() {
48
51
  defaultSidebarWidth={420}
49
52
  position="right"
50
53
  >
51
- <YourApp />
54
+ <header>
55
+ <AgentToggleButton />
56
+ </header>
57
+
58
+ <main>
59
+ <Outlet />
60
+ </main>
52
61
  </AgentSidebar>
53
62
  );
54
63
  }
55
-
56
- // somewhere in your header / navbar
57
- <AgentToggleButton />;
58
64
  ```
59
65
 
60
66
  That's it. The user now has a toggleable agent on every page — with chat history, workspace tab, CLI terminal, voice input, and a fullscreen mode. State persists across reloads via `localStorage`.
61
67
 
62
68
  ### Props
63
69
 
64
- - **`children`** — your app. Rendered in the main area; the sidebar overlays from the chosen side.
70
+ - **`children`** — your app's normal layout and routes. Rendered in the main area; the agent panel mounts beside it on desktop and over it on mobile/fullscreen.
65
71
  - **`emptyStateText`** — greeting shown when the chat has no messages. Default: `"How can I help you?"`.
66
72
  - **`suggestions`** — starter prompts rendered as clickable chips when empty.
67
73
  - **`dynamicSuggestions`** — context-aware prompt chips merged with `suggestions`. Enabled by default; pass `false` to show only static suggestions, or `{ max, includeStatic, getSuggestions }` to customize.
@@ -188,8 +194,9 @@ first so client code does not learn a second, ad hoc transport.
188
194
 
189
195
  ### Build your own sidebar from pieces {#build-your-own-sidebar}
190
196
 
191
- The stock sidebar is optional. A custom sidebar can keep your own layout and
192
- still reuse the framework runtime:
197
+ The stock sidebar is optional. This example builds the agent-side UI itself.
198
+ Render it inside your own shell, drawer, split pane, or route when you want to
199
+ own the layout around the agent runtime:
193
200
 
194
201
  ```tsx
195
202
  import { AssistantChat, useChatThreads } from "@agent-native/core/client/chat";
@@ -42,6 +42,12 @@ This keeps plan content out of the Agent-Native Plan database. Hosted sharing,
42
42
  comments, screenshots, and plan history are unavailable until you explicitly
43
43
  publish later.
44
44
 
45
+ Agent Native Desktop has a separate local-file sync path for hosted plans: the
46
+ Desktop app can mirror a hosted plan to local MDX files and import edits back
47
+ without cloning the Plan app or running a CLI. That workflow keeps the hosted
48
+ Plan database as the source of truth; use local-files privacy mode when the goal
49
+ is no Plan DB writes.
50
+
45
51
  > The plugin (`agent-native-visual-plans`) carries app id `visual-plans`, which is why the Claude Code plugin name and Codex plugin name are both `agent-native-visual-plans`. The Plan app's display name is "Agent-Native Plan".
46
52
 
47
53
  ## Install routes {#install}
@@ -24,6 +24,9 @@ When you open the app, you'll see a sidebar tree of pages on the left, the edito
24
24
  - **Write rich text** with headings, lists, tables, code blocks, images, and links. Slash commands (`/`) insert blocks; selecting text pops up a formatting toolbar.
25
25
  - **Organize pages in a tree** — nest infinitely, drag to reorder, favorite pages you use often.
26
26
  - **Search across everything** with full-text search across titles and content.
27
+ - **Sync with local Markdown/MDX files.** Use the `/local-files` view to export
28
+ your workspace to files, edit them in your own tools, preview changes, and
29
+ import them back.
27
30
  - **Sync with Notion.** Link a local doc to a Notion page and pull or push content in either direction. Comments sync both ways too.
28
31
  - **Collaborate in real time.** Multiple people (and the agent) can edit the same doc at the same time.
29
32
  - **Share docs** with teammates or make them public — private by default, with viewer / editor / admin roles.
@@ -43,6 +46,24 @@ When you open the app, click **+ New page** in the sidebar, give it a title, and
43
46
 
44
47
  Select text and hit Cmd+I to focus the agent with that selection pre-loaded — "make this punchier" then operates on exactly what you highlighted.
45
48
 
49
+ ## Local Markdown files {#local-files}
50
+
51
+ Content can round-trip documents through local files without cloning or running
52
+ the Content app locally. Open `/local-files`, choose a folder in your browser or
53
+ Agent Native Desktop, and export the current document tree as Markdown/MDX under
54
+ `content/`.
55
+
56
+ Each exported file contains frontmatter for document metadata (`id`, `title`,
57
+ `parentId`, `position`, favorite/search/visibility flags, and `updatedAt`) plus
58
+ the document body as Markdown. You can edit those files in your normal editor,
59
+ then return to `/local-files` to preview and import changes back into Content.
60
+
61
+ This workflow is useful when you want content in source control, want to batch
62
+ edit docs with local tools, or want a no-clone path for teams that prefer files
63
+ as the review surface. The hosted app remains the source of truth for sharing,
64
+ comments, permissions, and live collaboration; the local folder is an explicit
65
+ sync surface.
66
+
46
67
  ## Why it's interesting
47
68
 
48
69
  Three things make Content a good showcase of the framework:
@@ -111,6 +132,21 @@ Documents can be linked to a Notion page and synced in either direction:
111
132
 
112
133
  Sync state is tracked in the `document_sync_links` table (last synced time, conflict flag, last error). Markdown-to-Notion block conversion lives in `shared/notion-markdown.ts`. Conflict and status UI is in `app/components/editor/NotionConflictBanner.tsx` and `NotionSyncBar.tsx`. See the `notion-integration` skill for the full flow.
113
134
 
135
+ ### Local file sync
136
+
137
+ The protected `/local-files` route uses the browser File System Access API (or
138
+ the same Chromium capability inside Agent Native Desktop) to read and write
139
+ Markdown/MDX files from a user-chosen folder. It calls:
140
+
141
+ - `export-content-source` — reads the accessible document tree and returns a
142
+ deterministic `content/` file bundle.
143
+ - `import-content-source` — validates files, creates new private documents,
144
+ updates documents where the caller has editor access, preserves version
145
+ history, and rejects invalid parent cycles.
146
+
147
+ The source format lives in `shared/content-source.ts`. Keep that file as the
148
+ single contract for filenames, frontmatter, parsing, and serialization.
149
+
114
150
  ### Comments
115
151
 
116
152
  Threaded comments on documents with quoted-text anchors, replies, and resolve state. Backed by the `document_comments` table and `app/components/editor/CommentsSidebar.tsx`. Actions: `list-comments`, `add-comment`. Notion comments can sync both ways via `sync-notion-comments`.
@@ -208,6 +208,28 @@ and commenting, and returns the hosted URL. It does
208
208
  not automatically make your coding agent's LLM local; choose a local or approved
209
209
  model if that privacy boundary matters too.
210
210
 
211
+ ## Desktop local file sync {#desktop-local-sync}
212
+
213
+ Agent Native Desktop also gives hosted Plans a native local-folder bridge. This
214
+ is different from local-files privacy mode: the hosted Plan database remains the
215
+ source of truth for sharing, comments, history, and live review, while Desktop
216
+ can mirror the current plan's source files to a folder you choose.
217
+
218
+ Open a plan in Agent Native Desktop, use the plan menu's **Local files** actions,
219
+ then:
220
+
221
+ - **Link local folder** — choose the folder for that plan's MDX source.
222
+ - **Sync to local folder** — write `plan.mdx`, optional `canvas.mdx`,
223
+ optional `prototype.mdx`, optional `.plan-state.json`, and image assets.
224
+ - **Import local edits** — read the folder and apply it through
225
+ `import-visual-plan-source` with the plan's current update timestamp.
226
+ - **Auto-sync changes** — keep exporting the hosted plan's latest source after
227
+ edits made in the app.
228
+
229
+ This path does not require cloning the Plan app or running a CLI. It is for
230
+ file-first review/editing around a hosted plan, not for keeping plan content out
231
+ of the hosted database.
232
+
211
233
  ## Useful prompts
212
234
 
213
235
  - "Use `/visual-plan` before changing the auth flow."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.49.0",
3
+ "version": "0.49.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"