import { Cause, Effect, Layer, Schema } from "effect"; import { LanguageModel, Prompt, Tool } from "effect/unstable/ai"; import { type Agent, type Result, type RunError, type RunOptions, type RunResult, type RunRequirements } from "../agent/agent.js"; import { type AgentToolToolkit } from "../agent/agent-tool.js"; import { type ClosedToolSet } from "../tools/tool-executor.js"; import { type TurnPolicy } from "../turn/turn-policy.js"; import { HandoffCatalog, type HandoffTarget } from "./handoff-target.js"; import type { ContextProjection } from "./handoff-projection.js"; declare const defaultDelegateParameters: Schema.Struct<{ readonly prompt: Schema.String; }>; type DefaultDelegateParameters = typeof defaultDelegateParameters; declare const RegistrationError_base: Schema.Class, Cause.YieldableError>; export declare class RegistrationError extends RegistrationError_base { } export interface Registration = Record, R = never> { readonly name: string; readonly run: (options: O) => Effect.Effect, RunError | RegistrationError, Exclude, R>, import("effect/Scope").Scope>>; readonly requirements: (value: R) => R; } export declare const register: { (layer: Layer.Layer): >(agent: Agent) => Registration; , R, E>(agent: Agent, layer: Layer.Layer): Registration; }; export interface DelegateOptions { readonly nameOverride?: string; readonly description?: string; readonly parameters?: Parameters; readonly success?: Success; readonly toPrompt?: (params: Parameters["Type"]) => Prompt.RawInput; readonly fromResult?: (result: Result) => Success["Type"]; } export interface HandoffToolOptions { readonly nameOverride?: string; readonly description?: string; readonly projection?: ContextProjection; readonly maxRepeatedEdge?: number; } export interface FanOutChild = Record, R = never> { readonly registration: Registration; readonly prompt: Prompt.RawInput; readonly options?: Omit; } export type FanOutJoin = { readonly _tag: "AllSuccess"; } | { readonly _tag: "AllSettled"; } | { readonly _tag: "FirstSuccess"; } | { readonly _tag: "Quorum"; readonly required: number; } | { readonly _tag: "BestEffort"; }; export type FanOutRemainder = "await" | "request-cancel" | "terminate"; interface FanOutBaseOptions { readonly concurrency?: number; readonly remainder?: FanOutRemainder; } export interface FanOutAllSuccessOptions extends FanOutBaseOptions { readonly join?: { readonly _tag: "AllSuccess"; }; } export interface FanOutCollectOptions extends FanOutBaseOptions { readonly join: { readonly _tag: "AllSettled"; } | { readonly _tag: "FirstSuccess"; } | { readonly _tag: "Quorum"; readonly required: number; } | { readonly _tag: "BestEffort"; }; } export type FanOutOptions = FanOutAllSuccessOptions | FanOutCollectOptions; export type FanOutMemberResult = { readonly ordinal: number; readonly status: "succeeded"; readonly result: Result; } | { readonly ordinal: number; readonly status: "failed"; readonly cause: Cause.Cause; } | { readonly ordinal: number; readonly status: "cancelled"; readonly cause?: Cause.Cause; }; declare const FanOutUnsatisfied_base: Schema.Class; readonly required: Schema.Int; readonly succeeded: Schema.Int; readonly settled: Schema.Int; readonly total: Schema.Int; }>, Cause.YieldableError>; export declare class FanOutUnsatisfied extends FanOutUnsatisfied_base { } export interface Supervisor = Record> { readonly agent: Agent; readonly toolkit: ClosedToolSet; readonly catalog: Layer.Layer; } export interface SupervisorOptions { readonly name: string; readonly instructions?: string; readonly specialists: ReadonlyArray; readonly policy?: TurnPolicy; readonly handoffOptions?: HandoffToolOptions; } type HandoffToolkit = { readonly name: string; readonly tool: import("../policy/handoff-runtime.js").HandoffToolSpecResult["tool"]; readonly tools: Record; readonly invoke: (params: unknown) => Effect.Effect; }; export declare const delegateTool: { = Record, R = never, Parameters extends Schema.Top = DefaultDelegateParameters, Success extends Schema.Top = typeof Schema.String>(options?: DelegateOptions): (target: Registration) => AgentToolToolkit>; = Record, R = never, Parameters extends Schema.Top = DefaultDelegateParameters, Success extends Schema.Top = typeof Schema.String>(target: Registration, options?: DelegateOptions): AgentToolToolkit>; }; export declare const sameRunHandoffTool: { (options?: HandoffToolOptions): (handoffTarget: HandoffTarget) => HandoffToolkit; (handoffTarget: HandoffTarget, options?: HandoffToolOptions): HandoffToolkit; }; export declare const fanOut: { = Record, R = never>(options: FanOutCollectOptions): (children: ReadonlyArray>) => Effect.Effect, RunError | RegistrationError | FanOutUnsatisfied>; = Record, R = never>(options?: FanOutAllSuccessOptions): (children: ReadonlyArray>) => Effect.Effect, RunError | RegistrationError>; = Record, R = never>(options: FanOutOptions): (children: ReadonlyArray>) => Effect.Effect | ReadonlyArray, RunError | RegistrationError | FanOutUnsatisfied>; = Record, R = never>(): (children: ReadonlyArray>) => Effect.Effect, RunError | RegistrationError>; = Record, R = never>(children: ReadonlyArray>, options: FanOutCollectOptions): Effect.Effect, RunError | RegistrationError | FanOutUnsatisfied>; = Record, R = never>(children: ReadonlyArray>, options?: FanOutAllSuccessOptions): Effect.Effect, RunError | RegistrationError>; = Record, R = never>(children: ReadonlyArray>, options: FanOutOptions): Effect.Effect | ReadonlyArray, RunError | RegistrationError | FanOutUnsatisfied>; }; export declare const supervisor: (options: SupervisorOptions) => Supervisor | LanguageModel.LanguageModel, Record>>; export { target, layerCatalog, HandoffCatalog, type HandoffTarget } from "./handoff-target.js"; export { HandoffInput, HandoffOutput, defaultContextProjection, filterContextProjection, HandoffProjectionInvalid, } from "./handoff-projection.js"; export { executeSameRunHandoff, HandoffRejected } from "./handoff-runtime.js"; export { HandoffCommit, HandoffControlState } from "../agent/handoff-state.js";