@agent-native/core 0.20.9 → 0.22.0
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/dist/action.d.ts +61 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +14 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +4 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +19 -7
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +1 -0
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/connect.d.ts +18 -3
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +619 -19
- package/dist/cli/connect.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +6 -2
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +13 -6
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.js +1 -1
- package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +13 -8
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/agent-sidebar-state.d.ts +2 -0
- package/dist/client/agent-sidebar-state.d.ts.map +1 -1
- package/dist/client/agent-sidebar-state.js +40 -0
- package/dist/client/agent-sidebar-state.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +1 -0
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
- package/dist/client/conversation/AgentConversation.js +3 -2
- package/dist/client/conversation/AgentConversation.js.map +1 -1
- package/dist/client/conversation/code-agent-transcript.js +1 -0
- package/dist/client/conversation/code-agent-transcript.js.map +1 -1
- package/dist/client/conversation/types.d.ts +2 -0
- package/dist/client/conversation/types.d.ts.map +1 -1
- package/dist/client/conversation/types.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/mcp-apps/McpAppRenderer.d.ts +10 -0
- package/dist/client/mcp-apps/McpAppRenderer.d.ts.map +1 -0
- package/dist/client/mcp-apps/McpAppRenderer.js +301 -0
- package/dist/client/mcp-apps/McpAppRenderer.js.map +1 -0
- package/dist/client/sse-event-processor.d.ts +3 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +2 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-db-sync.d.ts +5 -5
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +15 -5
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/client/use-db-sync.spec.d.ts +2 -0
- package/dist/client/use-db-sync.spec.d.ts.map +1 -0
- package/dist/client/use-db-sync.spec.js +80 -0
- package/dist/client/use-db-sync.spec.js.map +1 -0
- package/dist/code-agents/transcript-normalizer.d.ts +2 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +17 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +29 -21
- package/dist/db/client.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +62 -3
- package/dist/extensions/actions.js.map +1 -1
- package/dist/extensions/content-patch.d.ts +71 -0
- package/dist/extensions/content-patch.d.ts.map +1 -0
- package/dist/extensions/content-patch.js +251 -0
- package/dist/extensions/content-patch.js.map +1 -0
- package/dist/extensions/routes.js +6 -1
- package/dist/extensions/routes.js.map +1 -1
- package/dist/extensions/store.d.ts +4 -4
- package/dist/extensions/store.d.ts.map +1 -1
- package/dist/extensions/store.js +14 -18
- package/dist/extensions/store.js.map +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/build-server.d.ts +3 -0
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +207 -8
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/oauth-route.d.ts +22 -0
- package/dist/mcp/oauth-route.d.ts.map +1 -0
- package/dist/mcp/oauth-route.js +618 -0
- package/dist/mcp/oauth-route.js.map +1 -0
- package/dist/mcp/oauth-store.d.ts +89 -0
- package/dist/mcp/oauth-store.d.ts.map +1 -0
- package/dist/mcp/oauth-store.js +391 -0
- package/dist/mcp/oauth-store.js.map +1 -0
- package/dist/mcp/oauth-token.d.ts +28 -0
- package/dist/mcp/oauth-token.d.ts.map +1 -0
- package/dist/mcp/oauth-token.js +83 -0
- package/dist/mcp/oauth-token.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +5 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stdio.d.ts +2 -2
- package/dist/mcp/stdio.d.ts.map +1 -1
- package/dist/mcp/stdio.js +26 -8
- package/dist/mcp/stdio.js.map +1 -1
- package/dist/mcp-client/app-result.d.ts +40 -0
- package/dist/mcp-client/app-result.d.ts.map +1 -0
- package/dist/mcp-client/app-result.js +19 -0
- package/dist/mcp-client/app-result.js.map +1 -0
- package/dist/mcp-client/index.d.ts +5 -2
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +201 -25
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/manager.d.ts +16 -0
- package/dist/mcp-client/manager.d.ts.map +1 -1
- package/dist/mcp-client/manager.js +58 -1
- package/dist/mcp-client/manager.js.map +1 -1
- package/dist/mcp-client/routes.d.ts +4 -1
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +159 -0
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/scripts/dev/shell.d.ts.map +1 -1
- package/dist/scripts/dev/shell.js +24 -1
- package/dist/scripts/dev/shell.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +3 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +14 -8
- package/dist/server/auth.js.map +1 -1
- package/dist/server/builder-browser.d.ts +6 -0
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +15 -0
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +5 -4
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +17 -2
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/styles/agent-conversation.css +53 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +193 -72
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +88 -38
- package/dist/templates/default/AGENTS.md +3 -3
- package/dist/templates/default/actions/hello.ts +13 -20
- package/dist/templates/default/actions/navigate.ts +19 -51
- package/dist/templates/default/actions/view-screen.ts +16 -33
- package/dist/templates/default/app/hooks/use-navigation-state.ts +13 -3
- package/dist/templates/default/app/lib/tab-id.ts +1 -0
- package/dist/templates/default/app/root.tsx +2 -1
- package/dist/templates/default/app/routes/_index.tsx +11 -0
- package/dist/templates/default/package.json +2 -1
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +9 -1
- package/dist/templates/workspace-core/AGENTS.md +8 -0
- package/dist/templates/workspace-root/AGENTS.md +7 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +2 -2
- package/dist/vite/client.js.map +1 -1
- package/docs/content/actions.md +26 -3
- package/docs/content/authentication.md +16 -1
- package/docs/content/client.md +11 -8
- package/docs/content/context-awareness.md +2 -3
- package/docs/content/creating-templates.md +2 -2
- package/docs/content/external-agents.md +106 -19
- package/docs/content/faq.md +2 -2
- package/docs/content/key-concepts.md +31 -23
- package/docs/content/mcp-clients.md +1 -1
- package/docs/content/mcp-protocol.md +65 -27
- package/docs/content/template-starter.md +3 -3
- package/docs/content/what-is-agent-native.md +4 -2
- package/package.json +3 -1
- package/src/templates/default/.agents/skills/actions/SKILL.md +193 -72
- package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +88 -38
- package/src/templates/default/AGENTS.md +3 -3
- package/src/templates/default/actions/hello.ts +13 -20
- package/src/templates/default/actions/navigate.ts +19 -51
- package/src/templates/default/actions/view-screen.ts +16 -33
- package/src/templates/default/app/hooks/use-navigation-state.ts +13 -3
- package/src/templates/default/app/lib/tab-id.ts +1 -0
- package/src/templates/default/app/root.tsx +2 -1
- package/src/templates/default/app/routes/_index.tsx +11 -0
- package/src/templates/default/package.json +2 -1
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +9 -1
- package/src/templates/workspace-core/AGENTS.md +8 -0
- package/src/templates/workspace-root/AGENTS.md +7 -0
- package/dist/templates/default/server/routes/api/hello.get.ts +0 -5
- package/dist/templates/default/shared/api.ts +0 -6
- package/src/templates/default/server/routes/api/hello.get.ts +0 -5
- package/src/templates/default/shared/api.ts +0 -6
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.log(`Hello, ${name}!`);
|
|
15
|
-
|
|
16
|
-
// Example: send a message to agent chat (works in Electron context)
|
|
17
|
-
if (parsed["send-chat"] === "true") {
|
|
18
|
-
agentChat.submit(`Hello from the script system! Name: ${name}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export default defineAction({
|
|
5
|
+
description: "Return a friendly greeting.",
|
|
6
|
+
schema: z.object({
|
|
7
|
+
name: z.string().default("world").describe("Name to greet"),
|
|
8
|
+
}),
|
|
9
|
+
http: { method: "GET" },
|
|
10
|
+
run: async ({ name }) => {
|
|
11
|
+
return { message: `Hello, ${name}!` };
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -1,56 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
* Navigate the UI to a view.
|
|
3
|
-
*
|
|
4
|
-
* Writes a navigate command to application state which the UI reads and auto-deletes.
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* pnpm action navigate --view=home
|
|
8
|
-
* pnpm action navigate --path=/some/route
|
|
9
|
-
*
|
|
10
|
-
* Options:
|
|
11
|
-
* --view View name to navigate to
|
|
12
|
-
* --path URL path to navigate to
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { parseArgs } from "@agent-native/core";
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
16
2
|
import { writeAppState } from "@agent-native/core/application-state";
|
|
17
|
-
import
|
|
3
|
+
import { z } from "zod";
|
|
18
4
|
|
|
19
|
-
export
|
|
5
|
+
export default defineAction({
|
|
20
6
|
description:
|
|
21
7
|
"Navigate the UI to a specific view or path. Writes a navigate command to application state which the UI reads and auto-deletes.",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
schema: z.object({
|
|
9
|
+
view: z.string().optional().describe("View name to navigate to"),
|
|
10
|
+
path: z.string().optional().describe("URL path to navigate to"),
|
|
11
|
+
}),
|
|
12
|
+
http: false,
|
|
13
|
+
run: async (args) => {
|
|
14
|
+
if (!args.view && !args.path) {
|
|
15
|
+
return "Error: At least --view or --path is required.";
|
|
16
|
+
}
|
|
17
|
+
const nav: Record<string, string> = {};
|
|
18
|
+
if (args.view) nav.view = args.view;
|
|
19
|
+
if (args.path) nav.path = args.path;
|
|
20
|
+
nav._writeId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
21
|
+
await writeAppState("navigate", nav);
|
|
22
|
+
return `Navigating to ${args.view || args.path}`;
|
|
28
23
|
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export async function run(args: Record<string, string>): Promise<string> {
|
|
32
|
-
if (!args.view && !args.path) {
|
|
33
|
-
return "Error: At least --view or --path is required.";
|
|
34
|
-
}
|
|
35
|
-
const nav: Record<string, string> = {};
|
|
36
|
-
if (args.view) nav.view = args.view;
|
|
37
|
-
if (args.path) nav.path = args.path;
|
|
38
|
-
// Unique-per-write token so the UI's `use-navigation-state` hook can dedup
|
|
39
|
-
// race-driven re-reads of the same command.
|
|
40
|
-
nav._writeId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
41
|
-
await writeAppState("navigate", nav);
|
|
42
|
-
return `Navigating to ${args.view || args.path}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default async function main(): Promise<void> {
|
|
46
|
-
const args = parseArgs(process.argv.slice(2)) as Record<string, string>;
|
|
47
|
-
if (!args.view && !args.path) {
|
|
48
|
-
console.error(
|
|
49
|
-
"Error: At least --view or --path is required. Usage: pnpm action navigate --view=home",
|
|
50
|
-
);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
const result = await run(args);
|
|
54
|
-
console.error(result);
|
|
55
|
-
console.log(JSON.stringify({ result }));
|
|
56
|
-
}
|
|
24
|
+
});
|
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
* See what the user is currently looking at on screen.
|
|
3
|
-
*
|
|
4
|
-
* Reads and returns the current navigation state from application state.
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* pnpm action view-screen
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { parseArgs } from "@agent-native/core";
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
11
2
|
import { readAppState } from "@agent-native/core/application-state";
|
|
12
|
-
import
|
|
3
|
+
import { z } from "zod";
|
|
13
4
|
|
|
14
|
-
export
|
|
5
|
+
export default defineAction({
|
|
15
6
|
description:
|
|
16
7
|
"See what the user is currently looking at on screen. Returns the current navigation state. Note: basic screen context is auto-included with each message — use this tool only when you need a detailed or refreshed snapshot.",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export async function run(_args: Record<string, string>): Promise<string> {
|
|
24
|
-
const navigation = await readAppState("navigation");
|
|
8
|
+
schema: z.object({}),
|
|
9
|
+
http: false,
|
|
10
|
+
readOnly: true,
|
|
11
|
+
run: async () => {
|
|
12
|
+
const navigation = await readAppState("navigation");
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
const screen: Record<string, unknown> = {};
|
|
15
|
+
if (navigation) screen.navigation = navigation;
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default async function main(): Promise<void> {
|
|
36
|
-
const args = parseArgs(process.argv.slice(2)) as Record<string, string>;
|
|
37
|
-
const result = await run(args);
|
|
38
|
-
console.log(result);
|
|
39
|
-
}
|
|
17
|
+
if (Object.keys(screen).length === 0) {
|
|
18
|
+
return "No application state found. Is the app running?";
|
|
19
|
+
}
|
|
20
|
+
return screen;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
appBasePath,
|
|
7
7
|
appPath,
|
|
8
8
|
} from "@agent-native/core/client";
|
|
9
|
+
import { TAB_ID } from "../lib/tab-id";
|
|
9
10
|
|
|
10
11
|
export interface NavigationState {
|
|
11
12
|
view: string;
|
|
@@ -30,7 +31,10 @@ export function useNavigationState() {
|
|
|
30
31
|
fetch(agentNativePath("/_agent-native/application-state/navigation"), {
|
|
31
32
|
method: "PUT",
|
|
32
33
|
keepalive: true,
|
|
33
|
-
headers: {
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
"X-Request-Source": TAB_ID,
|
|
37
|
+
},
|
|
34
38
|
body: JSON.stringify(state),
|
|
35
39
|
}).catch(() => {});
|
|
36
40
|
}, [location.pathname]);
|
|
@@ -65,7 +69,10 @@ export function useNavigationState() {
|
|
|
65
69
|
// up again. Re-fire DELETE and bail rather than navigate again.
|
|
66
70
|
fetch(agentNativePath("/_agent-native/application-state/navigate"), {
|
|
67
71
|
method: "DELETE",
|
|
68
|
-
headers: {
|
|
72
|
+
headers: {
|
|
73
|
+
"X-Agent-Native-CSRF": "1",
|
|
74
|
+
"X-Request-Source": TAB_ID,
|
|
75
|
+
},
|
|
69
76
|
}).catch(() => {});
|
|
70
77
|
qc.setQueryData(["navigate-command"], null);
|
|
71
78
|
return;
|
|
@@ -74,7 +81,10 @@ export function useNavigationState() {
|
|
|
74
81
|
|
|
75
82
|
fetch(agentNativePath("/_agent-native/application-state/navigate"), {
|
|
76
83
|
method: "DELETE",
|
|
77
|
-
headers: {
|
|
84
|
+
headers: {
|
|
85
|
+
"X-Agent-Native-CSRF": "1",
|
|
86
|
+
"X-Request-Source": TAB_ID,
|
|
87
|
+
},
|
|
78
88
|
}).catch(() => {});
|
|
79
89
|
|
|
80
90
|
const path = routerPath(cmd.path || pathFromView(cmd.view));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TAB_ID = Math.random().toString(36).slice(2, 10);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { Toaster } from "sonner";
|
|
26
26
|
import { configureTracking } from "@agent-native/core/client";
|
|
27
27
|
import { useNavigationState } from "./hooks/use-navigation-state";
|
|
28
|
+
import { TAB_ID } from "./lib/tab-id";
|
|
28
29
|
configureTracking({
|
|
29
30
|
getDefaultProps: (_name, properties) => ({
|
|
30
31
|
...properties,
|
|
@@ -86,7 +87,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
86
87
|
function DbSyncSetup() {
|
|
87
88
|
const qc = useQueryClient();
|
|
88
89
|
useNavigationState();
|
|
89
|
-
useDbSync({ queryClient: qc,
|
|
90
|
+
useDbSync({ queryClient: qc, ignoreSource: TAB_ID });
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useTheme } from "next-themes";
|
|
2
2
|
import { IconLoader2 } from "@tabler/icons-react";
|
|
3
|
+
import { useActionQuery } from "@agent-native/core/client";
|
|
3
4
|
|
|
4
5
|
export function meta() {
|
|
5
6
|
return [{ title: "{{APP_TITLE}}" }];
|
|
@@ -20,6 +21,7 @@ export function HydrateFallback() {
|
|
|
20
21
|
export default function IndexPage() {
|
|
21
22
|
const { resolvedTheme, setTheme } = useTheme();
|
|
22
23
|
const isDark = resolvedTheme === "dark";
|
|
24
|
+
const { data } = useActionQuery("hello", { name: "{{APP_TITLE}}" });
|
|
23
25
|
|
|
24
26
|
return (
|
|
25
27
|
<div className="flex flex-col items-center justify-center min-h-screen px-6">
|
|
@@ -38,6 +40,15 @@ export default function IndexPage() {
|
|
|
38
40
|
|
|
39
41
|
<div className="h-px bg-border" />
|
|
40
42
|
|
|
43
|
+
<div className="rounded-lg border border-border/50 px-4 py-3 text-left">
|
|
44
|
+
<p className="text-[13px] font-medium text-foreground">
|
|
45
|
+
Action-backed data
|
|
46
|
+
</p>
|
|
47
|
+
<p className="text-[12px] text-muted-foreground mt-0.5">
|
|
48
|
+
{data?.message ?? "Loading action result..."}
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
41
52
|
<div className="grid grid-cols-2 gap-3 text-left">
|
|
42
53
|
<a
|
|
43
54
|
href="https://agent-native.com/docs"
|
|
@@ -27,7 +27,7 @@ The agent modifies data in SQL, but the UI runs in the browser. SSE bridges same
|
|
|
27
27
|
useDbSync({ queryClient });
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
For each non-own event, `useDbSync` bumps a per-source counter (e.g. `dashboards`, `analyses`, `settings`, `action`) and invalidates a small fixed list of framework-internal prefixes (`["action"]`, `["app-state"]`, `["__set_url__"]`, etc.). It does **not** blanket-invalidate templates' own data queries — that caused a request storm in production.
|
|
30
|
+
For each non-own event, `useDbSync` bumps a per-source counter (e.g. `dashboards`, `analyses`, `settings`, `action`) and invalidates a small fixed list of framework-internal prefixes (`["action"]`, `["app-state"]`, `["__set_url__"]`, etc.). It does **not** blanket-invalidate templates' own data queries for ordinary domain events — that caused a request storm in production. The exception is `source: "action"`: a successful mutating action is the framework-wide "agent changed app data" signal, so `useDbSync` also refreshes active React Query observers as a compatibility safety net for custom apps that have not yet moved every read to `useActionQuery` or source-versioned query keys.
|
|
31
31
|
|
|
32
32
|
3. **Templates fold per-source counters into their query keys.** This is the pattern that makes "agent writes show up without a manual refresh" reliable:
|
|
33
33
|
|
|
@@ -136,6 +136,14 @@ Without jitter prevention, a cycle occurs: the UI writes state, sync detects the
|
|
|
136
136
|
|
|
137
137
|
Action routes (`/_agent-native/actions/:name`) work with the same sync system. When a POST/PUT/DELETE action writes to the database, the version counter increments and `useDbSync` picks up the change. Frontend mutations via `useActionMutation` automatically invalidate `["action"]` query keys on success, triggering refetches of `useActionQuery` hooks.
|
|
138
138
|
|
|
139
|
+
For custom apps, the best out-of-the-box path is:
|
|
140
|
+
|
|
141
|
+
1. Put read actions in `actions/` with `defineAction({ http: { method: "GET" } })`.
|
|
142
|
+
2. Put write actions in `actions/` with the default POST/PUT/DELETE behavior.
|
|
143
|
+
3. Call reads from React with `useActionQuery` and writes with `useActionMutation`.
|
|
144
|
+
|
|
145
|
+
This avoids duplicate `/api/*` JSON CRUD routes and makes agent-created records show up automatically. Raw `useQuery` can still work, but it should include `useChangeVersions(["action", "<domain-source>"])` in the query key for targeted refreshes.
|
|
146
|
+
|
|
139
147
|
### Auto-emit on mutating actions
|
|
140
148
|
|
|
141
149
|
The framework emits a poll event with `source: "action"` whenever any non-read-only action runs to completion — whether called via HTTP (`/_agent-native/actions/:name`) or as an agent tool call. Read-only actions (`http: { method: "GET" }` or explicit `readOnly: true`) are skipped.
|
|
@@ -66,6 +66,14 @@ shadcn/ui components and `@tabler/icons-react`. Do not add `lucide-react` or
|
|
|
66
66
|
another icon library. Read `.agents/skills/shadcn-ui/SKILL.md` before adding,
|
|
67
67
|
updating, or debugging shadcn components.
|
|
68
68
|
|
|
69
|
+
Normal app data must flow through actions. For CRUD that the agent can perform,
|
|
70
|
+
create `defineAction` files in `actions/`, mark reads with
|
|
71
|
+
`http: { method: "GET" }`, and call them from React with `useActionQuery` /
|
|
72
|
+
`useActionMutation`. Do not add duplicate JSON CRUD routes under `/api/*` for
|
|
73
|
+
the same data unless the route is for uploads, streaming, webhooks, OAuth, or
|
|
74
|
+
another route-only concern. Action-backed UI is what makes agent-created or
|
|
75
|
+
agent-edited records appear without a manual refresh.
|
|
76
|
+
|
|
69
77
|
In local development, run
|
|
70
78
|
`pnpm exec agent-native create <app-name> --template=<template>` from the
|
|
71
79
|
workspace root. In production, Dispatch posts new-app requests to Builder
|
|
@@ -95,6 +95,13 @@ coding agents can discover the same workspace-wide guidance from the root.
|
|
|
95
95
|
`@tabler/icons-react`. Do not add `lucide-react` or another icon library.
|
|
96
96
|
Read `packages/shared/.agents/skills/shadcn-ui/SKILL.md` before adding,
|
|
97
97
|
updating, or debugging shadcn components.
|
|
98
|
+
- Normal app data must flow through actions. For CRUD that the agent can
|
|
99
|
+
perform, create `defineAction` files in `actions/`, mark reads with
|
|
100
|
+
`http: { method: "GET" }`, and call them from React with `useActionQuery` /
|
|
101
|
+
`useActionMutation`. Do not add duplicate JSON CRUD routes under `/api/*`
|
|
102
|
+
for the same data unless the route is for uploads, streaming, webhooks,
|
|
103
|
+
OAuth, or another route-only concern. Action-backed UI is what makes
|
|
104
|
+
agent-created or agent-edited records appear without a manual refresh.
|
|
98
105
|
- In local development, scaffold the app from the workspace root with
|
|
99
106
|
`pnpm exec agent-native create <app-id> --template=<template>`. In production
|
|
100
107
|
Dispatch posts the request to Builder branch creation; the Builder branch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/vite/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,MAAM,CAAC;AA6Y/C,MAAM,WAAW,YAAY;IAC3B,sGAAsG;IACtG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oGAAoG;IACpG,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAClC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iDAAiD;IACjD,YAAY,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAqMD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAWT;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/vite/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,UAAU,EAAE,MAAM,MAAM,CAAC;AA6Y/C,MAAM,WAAW,YAAY;IAC3B,sGAAsG;IACtG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oGAAoG;IACpG,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAClC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iDAAiD;IACjD,YAAY,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjD;AAqMD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAWT;AA6KD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CAsP1E"}
|
package/dist/vite/client.js
CHANGED
|
@@ -624,7 +624,7 @@ function silenceConnectionResets() {
|
|
|
624
624
|
return (code === "ECONNRESET" ||
|
|
625
625
|
code === "ECONNABORTED" ||
|
|
626
626
|
code === "EPIPE" ||
|
|
627
|
-
/^(read ECONNRESET|socket hang up|aborted|write EPIPE)$/i.test(message));
|
|
627
|
+
/^(read ECONNRESET|write ECONNRESET|socket hang up|aborted|write EPIPE)$/i.test(message));
|
|
628
628
|
};
|
|
629
629
|
const isBenignErrorPayload = (payload) => {
|
|
630
630
|
const p = payload;
|
|
@@ -646,7 +646,7 @@ function silenceConnectionResets() {
|
|
|
646
646
|
server.config.logger.error = (msg, opts) => {
|
|
647
647
|
const text = typeof msg === "string" ? msg : String(msg ?? "");
|
|
648
648
|
if ((opts?.error && isBenign(opts.error)) ||
|
|
649
|
-
/Internal server error:\s*(read ECONNRESET|socket hang up|aborted|EPIPE)/i.test(text)) {
|
|
649
|
+
/Internal server error:\s*(read ECONNRESET|write ECONNRESET|socket hang up|aborted|EPIPE)/i.test(text)) {
|
|
650
650
|
return;
|
|
651
651
|
}
|
|
652
652
|
origError(msg, opts);
|