@langchain/langgraph-sdk 0.0.5 → 0.0.7
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.d.mts +1 -0
- package/dist/client.mjs +13 -1
- package/dist/schema.d.ts +4 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.mjs";
|
|
|
3
3
|
import { RunsCreatePayload, RunsStreamPayload, RunsWaitPayload, StreamEvent, CronsCreatePayload, OnConflictBehavior } from "./types.mjs";
|
|
4
4
|
interface ClientConfig {
|
|
5
5
|
apiUrl?: string;
|
|
6
|
+
apiKey?: string;
|
|
6
7
|
callerOptions?: AsyncCallerParams;
|
|
7
8
|
timeoutMs?: number;
|
|
8
9
|
defaultHeaders?: Record<string, string | null | undefined>;
|
package/dist/client.mjs
CHANGED
|
@@ -35,6 +35,9 @@ class BaseClient {
|
|
|
35
35
|
this.timeoutMs = config?.timeoutMs || 12_000;
|
|
36
36
|
this.apiUrl = config?.apiUrl || "http://localhost:8123";
|
|
37
37
|
this.defaultHeaders = config?.defaultHeaders || {};
|
|
38
|
+
if (config?.apiKey != null) {
|
|
39
|
+
this.defaultHeaders["X-Api-Key"] = config.apiKey;
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
42
|
prepareFetchOptions(path, options) {
|
|
40
43
|
const mutatedOptions = {
|
|
@@ -398,6 +401,7 @@ export class RunsClient extends BaseClient {
|
|
|
398
401
|
signal: payload?.signal,
|
|
399
402
|
}));
|
|
400
403
|
let parser;
|
|
404
|
+
let onEndEvent;
|
|
401
405
|
const textDecoder = new TextDecoder();
|
|
402
406
|
const stream = (response.body || new ReadableStream({ start: (ctrl) => ctrl.close() })).pipeThrough(new TransformStream({
|
|
403
407
|
async start(ctrl) {
|
|
@@ -414,9 +418,17 @@ export class RunsClient extends BaseClient {
|
|
|
414
418
|
});
|
|
415
419
|
}
|
|
416
420
|
});
|
|
421
|
+
onEndEvent = () => {
|
|
422
|
+
ctrl.enqueue({ event: "end", data: undefined });
|
|
423
|
+
};
|
|
417
424
|
},
|
|
418
425
|
async transform(chunk) {
|
|
419
|
-
|
|
426
|
+
const payload = textDecoder.decode(chunk);
|
|
427
|
+
parser.feed(payload);
|
|
428
|
+
// eventsource-parser will ignore events
|
|
429
|
+
// that are not terminated by a newline
|
|
430
|
+
if (payload.trim() === "event: end")
|
|
431
|
+
onEndEvent();
|
|
420
432
|
},
|
|
421
433
|
}));
|
|
422
434
|
yield* IterableReadableStream.fromReadableStream(stream);
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { JSONSchema7 } from "json-schema";
|
|
2
2
|
type Optional<T> = T | null | undefined;
|
|
3
|
+
type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
|
|
4
|
+
type ThreadStatus = "idle" | "busy" | "interrupted";
|
|
3
5
|
export interface Config {
|
|
4
6
|
/**
|
|
5
7
|
* Tags for this call and any sub-calls (eg. a Chain calling an LLM).
|
|
@@ -67,6 +69,7 @@ export interface Thread {
|
|
|
67
69
|
created_at: string;
|
|
68
70
|
updated_at: string;
|
|
69
71
|
metadata: Metadata;
|
|
72
|
+
status: ThreadStatus;
|
|
70
73
|
}
|
|
71
74
|
export interface Cron {
|
|
72
75
|
cron_id: string;
|
|
@@ -94,7 +97,7 @@ export interface Run {
|
|
|
94
97
|
assistant_id: string;
|
|
95
98
|
created_at: string;
|
|
96
99
|
updated_at: string;
|
|
97
|
-
status:
|
|
100
|
+
status: RunStatus;
|
|
98
101
|
metadata: Metadata;
|
|
99
102
|
}
|
|
100
103
|
export {};
|