DocsReact CorehooksActionDefinition
Package: @hexos/react-core

Defines a frontend action that the agent can trigger, with optimistic update support.

Actions are like FrontendToolDefinition but designed for state mutations. They support optimistic updates (apply changes immediately before the async handler resolves) and automatic rollback on errors. An optional confirmationMessage triggers a confirmation dialog before execution.

Related: useAgentAction registers and executes actions, ActionConfirmDialog renders confirmation UI.

interface ActionDefinition<TInput = unknown> {
    name: string;
    description: string;
    inputSchema: z.ZodType<TInput>;
    handler: (input: TInput) => Promise<void>;
    confirmationMessage?: string | ((input: TInput) => string);
    optimisticUpdate?: (input: TInput) => void;
    rollback?: (input: TInput, error: Error) => void;
}

name

string

description

string

inputSchema

z.ZodType

handler

(input: TInput) => Promise

confirmationMessage

string | ((input: TInput) => string)

optimisticUpdate

(input: TInput) => void

rollback

(input: TInput, error: Error) => void