@langchain/langgraph-sdk 0.0.11 → 0.0.14-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = void 0;
3
+ exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = void 0;
4
4
  const async_caller_js_1 = require("./utils/async_caller.cjs");
5
5
  const index_js_1 = require("./utils/eventsource-parser/index.cjs");
6
6
  const stream_js_1 = require("./utils/stream.cjs");
@@ -165,10 +165,13 @@ class AssistantsClient extends BaseClient {
165
165
  /**
166
166
  * Get the JSON representation of the graph assigned to a runnable
167
167
  * @param assistantId The ID of the assistant.
168
+ * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
168
169
  * @returns Serialized graph
169
170
  */
170
- async getGraph(assistantId) {
171
- return this.fetch(`/assistants/${assistantId}/graph`);
171
+ async getGraph(assistantId, options) {
172
+ return this.fetch(`/assistants/${assistantId}/graph`, {
173
+ params: { xray: options?.xray },
174
+ });
172
175
  }
173
176
  /**
174
177
  * Get the state and config schema of the graph assigned to a runnable
@@ -178,6 +181,21 @@ class AssistantsClient extends BaseClient {
178
181
  async getSchemas(assistantId) {
179
182
  return this.fetch(`/assistants/${assistantId}/schemas`);
180
183
  }
184
+ /**
185
+ * Get the schemas of an assistant by ID.
186
+ *
187
+ * @param assistantId The ID of the assistant to get the schema of.
188
+ * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
189
+ * @returns The subgraphs of the assistant.
190
+ */
191
+ async getSubgraphs(assistantId, options) {
192
+ if (options?.namespace) {
193
+ return this.fetch(`/assistants/${assistantId}/subgraphs/${options.namespace}`, { params: { recurse: options?.recurse } });
194
+ }
195
+ return this.fetch(`/assistants/${assistantId}/subgraphs`, {
196
+ params: { recurse: options?.recurse },
197
+ });
198
+ }
181
199
  /**
182
200
  * Create a new assistant.
183
201
  * @param payload Payload for creating an assistant.
@@ -351,10 +369,20 @@ class ThreadsClient extends BaseClient {
351
369
  * @param threadId ID of the thread.
352
370
  * @returns Thread state.
353
371
  */
354
- async getState(threadId, checkpointId) {
355
- return this.fetch(checkpointId != null
356
- ? `/threads/${threadId}/state/${checkpointId}`
357
- : `/threads/${threadId}/state`);
372
+ async getState(threadId, checkpoint, options) {
373
+ if (checkpoint != null) {
374
+ if (typeof checkpoint !== "string") {
375
+ return this.fetch(`/threads/${threadId}/state/checkpoint`, {
376
+ method: "POST",
377
+ json: { checkpoint, subgraphs: options?.subgraphs },
378
+ });
379
+ }
380
+ // deprecated
381
+ return this.fetch(`/threads/${threadId}/state/${checkpoint}`, { params: { subgraphs: options?.subgraphs } });
382
+ }
383
+ return this.fetch(`/threads/${threadId}/state`, {
384
+ params: { subgraphs: options?.subgraphs },
385
+ });
358
386
  }
359
387
  /**
360
388
  * Add state to a thread.
@@ -368,6 +396,7 @@ class ThreadsClient extends BaseClient {
368
396
  json: {
369
397
  values: options.values,
370
398
  checkpoint_id: options.checkpointId,
399
+ checkpoint: options.checkpoint,
371
400
  as_node: options?.asNode,
372
401
  },
373
402
  });
@@ -427,6 +456,7 @@ class RunsClient extends BaseClient {
427
456
  config: payload?.config,
428
457
  metadata: payload?.metadata,
429
458
  stream_mode: payload?.streamMode,
459
+ stream_subgraphs: payload?.streamSubgraphs,
430
460
  feedback_keys: payload?.feedbackKeys,
431
461
  assistant_id: assistantId,
432
462
  interrupt_before: payload?.interruptBefore,
@@ -661,6 +691,124 @@ class RunsClient extends BaseClient {
661
691
  }
662
692
  }
663
693
  exports.RunsClient = RunsClient;
694
+ class StoreClient extends BaseClient {
695
+ /**
696
+ * Store or update an item.
697
+ *
698
+ * @param namespace A list of strings representing the namespace path.
699
+ * @param key The unique identifier for the item within the namespace.
700
+ * @param value A dictionary containing the item's data.
701
+ * @returns Promise<void>
702
+ */
703
+ async putItem(namespace, key, value) {
704
+ namespace.forEach((label) => {
705
+ if (label.includes(".")) {
706
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
707
+ }
708
+ });
709
+ const payload = {
710
+ namespace,
711
+ key,
712
+ value,
713
+ };
714
+ return this.fetch("/store/items", {
715
+ method: "PUT",
716
+ json: payload,
717
+ });
718
+ }
719
+ /**
720
+ * Retrieve a single item.
721
+ *
722
+ * @param namespace A list of strings representing the namespace path.
723
+ * @param key The unique identifier for the item.
724
+ * @returns Promise<Item>
725
+ */
726
+ async getItem(namespace, key) {
727
+ namespace.forEach((label) => {
728
+ if (label.includes(".")) {
729
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
730
+ }
731
+ });
732
+ const response = await this.fetch("/store/items", {
733
+ params: { namespace: namespace.join("."), key },
734
+ });
735
+ return {
736
+ ...response,
737
+ createdAt: response.created_at,
738
+ updatedAt: response.updated_at,
739
+ };
740
+ }
741
+ /**
742
+ * Delete an item.
743
+ *
744
+ * @param namespace A list of strings representing the namespace path.
745
+ * @param key The unique identifier for the item.
746
+ * @returns Promise<void>
747
+ */
748
+ async deleteItem(namespace, key) {
749
+ namespace.forEach((label) => {
750
+ if (label.includes(".")) {
751
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
752
+ }
753
+ });
754
+ return this.fetch("/store/items", {
755
+ method: "DELETE",
756
+ json: { namespace, key },
757
+ });
758
+ }
759
+ /**
760
+ * Search for items within a namespace prefix.
761
+ *
762
+ * @param namespacePrefix List of strings representing the namespace prefix.
763
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
764
+ * @param options.limit Maximum number of items to return (default is 10).
765
+ * @param options.offset Number of items to skip before returning results (default is 0).
766
+ * @returns Promise<SearchItemsResponse>
767
+ */
768
+ async searchItems(namespacePrefix, options) {
769
+ const payload = {
770
+ namespace_prefix: namespacePrefix,
771
+ filter: options?.filter,
772
+ limit: options?.limit ?? 10,
773
+ offset: options?.offset ?? 0,
774
+ };
775
+ const response = await this.fetch("/store/items/search", {
776
+ method: "POST",
777
+ json: payload,
778
+ });
779
+ return {
780
+ items: response.items.map((item) => ({
781
+ ...item,
782
+ createdAt: item.created_at,
783
+ updatedAt: item.updated_at,
784
+ })),
785
+ };
786
+ }
787
+ /**
788
+ * List namespaces with optional match conditions.
789
+ *
790
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
791
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
792
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
793
+ * @param options.limit Maximum number of namespaces to return (default is 100).
794
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
795
+ * @returns Promise<ListNamespaceResponse>
796
+ */
797
+ async listNamespaces(options) {
798
+ const payload = {
799
+ prefix: options?.prefix,
800
+ suffix: options?.suffix,
801
+ max_depth: options?.maxDepth,
802
+ limit: options?.limit ?? 100,
803
+ offset: options?.offset ?? 0,
804
+ };
805
+ return this.fetch("/store/namespaces", {
806
+ method: "POST",
807
+ json: payload,
808
+ });
809
+ }
810
+ }
811
+ exports.StoreClient = StoreClient;
664
812
  class Client {
665
813
  constructor(config) {
666
814
  /**
@@ -699,10 +847,20 @@ class Client {
699
847
  writable: true,
700
848
  value: void 0
701
849
  });
850
+ /**
851
+ * The client for interacting with the KV store.
852
+ */
853
+ Object.defineProperty(this, "store", {
854
+ enumerable: true,
855
+ configurable: true,
856
+ writable: true,
857
+ value: void 0
858
+ });
702
859
  this.assistants = new AssistantsClient(config);
703
860
  this.threads = new ThreadsClient(config);
704
861
  this.runs = new RunsClient(config);
705
862
  this.crons = new CronsClient(config);
863
+ this.store = new StoreClient(config);
706
864
  }
707
865
  }
708
866
  exports.Client = Client;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion } from "./schema.js";
1
+ import { Assistant, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item } from "./schema.js";
2
2
  import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
3
3
  import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent, CronsCreatePayload, OnConflictBehavior } from "./types.js";
