import type { RunEvent, RunRecord } from '../types/server.js'; /** Options for `createRemoteGraph()`. */ export interface RemoteGraphOptions { /** Where the server is, such as `https://agents.internal/api`. */ url: string; /** The assistant to run. */ assistant: string; /** Headers added to every request, such as authorization. */ headers?: Record; /** Replaces the global `fetch`. */ fetch?: typeof fetch; /** How long to wait for a run to finish, in milliseconds. Defaults to 5 minutes. */ timeoutMs?: number; /** How often to poll when the server's event stream is unavailable, in milliseconds. Defaults to 500. */ pollIntervalMs?: number; } /** A run on a remote server, as the client reports it. */ export interface RemoteRunResult { /** The run's id, for cancelling or reconnecting to it. */ runId: string; /** The thread it belonged to, when it had one. */ threadId?: string; /** Where it ended. */ status: RunRecord['status']; /** What it produced. */ output?: unknown; /** What it is waiting for, when it stopped to ask. */ interrupt?: unknown; /** Why it failed. */ error?: RunRecord['error']; } /** * A graph running on another server, usable as a subgraph. * * `invoke()` and `stream()` mirror a compiled graph, so an orchestrating graph can call a deployed * one through `asNode()` without knowing it is remote. The stream reconnects from the last event it * saw, so a dropped connection costs a round trip rather than the run. */ export interface RemoteGraph { /** Runs an input to completion and returns the result. */ invoke(input?: unknown, options?: { threadId?: string; signal?: AbortSignal; idempotencyKey?: string; }): Promise; /** Runs an input, yielding each event the server records. */ stream(input?: unknown, options?: { threadId?: string; signal?: AbortSignal; idempotencyKey?: string; }): AsyncIterable; /** Answers an interrupt on a thread and runs on. */ resume(threadId: string, value: unknown, options?: { signal?: AbortSignal; }): Promise; /** Creates a thread on the server. */ createThread(options?: { metadata?: Record; }): Promise<{ id: string; }>; /** The assistant's state for a thread. */ state(threadId: string): Promise; /** Cancels a run. */ cancel(runId: string, reason?: string): Promise; /** The remote graph as a node, so a local graph can call it as a subgraph. */ asNode(): (context: { state: Record; signal?: AbortSignal; }) => Promise; } /** Creates a client for an assistant on a remote agent server. */ export declare function createRemoteGraph(options: RemoteGraphOptions): RemoteGraph;