@langchain/langgraph-sdk 0.0.22 → 0.0.23-dev.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/client.d.cts +1 -1
- package/dist/client.cjs +16 -25
- package/dist/index.cjs +1 -5
- package/dist/schema.cjs +1 -2
- package/dist/types.cjs +1 -2
- package/dist/types.d.ts +1 -1
- package/dist/utils/async_caller.cjs +7 -14
- package/dist/utils/eventsource-parser/index.cjs +1 -5
- package/dist/utils/eventsource-parser/parse.cjs +1 -5
- package/dist/utils/eventsource-parser/stream.cjs +3 -7
- package/dist/utils/eventsource-parser/types.cjs +1 -2
- package/dist/utils/signals.cjs +1 -5
- package/dist/utils/stream.cjs +1 -5
- package/index.d.cts +1 -1
- package/package.json +9 -10
package/client.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/client.
|
|
1
|
+
export * from './dist/client.js'
|
package/dist/client.cjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const index_js_1 = require("./utils/eventsource-parser/index.cjs");
|
|
6
|
-
const stream_js_1 = require("./utils/stream.cjs");
|
|
7
|
-
const signals_js_1 = require("./utils/signals.cjs");
|
|
1
|
+
import { AsyncCaller } from "./utils/async_caller.js";
|
|
2
|
+
import { createParser, } from "./utils/eventsource-parser/index.js";
|
|
3
|
+
import { IterableReadableStream } from "./utils/stream.js";
|
|
4
|
+
import { mergeSignals } from "./utils/signals.js";
|
|
8
5
|
class BaseClient {
|
|
9
6
|
constructor(config) {
|
|
10
7
|
Object.defineProperty(this, "asyncCaller", {
|
|
@@ -31,7 +28,7 @@ class BaseClient {
|
|
|
31
28
|
writable: true,
|
|
32
29
|
value: void 0
|
|
33
30
|
});
|
|
34
|
-
this.asyncCaller = new
|
|
31
|
+
this.asyncCaller = new AsyncCaller({
|
|
35
32
|
maxRetries: 4,
|
|
36
33
|
maxConcurrency: 4,
|
|
37
34
|
...config?.callerOptions,
|
|
@@ -67,7 +64,7 @@ class BaseClient {
|
|
|
67
64
|
else {
|
|
68
65
|
timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
69
66
|
}
|
|
70
|
-
mutatedOptions.signal =
|
|
67
|
+
mutatedOptions.signal = mergeSignals(timeoutSignal, mutatedOptions.signal);
|
|
71
68
|
const targetUrl = new URL(`${this.apiUrl}${path}`);
|
|
72
69
|
if (mutatedOptions.params) {
|
|
73
70
|
for (const [key, value] of Object.entries(mutatedOptions.params)) {
|
|
@@ -90,7 +87,7 @@ class BaseClient {
|
|
|
90
87
|
return response.json();
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
|
-
class CronsClient extends BaseClient {
|
|
90
|
+
export class CronsClient extends BaseClient {
|
|
94
91
|
/**
|
|
95
92
|
*
|
|
96
93
|
* @param threadId The ID of the thread.
|
|
@@ -166,8 +163,7 @@ class CronsClient extends BaseClient {
|
|
|
166
163
|
});
|
|
167
164
|
}
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
class AssistantsClient extends BaseClient {
|
|
166
|
+
export class AssistantsClient extends BaseClient {
|
|
171
167
|
/**
|
|
172
168
|
* Get an assistant by ID.
|
|
173
169
|
*
|
|
@@ -302,8 +298,7 @@ class AssistantsClient extends BaseClient {
|
|
|
302
298
|
});
|
|
303
299
|
}
|
|
304
300
|
}
|
|
305
|
-
|
|
306
|
-
class ThreadsClient extends BaseClient {
|
|
301
|
+
export class ThreadsClient extends BaseClient {
|
|
307
302
|
/**
|
|
308
303
|
* Get a thread by ID.
|
|
309
304
|
*
|
|
@@ -458,8 +453,7 @@ class ThreadsClient extends BaseClient {
|
|
|
458
453
|
});
|
|
459
454
|
}
|
|
460
455
|
}
|
|
461
|
-
|
|
462
|
-
class RunsClient extends BaseClient {
|
|
456
|
+
export class RunsClient extends BaseClient {
|
|
463
457
|
/**
|
|
464
458
|
* Create a run and stream the results.
|
|
465
459
|
*
|
|
@@ -499,7 +493,7 @@ class RunsClient extends BaseClient {
|
|
|
499
493
|
const textDecoder = new TextDecoder();
|
|
500
494
|
const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
|
|
501
495
|
async start(ctrl) {
|
|
502
|
-
parser =
|
|
496
|
+
parser = createParser((event) => {
|
|
503
497
|
if ((payload?.signal && payload.signal.aborted) ||
|
|
504
498
|
(event.type === "event" && event.data === "[DONE]")) {
|
|
505
499
|
ctrl.terminate();
|
|
@@ -525,7 +519,7 @@ class RunsClient extends BaseClient {
|
|
|
525
519
|
onEndEvent();
|
|
526
520
|
},
|
|
527
521
|
}));
|
|
528
|
-
yield*
|
|
522
|
+
yield* IterableReadableStream.fromReadableStream(stream);
|
|
529
523
|
}
|
|
530
524
|
/**
|
|
531
525
|
* Create a run.
|
|
@@ -693,7 +687,7 @@ class RunsClient extends BaseClient {
|
|
|
693
687
|
const textDecoder = new TextDecoder();
|
|
694
688
|
const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
|
|
695
689
|
async start(ctrl) {
|
|
696
|
-
parser =
|
|
690
|
+
parser = createParser((event) => {
|
|
697
691
|
if ((signal && signal.aborted) ||
|
|
698
692
|
(event.type === "event" && event.data === "[DONE]")) {
|
|
699
693
|
ctrl.terminate();
|
|
@@ -719,7 +713,7 @@ class RunsClient extends BaseClient {
|
|
|
719
713
|
onEndEvent();
|
|
720
714
|
},
|
|
721
715
|
}));
|
|
722
|
-
yield*
|
|
716
|
+
yield* IterableReadableStream.fromReadableStream(stream);
|
|
723
717
|
}
|
|
724
718
|
/**
|
|
725
719
|
* Delete a run.
|
|
@@ -734,8 +728,7 @@ class RunsClient extends BaseClient {
|
|
|
734
728
|
});
|
|
735
729
|
}
|
|
736
730
|
}
|
|
737
|
-
|
|
738
|
-
class StoreClient extends BaseClient {
|
|
731
|
+
export class StoreClient extends BaseClient {
|
|
739
732
|
/**
|
|
740
733
|
* Store or update an item.
|
|
741
734
|
*
|
|
@@ -854,8 +847,7 @@ class StoreClient extends BaseClient {
|
|
|
854
847
|
});
|
|
855
848
|
}
|
|
856
849
|
}
|
|
857
|
-
|
|
858
|
-
class Client {
|
|
850
|
+
export class Client {
|
|
859
851
|
constructor(config) {
|
|
860
852
|
/**
|
|
861
853
|
* The client for interacting with assistants.
|
|
@@ -909,4 +901,3 @@ class Client {
|
|
|
909
901
|
this.store = new StoreClient(config);
|
|
910
902
|
}
|
|
911
903
|
}
|
|
912
|
-
exports.Client = Client;
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = void 0;
|
|
4
|
-
var client_js_1 = require("./client.cjs");
|
|
5
|
-
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
|
|
1
|
+
export { Client } from "./client.js";
|
package/dist/schema.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkpoint, Config, Metadata } from "./schema.js";
|
|
2
|
-
export type StreamMode = "values" | "messages" | "updates" | "events" | "debug";
|
|
2
|
+
export type StreamMode = "values" | "messages" | "updates" | "events" | "debug" | "custom" | "messages-tuple";
|
|
3
3
|
export type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue";
|
|
4
4
|
export type OnConflictBehavior = "raise" | "do_nothing";
|
|
5
5
|
export type OnCompletionBehavior = "complete" | "continue";
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AsyncCaller = void 0;
|
|
7
|
-
const p_retry_1 = __importDefault(require("p-retry"));
|
|
8
|
-
const p_queue_1 = __importDefault(require("p-queue"));
|
|
1
|
+
import pRetry from "p-retry";
|
|
2
|
+
import PQueueMod from "p-queue";
|
|
9
3
|
const STATUS_NO_RETRY = [
|
|
10
4
|
400, // Bad Request
|
|
11
5
|
401, // Unauthorized
|
|
@@ -79,7 +73,7 @@ class HTTPError extends Error {
|
|
|
79
73
|
* means that by default, each call will be retried up to 5 times, with an
|
|
80
74
|
* exponential backoff between each attempt.
|
|
81
75
|
*/
|
|
82
|
-
class AsyncCaller {
|
|
76
|
+
export class AsyncCaller {
|
|
83
77
|
constructor(params) {
|
|
84
78
|
Object.defineProperty(this, "maxConcurrency", {
|
|
85
79
|
enumerable: true,
|
|
@@ -113,15 +107,15 @@ class AsyncCaller {
|
|
|
113
107
|
});
|
|
114
108
|
this.maxConcurrency = params.maxConcurrency ?? Infinity;
|
|
115
109
|
this.maxRetries = params.maxRetries ?? 4;
|
|
116
|
-
if ("default" in
|
|
110
|
+
if ("default" in PQueueMod) {
|
|
117
111
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
-
this.queue = new
|
|
112
|
+
this.queue = new PQueueMod.default({
|
|
119
113
|
concurrency: this.maxConcurrency,
|
|
120
114
|
});
|
|
121
115
|
}
|
|
122
116
|
else {
|
|
123
117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
-
this.queue = new
|
|
118
|
+
this.queue = new PQueueMod({ concurrency: this.maxConcurrency });
|
|
125
119
|
}
|
|
126
120
|
this.onFailedResponseHook = params?.onFailedResponseHook;
|
|
127
121
|
this.customFetch = params.fetch;
|
|
@@ -129,7 +123,7 @@ class AsyncCaller {
|
|
|
129
123
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
124
|
call(callable, ...args) {
|
|
131
125
|
const onFailedResponseHook = this.onFailedResponseHook;
|
|
132
|
-
return this.queue.add(() => (
|
|
126
|
+
return this.queue.add(() => pRetry(() => callable(...args).catch(async (error) => {
|
|
133
127
|
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
134
128
|
if (error instanceof Error) {
|
|
135
129
|
throw error;
|
|
@@ -192,4 +186,3 @@ class AsyncCaller {
|
|
|
192
186
|
return this.call(() => fetchFn(...args).then((res) => (res.ok ? res : Promise.reject(res))));
|
|
193
187
|
}
|
|
194
188
|
}
|
|
195
|
-
exports.AsyncCaller = AsyncCaller;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// From https://github.com/rexxars/eventsource-parser
|
|
3
2
|
// Inlined due to CJS import issues
|
|
4
|
-
|
|
5
|
-
exports.createParser = void 0;
|
|
6
|
-
var parse_js_1 = require("./parse.cjs");
|
|
7
|
-
Object.defineProperty(exports, "createParser", { enumerable: true, get: function () { return parse_js_1.createParser; } });
|
|
3
|
+
export { createParser } from "./parse.js";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createParser = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Creates a new EventSource parser.
|
|
6
3
|
*
|
|
@@ -10,7 +7,7 @@ exports.createParser = void 0;
|
|
|
10
7
|
* @returns A new EventSource parser, with `parse` and `reset` methods.
|
|
11
8
|
* @public
|
|
12
9
|
*/
|
|
13
|
-
function createParser(onParse) {
|
|
10
|
+
export function createParser(onParse) {
|
|
14
11
|
// Processing state
|
|
15
12
|
let isFirstChunk;
|
|
16
13
|
let buffer;
|
|
@@ -143,7 +140,6 @@ function createParser(onParse) {
|
|
|
143
140
|
}
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
|
-
exports.createParser = createParser;
|
|
147
143
|
const BOM = [239, 187, 191];
|
|
148
144
|
function hasBom(buffer) {
|
|
149
145
|
return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventSourceParserStream = void 0;
|
|
4
|
-
const parse_js_1 = require("./parse.cjs");
|
|
1
|
+
import { createParser } from "./parse.js";
|
|
5
2
|
/**
|
|
6
3
|
* A TransformStream that ingests a stream of strings and produces a stream of ParsedEvents.
|
|
7
4
|
*
|
|
@@ -14,12 +11,12 @@ const parse_js_1 = require("./parse.cjs");
|
|
|
14
11
|
* ```
|
|
15
12
|
* @public
|
|
16
13
|
*/
|
|
17
|
-
class EventSourceParserStream extends TransformStream {
|
|
14
|
+
export class EventSourceParserStream extends TransformStream {
|
|
18
15
|
constructor() {
|
|
19
16
|
let parser;
|
|
20
17
|
super({
|
|
21
18
|
start(controller) {
|
|
22
|
-
parser =
|
|
19
|
+
parser = createParser((event) => {
|
|
23
20
|
if (event.type === "event") {
|
|
24
21
|
controller.enqueue(event);
|
|
25
22
|
}
|
|
@@ -31,4 +28,3 @@ class EventSourceParserStream extends TransformStream {
|
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
|
-
exports.EventSourceParserStream = EventSourceParserStream;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/utils/signals.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeSignals = void 0;
|
|
4
|
-
function mergeSignals(...signals) {
|
|
1
|
+
export function mergeSignals(...signals) {
|
|
5
2
|
const nonZeroSignals = signals.filter((signal) => signal != null);
|
|
6
3
|
if (nonZeroSignals.length === 0)
|
|
7
4
|
return undefined;
|
|
@@ -19,4 +16,3 @@ function mergeSignals(...signals) {
|
|
|
19
16
|
}
|
|
20
17
|
return controller.signal;
|
|
21
18
|
}
|
|
22
|
-
exports.mergeSignals = mergeSignals;
|
package/dist/utils/stream.cjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IterableReadableStream = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Support async iterator syntax for ReadableStreams in all environments.
|
|
6
3
|
* Source: https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
7
4
|
*/
|
|
8
|
-
class IterableReadableStream extends ReadableStream {
|
|
5
|
+
export class IterableReadableStream extends ReadableStream {
|
|
9
6
|
constructor() {
|
|
10
7
|
super(...arguments);
|
|
11
8
|
Object.defineProperty(this, "reader", {
|
|
@@ -112,4 +109,3 @@ class IterableReadableStream extends ReadableStream {
|
|
|
112
109
|
});
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
|
-
exports.IterableReadableStream = IterableReadableStream;
|
package/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/index.
|
|
1
|
+
export * from './dist/index.js'
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23-dev.0",
|
|
4
4
|
"description": "Client library for interacting with the LangGraph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@1.22.19",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"clean": "rm -rf dist/
|
|
9
|
-
"build": "yarn clean && yarn
|
|
10
|
-
"build:esm": "rm -f src/package.json && tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
|
|
11
|
-
"build:cjs": "echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && node scripts/move-cjs-to-dist.js && rm -r dist-cjs src/package.json",
|
|
8
|
+
"clean": "rm -rf dist/ dist-cjs/",
|
|
9
|
+
"build": "yarn clean && yarn lc_build --create-entrypoints --pre --tree-shaking",
|
|
12
10
|
"prepublish": "yarn run build",
|
|
13
11
|
"format": "prettier --write src",
|
|
14
12
|
"lint": "prettier --check src && tsc --noEmit"
|
|
@@ -22,6 +20,7 @@
|
|
|
22
20
|
"uuid": "^9.0.0"
|
|
23
21
|
},
|
|
24
22
|
"devDependencies": {
|
|
23
|
+
"@langchain/scripts": "^0.1.3",
|
|
25
24
|
"@tsconfig/recommended": "^1.0.2",
|
|
26
25
|
"@types/node": "^20.12.12",
|
|
27
26
|
"@types/uuid": "^9.0.1",
|
|
@@ -54,13 +53,13 @@
|
|
|
54
53
|
},
|
|
55
54
|
"files": [
|
|
56
55
|
"dist/",
|
|
57
|
-
"client.cjs",
|
|
58
|
-
"client.js",
|
|
59
|
-
"client.d.ts",
|
|
60
|
-
"client.d.cts",
|
|
61
56
|
"index.cjs",
|
|
62
57
|
"index.js",
|
|
63
58
|
"index.d.ts",
|
|
64
|
-
"index.d.cts"
|
|
59
|
+
"index.d.cts",
|
|
60
|
+
"client.cjs",
|
|
61
|
+
"client.js",
|
|
62
|
+
"client.d.ts",
|
|
63
|
+
"client.d.cts"
|
|
65
64
|
]
|
|
66
65
|
}
|