4
4
  interface ClientConfig {
@@ -67,15 +67,29 @@ export declare class AssistantsClient extends BaseClient {
67
67
  /**
68
68
  * Get the JSON representation of the graph assigned to a runnable
69
69
  * @param assistantId The ID of the assistant.
70
+ * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
70
71
  * @returns Serialized graph
71
72
  */
72
- getGraph(assistantId: string): Promise<AssistantGraph>;
73
+ getGraph(assistantId: string, options?: {
74
+ xray?: boolean | number;
75
+ }): Promise<AssistantGraph>;
73
76
  /**
74
77
  * Get the state and config schema of the graph assigned to a runnable
75
78
  * @param assistantId The ID of the assistant.
76
79
  * @returns Graph schema
77
80
  */
78
81
  getSchemas(assistantId: string): Promise<GraphSchema>;
82
+ /**
83
+ * Get the schemas of an assistant by ID.
84
+ *
85
+ * @param assistantId The ID of the assistant to get the schema of.
86
+ * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
87
+ * @returns The subgraphs of the assistant.
88
+ */
89
+ getSubgraphs(assistantId: string, options?: {
90
+ namespace?: string;
91
+ recurse?: boolean;
92
+ }): Promise<Subgraphs>;
79
93
  /**
80
94
  * Create a new assistant.
81
95
  * @param payload Payload for creating an assistant.
@@ -212,7 +226,9 @@ export declare class ThreadsClient extends BaseClient {
212
226
  * @param threadId ID of the thread.
213
227
  * @returns Thread state.
214
228
  */
215
- getState<ValuesType = DefaultValues>(threadId: string, checkpointId?: string): Promise<ThreadState<ValuesType>>;
229
+ getState<ValuesType = DefaultValues>(threadId: string, checkpoint?: Checkpoint | string, options?: {
230
+ subgraphs?: boolean;
231
+ }): Promise<ThreadState<ValuesType>>;
216
232
  /**
217
233
  * Add state to a thread.
218
234
  *
@@ -221,6 +237,7 @@ export declare class ThreadsClient extends BaseClient {
221
237
  */
222
238
  updateState<ValuesType = DefaultValues>(threadId: string, options: {
223
239
  values: ValuesType;
240
+ checkpoint?: Checkpoint;
224
241
  checkpointId?: string;
225
242
  asNode?: string;
226
243
  }): Promise<Pick<Config, "configurable">>;
@@ -340,6 +357,64 @@ export declare class RunsClient extends BaseClient {
340
357
  */
341
358
  delete(threadId: string, runId: string): Promise<void>;
342
359
  }
360
+ export declare class StoreClient extends BaseClient {
361
+ /**
362
+ * Store or update an item.
363
+ *
364
+ * @param namespace A list of strings representing the namespace path.
365
+ * @param key The unique identifier for the item within the namespace.
366
+ * @param value A dictionary containing the item's data.
367
+ * @returns Promise<void>
368
+ */
369
+ putItem(namespace: string[], key: string, value: Record<string, any>): Promise<void>;
370
+ /**
371
+ * Retrieve a single item.
372
+ *
373
+ * @param namespace A list of strings representing the namespace path.
374
+ * @param key The unique identifier for the item.
375
+ * @returns Promise<Item>
376
+ */
377
+ getItem(namespace: string[], key: string): Promise<Item | null>;
378
+ /**
379
+ * Delete an item.
380
+ *
381
+ * @param namespace A list of strings representing the namespace path.
382
+ * @param key The unique identifier for the item.
383
+ * @returns Promise<void>
384
+ */
385
+ deleteItem(namespace: string[], key: string): Promise<void>;
386
+ /**
387
+ * Search for items within a namespace prefix.
388
+ *
389
+ * @param namespacePrefix List of strings representing the namespace prefix.
390
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
391
+ * @param options.limit Maximum number of items to return (default is 10).
392
+ * @param options.offset Number of items to skip before returning results (default is 0).
393
+ * @returns Promise<SearchItemsResponse>
394
+ */
395
+ searchItems(namespacePrefix: string[], options?: {
396
+ filter?: Record<string, any>;
397
+ limit?: number;
398
+ offset?: number;
399
+ }): Promise<SearchItemsResponse>;
400
+ /**
401
+ * List namespaces with optional match conditions.
402
+ *
403
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
404
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
405
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
406
+ * @param options.limit Maximum number of namespaces to return (default is 100).
407
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
408
+ * @returns Promise<ListNamespaceResponse>
409
+ */
410
+ listNamespaces(options?: {
411
+ prefix?: string[];
412
+ suffix?: string[];
413
+ maxDepth?: number;
414
+ limit?: number;
415
+ offset?: number;
416
+ }): Promise<ListNamespaceResponse>;
417
+ }
343
418
  export declare class Client {
344
419
  /**
345
420
  * The client for interacting with assistants.
@@ -357,6 +432,10 @@ export declare class Client {
357
432
  * The client for interacting with cron runs.
358
433
  */
359
434
  crons: CronsClient;
435
+ /**
436
+ * The client for interacting with the KV store.
437
+ */
438
+ store: StoreClient;
360
439
  constructor(config?: ClientConfig);
361
440
  }
362
441
  export {};
package/dist/client.js CHANGED
@@ -161,10 +161,13 @@ export class AssistantsClient extends BaseClient {
161
161
  /**
162
162
  * Get the JSON representation of the graph assigned to a runnable
163
163
  * @param assistantId The ID of the assistant.
164
+ * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
164
165
  * @returns Serialized graph
165
166
  */
166
- async getGraph(assistantId) {
167
- return this.fetch(`/assistants/${assistantId}/graph`);
167
+ async getGraph(assistantId, options) {
168
+ return this.fetch(`/assistants/${assistantId}/graph`, {
169
+ params: { xray: options?.xray },
170
+ });
168
171
  }
169
172
  /**
170
173
  * Get the state and config schema of the graph assigned to a runnable
@@ -174,6 +177,21 @@ export class AssistantsClient extends BaseClient {
174
177
  async getSchemas(assistantId) {
175
178
  return this.fetch(`/assistants/${assistantId}/schemas`);
176
179
  }
180
+ /**
181
+ * Get the schemas of an assistant by ID.
182
+ *
183
+ * @param assistantId The ID of the assistant to get the schema of.
184
+ * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
185
+ * @returns The subgraphs of the assistant.
186
+ */
187
+ async getSubgraphs(assistantId, options) {
188
+ if (options?.namespace) {
189
+ return this.fetch(`/assistants/${assistantId}/subgraphs/${options.namespace}`, { params: { recurse: options?.recurse } });
190
+ }
191
+ return this.fetch(`/assistants/${assistantId}/subgraphs`, {
192
+ params: { recurse: options?.recurse },
193
+ });
194
+ }
177
195
  /**
178
196
  * Create a new assistant.
179
197
  * @param payload Payload for creating an assistant.
@@ -346,10 +364,20 @@ export class ThreadsClient extends BaseClient {
346
364
  * @param threadId ID of the thread.
347
365
  * @returns Thread state.
348
366
  */
349
- async getState(threadId, checkpointId) {
350
- return this.fetch(checkpointId != null
351
- ? `/threads/${threadId}/state/${checkpointId}`
352
- : `/threads/${threadId}/state`);
367
+ async getState(threadId, checkpoint, options) {
368
+ if (checkpoint != null) {
369
+ if (typeof checkpoint !== "string") {
370
+ return this.fetch(`/threads/${threadId}/state/checkpoint`, {
371
+ method: "POST",
372
+ json: { checkpoint, subgraphs: options?.subgraphs },
373
+ });
374
+ }
375
+ // deprecated
376
+ return this.fetch(`/threads/${threadId}/state/${checkpoint}`, { params: { subgraphs: options?.subgraphs } });
377
+ }
378
+ return this.fetch(`/threads/${threadId}/state`, {
379
+ params: { subgraphs: options?.subgraphs },
380
+ });
353
381
  }
354
382
  /**
355
383
  * Add state to a thread.
@@ -363,6 +391,7 @@ export class ThreadsClient extends BaseClient {
363
391
  json: {
364
392
  values: options.values,
365
393
  checkpoint_id: options.checkpointId,
394
+ checkpoint: options.checkpoint,
366
395
  as_node: options?.asNode,
367
396
  },
368
397
  });
@@ -421,6 +450,7 @@ export class RunsClient extends BaseClient {
421
450
  config: payload?.config,
422
451
  metadata: payload?.metadata,
423
452
  stream_mode: payload?.streamMode,
453
+ stream_subgraphs: payload?.streamSubgraphs,
424
454
  feedback_keys: payload?.feedbackKeys,
425
455
  assistant_id: assistantId,
426
456
  interrupt_before: payload?.interruptBefore,
@@ -654,6 +684,123 @@ export class RunsClient extends BaseClient {
654
684
  });
655
685
  }
656
686
  }
687
+ export class StoreClient extends BaseClient {
688
+ /**
689
+ * Store or update an item.
690
+ *
691
+ * @param namespace A list of strings representing the namespace path.
692
+ * @param key The unique identifier for the item within the namespace.
693
+ * @param value A dictionary containing the item's data.
694
+ * @returns Promise<void>
695
+ */
696
+ async putItem(namespace, key, value) {
697
+ namespace.forEach((label) => {
698
+ if (label.includes(".")) {
699
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
700
+ }
701
+ });
702
+ const payload = {
703
+ namespace,
704
+ key,
705
+ value,
706
+ };
707
+ return this.fetch("/store/items", {
708
+ method: "PUT",
709
+ json: payload,
710
+ });
711
+ }
712
+ /**
713
+ * Retrieve a single item.
714
+ *
715
+ * @param namespace A list of strings representing the namespace path.
716
+ * @param key The unique identifier for the item.
717
+ * @returns Promise<Item>
718
+ */
719
+ async getItem(namespace, key) {
720
+ namespace.forEach((label) => {
721
+ if (label.includes(".")) {
722
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
723
+ }
724
+ });
725
+ const response = await this.fetch("/store/items", {
726
+ params: { namespace: namespace.join("."), key },
727
+ });
728
+ return {
729
+ ...response,
730
+ createdAt: response.created_at,
731
+ updatedAt: response.updated_at,
732
+ };
733
+ }
734
+ /**
735
+ * Delete an item.
736
+ *
737
+ * @param namespace A list of strings representing the namespace path.
738
+ * @param key The unique identifier for the item.
739
+ * @returns Promise<void>
740
+ */
741
+ async deleteItem(namespace, key) {
742
+ namespace.forEach((label) => {
743
+ if (label.includes(".")) {
744
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
745
+ }
746
+ });
747
+ return this.fetch("/store/items", {
748
+ method: "DELETE",
749
+ json: { namespace, key },
750
+ });
751
+ }
752
+ /**
753
+ * Search for items within a namespace prefix.
754
+ *
755
+ * @param namespacePrefix List of strings representing the namespace prefix.
756
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
757
+ * @param options.limit Maximum number of items to return (default is 10).
758
+ * @param options.offset Number of items to skip before returning results (default is 0).
759
+ * @returns Promise<SearchItemsResponse>
760
+ */
761
+ async searchItems(namespacePrefix, options) {
762
+ const payload = {
763
+ namespace_prefix: namespacePrefix,
764
+ filter: options?.filter,
765
+ limit: options?.limit ?? 10,
766
+ offset: options?.offset ?? 0,
767
+ };
768
+ const response = await this.fetch("/store/items/search", {
769
+ method: "POST",
770
+ json: payload,
771
+ });
772
+ return {
773
+ items: response.items.map((item) => ({
774
+ ...item,
775
+ createdAt: item.created_at,
776
+ updatedAt: item.updated_at,
777
+ })),
778
+ };
779
+ }
780
+ /**
781
+ * List namespaces with optional match conditions.
782
+ *
783
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
784
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
785
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
786
+ * @param options.limit Maximum number of namespaces to return (default is 100).
787
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
788
+ * @returns Promise<ListNamespaceResponse>
789
+ */
790
+ async listNamespaces(options) {
791
+ const payload = {
792
+ prefix: options?.prefix,
793
+ suffix: options?.suffix,
794
+ max_depth: options?.maxDepth,
795
+ limit: options?.limit ?? 100,
796
+ offset: options?.offset ?? 0,
797
+ };
798
+ return this.fetch("/store/namespaces", {
799
+ method: "POST",
800
+ json: payload,
801
+ });
802
+ }
803
+ }
657
804
  export class Client {
658
805
  constructor(config) {
659
806
  /**
@@ -692,9 +839,19 @@ export class Client {
692
839
  writable: true,
693
840
  value: void 0
694
841
  });
842
+ /**
843
+ * The client for interacting with the KV store.
844
+ */
845
+ Object.defineProperty(this, "store", {
846
+ enumerable: true,
847
+ configurable: true,
848
+ writable: true,
849
+ value: void 0
850
+ });
695
851
  this.assistants = new AssistantsClient(config);
696
852
  this.threads = new ThreadsClient(config);
697
853
  this.runs = new RunsClient(config);
698
854
  this.crons = new CronsClient(config);
855
+ this.store = new StoreClient(config);
699
856
  }
700
857
  }
package/dist/schema.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { JSONSchema7 } from "json-schema";
2
2
  type Optional<T> = T | null | undefined;
3
3
  type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
4
4
  type ThreadStatus = "idle" | "busy" | "interrupted";
5
+ type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
5
6
  export interface Config {
6
7
  /**
7
8
  * Tags for this call and any sub-calls (eg. a Chain calling an LLM).
@@ -54,56 +55,121 @@ export interface GraphSchema {
54
55
  */
55
56
  config_schema?: JSONSchema7;
56
57
  }
58
+ export type Subgraphs = Record<string, GraphSchema>;
57
59
  export type Metadata = Optional<Record<string, unknown>>;
58
60
  export interface AssistantBase {
61
+ /** The ID of the assistant. */
59
62
  assistant_id: string;
63
+ /** The ID of the graph. */
60
64
  graph_id: string;
65
+ /** The assistant config. */
61
66
  config: Config;
67
+ /** The time the assistant was created. */
62
68
  created_at: string;
69
+ /** The assistant metadata. */
63
70
  metadata: Metadata;
71
+ /** The version of the assistant. */
64
72
  version: number;
65
73
  }
66
74
  export interface AssistantVersion extends AssistantBase {
67
75
  }
68
76
  export interface Assistant extends AssistantBase {
77
+ /** The last time the assistant was updated. */
69
78
  updated_at: string;
79
+ /** The name of the assistant */
70
80
  name: string;
71
81
  }
72
82
  export type AssistantGraph = Record<string, Array<Record<string, unknown>>>;
73
- export interface Thread {
83
+ export interface Thread<ValuesType = DefaultValues> {
84
+ /** The ID of the thread. */
74
85
  thread_id: string;
86
+ /** The time the thread was created. */
75
87
  created_at: string;
88
+ /** The last time the thread was updated. */
76
89
  updated_at: string;
90
+ /** The thread metadata. */
77
91
  metadata: Metadata;
92
+ /** The status of the thread */
78
93
  status: ThreadStatus;
94
+ /** The current state of the thread. */
95
+ values: ValuesType;
79
96
  }
80
97
  export interface Cron {
98
+ /** The ID of the cron */
81
99
  cron_id: string;
100
+ /** The ID of the thread */
82
101
  thread_id: Optional<string>;
102
+ /** The end date to stop running the cron. */
83
103
  end_time: Optional<string>;
104
+ /** The schedule to run, cron format. */
84
105
  schedule: string;
106
+ /** The time the cron was created. */
85
107
  created_at: string;
108
+ /** The last time the cron was updated. */
86
109
  updated_at: string;
110
+ /** The run payload to use for creating new run. */
87
111
  payload: Record<string, unknown>;
88
112
  }
89
113
  export type DefaultValues = Record<string, unknown>[] | Record<string, unknown>;
90
114
  export interface ThreadState<ValuesType = DefaultValues> {
115
+ /** The state values */
91
116
  values: ValuesType;
117
+ /** The next nodes to execute. If empty, the thread is done until new input is received */
92
118
  next: string[];
93
- checkpoint_id: string;
119
+ /** Checkpoint of the thread state */
120
+ checkpoint: Checkpoint;
121
+ /** Metadata for this state */
94
122
  metadata: Metadata;
123
+ /** Time of state creation */
95
124
  created_at: Optional<string>;
96
- parent_checkpoint_id: Optional<string>;
97
- config: Config;
98
- parent_config?: Config;
125
+ /** The parent checkpoint. If missing, this is the root checkpoint */
126
+ parent_checkpoint: Optional<Checkpoint>;
127
+ /** Tasks to execute in this step. If already attempted, may contain an error */
128
+ tasks: Array<ThreadTask>;
129
+ }
130
+ export interface ThreadTask {
131
+ id: string;
132
+ name: string;
133
+ error: Optional<string>;
134
+ interrupts: Array<Record<string, unknown>>;
135
+ checkpoint: Optional<Checkpoint>;
136
+ state: Optional<ThreadState>;
99
137
  }
100
138
  export interface Run {
139
+ /** The ID of the run */
101
140
  run_id: string;
141
+ /** The ID of the thread */
102
142
  thread_id: string;
143
+ /** The assistant that wwas used for this run */
103
144
  assistant_id: string;
145
+ /** The time the run was created */
104
146
  created_at: string;
147
+ /** The last time the run was updated */
105
148
  updated_at: string;
149
+ /** The status of the run. */
106
150
  status: RunStatus;
151
+ /** Run metadata */
107
152
  metadata: Metadata;
153
+ /** Strategy to handle concurrent runs on the same thread */
154
+ multitask_strategy: Optional<MultitaskStrategy>;
155
+ }
156
+ export interface Checkpoint {
157
+ thread_id: string;
158
+ checkpoint_ns: string;
159
+ checkpoint_id: Optional<string>;
160
+ checkpoint_map: Optional<Record<string, unknown>>;
161
+ }
162
+ export interface ListNamespaceResponse {
163
+ namespaces: string[][];
164
+ }
165
+ export interface SearchItemsResponse {
166
+ items: Item[];
167
+ }
168
+ export interface Item {
169
+ namespace: string[];
170
+ key: string;
171
+ value: Record<string, any>;
172
+ createdAt: string;
173
+ updatedAt: string;
108
174
  }
109
175
  export {};
package/dist/types.d.ts CHANGED
@@ -75,6 +75,10 @@ export interface RunsStreamPayload extends RunsInvokePayload {
75
75
  * afterwards using the `client.runs.listEvents()` method.
76
76
  */
77
77
  streamMode?: StreamMode | Array<StreamMode>;
78
+ /**
79
+ * Stream output from subgraphs. By default, streams only the top graph.
80
+ */
81
+ streamSubgraphs?: boolean;
78
82
  /**
79
83
  * Pass one or more feedbackKeys if you want to request short-lived signed URLs
80
84
  * for submitting feedback to LangSmith with this key for this run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.14-rc.0",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",