import { Effect, Schema } from "effect"; import type { Prompt } from "effect/unstable/ai"; import type { AgentPin, CapabilityPin } from "../durable/pin.js"; import type { AgentRunResult, ProgramAuthorizationFailure, ProgramCapabilityDenied, ProgramOperationName } from "./program-capabilities.js"; import { ProgramCancelled, ProgramInvocationFailure, ProgramSuspended } from "./program-capabilities.js"; /** @experimental Replay behavior selected by the host, never by program source. */ export declare const ProgramReplayPolicy: Schema.Literals; /** @experimental */ export type ProgramReplayPolicy = typeof ProgramReplayPolicy.Type; /** @experimental Host-owned authorization callback for one decoded invocation. */ export type Authorize = (request: { readonly operation: ProgramOperationName; readonly input: I; }) => Effect.Effect; /** @experimental One live typed tool implementation and its exact identity. */ export interface ToolBinding { readonly name: string; readonly pin: CapabilityPin; readonly input: Schema.Codec; readonly output: Schema.Codec; readonly replay: ProgramReplayPolicy; readonly authorize: Authorize; readonly execute: (input: I) => Effect.Effect; } /** @experimental One live typed named step implementation and its exact identity. */ export interface StepBinding extends Omit, "name"> { readonly name: string; } /** @experimental One exact Agent implementation callable by a program host. */ export interface AgentBinding { readonly selection: string; readonly agent: AgentPin; readonly inputPin: CapabilityPin; readonly input: Schema.Codec; readonly replay: ProgramReplayPolicy; readonly authorize: Authorize; readonly execute: (input: I) => Effect.Effect; } /** * @experimental One decoded invocation of a bound tool or step. The decoded input stays inside the binding, so * authorization and execution keep the exact type the binding declared. */ export interface Invocation { readonly authorize: (operation: ProgramOperationName) => Effect.Effect; readonly execute: Effect.Effect; } /** @experimental One decoded Agent invocation, exposing only the prompt every Agent input must produce. */ export interface AgentInvocation { readonly prompt: Prompt.RawInput; readonly authorize: (operation: ProgramOperationName) => Effect.Effect; readonly execute: Effect.Effect; } /** * @experimental Host-facing view of one bound tool in a heterogeneous binding set. Its identity, replay policy, and * boundary codecs stay observable; its decoded input type is reachable only through {@link Invocation}. */ export interface AnyTool { readonly name: string; readonly pin: CapabilityPin; readonly input: Schema.Codec; readonly output: Schema.Codec; readonly replay: ProgramReplayPolicy; readonly decode: (encoded: unknown) => Effect.Effect; } /** @experimental Host-facing view of one bound named step, with the same hidden input as {@link AnyTool}. */ export interface AnyStep extends AnyTool { } /** @experimental A bound tool retaining its exact decoded invocation types. */ export type TypedTool = AnyTool & { readonly decode: (encoded: unknown) => Effect.Effect; }; /** @experimental A bound step retaining its exact decoded invocation types. */ export type TypedStep = TypedTool; /** @experimental Host-facing view of one bound Agent, with its decoded input hidden behind {@link AgentInvocation}. */ export interface AnyAgent { readonly selection: string; readonly agent: AgentPin; readonly inputPin: CapabilityPin; readonly input: Schema.Codec; readonly replay: ProgramReplayPolicy; readonly decode: (encoded: unknown) => Effect.Effect; } /** @experimental Complete live authority available to a ProgramHost. */ export interface Bindings { readonly tools: ReadonlyArray; readonly steps: ReadonlyArray; readonly agents: ReadonlyArray; } /** @experimental Construct a typed tool binding. */ export declare const tool: (binding: ToolBinding) => TypedTool & { readonly decode: (encoded: unknown) => Effect.Effect, Schema.SchemaError>; }; /** @experimental Construct a typed named step binding. */ export declare const step: (binding: StepBinding) => TypedStep & { readonly decode: (encoded: unknown) => Effect.Effect, Schema.SchemaError>; }; /** @experimental Construct an exact typed Agent binding. */ export declare const agent: (binding: AgentBinding) => AnyAgent; /** @experimental Construct the host's complete live Program binding set. */ export declare const make: (bindings: Bindings) => Bindings;