@langchain/langgraph-sdk 0.0.13 → 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 +130 -1
- package/dist/client.d.ts +65 -2
- package/dist/client.js +128 -0
- package/dist/schema.d.ts +13 -0
- package/package.json +1 -1
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,124 @@ 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 {
|
|
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;
|
|
693
812
|
class Client {
|
|
694
813
|
constructor(config) {
|
|
695
814
|
/**
|
|
@@ -728,10 +847,20 @@ class Client {
|
|
|
728
847
|
writable: true,
|
|
729
848
|
value: void 0
|
|
730
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
|
+
});
|
|
731
859
|
this.assistants = new AssistantsClient(config);
|
|
732
860
|
this.threads = new ThreadsClient(config);
|
|
733
861
|
this.runs = new RunsClient(config);
|
|
734
862
|
this.crons = new CronsClient(config);
|
|
863
|
+
this.store = new StoreClient(config);
|
|
735
864
|
}
|
|
736
865
|
}
|
|
737
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, 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,123 @@ 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 {
|
|
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
|
+
}
|
|
686
804
|
export class Client {
|
|
687
805
|
constructor(config) {
|
|
688
806
|
/**
|
|
@@ -721,9 +839,19 @@ export class Client {
|
|
|
721
839
|
writable: true,
|
|
722
840
|
value: void 0
|
|
723
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
|
+
});
|
|
724
851
|
this.assistants = new AssistantsClient(config);
|
|
725
852
|
this.threads = new ThreadsClient(config);
|
|
726
853
|
this.runs = new RunsClient(config);
|
|
727
854
|
this.crons = new CronsClient(config);
|
|
855
|
+
this.store = new StoreClient(config);
|
|
728
856
|
}
|
|
729
857
|
}
|
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 {};
|