import type { Schema, SchemaIssue } from './schema.js'; import type { ToolDef } from './tools.js'; import type { AgentInit, FabricAgent } from './types.js'; declare const actionSymbol: unique symbol; /** * What an action runs against: the harness entry point (`init` can prompt * models, spawn sessions, and call tools) plus the platform environment. * Jobs, agents, and servers all satisfy this — it is the harness slice of * `FabricContext`. */ export interface ActionHost { init: (options?: AgentInit) => Promise; env?: Record; } /** * Context passed to an action's `run`. Unlike a tool's `execute` (a leaf * capability invoked by the model), an action receives the harness itself * and can orchestrate: prompt models, spawn sessions, call other actions. */ export interface ActionContext extends ActionHost { input: TInput; } export interface ActionOptions { name: string; description: string; /** Optional input schema. Must be a top-level object schema (it becomes the tool JSON schema when the action is exposed as a tool). */ input?: Schema; /** Optional output schema; when set, `run`'s result is validated against it. */ output?: Schema; run(context: ActionContext): Promise | TOutput; } /** * A named, schema-validated unit of harness work created with * {@link defineAction}. First-class in v2: registrable on agent profiles as * a tool, callable from jobs and agents, evaluable via `fh test`, and * deployable as a platform job task. */ export interface ActionDefinition extends ActionOptions { readonly [actionSymbol]: true; } export declare class ActionError extends Error { readonly code: 'INPUT_VALIDATION' | 'OUTPUT_VALIDATION' | 'OUTPUT_SERIALIZATION'; readonly action: string; readonly issues: SchemaIssue[] | undefined; constructor(code: ActionError['code'], action: string, message: string, issues?: SchemaIssue[]); } /** * Define an action — the harness-context counterpart to `defineTool`. * A tool is a leaf capability the model calls; an action holds the harness * (`context.init`) and can prompt, spawn sessions, and compose other work. * Input/output use the harness `schema` builders and are validated on every * {@link runAction} call; outputs must be JSON-serializable. */ export declare function defineAction(options: ActionOptions): ActionDefinition; export declare function isActionDefinition(value: unknown): value is ActionDefinition; /** * Validate input, run the action against `host`, validate + JSON-clone the * output. The returned value is always safely serializable (a fresh JSON * clone), so callers can persist or transmit it without sharing references. */ export declare function runAction(action: ActionDefinition, host: ActionHost, input?: unknown): Promise; /** * Expose an action to the model as a tool on an agent profile. The tool's * JSON schema comes from the action's input schema; execution validates * input/output exactly like {@link runAction}. */ export declare function actionAsTool(action: ActionDefinition, host: ActionHost): ToolDef; export {}; //# sourceMappingURL=action.d.ts.map