diff --git a/libs/sdk-js/src/client.ts b/libs/sdk-js/src/client.ts index 84ef3d44c..4fef0bc71 100644 --- a/libs/sdk-js/src/client.ts +++ b/libs/sdk-js/src/client.ts @@ -638,6 +638,33 @@ export class ThreadsClient< ); } + /** + * Create a new thread from a batch states. + */ + async bulkUpdateState( + supersteps: Array<{ updates: Array<{ values: unknown; asNode: string }> }>, + options: { + threadId?: string; + metadata?: Metadata; + ifExists?: OnConflictBehavior; + }, + ): Promise> { + return this.fetch>("/threads/state/batch", { + method: "POST", + json: { + supersteps: supersteps.map((s) => ({ + updates: s.updates.map((u) => ({ + values: u.values, + as_node: u.asNode, + })), + })), + thread_id: options.threadId, + metadata: options.metadata, + if_exists: options.ifExists, + }, + }); + } + /** * Patch the metadata of a thread. *