@langchain/langgraph-sdk 0.0.63 → 0.0.65

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/auth.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/auth/index.cjs');
package/auth.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/auth/index.js'
package/auth.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/auth/index.js'
package/auth.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/auth/index.js'
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTPException = void 0;
4
+ const HTTP_STATUS_MAPPING = {
5
+ 100: "Continue",
6
+ 101: "Switching Protocols",
7
+ 102: "Processing",
8
+ 103: "Early Hints",
9
+ 200: "OK",
10
+ 201: "Created",
11
+ 202: "Accepted",
12
+ 203: "Non-Authoritative Information",
13
+ 204: "No Content",
14
+ 205: "Reset Content",
15
+ 206: "Partial Content",
16
+ 207: "Multi-Status",
17
+ 208: "Already Reported",
18
+ 226: "IM Used",
19
+ 300: "Multiple Choices",
20
+ 301: "Moved Permanently",
21
+ 302: "Found",
22
+ 303: "See Other",
23
+ 304: "Not Modified",
24
+ 305: "Use Proxy",
25
+ 307: "Temporary Redirect",
26
+ 308: "Permanent Redirect",
27
+ 400: "Bad Request",
28
+ 401: "Unauthorized",
29
+ 402: "Payment Required",
30
+ 403: "Forbidden",
31
+ 404: "Not Found",
32
+ 405: "Method Not Allowed",
33
+ 406: "Not Acceptable",
34
+ 407: "Proxy Authentication Required",
35
+ 408: "Request Timeout",
36
+ 409: "Conflict",
37
+ 410: "Gone",
38
+ 411: "Length Required",
39
+ 412: "Precondition Failed",
40
+ 413: "Request Entity Too Large",
41
+ 414: "Request-URI Too Long",
42
+ 415: "Unsupported Media Type",
43
+ 416: "Requested Range Not Satisfiable",
44
+ 417: "Expectation Failed",
45
+ 418: "I'm a Teapot",
46
+ 421: "Misdirected Request",
47
+ 422: "Unprocessable Entity",
48
+ 423: "Locked",
49
+ 424: "Failed Dependency",
50
+ 425: "Too Early",
51
+ 426: "Upgrade Required",
52
+ 428: "Precondition Required",
53
+ 429: "Too Many Requests",
54
+ 431: "Request Header Fields Too Large",
55
+ 451: "Unavailable For Legal Reasons",
56
+ 500: "Internal Server Error",
57
+ 501: "Not Implemented",
58
+ 502: "Bad Gateway",
59
+ 503: "Service Unavailable",
60
+ 504: "Gateway Timeout",
61
+ 505: "HTTP Version Not Supported",
62
+ 506: "Variant Also Negotiates",
63
+ 507: "Insufficient Storage",
64
+ 508: "Loop Detected",
65
+ 510: "Not Extended",
66
+ 511: "Network Authentication Required",
67
+ };
68
+ class HTTPException extends Error {
69
+ constructor(status, options) {
70
+ super(options?.message ?? HTTP_STATUS_MAPPING[status] ?? "Unknown error", {
71
+ cause: options?.cause,
72
+ });
73
+ Object.defineProperty(this, "status", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+ Object.defineProperty(this, "headers", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: void 0
84
+ });
85
+ this.status = status;
86
+ this.headers = options?.headers ?? {};
87
+ }
88
+ }
89
+ exports.HTTPException = HTTPException;
@@ -0,0 +1,9 @@
1
+ export declare class HTTPException extends Error {
2
+ status: number;
3
+ headers: HeadersInit;
4
+ constructor(status: number, options?: {
5
+ message?: string;
6
+ headers?: HeadersInit;
7
+ cause?: unknown;
8
+ });
9
+ }
@@ -0,0 +1,85 @@
1
+ const HTTP_STATUS_MAPPING = {
2
+ 100: "Continue",
3
+ 101: "Switching Protocols",
4
+ 102: "Processing",
5
+ 103: "Early Hints",
6
+ 200: "OK",
7
+ 201: "Created",
8
+ 202: "Accepted",
9
+ 203: "Non-Authoritative Information",
10
+ 204: "No Content",
11
+ 205: "Reset Content",
12
+ 206: "Partial Content",
13
+ 207: "Multi-Status",
14
+ 208: "Already Reported",
15
+ 226: "IM Used",
16
+ 300: "Multiple Choices",
17
+ 301: "Moved Permanently",
18
+ 302: "Found",
19
+ 303: "See Other",
20
+ 304: "Not Modified",
21
+ 305: "Use Proxy",
22
+ 307: "Temporary Redirect",
23
+ 308: "Permanent Redirect",
24
+ 400: "Bad Request",
25
+ 401: "Unauthorized",
26
+ 402: "Payment Required",
27
+ 403: "Forbidden",
28
+ 404: "Not Found",
29
+ 405: "Method Not Allowed",
30
+ 406: "Not Acceptable",
31
+ 407: "Proxy Authentication Required",
32
+ 408: "Request Timeout",
33
+ 409: "Conflict",
34
+ 410: "Gone",
35
+ 411: "Length Required",
36
+ 412: "Precondition Failed",
37
+ 413: "Request Entity Too Large",
38
+ 414: "Request-URI Too Long",
39
+ 415: "Unsupported Media Type",
40
+ 416: "Requested Range Not Satisfiable",
41
+ 417: "Expectation Failed",
42
+ 418: "I'm a Teapot",
43
+ 421: "Misdirected Request",
44
+ 422: "Unprocessable Entity",
45
+ 423: "Locked",
46
+ 424: "Failed Dependency",
47
+ 425: "Too Early",
48
+ 426: "Upgrade Required",
49
+ 428: "Precondition Required",
50
+ 429: "Too Many Requests",
51
+ 431: "Request Header Fields Too Large",
52
+ 451: "Unavailable For Legal Reasons",
53
+ 500: "Internal Server Error",
54
+ 501: "Not Implemented",
55
+ 502: "Bad Gateway",
56
+ 503: "Service Unavailable",
57
+ 504: "Gateway Timeout",
58
+ 505: "HTTP Version Not Supported",
59
+ 506: "Variant Also Negotiates",
60
+ 507: "Insufficient Storage",
61
+ 508: "Loop Detected",
62
+ 510: "Not Extended",
63
+ 511: "Network Authentication Required",
64
+ };
65
+ export class HTTPException extends Error {
66
+ constructor(status, options) {
67
+ super(options?.message ?? HTTP_STATUS_MAPPING[status] ?? "Unknown error", {
68
+ cause: options?.cause,
69
+ });
70
+ Object.defineProperty(this, "status", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: void 0
75
+ });
76
+ Object.defineProperty(this, "headers", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: void 0
81
+ });
82
+ this.status = status;
83
+ this.headers = options?.headers ?? {};
84
+ }
85
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTPException = exports.Auth = void 0;
4
+ class Auth {
5
+ constructor() {
6
+ Object.defineProperty(this, "~handlerCache", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: {}
11
+ });
12
+ }
13
+ authenticate(cb) {
14
+ this["~handlerCache"].authenticate = cb;
15
+ return this;
16
+ }
17
+ on(event, callback) {
18
+ this["~handlerCache"].callbacks ??= {};
19
+ const events = Array.isArray(event) ? event : [event];
20
+ for (const event of events) {
21
+ this["~handlerCache"].callbacks[event] = callback;
22
+ }
23
+ return this;
24
+ }
25
+ }
26
+ exports.Auth = Auth;
27
+ var error_js_1 = require("./error.cjs");
28
+ Object.defineProperty(exports, "HTTPException", { enumerable: true, get: function () { return error_js_1.HTTPException; } });
@@ -0,0 +1,11 @@
1
+ import type { AuthenticateCallback, AnyCallback, CallbackEvent, OnCallback, BaseAuthReturn, ToUserLike, BaseUser } from "./types.js";
2
+ export declare class Auth<TExtra = {}, TAuthReturn extends BaseAuthReturn = BaseAuthReturn, TUser extends BaseUser = ToUserLike<TAuthReturn>> {
3
+ "~handlerCache": {
4
+ authenticate?: AuthenticateCallback<BaseAuthReturn>;
5
+ callbacks?: Record<string, AnyCallback>;
6
+ };
7
+ authenticate<T extends BaseAuthReturn>(cb: AuthenticateCallback<T>): Auth<TExtra, T>;
8
+ on<T extends CallbackEvent>(event: T, callback: OnCallback<T, TUser>): this;
9
+ }
10
+ export type { Filters, ResourceActionType } from "./types.js";
11
+ export { HTTPException } from "./error.js";
@@ -0,0 +1,23 @@
1
+ export class Auth {
2
+ constructor() {
3
+ Object.defineProperty(this, "~handlerCache", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: {}
8
+ });
9
+ }
10
+ authenticate(cb) {
11
+ this["~handlerCache"].authenticate = cb;
12
+ return this;
13
+ }
14
+ on(event, callback) {
15
+ this["~handlerCache"].callbacks ??= {};
16
+ const events = Array.isArray(event) ? event : [event];
17
+ for (const event of events) {
18
+ this["~handlerCache"].callbacks[event] = callback;
19
+ }
20
+ return this;
21
+ }
22
+ }
23
+ export { HTTPException } from "./error.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,224 @@
1
+ type Maybe<T> = T | null | undefined;
2
+ type PromiseMaybe<T> = Promise<T> | T;
3
+ interface AssistantConfig {
4
+ tags?: Maybe<string[]>;
5
+ recursion_limit?: Maybe<number>;
6
+ configurable?: Maybe<{
7
+ thread_id?: Maybe<string>;
8
+ thread_ts?: Maybe<string>;
9
+ [key: string]: unknown;
10
+ }>;
11
+ }
12
+ interface AssistantCreate {
13
+ assistant_id?: Maybe<string>;
14
+ metadata?: Maybe<Record<string, unknown>>;
15
+ config?: Maybe<AssistantConfig>;
16
+ if_exists?: Maybe<"raise" | "do_nothing">;
17
+ name?: Maybe<string>;
18
+ graph_id: string;
19
+ }
20
+ interface AssistantRead {
21
+ assistant_id: string;
22
+ metadata?: Maybe<Record<string, unknown>>;
23
+ }
24
+ interface AssistantUpdate {
25
+ assistant_id: string;
26
+ metadata?: Maybe<Record<string, unknown>>;
27
+ config?: Maybe<AssistantConfig>;
28
+ graph_id?: Maybe<string>;
29
+ name?: Maybe<string>;
30
+ version?: Maybe<number>;
31
+ }
32
+ interface AssistantDelete {
33
+ assistant_id: string;
34
+ }
35
+ interface AssistantSearch {
36
+ graph_id?: Maybe<string>;
37
+ metadata?: Maybe<Record<string, unknown>>;
38
+ limit?: Maybe<number>;
39
+ offset?: Maybe<number>;
40
+ }
41
+ interface ThreadCreate {
42
+ thread_id?: Maybe<string>;
43
+ metadata?: Maybe<Record<string, unknown>>;
44
+ if_exists?: Maybe<"raise" | "do_nothing">;
45
+ }
46
+ interface ThreadRead {
47
+ thread_id?: Maybe<string>;
48
+ }
49
+ interface ThreadUpdate {
50
+ thread_id?: Maybe<string>;
51
+ metadata?: Maybe<Record<string, unknown>>;
52
+ action?: Maybe<"interrupt" | "rollback">;
53
+ }
54
+ interface ThreadDelete {
55
+ thread_id?: Maybe<string>;
56
+ run_id?: Maybe<string>;
57
+ }
58
+ interface ThreadSearch {
59
+ thread_id?: Maybe<string>;
60
+ status?: Maybe<"idle" | "busy" | "interrupted" | "error" | (string & {})>;
61
+ metadata?: Maybe<Record<string, unknown>>;
62
+ values?: Maybe<Record<string, unknown>>;
63
+ limit?: Maybe<number>;
64
+ offset?: Maybe<number>;
65
+ }
66
+ interface CronCreate {
67
+ payload?: Maybe<Record<string, unknown>>;
68
+ schedule: string;
69
+ cron_id?: Maybe<string>;
70
+ thread_id?: Maybe<string>;
71
+ user_id?: Maybe<string>;
72
+ end_time?: Maybe<string>;
73
+ }
74
+ interface CronRead {
75
+ cron_id: string;
76
+ }
77
+ interface CronUpdate {
78
+ cron_id: string;
79
+ payload?: Maybe<Record<string, unknown>>;
80
+ schedule?: Maybe<string>;
81
+ }
82
+ interface CronDelete {
83
+ cron_id: string;
84
+ }
85
+ interface CronSearch {
86
+ assistant_id?: Maybe<string>;
87
+ thread_id?: Maybe<string>;
88
+ limit?: Maybe<number>;
89
+ offset?: Maybe<number>;
90
+ }
91
+ interface StorePut {
92
+ namespace: string[];
93
+ key: string;
94
+ value: Record<string, unknown>;
95
+ }
96
+ interface StoreGet {
97
+ namespace: Maybe<string[]>;
98
+ key: string;
99
+ }
100
+ interface StoreSearch {
101
+ namespace?: Maybe<string[]>;
102
+ filter?: Maybe<Record<string, unknown>>;
103
+ limit?: Maybe<number>;
104
+ offset?: Maybe<number>;
105
+ query?: Maybe<string>;
106
+ }
107
+ interface StoreListNamespaces {
108
+ namespace?: Maybe<string[]>;
109
+ suffix?: Maybe<string[]>;
110
+ max_depth?: Maybe<number>;
111
+ limit?: Maybe<number>;
112
+ offset?: Maybe<number>;
113
+ }
114
+ interface StoreDelete {
115
+ namespace?: Maybe<string[]>;
116
+ key: string;
117
+ }
118
+ interface RunsCreate {
119
+ thread_id?: Maybe<string>;
120
+ assistant_id: string;
121
+ run_id: string;
122
+ status: Maybe<"pending" | "running" | "error" | "success" | "timeout" | "interrupted">;
123
+ metadata?: Maybe<Record<string, unknown>>;
124
+ prevent_insert_if_inflight?: Maybe<boolean>;
125
+ multitask_strategy?: Maybe<"interrupt" | "rollback" | "reject" | "enqueue">;
126
+ if_not_exists?: Maybe<"reject" | "create">;
127
+ after_seconds?: Maybe<number>;
128
+ kwargs: Record<string, unknown>;
129
+ }
130
+ export interface ResourceActionType {
131
+ ["threads:create"]: ThreadCreate;
132
+ ["threads:read"]: ThreadRead;
133
+ ["threads:update"]: ThreadUpdate;
134
+ ["threads:delete"]: ThreadDelete;
135
+ ["threads:search"]: ThreadSearch;
136
+ ["threads:create_run"]: RunsCreate;
137
+ ["assistants:create"]: AssistantCreate;
138
+ ["assistants:read"]: AssistantRead;
139
+ ["assistants:update"]: AssistantUpdate;
140
+ ["assistants:delete"]: AssistantDelete;
141
+ ["assistants:search"]: AssistantSearch;
142
+ ["crons:create"]: CronCreate;
143
+ ["crons:read"]: CronRead;
144
+ ["crons:update"]: CronUpdate;
145
+ ["crons:delete"]: CronDelete;
146
+ ["crons:search"]: CronSearch;
147
+ ["store:put"]: StorePut;
148
+ ["store:get"]: StoreGet;
149
+ ["store:search"]: StoreSearch;
150
+ ["store:list_namespaces"]: StoreListNamespaces;
151
+ ["store:delete"]: StoreDelete;
152
+ }
153
+ interface ResourceType {
154
+ threads: "threads:create" | "threads:read" | "threads:update" | "threads:delete" | "threads:search" | "threads:create_run";
155
+ assistants: "assistants:create" | "assistants:read" | "assistants:update" | "assistants:delete" | "assistants:search";
156
+ crons: "crons:create" | "crons:read" | "crons:update" | "crons:delete" | "crons:search";
157
+ store: "store:put" | "store:get" | "store:search" | "store:list_namespaces" | "store:delete";
158
+ }
159
+ interface ActionType {
160
+ "*:create": "threads:create" | "assistants:create" | "crons:create";
161
+ "*:read": "threads:read" | "assistants:read" | "crons:read";
162
+ "*:update": "threads:update" | "assistants:update" | "crons:update";
163
+ "*:delete": "threads:delete" | "assistants:delete" | "crons:delete" | "store:delete";
164
+ "*:search": "threads:search" | "assistants:search" | "crons:search" | "store:search";
165
+ "*:create_run": "threads:create_run";
166
+ "*:put": "store:put";
167
+ "*:get": "store:get";
168
+ "*:list_namespaces": "store:list_namespaces";
169
+ }
170
+ export type BaseAuthReturn = {
171
+ is_authenticated?: boolean;
172
+ display_name?: string;
173
+ identity: string;
174
+ permissions: string[];
175
+ } | string;
176
+ export interface BaseUser {
177
+ is_authenticated: boolean;
178
+ display_name: string;
179
+ identity: string;
180
+ permissions: string[];
181
+ }
182
+ export type ToUserLike<T extends BaseAuthReturn> = T extends string ? {
183
+ is_authenticated: boolean;
184
+ display_name: string;
185
+ identity: string;
186
+ permissions: string[];
187
+ } : Omit<T, "is_authenticated" | "display_name"> & {
188
+ is_authenticated: boolean;
189
+ display_name: string;
190
+ };
191
+ type CallbackParameter<Resource extends string = string, Action extends string = string, Value extends unknown = unknown, TUser extends BaseUser = BaseUser> = {
192
+ resource: Resource;
193
+ action: Action;
194
+ value: Value;
195
+ user: TUser;
196
+ permissions: string[];
197
+ };
198
+ type ContextMap = {
199
+ [ActionType in keyof ResourceActionType]: CallbackParameter<ActionType extends `${infer Resource}:${string}` ? Resource : never, ActionType, ResourceActionType[ActionType], BaseUser>;
200
+ };
201
+ type ActionCallbackParameter<T extends keyof ActionType, TUser extends BaseUser = BaseUser> = ContextMap[ActionType[T]] & {
202
+ user: TUser;
203
+ };
204
+ type AuthCallbackParameter<T extends keyof ResourceActionType, TUser extends BaseUser = BaseUser> = ContextMap[T] & {
205
+ user: TUser;
206
+ };
207
+ type ResourceCallbackParameter<T extends keyof ResourceType, TUser extends BaseUser = BaseUser> = ContextMap[ResourceType[T]] & {
208
+ user: TUser;
209
+ };
210
+ export type Filters<TKey extends string | number | symbol> = {
211
+ [key in TKey]: string | {
212
+ [op in "$contains" | "$eq"]?: string;
213
+ };
214
+ };
215
+ export interface AuthenticateCallback<T extends BaseAuthReturn> {
216
+ (request: Request): PromiseMaybe<T>;
217
+ }
218
+ type OnKey = keyof ResourceType | keyof ActionType | keyof ResourceActionType;
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 ResourceActionType ? AuthCallbackParameter<T, TUser> : never;
220
+ type OnParameter<T extends "*" | OnKey | OnKey[], TUser extends BaseUser = BaseUser> = T extends OnKey[] ? OnSingleParameter<T[number], TUser> : T extends "*" ? AuthCallbackParameter<keyof ResourceActionType, TUser> : T extends OnKey ? OnSingleParameter<T, TUser> : never;
221
+ export type AnyCallback = (request: CallbackParameter) => void | boolean | Filters<string>;
222
+ export type CallbackEvent = "*" | OnKey | OnKey[];
223
+ 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>;
224
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",
@@ -72,6 +72,15 @@
72
72
  "import": "./client.js",
73
73
  "require": "./client.cjs"
74
74
  },
75
+ "./auth": {
76
+ "types": {
77
+ "import": "./auth.d.ts",
78
+ "require": "./auth.d.cts",
79
+ "default": "./auth.d.ts"
80
+ },
81
+ "import": "./auth.js",
82
+ "require": "./auth.cjs"
83
+ },
75
84
  "./react": {
76
85
  "types": {
77
86
  "import": "./react.d.ts",
@@ -111,6 +120,10 @@
111
120
  "client.js",
112
121
  "client.d.ts",
113
122
  "client.d.cts",
123
+ "auth.cjs",
124
+ "auth.js",
125
+ "auth.d.ts",
126
+ "auth.d.cts",
114
127
  "react.cjs",
115
128
  "react.js",
116
129
  "react.d.ts",