import type { TSchema } from "typebox"; import type { AgentHistoryEntry } from "./agent-history.js"; import { type ClaudeCodeHarnessOptions } from "./claude-code-harness.js"; import { type CodexHarnessOptions } from "./codex-harness.js"; import type { StructuredOutputSchema } from "./structured-output.js"; /** Providers that can execute a workflow agent. */ export type WorkflowExecutor = "pi" | "codex" | "claude-code"; export type ExecutorCapability = "structured-output" | "jsonl" | "usage" | "history" | "workspace-write"; export interface ExecutorCapabilityDescriptor { executor: WorkflowExecutor; /** Human-readable wire protocol identity, useful for diagnostics and telemetry. */ protocol: string; /** Provider protocol/CLI shape version, not this package version. */ protocolVersion: string; command?: string; capabilities: readonly ExecutorCapability[]; } export declare const EXECUTOR_CAPABILITY_DESCRIPTORS: Readonly>; export interface ExecutorUsage { input: number; output: number; total: number; cost: number; cacheRead: number; cacheWrite: number; } export interface ExecutorRunRequest { prompt: string; cwd?: string; model?: string; schema?: TSchema | StructuredOutputSchema; signal?: AbortSignal; env?: NodeJS.ProcessEnv; label?: string; /** * Best-effort cumulative provider usage. May fire before a failed run rejects; * omitted when the provider reports no usage. Callback failures are ignored. */ onUsage?: (usage: ExecutorUsage) => void; } export interface ExecutorRunResult { /** Validated structured result, or final text for an unstructured request. */ result: T; /** Original final assistant text when the provider exposed text. */ text?: string; usage?: ExecutorUsage; history?: AgentHistoryEntry[]; /** Provider protocol events retained for diagnostics; callers should not mutate. */ events?: readonly unknown[]; } export interface AgentExecutor { readonly executor: WorkflowExecutor; readonly descriptor: ExecutorCapabilityDescriptor; run(request: ExecutorRunRequest): Promise>; } export type ExecutorFactory = () => AgentExecutor; export type ExecutorRegistration = AgentExecutor | ExecutorFactory; export interface ExecutorRegistry { get(executor: WorkflowExecutor): AgentExecutor | undefined; require(executor: WorkflowExecutor): AgentExecutor; register(executor: WorkflowExecutor, registration: ExecutorRegistration): this; descriptors(): readonly ExecutorCapabilityDescriptor[]; } /** Build an injectable registry. Registrations may be concrete or lazy factories. */ export declare function createExecutorRegistry(registrations?: Partial>): ExecutorRegistry; export interface DefaultExecutorRegistryOptions { /** Optional host-provided Pi adapter; Pi itself is owned by WorkflowAgent. */ pi?: ExecutorRegistration; codex?: CodexHarnessOptions; claudeCode?: ClaudeCodeHarnessOptions; } /** * Create the standard registry without probing binaries or credentials. Codex and * Claude adapters are constructed on first `get`, so importing the package remains * safe on hosts that install neither CLI. */ export declare function createDefaultExecutorRegistry(options?: DefaultExecutorRegistryOptions): ExecutorRegistry; /** A fresh default registry; no executable is launched until an adapter is run. */ export declare const defaultExecutorRegistry: () => ExecutorRegistry; export declare const DEFAULT_EXECUTOR_REGISTRY: () => ExecutorRegistry; export declare function getExecutorProtocolVersion(executor: WorkflowExecutor): string;