/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
import {
Client,
ClientConfig,
Command,
Config,
CustomStreamEvent,
DebugStreamEvent,
EventsStreamEvent,
MetadataStreamEvent,
ThreadState,
UpdatesStreamEvent,
} from '@langchain/langgraph-sdk';
export type MessageMetadata> = {
/**
* The ID of the message used.
*/
messageId: string;
/**
* The first thread state the message was seen in.
*/
firstSeenState: ThreadState | undefined;
/**
* The branch of the message.
*/
branch: string | undefined;
/**
* The list of branches this message is part of.
* This is useful for displaying branching controls.
*/
branchOptions: string[] | undefined;
/**
* Metadata sent alongside the message during run streaming.
* @remarks This metadata only exists temporarily in browser memory during streaming and is not persisted after completion.
*/
streamMetadata: Record | undefined;
};
export type BagTemplate = {
ConfigurableType?: Record;
InterruptType?: unknown;
CustomEventType?: unknown;
UpdateType?: unknown;
};
export type GetUpdateType<
Bag extends BagTemplate,
StateType extends Record,
> = Bag extends { UpdateType: unknown }
? Bag['UpdateType']
: Partial;
export type GetConfigurableType = Bag extends {
ConfigurableType: Record;
}
? Bag['ConfigurableType']
: Record;
export type GetInterruptType = Bag extends {
InterruptType: unknown;
}
? Bag['InterruptType']
: unknown;
export type GetCustomEventType = Bag extends {
CustomEventType: unknown;
}
? Bag['CustomEventType']
: unknown;
export interface RunCallbackMeta {
run_id: string;
thread_id: string;
}
export interface UseStreamThread> {
data: ThreadState[] | null | undefined;
error: unknown;
isLoading: boolean;
mutate: (
mutateId?: string,
) => Promise[] | null | undefined>;
}
type ConfigWithConfigurable> =
Config & { configurable?: ConfigurableType };
/**
* Transport used to stream the thread.
* Only applicable for custom endpoints using `toLangGraphEventStream` or `toLangGraphEventStreamResponse`.
*/
export interface UseStreamTransport<
StateType extends Record = Record,
Bag extends BagTemplate = BagTemplate,
> {
stream: (payload: {
input: GetUpdateType | null | undefined;
context: GetConfigurableType | undefined;
command: Command | undefined;
config: ConfigWithConfigurable> | undefined;
signal: AbortSignal;
}) => Promise>;
}