refactor: split repo into docs/ mockup/ app/
- move static mockups from resource/ui to mockup/ - move React app scaffold from resource/ui to app/ - move prome.md + images to docs/ - drop empty resource/jsonfile and resource/ - add root .gitignore - rewrite README for new layout - fix paths in mockup/index.html (resource/ui -> mockup, docs/prome.md)
This commit is contained in:
1 parent
8e87e47017
commit
92a2adad6a
133 files changed
+23416
-50
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import action from "./hello";
|
||||
|
||||
describe("hello", () => {
|
||||
it("defaults name to world when omitted", async () => {
|
||||
const result = await action.run({});
|
||||
|
||||
expect(result).toEqual({ message: "Hello, world!" });
|
||||
});
|
||||
|
||||
it("greets the provided name", async () => {
|
||||
const result = await action.run({ name: "Steve" });
|
||||
|
||||
expect(result).toEqual({ message: "Hello, Steve!" });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineAction } from "@agent-native/core/action";
|
||||
import { z } from "zod";
|
||||
|
||||
export default defineAction({
|
||||
description: "Return a friendly greeting.",
|
||||
mcpTool: true,
|
||||
schema: z.object({
|
||||
name: z.string().default("world").describe("Name to greet"),
|
||||
}),
|
||||
http: { method: "GET" },
|
||||
run: async ({ name }) => {
|
||||
return { message: `Hello, ${name}!` };
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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=home
|
||||
* pnpm action navigate --path=/some/route
|
||||
*
|
||||
* Options:
|
||||
* --view View name to navigate to
|
||||
* --path URL path to navigate to
|
||||
*/
|
||||
|
||||
import { defineAction, fail } from "@agent-native/core/action";
|
||||
import { writeAppStateForCurrentTab } 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. The default product surface is the home canvas at /; agent chat stays in the right rail.",
|
||||
schema: z.object({
|
||||
view: z.string().optional().describe("View name to navigate to"),
|
||||
path: z.string().optional().describe("URL path to navigate to"),
|
||||
}),
|
||||
http: false,
|
||||
run: async (args) => {
|
||||
if (!args.view && !args.path) {
|
||||
fail("At least --view or --path is required.", {
|
||||
errorCode: "navigate_target_required",
|
||||
});
|
||||
}
|
||||
const nav: Record<string, string> = {};
|
||||
if (args.view) nav.view = args.view;
|
||||
if (args.path) nav.path = args.path;
|
||||
nav._writeId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
await writeAppStateForCurrentTab("navigate", nav);
|
||||
return `Navigating to ${args.view || args.path}`;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const executeRequest = vi.fn();
|
||||
|
||||
vi.mock("@agent-native/core/provider-api", () => ({
|
||||
createProviderApiRuntime: () => ({ executeRequest }),
|
||||
}));
|
||||
|
||||
const { default: action, requiresProviderApiApproval } =
|
||||
await import("./provider-api-request");
|
||||
|
||||
describe("provider-api-request", () => {
|
||||
beforeEach(() => {
|
||||
executeRequest.mockReset();
|
||||
});
|
||||
|
||||
it("routes Slack reads through the shared provider runtime", async () => {
|
||||
executeRequest.mockResolvedValue({ ok: true, team: "Example" });
|
||||
|
||||
await expect(
|
||||
action.run({ provider: "slack", method: "GET", path: "/auth.test" }),
|
||||
).resolves.toEqual({ ok: true, team: "Example" });
|
||||
expect(executeRequest).toHaveBeenCalledWith({
|
||||
provider: "slack",
|
||||
method: "GET",
|
||||
path: "/auth.test",
|
||||
});
|
||||
});
|
||||
|
||||
it("requires approval for provider writes", () => {
|
||||
expect(requiresProviderApiApproval({ method: "GET" })).toBe(false);
|
||||
expect(requiresProviderApiApproval({ method: "HEAD" })).toBe(false);
|
||||
expect(requiresProviderApiApproval({ method: "POST" })).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { createProviderApiRuntime } from "@agent-native/core/provider-api";
|
||||
import { createProviderApiRequestAction } from "@agent-native/core/provider-api/actions/provider-api";
|
||||
import { z } from "zod";
|
||||
|
||||
const runtime = createProviderApiRuntime({
|
||||
appId: "chat",
|
||||
providerIds: ["slack"],
|
||||
});
|
||||
|
||||
const schema = z.object({
|
||||
provider: z.literal("slack").default("slack"),
|
||||
method: z
|
||||
.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"])
|
||||
.default("GET"),
|
||||
path: z.string().min(1).describe("Slack Web API path, such as /auth.test."),
|
||||
query: z.unknown().optional().describe("Optional query parameters."),
|
||||
headers: z
|
||||
.record(z.string(), z.unknown())
|
||||
.optional()
|
||||
.describe("Optional non-authentication headers."),
|
||||
body: z.unknown().optional().describe("Optional request body."),
|
||||
connectionId: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe("Optional workspace connection to use."),
|
||||
timeoutMs: z.coerce.number().int().min(1_000).max(120_000).optional(),
|
||||
maxBytes: z.coerce
|
||||
.number()
|
||||
.int()
|
||||
.min(1_000)
|
||||
.max(4 * 1024 * 1024)
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export function requiresProviderApiApproval(args: { method: string }): boolean {
|
||||
return args.method !== "GET" && args.method !== "HEAD";
|
||||
}
|
||||
|
||||
export default createProviderApiRequestAction(runtime, {
|
||||
appId: "chat",
|
||||
schema,
|
||||
http: false,
|
||||
needsApproval: requiresProviderApiApproval,
|
||||
description:
|
||||
"Call Slack's authenticated Web API through the user's workspace connection. Use this when the conversation needs a concrete Slack read or write. If Slack is not connected, the runtime pauses the run and surfaces the standard contextual connection card; do not replace that request with prose or ask for credentials in chat.",
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import { runScript } from "@agent-native/core/scripts";
|
||||
void runScript();
|
||||
@@ -0,0 +1,36 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
readAppState: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@agent-native/core/application-state", () => ({
|
||||
readAppState: mocks.readAppState,
|
||||
}));
|
||||
|
||||
import action from "./view-screen";
|
||||
|
||||
describe("view-screen", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("returns the current navigation state when present", async () => {
|
||||
mocks.readAppState.mockResolvedValue({ view: "chat", threadId: "t1" });
|
||||
|
||||
const result = await action.run({});
|
||||
|
||||
expect(mocks.readAppState).toHaveBeenCalledWith("navigation");
|
||||
expect(result).toEqual({
|
||||
navigation: { view: "chat", threadId: "t1" },
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a fallback message when there is no navigation state", async () => {
|
||||
mocks.readAppState.mockResolvedValue(null);
|
||||
|
||||
const result = await action.run({});
|
||||
|
||||
expect(result).toBe("No application state found. Is the app running?");
|
||||
});
|
||||
});
|
||||
@@ -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 app canvas plus agent rail. 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;
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user