@langchain/langgraph-sdk 0.0.34 → 0.0.36
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 +4 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +4 -3
- package/dist/index.cjs +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/schema.d.ts +16 -0
- package/dist/singletons/fetch.cjs +27 -0
- package/dist/singletons/fetch.d.ts +11 -0
- package/dist/singletons/fetch.js +22 -0
- package/package.json +7 -2
package/dist/client.cjs
CHANGED
|
@@ -6,6 +6,7 @@ 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
8
|
const env_js_1 = require("./utils/env.cjs");
|
|
9
|
+
const fetch_js_1 = require("./singletons/fetch.cjs");
|
|
9
10
|
/**
|
|
10
11
|
* Get the API key from the environment.
|
|
11
12
|
* Precedence:
|
|
@@ -112,7 +113,7 @@ class BaseClient {
|
|
|
112
113
|
return [targetUrl, mutatedOptions];
|
|
113
114
|
}
|
|
114
115
|
async fetch(path, options) {
|
|
115
|
-
const response = await this.asyncCaller.
|
|
116
|
+
const response = await this.asyncCaller.call((0, fetch_js_1._getFetchImplementation)(), ...this.prepareFetchOptions(path, options));
|
|
116
117
|
if (response.status === 202 || response.status === 204) {
|
|
117
118
|
return undefined;
|
|
118
119
|
}
|
|
@@ -518,7 +519,7 @@ class RunsClient extends BaseClient {
|
|
|
518
519
|
if_not_exists: payload?.ifNotExists,
|
|
519
520
|
};
|
|
520
521
|
const endpoint = threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`;
|
|
521
|
-
const response = await this.asyncCaller.
|
|
522
|
+
const response = await this.asyncCaller.call((0, fetch_js_1._getFetchImplementation)(), ...this.prepareFetchOptions(endpoint, {
|
|
522
523
|
method: "POST",
|
|
523
524
|
json,
|
|
524
525
|
timeoutMs: null,
|
|
@@ -722,7 +723,7 @@ class RunsClient extends BaseClient {
|
|
|
722
723
|
options instanceof AbortSignal
|
|
723
724
|
? { signal: options }
|
|
724
725
|
: options;
|
|
725
|
-
const response = await this.asyncCaller.
|
|
726
|
+
const response = await this.asyncCaller.call((0, fetch_js_1._getFetchImplementation)(), ...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
|
|
726
727
|
method: "GET",
|
|
727
728
|
timeoutMs: null,
|
|
728
729
|
signal: opts?.signal,
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, RunStatus, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item, ThreadStatus } from "./schema.js";
|
|
1
|
+
import { Assistant, AssistantGraph, CancelAction, Config, DefaultValues, GraphSchema, Metadata, Run, RunStatus, Thread, ThreadState, Cron, AssistantVersion, Subgraphs, Checkpoint, SearchItemsResponse, ListNamespaceResponse, Item, ThreadStatus, CronCreateResponse, CronCreateForThreadResponse } 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
4
|
/**
|
|
@@ -46,14 +46,14 @@ export declare class CronsClient extends BaseClient {
|
|
|
46
46
|
* @param payload Payload for creating a cron job.
|
|
47
47
|
* @returns The created background run.
|
|
48
48
|
*/
|
|
49
|
-
createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<
|
|
49
|
+
createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateForThreadResponse>;
|
|
50
50
|
/**
|
|
51
51
|
*
|
|
52
52
|
* @param assistantId Assistant ID to use for this cron job.
|
|
53
53
|
* @param payload Payload for creating a cron job.
|
|
54
54
|
* @returns
|
|
55
55
|
*/
|
|
56
|
-
create(assistantId: string, payload?: CronsCreatePayload): Promise<
|
|
56
|
+
create(assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateResponse>;
|
|
57
57
|
/**
|
|
58
58
|
*
|
|
59
59
|
* @param cronId Cron ID of Cron job to delete.
|
package/dist/client.js
CHANGED
|
@@ -3,6 +3,7 @@ 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
5
|
import { getEnvironmentVariable } from "./utils/env.js";
|
|
6
|
+
import { _getFetchImplementation } from "./singletons/fetch.js";
|
|
6
7
|
/**
|
|
7
8
|
* Get the API key from the environment.
|
|
8
9
|
* Precedence:
|
|
@@ -108,7 +109,7 @@ class BaseClient {
|
|
|
108
109
|
return [targetUrl, mutatedOptions];
|
|
109
110
|
}
|
|
110
111
|
async fetch(path, options) {
|
|
111
|
-
const response = await this.asyncCaller.
|
|
112
|
+
const response = await this.asyncCaller.call(_getFetchImplementation(), ...this.prepareFetchOptions(path, options));
|
|
112
113
|
if (response.status === 202 || response.status === 204) {
|
|
113
114
|
return undefined;
|
|
114
115
|
}
|
|
@@ -511,7 +512,7 @@ export class RunsClient extends BaseClient {
|
|
|
511
512
|
if_not_exists: payload?.ifNotExists,
|
|
512
513
|
};
|
|
513
514
|
const endpoint = threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`;
|
|
514
|
-
const response = await this.asyncCaller.
|
|
515
|
+
const response = await this.asyncCaller.call(_getFetchImplementation(), ...this.prepareFetchOptions(endpoint, {
|
|
515
516
|
method: "POST",
|
|
516
517
|
json,
|
|
517
518
|
timeoutMs: null,
|
|
@@ -715,7 +716,7 @@ export class RunsClient extends BaseClient {
|
|
|
715
716
|
options instanceof AbortSignal
|
|
716
717
|
? { signal: options }
|
|
717
718
|
: options;
|
|
718
|
-
const response = await this.asyncCaller.
|
|
719
|
+
const response = await this.asyncCaller.call(_getFetchImplementation(), ...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
|
|
719
720
|
method: "GET",
|
|
720
721
|
timeoutMs: null,
|
|
721
722
|
signal: opts?.signal,
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = void 0;
|
|
3
|
+
exports.overrideFetchImplementation = exports.Client = void 0;
|
|
4
4
|
var client_js_1 = require("./client.cjs");
|
|
5
5
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
|
|
6
|
+
var fetch_js_1 = require("./singletons/fetch.cjs");
|
|
7
|
+
Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Client } from "./client.js";
|
|
2
2
|
export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadTask, ThreadState, ThreadStatus, Cron, Checkpoint, Interrupt, } from "./schema.js";
|
|
3
|
+
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
3
4
|
export type { OnConflictBehavior, Command } from "./types.js";
|
package/dist/index.js
CHANGED
package/dist/schema.d.ts
CHANGED
|
@@ -207,4 +207,20 @@ export interface SearchItem extends Item {
|
|
|
207
207
|
export interface SearchItemsResponse {
|
|
208
208
|
items: SearchItem[];
|
|
209
209
|
}
|
|
210
|
+
export interface CronCreateResponse {
|
|
211
|
+
cron_id: string;
|
|
212
|
+
assistant_id: string;
|
|
213
|
+
thread_id: string | undefined;
|
|
214
|
+
user_id: string;
|
|
215
|
+
payload: Record<string, unknown>;
|
|
216
|
+
schedule: string;
|
|
217
|
+
next_run_date: string;
|
|
218
|
+
end_time: string | undefined;
|
|
219
|
+
created_at: string;
|
|
220
|
+
updated_at: string;
|
|
221
|
+
metadata: Metadata;
|
|
222
|
+
}
|
|
223
|
+
export interface CronCreateForThreadResponse extends Omit<CronCreateResponse, "thread_id"> {
|
|
224
|
+
thread_id: string;
|
|
225
|
+
}
|
|
210
226
|
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._getFetchImplementation = exports.overrideFetchImplementation = void 0;
|
|
4
|
+
// Wrap the default fetch call due to issues with illegal invocations
|
|
5
|
+
// in some environments:
|
|
6
|
+
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
7
|
+
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
8
|
+
const DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
9
|
+
const LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for("lg:fetch_implementation");
|
|
10
|
+
/**
|
|
11
|
+
* Overrides the fetch implementation used for LangSmith calls.
|
|
12
|
+
* You should use this if you need to use an implementation of fetch
|
|
13
|
+
* other than the default global (e.g. for dealing with proxies).
|
|
14
|
+
* @param fetch The new fetch function to use.
|
|
15
|
+
*/
|
|
16
|
+
const overrideFetchImplementation = (fetch) => {
|
|
17
|
+
globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;
|
|
18
|
+
};
|
|
19
|
+
exports.overrideFetchImplementation = overrideFetchImplementation;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
const _getFetchImplementation = () => {
|
|
24
|
+
return (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
|
|
25
|
+
DEFAULT_FETCH_IMPLEMENTATION);
|
|
26
|
+
};
|
|
27
|
+
exports._getFetchImplementation = _getFetchImplementation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overrides the fetch implementation used for LangSmith calls.
|
|
3
|
+
* You should use this if you need to use an implementation of fetch
|
|
4
|
+
* other than the default global (e.g. for dealing with proxies).
|
|
5
|
+
* @param fetch The new fetch function to use.
|
|
6
|
+
*/
|
|
7
|
+
export declare const overrideFetchImplementation: (fetch: (...args: any[]) => any) => void;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const _getFetchImplementation: () => (...args: any[]) => any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Wrap the default fetch call due to issues with illegal invocations
|
|
2
|
+
// in some environments:
|
|
3
|
+
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
4
|
+
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
5
|
+
const DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
6
|
+
const LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for("lg:fetch_implementation");
|
|
7
|
+
/**
|
|
8
|
+
* Overrides the fetch implementation used for LangSmith calls.
|
|
9
|
+
* You should use this if you need to use an implementation of fetch
|
|
10
|
+
* other than the default global (e.g. for dealing with proxies).
|
|
11
|
+
* @param fetch The new fetch function to use.
|
|
12
|
+
*/
|
|
13
|
+
export const overrideFetchImplementation = (fetch) => {
|
|
14
|
+
globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const _getFetchImplementation = () => {
|
|
20
|
+
return (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
|
|
21
|
+
DEFAULT_FETCH_IMPLEMENTATION);
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "Client library for interacting with the LangGraph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@1.22.19",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build": "yarn clean && yarn lc_build --create-entrypoints --pre --tree-shaking",
|
|
10
10
|
"prepublish": "yarn run build",
|
|
11
11
|
"format": "prettier --write src",
|
|
12
|
-
"lint": "prettier --check src && tsc --noEmit"
|
|
12
|
+
"lint": "prettier --check src && tsc --noEmit",
|
|
13
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts"
|
|
13
14
|
},
|
|
14
15
|
"main": "index.js",
|
|
15
16
|
"license": "MIT",
|
|
@@ -20,12 +21,16 @@
|
|
|
20
21
|
"uuid": "^9.0.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
24
|
+
"@jest/globals": "^29.7.0",
|
|
23
25
|
"@langchain/scripts": "^0.1.4",
|
|
24
26
|
"@tsconfig/recommended": "^1.0.2",
|
|
27
|
+
"@types/jest": "^29.5.12",
|
|
25
28
|
"@types/node": "^20.12.12",
|
|
26
29
|
"@types/uuid": "^9.0.1",
|
|
27
30
|
"concat-md": "^0.5.1",
|
|
31
|
+
"jest": "^29.7.0",
|
|
28
32
|
"prettier": "^3.2.5",
|
|
33
|
+
"ts-jest": "^29.1.2",
|
|
29
34
|
"typedoc": "^0.26.1",
|
|
30
35
|
"typedoc-plugin-markdown": "^4.1.0",
|
|
31
36
|
"typescript": "^5.4.5"
|