Initial commit from agent-native create

This commit is contained in:
agent-native
2026-07-25 17:10:38 +00:00
commit ffea2aeff7
120 changed files with 6804 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import { defineAction } from "@agent-native/core/action";
import { z } from "zod";
export default defineAction({
description: "Return a friendly greeting.",
schema: z.object({
name: z.string().default("world").describe("Name to greet"),
}),
http: { method: "GET" },
run: async ({ name }) => {
return { message: `Hello, ${name}!` };
},
});
+41
View File
@@ -0,0 +1,41 @@
/**
* Navigate the UI to a view.
*
* Writes a navigate command to application state which the UI reads and auto-deletes.
*
* Usage:
* pnpm action navigate --view=chat
* pnpm action navigate --path=/some/route
*
* Options:
* --view View name to navigate to
* --path URL path to navigate to
* --threadId Chat thread ID to open on the chat route
*/
import { defineAction } from "@agent-native/core/action";
import { writeAppState } from "@agent-native/core/application-state";
import { z } from "zod";
export default defineAction({
description:
"Navigate the UI to a specific view or path. Writes a navigate command to application state which the UI reads and auto-deletes.",
schema: z.object({
view: z.string().optional().describe("View name to navigate to"),
path: z.string().optional().describe("URL path to navigate to"),
threadId: z.string().optional().describe("Chat thread ID to open"),
}),
http: false,
run: async (args) => {
if (!args.view && !args.path) {
throw new Error("At least --view or --path is required.");
}
const nav: Record<string, string> = {};
if (args.view) nav.view = args.view;
if (args.path) nav.path = args.path;
if (args.threadId) nav.threadId = args.threadId;
nav._writeId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
await writeAppState("navigate", nav);
return `Navigating to ${args.view || args.path}`;
},
});
+2
View File
@@ -0,0 +1,2 @@
import { runScript } from "@agent-native/core/scripts";
runScript();
+31
View File
@@ -0,0 +1,31 @@
/**
* See what the user is currently looking at on screen.
*
* Reads and returns the current navigation state from application state.
*
* Usage:
* pnpm action view-screen
*/
import { defineAction } from "@agent-native/core/action";
import { readAppState } from "@agent-native/core/application-state";
import { z } from "zod";
export default defineAction({
description:
"See what the user is currently looking at on screen. Returns the current navigation state for the chat-first app. Always call this first before taking any action.",
schema: z.object({}),
http: false,
readOnly: true,
run: async () => {
const navigation = await readAppState("navigation");
const screen: Record<string, unknown> = {};
if (navigation) screen.navigation = navigation;
if (Object.keys(screen).length === 0) {
return "No application state found. Is the app running?";
}
return screen;
},
});