@langchain/langgraph-sdk 0.0.13 → 0.0.14

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,6 +165,7 @@ 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
171
  async getGraph(assistantId, options) {
@@ -690,6 +691,126 @@ class RunsClient extends BaseClient {
690
691
  }
691
692
  }
692
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 response
736
+ ? {
737
+ ...response,
738
+ createdAt: response.created_at,
739
+ updatedAt: response.updated_at,
740
+ }
741
+ : null;
742
+ }
743
+ /**
744
+ * Delete an item.
745
+ *
746
+ * @param namespace A list of strings representing the namespace path.
747
+ * @param key The unique identifier for the item.
748
+ * @returns Promise<void>
749
+ */
750
+ async deleteItem(namespace, key) {
751
+ namespace.forEach((label) => {
752
+ if (label.includes(".")) {
753
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
754
+ }
755
+ });
756
+ return this.fetch("/store/items", {
757
+ method: "DELETE",
758
+ json: { namespace, key },
759
+ });
760
+ }
761
+ /**
762
+ * Search for items within a namespace prefix.
763
+ *
764
+ * @param namespacePrefix List of strings representing the namespace prefix.
765
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
766
+ * @param options.limit Maximum number of items to return (default is 10).
767
+ * @param options.offset Number of items to skip before returning results (default is 0).
768
+ * @returns Promise<SearchItemsResponse>
769
+ */
770
+ async searchItems(namespacePrefix, options) {
771
+ const payload = {
772
+ namespace_prefix: namespacePrefix,
773
+ filter: options?.filter,
774
+ limit: options?.limit ?? 10,
775
+ offset: options?.offset ?? 0,
776
+ };
777
+ const response = await this.fetch("/store/items/search", {
778
+ method: "POST",
779
+ json: payload,
780
+ });
781
+ return {
782
+ items: response.items.map((item) => ({
783
+ ...item,
784
+ createdAt: item.created_at,
785
+ updatedAt: item.updated_at,
786
+ })),
787
+ };
788
+ }
789
+ /**
790
+ * List namespaces with optional match conditions.
791
+ *
792
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
793
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
794
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
795
+ * @param options.limit Maximum number of namespaces to return (default is 100).
796
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
797
+ * @returns Promise<ListNamespaceResponse>
798
+ */
799
+ async listNamespaces(options) {
800
+ const payload = {
801
+ prefix: options?.prefix,
802
+ suffix: options?.suffix,
803
+ max_depth: options?.maxDepth,
804
+ limit: options?.limit ?? 100,
805
+ offset: options?.offset ?? 0,
806
+ };
807
+ return this.fetch("/store/namespaces", {
808
+ method: "POST",
809
+ json: payload,
810
+ });
811
+ }
812
+ }
813
+ exports.StoreClient = StoreClient;
693
814
  class Client {
694
815
  constructor(config) {
695
816
  /**
@@ -728,10 +849,20 @@ class Client {
728
849
  writable: true,
729
850
  value: void 0
730
851
  });
852
+ /**
853
+ * The client for interacting with the KV store.
854
+ */
855
+ Object.defineProperty(this, "store", {
856
+ enumerable: true,
857
+ configurable: true,
858
+ writable: true,
859
+ value: void 0
860
+ });
731
861
  this.assistants = new AssistantsClient(config);
732
862
  this.threads = new ThreadsClient(config);
733
863
  this.runs = new RunsClient(config);
734
864
  this.crons = new CronsClient(config);
865
+ this.store = new StoreClient(config);
735
866
  }
736
867
  }
737
868
  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, Subgraphs, Checkpoint } 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,10 +67,11 @@ 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
73
  getGraph(assistantId: string, options?: {
73
- xray?: boolean;
74
+ xray?: boolean | number;
74
75
  }): Promise<AssistantGraph>;
75
76
  /**
76
77
  * Get the state and config schema of the graph assigned to a runnable
@@ -356,6 +357,64 @@ export declare class RunsClient extends BaseClient {
356
357
  */
357
358
  delete(threadId: string, runId: string): Promise<void>;
