import { Checkpoint, Config, DefaultValues, Metadata, SortOrder, Thread, ThreadSelectField, ThreadSortBy, ThreadState, ThreadStatus, ThreadValuesFilter } from "../../schema.js"; import { ThreadStreamMode } from "../../types.stream.js"; import { Command, OnConflictBehavior, StreamEvent } from "../../types.js"; import { BaseClient } from "../base.js"; import { ThreadStreamOptions } from "../stream/types.js"; import { ThreadStream } from "../stream/index.js"; //#region src/client/threads/index.d.ts declare class ThreadsClient extends BaseClient { /** * Get a thread by ID. * * @param threadId ID of the thread. * @returns The thread. */ get(threadId: string, options?: { signal?: AbortSignal; include?: string[]; }): Promise>; /** * Create a new thread. * * @param payload Payload for creating a thread. * @returns The created thread. */ create(payload?: { metadata?: Metadata; threadId?: string; ifExists?: OnConflictBehavior; graphId?: string; supersteps?: Array<{ updates: Array<{ values: unknown; command?: Command; asNode: string; }>; }>; ttl?: number | { ttl: number; strategy?: "delete"; }; signal?: AbortSignal; }): Promise>; /** * Copy an existing thread * @param threadId ID of the thread to be copied * @returns Newly copied thread */ copy(threadId: string, options?: { signal?: AbortSignal; }): Promise>; /** * Update a thread. * * @param threadId ID of the thread. * @param payload Payload for updating the thread. * @returns The updated thread. */ update(threadId: string, payload?: { metadata?: Metadata; ttl?: number | { ttl: number; strategy?: "delete"; }; returnMinimal?: false; signal?: AbortSignal; }): Promise; update(threadId: string, payload: { metadata?: Metadata; ttl?: number | { ttl: number; strategy?: "delete"; }; returnMinimal: true; signal?: AbortSignal; }): Promise; update(threadId: string, payload: { metadata?: Metadata; ttl?: number | { ttl: number; strategy?: "delete"; }; returnMinimal: boolean; signal?: AbortSignal; }): Promise; /** * Delete a thread. * * @param threadId ID of the thread. */ delete(threadId: string, options?: { signal?: AbortSignal; }): Promise; /** * Prune threads by ID. The 'delete' strategy removes threads entirely. * The 'keep_latest' strategy prunes old checkpoints but keeps threads * and their latest state. * * @param threadIds List of thread IDs to prune. * @param options Additional options for pruning. * @param options.strategy The prune strategy. Defaults to 'delete'. * @param options.signal Signal to abort the request. * @returns An object containing `pruned_count`. */ prune(threadIds: string[], options?: { strategy?: "delete" | "keep_latest"; signal?: AbortSignal; }): Promise<{ pruned_count: number; }>; /** * List threads * * @param query Query options * @returns List of threads */ search(query?: { metadata?: Metadata; ids?: string[]; limit?: number; offset?: number; status?: ThreadStatus; sortBy?: ThreadSortBy; sortOrder?: SortOrder; select?: ThreadSelectField[]; values?: ThreadValuesFilter; extract?: Record; signal?: AbortSignal; }): Promise[]>; /** * Count threads matching filters. * * @param query.metadata Thread metadata to filter on. * @param query.values State values to filter on. * @param query.status Thread status to filter on. * @returns Number of threads matching the criteria. */ count(query?: { metadata?: Metadata; values?: ValuesType; status?: ThreadStatus; signal?: AbortSignal; }): Promise; /** * Get state for a thread. * * @param threadId ID of the thread. * @returns Thread state. */ getState(threadId: string, checkpoint?: Checkpoint | string, options?: { subgraphs?: boolean; signal?: AbortSignal; }): Promise>; /** * Add state to a thread. * * @param threadId The ID of the thread. * @returns */ updateState(threadId: string, options: { values: ValuesType; checkpoint?: Checkpoint; checkpointId?: string; asNode?: string; signal?: AbortSignal; }): Promise>; /** * Patch the metadata of a thread. * * @param threadIdOrConfig Thread ID or config to patch the state of. * @param metadata Metadata to patch the state with. */ patchState(threadIdOrConfig: string | Config, metadata: Metadata, options?: { signal?: AbortSignal; }): Promise; /** * Get all past states for a thread. * * @param threadId ID of the thread. * @param options Additional options. * @returns List of thread states. */ getHistory(threadId: string, options?: { limit?: number; before?: Config; checkpoint?: Partial>; metadata?: Metadata; signal?: AbortSignal; }): Promise[]>; joinStream(threadId: string, options?: { lastEventId?: string; streamMode?: ThreadStreamMode | ThreadStreamMode[]; signal?: AbortSignal; }): AsyncGenerator<{ id?: string; event: StreamEvent; data: any; }>; /** * Open a protocol stream over the thread-centric v2 protocol. * * Returns a {@link ThreadStream} with lazy getters * (`.messages`, `.values`, `.toolCalls`, `.subgraphs`, `.subagents`, * `.output`) and `thread.run.start({ input, ... })` for starting runs. * Mirrors the in-process `graph.streamEvents(..., { version: "v3" })` API. * * The thread is bound to `options.assistantId` for its lifetime. * The wire transport defaults to SSE; pass `transport: "websocket"` * in options (or configure `streamProtocol: "v2-websocket"` on the * client) to use a WebSocket instead. * * @example New thread (UUID generated client-side) * ```ts * const thread = client.threads.stream({ assistantId: "my-agent" }); * ``` * * @example Attach to an existing thread * ```ts * const thread = client.threads.stream(threadId, { assistantId: "my-agent" }); * ``` * * @example WebSocket transport * ```ts * const thread = client.threads.stream({ * assistantId: "my-agent", * transport: "websocket", * }); * ``` */ stream = Record>(options: ThreadStreamOptions): ThreadStream; stream = Record>(threadId: string, options: ThreadStreamOptions): ThreadStream; } //#endregion export { ThreadsClient }; //# sourceMappingURL=index.d.ts.map