@langchain/langgraph-sdk 0.0.65 → 0.0.67
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/auth/index.cjs +4 -0
- package/dist/auth/index.d.ts +5 -1
- package/dist/auth/index.js +4 -0
- package/dist/auth/types.d.ts +71 -7
- package/dist/client.cjs +16 -3
- package/dist/client.js +16 -3
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/stream.d.ts +1 -1
- package/dist/utils/async_caller.cjs +1 -6
- package/dist/utils/async_caller.js +1 -6
- package/package.json +2 -2
package/dist/auth/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HTTPException = exports.Auth = void 0;
|
|
4
4
|
class Auth {
|
|
5
5
|
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
6
10
|
Object.defineProperty(this, "~handlerCache", {
|
|
7
11
|
enumerable: true,
|
|
8
12
|
configurable: true,
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { AuthenticateCallback, AnyCallback, CallbackEvent, OnCallback, BaseAuthReturn, ToUserLike, BaseUser } from "./types.js";
|
|
2
2
|
export declare class Auth<TExtra = {}, TAuthReturn extends BaseAuthReturn = BaseAuthReturn, TUser extends BaseUser = ToUserLike<TAuthReturn>> {
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
3
7
|
"~handlerCache": {
|
|
4
8
|
authenticate?: AuthenticateCallback<BaseAuthReturn>;
|
|
5
9
|
callbacks?: Record<string, AnyCallback>;
|
|
@@ -7,5 +11,5 @@ export declare class Auth<TExtra = {}, TAuthReturn extends BaseAuthReturn = Base
|
|
|
7
11
|
authenticate<T extends BaseAuthReturn>(cb: AuthenticateCallback<T>): Auth<TExtra, T>;
|
|
8
12
|
on<T extends CallbackEvent>(event: T, callback: OnCallback<T, TUser>): this;
|
|
9
13
|
}
|
|
10
|
-
export type { Filters,
|
|
14
|
+
export type { Filters as AuthFilters, EventValueMap as AuthEventValueMap, } from "./types.js";
|
|
11
15
|
export { HTTPException } from "./error.js";
|
package/dist/auth/index.js
CHANGED
package/dist/auth/types.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ interface AssistantConfig {
|
|
|
9
9
|
[key: string]: unknown;
|
|
10
10
|
}>;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @inline
|
|
14
|
+
*/
|
|
12
15
|
interface AssistantCreate {
|
|
13
16
|
assistant_id?: Maybe<string>;
|
|
14
17
|
metadata?: Maybe<Record<string, unknown>>;
|
|
@@ -17,10 +20,16 @@ interface AssistantCreate {
|
|
|
17
20
|
name?: Maybe<string>;
|
|
18
21
|
graph_id: string;
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @inline
|
|
25
|
+
*/
|
|
20
26
|
interface AssistantRead {
|
|
21
27
|
assistant_id: string;
|
|
22
28
|
metadata?: Maybe<Record<string, unknown>>;
|
|
23
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @inline
|
|
32
|
+
*/
|
|
24
33
|
interface AssistantUpdate {
|
|
25
34
|
assistant_id: string;
|
|
26
35
|
metadata?: Maybe<Record<string, unknown>>;
|
|
@@ -29,32 +38,53 @@ interface AssistantUpdate {
|
|
|
29
38
|
name?: Maybe<string>;
|
|
30
39
|
version?: Maybe<number>;
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @inline
|
|
43
|
+
*/
|
|
32
44
|
interface AssistantDelete {
|
|
33
45
|
assistant_id: string;
|
|
34
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* @inline
|
|
49
|
+
*/
|
|
35
50
|
interface AssistantSearch {
|
|
36
51
|
graph_id?: Maybe<string>;
|
|
37
52
|
metadata?: Maybe<Record<string, unknown>>;
|
|
38
53
|
limit?: Maybe<number>;
|
|
39
54
|
offset?: Maybe<number>;
|
|
40
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @inline
|
|
58
|
+
*/
|
|
41
59
|
interface ThreadCreate {
|
|
42
60
|
thread_id?: Maybe<string>;
|
|
43
61
|
metadata?: Maybe<Record<string, unknown>>;
|
|
44
62
|
if_exists?: Maybe<"raise" | "do_nothing">;
|
|
45
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @inline
|
|
66
|
+
*/
|
|
46
67
|
interface ThreadRead {
|
|
47
68
|
thread_id?: Maybe<string>;
|
|
48
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @inline
|
|
72
|
+
*/
|
|
49
73
|
interface ThreadUpdate {
|
|
50
74
|
thread_id?: Maybe<string>;
|
|
51
75
|
metadata?: Maybe<Record<string, unknown>>;
|
|
52
76
|
action?: Maybe<"interrupt" | "rollback">;
|
|
53
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @inline
|
|
80
|
+
*/
|
|
54
81
|
interface ThreadDelete {
|
|
55
82
|
thread_id?: Maybe<string>;
|
|
56
83
|
run_id?: Maybe<string>;
|
|
57
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* @inline
|
|
87
|
+
*/
|
|
58
88
|
interface ThreadSearch {
|
|
59
89
|
thread_id?: Maybe<string>;
|
|
60
90
|
status?: Maybe<"idle" | "busy" | "interrupted" | "error" | (string & {})>;
|
|
@@ -63,6 +93,9 @@ interface ThreadSearch {
|
|
|
63
93
|
limit?: Maybe<number>;
|
|
64
94
|
offset?: Maybe<number>;
|
|
65
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @inline
|
|
98
|
+
*/
|
|
66
99
|
interface CronCreate {
|
|
67
100
|
payload?: Maybe<Record<string, unknown>>;
|
|
68
101
|
schedule: string;
|
|
@@ -71,32 +104,53 @@ interface CronCreate {
|
|
|
71
104
|
user_id?: Maybe<string>;
|
|
72
105
|
end_time?: Maybe<string>;
|
|
73
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* @inline
|
|
109
|
+
*/
|
|
74
110
|
interface CronRead {
|
|
75
111
|
cron_id: string;
|
|
76
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* @inline
|
|
115
|
+
*/
|
|
77
116
|
interface CronUpdate {
|
|
78
117
|
cron_id: string;
|
|
79
118
|
payload?: Maybe<Record<string, unknown>>;
|
|
80
119
|
schedule?: Maybe<string>;
|
|
81
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* @inline
|
|
123
|
+
*/
|
|
82
124
|
interface CronDelete {
|
|
83
125
|
cron_id: string;
|
|
84
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* @inline
|
|
129
|
+
*/
|
|
85
130
|
interface CronSearch {
|
|
86
131
|
assistant_id?: Maybe<string>;
|
|
87
132
|
thread_id?: Maybe<string>;
|
|
88
133
|
limit?: Maybe<number>;
|
|
89
134
|
offset?: Maybe<number>;
|
|
90
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* @inline
|
|
138
|
+
*/
|
|
91
139
|
interface StorePut {
|
|
92
140
|
namespace: string[];
|
|
93
141
|
key: string;
|
|
94
142
|
value: Record<string, unknown>;
|
|
95
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* @inline
|
|
146
|
+
*/
|
|
96
147
|
interface StoreGet {
|
|
97
148
|
namespace: Maybe<string[]>;
|
|
98
149
|
key: string;
|
|
99
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* @inline
|
|
153
|
+
*/
|
|
100
154
|
interface StoreSearch {
|
|
101
155
|
namespace?: Maybe<string[]>;
|
|
102
156
|
filter?: Maybe<Record<string, unknown>>;
|
|
@@ -104,6 +158,9 @@ interface StoreSearch {
|
|
|
104
158
|
offset?: Maybe<number>;
|
|
105
159
|
query?: Maybe<string>;
|
|
106
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* @inline
|
|
163
|
+
*/
|
|
107
164
|
interface StoreListNamespaces {
|
|
108
165
|
namespace?: Maybe<string[]>;
|
|
109
166
|
suffix?: Maybe<string[]>;
|
|
@@ -111,10 +168,16 @@ interface StoreListNamespaces {
|
|
|
111
168
|
limit?: Maybe<number>;
|
|
112
169
|
offset?: Maybe<number>;
|
|
113
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* @inline
|
|
173
|
+
*/
|
|
114
174
|
interface StoreDelete {
|
|
115
175
|
namespace?: Maybe<string[]>;
|
|
116
176
|
key: string;
|
|
117
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* @inline
|
|
180
|
+
*/
|
|
118
181
|
interface RunsCreate {
|
|
119
182
|
thread_id?: Maybe<string>;
|
|
120
183
|
assistant_id: string;
|
|
@@ -127,7 +190,7 @@ interface RunsCreate {
|
|
|
127
190
|
after_seconds?: Maybe<number>;
|
|
128
191
|
kwargs: Record<string, unknown>;
|
|
129
192
|
}
|
|
130
|
-
export interface
|
|
193
|
+
export interface EventValueMap {
|
|
131
194
|
["threads:create"]: ThreadCreate;
|
|
132
195
|
["threads:read"]: ThreadRead;
|
|
133
196
|
["threads:update"]: ThreadUpdate;
|
|
@@ -188,7 +251,8 @@ export type ToUserLike<T extends BaseAuthReturn> = T extends string ? {
|
|
|
188
251
|
is_authenticated: boolean;
|
|
189
252
|
display_name: string;
|
|
190
253
|
};
|
|
191
|
-
type CallbackParameter<Resource extends string = string, Action extends string = string, Value extends unknown = unknown, TUser extends BaseUser = BaseUser> = {
|
|
254
|
+
type CallbackParameter<Event extends string = string, Resource extends string = string, Action extends string = string, Value extends unknown = unknown, TUser extends BaseUser = BaseUser> = {
|
|
255
|
+
event: Event;
|
|
192
256
|
resource: Resource;
|
|
193
257
|
action: Action;
|
|
194
258
|
value: Value;
|
|
@@ -196,12 +260,12 @@ type CallbackParameter<Resource extends string = string, Action extends string =
|
|
|
196
260
|
permissions: string[];
|
|
197
261
|
};
|
|
198
262
|
type ContextMap = {
|
|
199
|
-
[
|
|
263
|
+
[EventType in keyof EventValueMap]: CallbackParameter<EventType, EventType extends `${infer Resource}:${string}` ? Resource : never, EventType extends `${string}:${infer Action}` ? Action : never, EventValueMap[EventType], BaseUser>;
|
|
200
264
|
};
|
|
201
265
|
type ActionCallbackParameter<T extends keyof ActionType, TUser extends BaseUser = BaseUser> = ContextMap[ActionType[T]] & {
|
|
202
266
|
user: TUser;
|
|
203
267
|
};
|
|
204
|
-
type AuthCallbackParameter<T extends keyof
|
|
268
|
+
type AuthCallbackParameter<T extends keyof EventValueMap, TUser extends BaseUser = BaseUser> = ContextMap[T] & {
|
|
205
269
|
user: TUser;
|
|
206
270
|
};
|
|
207
271
|
type ResourceCallbackParameter<T extends keyof ResourceType, TUser extends BaseUser = BaseUser> = ContextMap[ResourceType[T]] & {
|
|
@@ -215,9 +279,9 @@ export type Filters<TKey extends string | number | symbol> = {
|
|
|
215
279
|
export interface AuthenticateCallback<T extends BaseAuthReturn> {
|
|
216
280
|
(request: Request): PromiseMaybe<T>;
|
|
217
281
|
}
|
|
218
|
-
type OnKey = keyof ResourceType | keyof ActionType | keyof
|
|
219
|
-
type OnSingleParameter<T extends OnKey, TUser extends BaseUser = BaseUser> = T extends keyof ResourceType ? ResourceCallbackParameter<T, TUser> : T extends keyof ActionType ? ActionCallbackParameter<T, TUser> : T extends keyof
|
|
220
|
-
type OnParameter<T extends "*" | OnKey | OnKey[], TUser extends BaseUser = BaseUser> = T extends OnKey[] ? OnSingleParameter<T[number], TUser> : T extends "*" ? AuthCallbackParameter<keyof
|
|
282
|
+
type OnKey = keyof ResourceType | keyof ActionType | keyof EventValueMap;
|
|
283
|
+
type OnSingleParameter<T extends OnKey, TUser extends BaseUser = BaseUser> = T extends keyof ResourceType ? ResourceCallbackParameter<T, TUser> : T extends keyof ActionType ? ActionCallbackParameter<T, TUser> : T extends keyof EventValueMap ? AuthCallbackParameter<T, TUser> : never;
|
|
284
|
+
type OnParameter<T extends "*" | OnKey | OnKey[], TUser extends BaseUser = BaseUser> = T extends OnKey[] ? OnSingleParameter<T[number], TUser> : T extends "*" ? AuthCallbackParameter<keyof EventValueMap, TUser> : T extends OnKey ? OnSingleParameter<T, TUser> : never;
|
|
221
285
|
export type AnyCallback = (request: CallbackParameter) => void | boolean | Filters<string>;
|
|
222
286
|
export type CallbackEvent = "*" | OnKey | OnKey[];
|
|
223
287
|
export type OnCallback<T extends CallbackEvent, TUser extends BaseUser = BaseUser, TMetadata extends Record<string, unknown> = Record<string, unknown>> = (request: OnParameter<T, TUser>) => void | boolean | Filters<keyof TMetadata>;
|
package/dist/client.cjs
CHANGED
|
@@ -58,16 +58,29 @@ class BaseClient {
|
|
|
58
58
|
writable: true,
|
|
59
59
|
value: void 0
|
|
60
60
|
});
|
|
61
|
-
|
|
61
|
+
const callerOptions = {
|
|
62
62
|
maxRetries: 4,
|
|
63
63
|
maxConcurrency: 4,
|
|
64
64
|
...config?.callerOptions,
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
|
+
let defaultApiUrl = "http://localhost:8123";
|
|
67
|
+
if (!config?.apiUrl &&
|
|
68
|
+
typeof globalThis === "object" &&
|
|
69
|
+
globalThis != null) {
|
|
70
|
+
const fetchSmb = Symbol.for("langgraph_api:fetch");
|
|
71
|
+
const urlSmb = Symbol.for("langgraph_api:url");
|
|
72
|
+
const global = globalThis;
|
|
73
|
+
if (global[fetchSmb])
|
|
74
|
+
callerOptions.fetch ??= global[fetchSmb];
|
|
75
|
+
if (global[urlSmb])
|
|
76
|
+
defaultApiUrl = global[urlSmb];
|
|
77
|
+
}
|
|
78
|
+
this.asyncCaller = new async_caller_js_1.AsyncCaller(callerOptions);
|
|
66
79
|
this.timeoutMs = config?.timeoutMs;
|
|
67
80
|
// default limit being capped by Chrome
|
|
68
81
|
// https://github.com/nodejs/undici/issues/1373
|
|
69
82
|
// Regex to remove trailing slash, if present
|
|
70
|
-
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") ||
|
|
83
|
+
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || defaultApiUrl;
|
|
71
84
|
this.defaultHeaders = config?.defaultHeaders || {};
|
|
72
85
|
const apiKey = getApiKey(config?.apiKey);
|
|
73
86
|
if (apiKey) {
|
package/dist/client.js
CHANGED
|
@@ -54,16 +54,29 @@ class BaseClient {
|
|
|
54
54
|
writable: true,
|
|
55
55
|
value: void 0
|
|
56
56
|
});
|
|
57
|
-
|
|
57
|
+
const callerOptions = {
|
|
58
58
|
maxRetries: 4,
|
|
59
59
|
maxConcurrency: 4,
|
|
60
60
|
...config?.callerOptions,
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
|
+
let defaultApiUrl = "http://localhost:8123";
|
|
63
|
+
if (!config?.apiUrl &&
|
|
64
|
+
typeof globalThis === "object" &&
|
|
65
|
+
globalThis != null) {
|
|
66
|
+
const fetchSmb = Symbol.for("langgraph_api:fetch");
|
|
67
|
+
const urlSmb = Symbol.for("langgraph_api:url");
|
|
68
|
+
const global = globalThis;
|
|
69
|
+
if (global[fetchSmb])
|
|
70
|
+
callerOptions.fetch ??= global[fetchSmb];
|
|
71
|
+
if (global[urlSmb])
|
|
72
|
+
defaultApiUrl = global[urlSmb];
|
|
73
|
+
}
|
|
74
|
+
this.asyncCaller = new AsyncCaller(callerOptions);
|
|
62
75
|
this.timeoutMs = config?.timeoutMs;
|
|
63
76
|
// default limit being capped by Chrome
|
|
64
77
|
// https://github.com/nodejs/undici/issues/1373
|
|
65
78
|
// Regex to remove trailing slash, if present
|
|
66
|
-
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") ||
|
|
79
|
+
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || defaultApiUrl;
|
|
67
80
|
this.defaultHeaders = config?.defaultHeaders || {};
|
|
68
81
|
const apiKey = getApiKey(config?.apiKey);
|
|
69
82
|
if (apiKey) {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useStream, type MessageMetadata } from "./stream.js";
|
|
1
|
+
export { useStream, type MessageMetadata, type UseStream, type UseStreamOptions, } from "./stream.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { useStream } from "./stream.js";
|
|
1
|
+
export { useStream, } from "./stream.js";
|
package/dist/react/stream.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ type GetInterruptType<Bag extends BagTemplate> = Bag extends {
|
|
|
53
53
|
type GetCustomEventType<Bag extends BagTemplate> = Bag extends {
|
|
54
54
|
CustomEventType: unknown;
|
|
55
55
|
} ? Bag["CustomEventType"] : unknown;
|
|
56
|
-
interface UseStreamOptions<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> {
|
|
56
|
+
export interface UseStreamOptions<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> {
|
|
57
57
|
/**
|
|
58
58
|
* The ID of the assistant to use.
|
|
59
59
|
*/
|
|
@@ -17,10 +17,8 @@ const STATUS_NO_RETRY = [
|
|
|
17
17
|
406, // Not Acceptable
|
|
18
18
|
407, // Proxy Authentication Required
|
|
19
19
|
408, // Request Timeout
|
|
20
|
-
422, // Unprocessable Entity
|
|
21
|
-
];
|
|
22
|
-
const STATUS_IGNORE = [
|
|
23
20
|
409, // Conflict
|
|
21
|
+
422, // Unprocessable Entity
|
|
24
22
|
];
|
|
25
23
|
/**
|
|
26
24
|
* Do not rely on globalThis.Response, rather just
|
|
@@ -159,9 +157,6 @@ class AsyncCaller {
|
|
|
159
157
|
if (STATUS_NO_RETRY.includes(error.status)) {
|
|
160
158
|
throw error;
|
|
161
159
|
}
|
|
162
|
-
else if (STATUS_IGNORE.includes(error.status)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
160
|
if (onFailedResponseHook && error.response) {
|
|
166
161
|
await onFailedResponseHook(error.response);
|
|
167
162
|
}
|
|
@@ -11,10 +11,8 @@ const STATUS_NO_RETRY = [
|
|
|
11
11
|
406, // Not Acceptable
|
|
12
12
|
407, // Proxy Authentication Required
|
|
13
13
|
408, // Request Timeout
|
|
14
|
-
422, // Unprocessable Entity
|
|
15
|
-
];
|
|
16
|
-
const STATUS_IGNORE = [
|
|
17
14
|
409, // Conflict
|
|
15
|
+
422, // Unprocessable Entity
|
|
18
16
|
];
|
|
19
17
|
/**
|
|
20
18
|
* Do not rely on globalThis.Response, rather just
|
|
@@ -153,9 +151,6 @@ export class AsyncCaller {
|
|
|
153
151
|
if (STATUS_NO_RETRY.includes(error.status)) {
|
|
154
152
|
throw error;
|
|
155
153
|
}
|
|
156
|
-
else if (STATUS_IGNORE.includes(error.status)) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
154
|
if (onFailedResponseHook && error.response) {
|
|
160
155
|
await onFailedResponseHook(error.response);
|
|
161
156
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.67",
|
|
4
4
|
"description": "Client library for interacting with the LangGraph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@1.22.19",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"format": "prettier --write src",
|
|
12
12
|
"lint": "prettier --check src && tsc --noEmit",
|
|
13
13
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
14
|
-
"typedoc": "typedoc && typedoc src/react/index.ts --out docs/react --options typedoc.react.json"
|
|
14
|
+
"typedoc": "typedoc && typedoc src/react/index.ts --out docs/react --options typedoc.react.json && typedoc src/auth/index.ts --out docs/auth --options typedoc.auth.json"
|
|
15
15
|
},
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"license": "MIT",
|