358
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
+ }
359
418
  export declare class Client {
360
419
  /**
361
420
  * The client for interacting with assistants.
@@ -373,6 +432,10 @@ export declare class Client {
373
432
  * The client for interacting with cron runs.
374
433
  */
375
434
  crons: CronsClient;
435
+ /**
436
+ * The client for interacting with the KV store.
437
+ */
438
+ store: StoreClient;
376
439
  constructor(config?: ClientConfig);
377
440
  }
378
441
  export {};
package/dist/client.js CHANGED
@@ -161,6 +161,7 @@ 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
167
  async getGraph(assistantId, options) {
@@ -683,6 +684,125 @@ export class RunsClient extends BaseClient {
683
684
  });
684
685
  }
685
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 response
729
+ ? {
730
+ ...response,
731
+ createdAt: response.created_at,
732
+ updatedAt: response.updated_at,
733
+ }
734
+ : null;
735
+ }
736
+ /**
737
+ * Delete an item.
738
+ *
739
+ * @param namespace A list of strings representing the namespace path.
740
+ * @param key The unique identifier for the item.
741
+ * @returns Promise<void>
742
+ */
743
+ async deleteItem(namespace, key) {
744
+ namespace.forEach((label) => {
745
+ if (label.includes(".")) {
746
+ throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
747
+ }
748
+ });
749
+ return this.fetch("/store/items", {
750
+ method: "DELETE",
751
+ json: { namespace, key },
752
+ });
753
+ }
754
+ /**
755
+ * Search for items within a namespace prefix.
756
+ *
757
+ * @param namespacePrefix List of strings representing the namespace prefix.
758
+ * @param options.filter Optional dictionary of key-value pairs to filter results.
759
+ * @param options.limit Maximum number of items to return (default is 10).
760
+ * @param options.offset Number of items to skip before returning results (default is 0).
761
+ * @returns Promise<SearchItemsResponse>
762
+ */
763
+ async searchItems(namespacePrefix, options) {
764
+ const payload = {
765
+ namespace_prefix: namespacePrefix,
766
+ filter: options?.filter,
767
+ limit: options?.limit ?? 10,
768
+ offset: options?.offset ?? 0,
769
+ };
770
+ const response = await this.fetch("/store/items/search", {
771
+ method: "POST",
772
+ json: payload,
773
+ });
774
+ return {
775
+ items: response.items.map((item) => ({
776
+ ...item,
777
+ createdAt: item.created_at,
778
+ updatedAt: item.updated_at,
779
+ })),
780
+ };
781
+ }
782
+ /**
783
+ * List namespaces with optional match conditions.
784
+ *
785
+ * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
786
+ * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
787
+ * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
788
+ * @param options.limit Maximum number of namespaces to return (default is 100).
789
+ * @param options.offset Number of namespaces to skip before returning results (default is 0).
790
+ * @returns Promise<ListNamespaceResponse>
791
+ */
792
+ async listNamespaces(options) {
793
+ const payload = {
794
+ prefix: options?.prefix,
795
+ suffix: options?.suffix,
796
+ max_depth: options?.maxDepth,
797
+ limit: options?.limit ?? 100,
798
+ offset: options?.offset ?? 0,
799
+ };
800
+ return this.fetch("/store/namespaces", {
801
+ method: "POST",
802
+ json: payload,
803
+ });
804
+ }
805
+ }
686
806
  export class Client {
687
807
  constructor(config) {
688
808
  /**
@@ -721,9 +841,19 @@ export class Client {
721
841
  writable: true,
722
842
  value: void 0
723
843
  });
844
+ /**
845
+ * The client for interacting with the KV store.
846
+ */
847
+ Object.defineProperty(this, "store", {
848
+ enumerable: true,
849
+ configurable: true,
850
+ writable: true,
851
+ value: void 0
852
+ });
724
853
  this.assistants = new AssistantsClient(config);
725
854
  this.threads = new ThreadsClient(config);
726
855
  this.runs = new RunsClient(config);
727
856
  this.crons = new CronsClient(config);
857
+ this.store = new StoreClient(config);
728
858
  }
729
859
  }
package/dist/schema.d.ts CHANGED
@@ -159,4 +159,17 @@ export interface Checkpoint {
159
159
  checkpoint_id: Optional<string>;
160
160
  checkpoint_map: Optional<Record<string, unknown>>;
161
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;
174
+ }
162
175
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",