@langchain/langgraph-sdk
Version:
Client library for interacting with the LangGraph API
60 lines (59 loc) • 2.58 kB
TypeScript
import { AsyncCaller } from "../../../utils/async_caller.js";
import { AgentServerAdapter, EventStreamHandle } from "../transport.js";
import { HeaderValue, ProtocolRequestHook, ProtocolTransportPaths } from "./types.js";
import { Command, CommandResponse, ErrorResponse, Message, SubscribeParams } from "@langchain/protocol";
//#region src/client/stream/transport/agent-server.d.ts
interface HttpAgentServerAdapterOptions {
apiUrl: string;
/**
* Thread this adapter targets. Optional: omit to construct an unbound
* adapter and let the framework bind it via {@link HttpAgentServerAdapter.setThreadId}
* (`client.threads.stream` does this) — e.g. lazy thread creation, where
* the id is only known after the first `submit()`.
*/
threadId?: string;
/** Auth / tenant / diagnostic headers applied to every request. */
defaultHeaders?: Record<string, HeaderValue>;
/** Per-request hook for last-mile header mutation. */
onRequest?: ProtocolRequestHook;
/** Override the default `/threads/:threadId/...` protocol paths. */
paths?: ProtocolTransportPaths;
/**
* Optional `fetch` override, forwarded to the SSE transport. Useful
* for auth proxies, Next.js route handlers, or tests with injected
* mocks. Ignored when `webSocketFactory` is also supplied.
*/
fetch?: typeof fetch;
/**
* Retries and concurrency for SSE/command HTTP. When omitted, requests
* use raw `fetch` with no automatic retries (same as constructing
* {@link ProtocolSseTransportAdapter} without this option).
*/
asyncCaller?: AsyncCaller;
/**
* Optional WebSocket factory. Supplying it flips the adapter into
* WebSocket mode — SSE is bypassed entirely.
*/
webSocketFactory?: (url: string) => WebSocket;
}
declare class HttpAgentServerAdapter implements AgentServerAdapter {
#private;
threadId: string;
readonly apiUrl: string;
/**
* Thread-state reads are SSE-only. WebSocket delegates omit this so
* {@link StreamController} falls back to `client.threads.getState()`.
*/
getState?: AgentServerAdapter["getState"];
constructor(options: HttpAgentServerAdapterOptions);
/** {@inheritDoc TransportAdapter.setThreadId} */
setThreadId(threadId: string): void;
open(): Promise<void>;
send(command: Command): Promise<CommandResponse | ErrorResponse | void>;
events(): AsyncIterable<Message>;
openEventStream(params: SubscribeParams): EventStreamHandle;
close(): Promise<void>;
}
//#endregion
export { HttpAgentServerAdapter, HttpAgentServerAdapterOptions };
//# sourceMappingURL=agent-server.d.ts.map