/** * createFred - the scoped Promise client for Fred. * * This is the recommended entry point for Promise-based consumers. It builds * the Effect runtime once, exposes small scoped sub-APIs (agents, workflows, * sessions, providers) as thin `Runtime.runPromise` shims over the service * Tags, and hands power users the raw runtime as an escape hatch: * * ```typescript * import { createFred } from '@fancyrobot/fred'; * * const fred = await createFred(); * await fred.agents.register({ id: 'helper', platform: 'openai', model: 'gpt-4o' }); * const result = await fred.workflows.run('my-pipeline', 'hello'); * await fred.shutdown(); * ``` * * Effect-native consumers should use `@fancyrobot/fred/effect` instead. * * This module is an approved Effect runtime boundary (see * tests/unit/core/migration/boundary-guard.test.ts). */ import { Cause, Effect } from 'effect'; import type * as Schema from 'effect/Schema'; import type { AgentConfig, AgentInstance, AgentResponse, AnyAgentInstance } from './agent/agent'; import type { PipelineConfigV2 } from './pipeline/pipeline'; import type { GraphWorkflowConfig } from './pipeline/graph'; import type { GraphExecutionResult } from './pipeline/graph-executor'; import type { PipelineResult } from './pipeline/executor'; import type { GraphValidationError, PipelineAlreadyExistsError, PipelineExecutionError } from './pipeline/errors'; import type { WorkflowIR } from './workflow/ir'; import type { WorkflowDescriptor } from './workflow/contracts'; import { type WorkflowExecutionResult } from './workflow/execute'; import type { Tool, ToolSchemaMetadata } from './tool/tool'; import type { ProviderConfig, ProviderDefinition } from './platform/provider'; import type { ProviderConnection, ProviderConnectionCredentials, ProviderConnectionDraft, ProviderConnectionId, ProviderConnectionNamespace, ResolvedProviderConnection } from './platform/connections'; import type { Tracer } from './tracing'; import type { RoutingConfig } from './routing/types'; import type { MCPGlobalServerConfig, ObservabilityConfig, TemplateConfig } from './config/types'; import { type InitializerOptions } from './config/initializer'; import type { ContextStorage, SessionDetails, SessionSummary } from './context/context'; import { type FredLayerOptions, type FredRuntime, type FredServices } from './services'; import type { SessionHandle } from './context/session-service'; import type { ProcessingOptions } from './message-processor/types'; import type { HookHandler, HookType } from './hooks'; import type { HumanInputResumeOptions, PendingPause } from './pipeline/pause/types'; import type { ResumeResult } from './pipeline/resume'; import type { ExecuteSubagentOptions, ExecuteSubagentResult, SpawnSubagentOptions, SubagentInfo } from './subagent/service'; import { type ServerStatus } from './mcp'; import type { MCPServerConfig } from './mcp/types'; import type { VariableFactory } from './variables'; import { type CheckpointStorage } from './pipeline/checkpoint'; /** Execute an already-compiled workflow against an existing Fred runtime. */ export declare function executeWorkflowViaRuntime(runtime: FredRuntime, workflow: WorkflowIR, input: unknown, options?: { conversationId?: string; tracer?: Tracer; }): Promise; /** Compatibility helper for the legacy graph-specific Promise entrypoint. */ export declare function executeGraphWorkflowViaRuntime(runtime: FredRuntime, id: string, input: string, options?: { conversationId?: string; tracer?: Tracer; }): Promise; declare const FredClientClosedError_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & { readonly _tag: "FredClientClosedError"; } & Readonly; /** * The FredClient was shut down; no further calls are allowed. */ export declare class FredClientClosedError extends FredClientClosedError_base<{ readonly message: string; }> { } export interface CreateFredOptions { /** Load and apply this YAML/JSON config before returning the client. */ configPath?: string; /** Runtime executors and provider defaults used by config initialization. */ configOptions?: InitializerOptions; /** Tracer applied to agent execution and message processing. */ tracer?: Tracer; /** Rule-based message routing configuration. */ routing?: RoutingConfig; /** OpenTelemetry observability configuration (baked into the runtime layers). */ observability?: ObservabilityConfig; /** Template engine configuration for agent prompts. */ template?: TemplateConfig; /** Persistent conversation storage adapter (e.g. SQLite/Postgres). */ storage?: ContextStorage; /** Persistent workflow-checkpoint storage adapter. */ checkpointStorage?: CheckpointStorage; /** Provider-connection service used for explicit persisted credentials. */ providerConnectionLayer?: FredLayerOptions['providerConnectionLayer']; /** Prompt adapter layer used while constructing AgentService. */ promptSourceLayer?: FredLayerOptions['promptSourceLayer']; } /** A supported V2, graph, or native-IR workflow definition. */ export type WorkflowDefinition = PipelineConfigV2 | GraphWorkflowConfig | WorkflowIR; /** Failures workflows.define can produce across the three workflow kinds. */ export type WorkflowDefineError = PipelineAlreadyExistsError | PipelineExecutionError | GraphValidationError; /** Result of workflows.run — shape depends on the workflow kind. */ export type WorkflowRunResult = PipelineResult | GraphExecutionResult | WorkflowExecutionResult; /** Safe, execution-free metadata for a tool discovered from an MCP server. */ export interface MCPToolMetadata { readonly id: string; readonly name: string; readonly description: string; readonly schema?: ToolSchemaMetadata; } /** Client-facing MCP server state. Secret-bearing registry config stays private. */ export interface MCPServerInfo { readonly id: string; readonly transport: MCPServerConfig['transport']; readonly lazy: boolean; readonly status: ServerStatus | 'stopped'; readonly connected: boolean; readonly tools: readonly MCPToolMetadata[]; readonly toolDiscoveryFailed?: boolean; } /** Per-server result used by best-effort bulk MCP lifecycle operations. */ export interface MCPServerOperationResult { readonly id: string; readonly success: boolean; readonly error?: string; } export type FredWarningListener = (message: string | null) => void; export interface FredClient { readonly agents: { register(config: AgentConfig): Promise>; remove(id: string): Promise; get(id: string): Promise; list(): Promise; }; /** Transport-neutral provider-connection management for clients and the CLI. */ readonly connections: { list(namespace: ProviderConnectionNamespace): Promise; get(namespace: ProviderConnectionNamespace, id: ProviderConnectionId): Promise; put(namespace: ProviderConnectionNamespace, connection: ProviderConnection, credentials: ProviderConnectionCredentials, expiresAt?: Date): Promise; updateMetadata(namespace: ProviderConnectionNamespace, connection: ProviderConnection): Promise; remove(namespace: ProviderConnectionNamespace, id: ProviderConnectionId): Promise; testDraft(draft: ProviderConnectionDraft, credentials: ProviderConnectionCredentials): Promise; test(namespace: ProviderConnectionNamespace, id: ProviderConnectionId): Promise; resolve(request: { readonly providerId: string; readonly connectionId: ProviderConnectionId; readonly namespace: ProviderConnectionNamespace; readonly apiKeyEnvVar?: string; } | { readonly providerId: string; readonly connectionId?: undefined; readonly namespace?: undefined; readonly apiKeyEnvVar?: string; }): Promise; }; readonly messages: { process(message: string, options?: ProcessingOptions): Promise; }; readonly tools: { register(tool: Tool): Promise; remove(id: string): Promise; list(): Promise; }; readonly hooks: { register(type: HookType, handler: HookHandler): Promise; unregister(type: HookType, handler: HookHandler): Promise; }; readonly templates: { addContext(namespace: string, resolver: () => unknown): Promise; invalidate(): Promise; }; readonly variables: { register(name: string, factory: VariableFactory): Promise; registerAll(variables: Record): Promise; snapshot(): Promise>; }; readonly workflows: { define(config: WorkflowDefinition): Promise; list(): Promise; describe(id: string): Promise; /** * Run a workflow. When a session is given (`sessionId`, or the legacy * `conversationId` alias), it is bound as the ambient session for the whole * run and used as the conversation/persistence key: agent steps that go * through the ContextStorage-backed path (e.g. `MessageProcessor`) read and * append history under it, so a later `run` with the same id continues that * conversation. Steps that don't touch conversation storage (e.g. pure * function steps) simply run under the bound id. Omit both for a run that is * not associated with any session. */ run(id: string, input: unknown, options?: { conversationId?: string; sessionId?: string; }): Promise; resume(runId: string, options: HumanInputResumeOptions): Promise; pending(runId: string): Promise; listPending(): Promise; }; readonly sessions: { /** Open a session: resume `id`, or mint a fresh one when omitted. */ open(id?: string): Promise; get(conversationId: string): Promise; list(): Promise; delete(conversationId: string): Promise; }; readonly providers: { use(idOrPackage: string, config?: ProviderConfig): Promise; }; readonly mcp: { configure(configs: Array): Promise; status(id: string): Promise; list(): Promise; listServers(): Promise; discoverTools(id: string): Promise; connect(id: string): Promise; connectAll(): Promise; disconnect(id: string): Promise; disconnectAll(): Promise; }; readonly warnings: { /** Subscribe to config hot-reload warnings and null clears. */ subscribe(listener: FredWarningListener): () => void; }; readonly subagents: { spawn(options: SpawnSubagentOptions): Promise; list(): Promise; inspect(id: string): Promise; execute(id: string, options?: ExecuteSubagentOptions): Promise; destroy(id: string): Promise; }; readonly effects: { run(effect: Effect.Effect): Promise; }; /** * Escape hatch to the Effect world: run custom Effects against the same * runtime (and therefore the same service state) the client uses. */ readonly runtime: FredRuntime; /** Release all resources. Idempotent; further client calls reject with FredClientClosedError. */ shutdown(): Promise; } /** * Create a Fred client with an initialized Effect runtime. */ export declare function createFred(options?: CreateFredOptions): Promise; export {}; //# sourceMappingURL=client.d.ts.map