Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(actions): add defineAction, the core of the action layer

Shahriar86ae1bbf3d1e
diff --git a/lib/actions/core.ts b/lib/actions/core.ts
new file mode 100644
index 0000000..d773f26
--- /dev/null
+++ b/lib/actions/core.ts
@@ -0,0 +1,31 @@
+import type { z } from 'zod';
+
+/** A declarative, remotely-invokable browser capability. */
+export interface Action<Input extends z.ZodType = z.ZodType, Output = unknown> {
+ /** Namespaced semantic name, e.g. `page.scrollTo`. */
+ readonly name: string;
+ /** One line, human- and LLM-readable, describing the side effect. */
+ readonly description: string;
+ /** Declarative parameter schema — also the source of MCP tool schemas. */
+ readonly input: Input;
+ readonly execute: (input: z.output<Input>) => Output | Promise<Output>;
+}
+
+/** An action with its generics erased — the registry and dispatcher operate on these. */
+export type AnyAction = Action<any, any>;
+
+export function defineAction<Input extends z.ZodType, Output>(
+ action: Action<Input, Output>,
+): Action<Input, Output> {
+ return Object.freeze(action);
+}
+
+export class ActionError extends Error {
+ constructor(
+ message: string,
+ readonly code = 'ACTION_FAILED',
+ ) {
+ super(message);
+ this.name = 'ActionError';
+ }
+}