@langchain/langgraph-sdk 0.0.24 → 0.0.26
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 +32 -4
- package/dist/client.d.ts +12 -0
- package/dist/client.js +30 -3
- package/dist/index.d.ts +2 -2
- package/dist/schema.d.ts +3 -0
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = void 0;
|
|
3
|
+
exports.Client = exports.StoreClient = exports.RunsClient = exports.ThreadsClient = exports.AssistantsClient = exports.CronsClient = exports.getApiKey = 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");
|
|
7
7
|
const signals_js_1 = require("./utils/signals.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* Get the API key from the environment.
|
|
10
|
+
* Precedence:
|
|
11
|
+
* 1. explicit argument
|
|
12
|
+
* 2. LANGGRAPH_API_KEY
|
|
13
|
+
* 3. LANGSMITH_API_KEY
|
|
14
|
+
* 4. LANGCHAIN_API_KEY
|
|
15
|
+
*
|
|
16
|
+
* @param apiKey - Optional API key provided as an argument
|
|
17
|
+
* @returns The API key if found, otherwise undefined
|
|
18
|
+
*/
|
|
19
|
+
function getApiKey(apiKey) {
|
|
20
|
+
if (apiKey) {
|
|
21
|
+
return apiKey;
|
|
22
|
+
}
|
|
23
|
+
const prefixes = ["LANGGRAPH", "LANGSMITH", "LANGCHAIN"];
|
|
24
|
+
for (const prefix of prefixes) {
|
|
25
|
+
const envKey = process.env[`${prefix}_API_KEY`];
|
|
26
|
+
if (envKey) {
|
|
27
|
+
// Remove surrounding quotes
|
|
28
|
+
return envKey.trim().replace(/^["']|["']$/g, "");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
exports.getApiKey = getApiKey;
|
|
8
34
|
class BaseClient {
|
|
9
35
|
constructor(config) {
|
|
10
36
|
Object.defineProperty(this, "asyncCaller", {
|
|
@@ -39,10 +65,12 @@ class BaseClient {
|
|
|
39
65
|
this.timeoutMs = config?.timeoutMs || 12_000;
|
|
40
66
|
// default limit being capped by Chrome
|
|
41
67
|
// https://github.com/nodejs/undici/issues/1373
|
|
42
|
-
|
|
68
|
+
// Regex to remove trailing slash, if present
|
|
69
|
+
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || "http://localhost:8123";
|
|
43
70
|
this.defaultHeaders = config?.defaultHeaders || {};
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
const apiKey = getApiKey(config?.apiKey);
|
|
72
|
+
if (apiKey) {
|
|
73
|
+
this.defaultHeaders["X-Api-Key"] = apiKey;
|
|
46
74
|
}
|
|
47
75
|
}
|
|
48
76
|
prepareFetchOptions(path, options) {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item, ThreadStatus } 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
|
+
/**
|
|
5
|
+
* Get the API key from the environment.
|
|
6
|
+
* Precedence:
|
|
7
|
+
* 1. explicit argument
|
|
8
|
+
* 2. LANGGRAPH_API_KEY
|
|
9
|
+
* 3. LANGSMITH_API_KEY
|
|
10
|
+
* 4. LANGCHAIN_API_KEY
|
|
11
|
+
*
|
|
12
|
+
* @param apiKey - Optional API key provided as an argument
|
|
13
|
+
* @returns The API key if found, otherwise undefined
|
|
14
|
+
*/
|
|
15
|
+
export declare function getApiKey(apiKey?: string): string | undefined;
|
|
4
16
|
interface ClientConfig {
|
|
5
17
|
apiUrl?: string;
|
|
6
18
|
apiKey?: string;
|
package/dist/client.js
CHANGED
|
@@ -2,6 +2,31 @@ import { AsyncCaller } from "./utils/async_caller.js";
|
|
|
2
2
|
import { createParser, } from "./utils/eventsource-parser/index.js";
|
|
3
3
|
import { IterableReadableStream } from "./utils/stream.js";
|
|
4
4
|
import { mergeSignals } from "./utils/signals.js";
|
|
5
|
+
/**
|
|
6
|
+
* Get the API key from the environment.
|
|
7
|
+
* Precedence:
|
|
8
|
+
* 1. explicit argument
|
|
9
|
+
* 2. LANGGRAPH_API_KEY
|
|
10
|
+
* 3. LANGSMITH_API_KEY
|
|
11
|
+
* 4. LANGCHAIN_API_KEY
|
|
12
|
+
*
|
|
13
|
+
* @param apiKey - Optional API key provided as an argument
|
|
14
|
+
* @returns The API key if found, otherwise undefined
|
|
15
|
+
*/
|
|
16
|
+
export function getApiKey(apiKey) {
|
|
17
|
+
if (apiKey) {
|
|
18
|
+
return apiKey;
|
|
19
|
+
}
|
|
20
|
+
const prefixes = ["LANGGRAPH", "LANGSMITH", "LANGCHAIN"];
|
|
21
|
+
for (const prefix of prefixes) {
|
|
22
|
+
const envKey = process.env[`${prefix}_API_KEY`];
|
|
23
|
+
if (envKey) {
|
|
24
|
+
// Remove surrounding quotes
|
|
25
|
+
return envKey.trim().replace(/^["']|["']$/g, "");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
5
30
|
class BaseClient {
|
|
6
31
|
constructor(config) {
|
|
7
32
|
Object.defineProperty(this, "asyncCaller", {
|
|
@@ -36,10 +61,12 @@ class BaseClient {
|
|
|
36
61
|
this.timeoutMs = config?.timeoutMs || 12_000;
|
|
37
62
|
// default limit being capped by Chrome
|
|
38
63
|
// https://github.com/nodejs/undici/issues/1373
|
|
39
|
-
|
|
64
|
+
// Regex to remove trailing slash, if present
|
|
65
|
+
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || "http://localhost:8123";
|
|
40
66
|
this.defaultHeaders = config?.defaultHeaders || {};
|
|
41
|
-
|
|
42
|
-
|
|
67
|
+
const apiKey = getApiKey(config?.apiKey);
|
|
68
|
+
if (apiKey) {
|
|
69
|
+
this.defaultHeaders["X-Api-Key"] = apiKey;
|
|
43
70
|
}
|
|
44
71
|
}
|
|
45
72
|
prepareFetchOptions(path, options) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Client } from "./client.js";
|
|
2
|
-
export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadState, ThreadStatus, Cron, Checkpoint, } from "./schema.js";
|
|
3
|
-
export type { OnConflictBehavior } from "./types.js";
|
|
2
|
+
export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadTask, ThreadState, ThreadStatus, Cron, Checkpoint, } from "./schema.js";
|
|
3
|
+
export type { OnConflictBehavior, Command } from "./types.js";
|
package/dist/schema.d.ts
CHANGED
|
@@ -150,10 +150,13 @@ export interface ThreadState<ValuesType = DefaultValues> {
|
|
|
150
150
|
export interface ThreadTask {
|
|
151
151
|
id: string;
|
|
152
152
|
name: string;
|
|
153
|
+
result?: unknown;
|
|
153
154
|
error: Optional<string>;
|
|
154
155
|
interrupts: Array<{
|
|
155
156
|
value: unknown;
|
|
156
157
|
when: "during";
|
|
158
|
+
resumable: boolean;
|
|
159
|
+
ns?: string[];
|
|
157
160
|
}>;
|
|
158
161
|
checkpoint: Optional<Checkpoint>;
|
|
159
162
|
state: Optional<ThreadState>;
|
package/dist/types.d.ts
CHANGED
|
@@ -10,8 +10,17 @@ export interface Send {
|
|
|
10
10
|
input: Record<string, unknown> | null;
|
|
11
11
|
}
|
|
12
12
|
export interface Command {
|
|
13
|
+
/**
|
|
14
|
+
* An object to update the thread state with.
|
|
15
|
+
*/
|
|
13
16
|
update?: Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* The value to return from an `interrupt` function call.
|
|
19
|
+
*/
|
|
14
20
|
resume?: unknown;
|
|
21
|
+
/**
|
|
22
|
+
* A single, or array of `Send` commands to trigger nodes.
|
|
23
|
+
*/
|
|
15
24
|
send?: Send | Send[];
|
|
16
25
|
}
|
|
17
26
|
interface RunsInvokePayload {
|