@langchain/langgraph-api 0.0.41 → 0.0.42
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/api/meta.mjs +2 -1
- package/dist/command.d.mts +1 -1
- package/dist/graph/parser/schema/types.template.mts +31 -34
- package/dist/http/middleware.mjs +1 -1
- package/dist/semver/index.mjs +2 -1
- package/dist/state.mjs +1 -3
- package/dist/storage/ops.d.mts +2 -2
- package/dist/stream.mjs +1 -1
- package/dist/ui/load.mjs +2 -1
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +12 -0
- package/package.json +15 -15
package/dist/api/meta.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
3
4
|
import * as url from "node:url";
|
|
4
5
|
const api = new Hono();
|
|
5
6
|
// Get the version using the same pattern as semver/index.mts
|
|
6
|
-
const packageJsonPath = url.fileURLToPath(
|
|
7
|
+
const packageJsonPath = path.resolve(url.fileURLToPath(import.meta.url), "../../../package.json");
|
|
7
8
|
let version;
|
|
8
9
|
try {
|
|
9
10
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
|
package/dist/command.d.mts
CHANGED
|
@@ -8,4 +8,4 @@ export interface RunCommand {
|
|
|
8
8
|
update?: Record<string, unknown> | [string, unknown][];
|
|
9
9
|
resume?: unknown;
|
|
10
10
|
}
|
|
11
|
-
export declare const getLangGraphCommand: (command: RunCommand) => Command<unknown>;
|
|
11
|
+
export declare const getLangGraphCommand: (command: RunCommand) => Command<unknown, Record<string, unknown>, string>;
|
|
@@ -20,12 +20,11 @@ type AnyGraph = {
|
|
|
20
20
|
|
|
21
21
|
type Wrap<T> = (a: T) => void;
|
|
22
22
|
type MatchBaseMessage<T> = T extends BaseMessage ? BaseMessage : never;
|
|
23
|
-
type MatchBaseMessageArray<T> =
|
|
24
|
-
|
|
25
|
-
?
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
: never;
|
|
23
|
+
type MatchBaseMessageArray<T> = T extends Array<infer C>
|
|
24
|
+
? Wrap<MatchBaseMessage<C>> extends Wrap<BaseMessage>
|
|
25
|
+
? BaseMessage[]
|
|
26
|
+
: never
|
|
27
|
+
: never;
|
|
29
28
|
|
|
30
29
|
type Defactorify<T> = T extends (...args: any[]) => infer R
|
|
31
30
|
? Awaited<R>
|
|
@@ -35,32 +34,31 @@ type Defactorify<T> = T extends (...args: any[]) => infer R
|
|
|
35
34
|
type Inspect<T, TDepth extends Array<0> = []> = TDepth extends [0, 0, 0]
|
|
36
35
|
? any
|
|
37
36
|
: T extends unknown
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
? {
|
|
38
|
+
[K in keyof T]: 0 extends 1 & T[K]
|
|
39
|
+
? T[K]
|
|
40
|
+
: Wrap<MatchBaseMessageArray<T[K]>> extends Wrap<BaseMessage[]>
|
|
41
|
+
? BaseMessage[]
|
|
42
|
+
: Wrap<MatchBaseMessage<T[K]>> extends Wrap<BaseMessage>
|
|
43
|
+
? BaseMessage
|
|
44
|
+
: Inspect<T[K], [0, ...TDepth]>;
|
|
45
|
+
}
|
|
46
|
+
: never;
|
|
48
47
|
|
|
49
48
|
type ReflectCompiled<T> = T extends { RunInput: infer S; RunOutput: infer U }
|
|
50
49
|
? { state: S; update: U }
|
|
51
50
|
: T extends { "~InputType": infer InputType; "~OutputType": infer OutputType }
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
? { state: OutputType; update: InputType }
|
|
52
|
+
: never;
|
|
54
53
|
|
|
55
54
|
// @ts-expect-error
|
|
56
|
-
type Reflect<T> =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
: never;
|
|
55
|
+
type Reflect<T> = Defactorify<T> extends infer DT
|
|
56
|
+
? DT extends {
|
|
57
|
+
compile(...args: any[]): infer Compiled;
|
|
58
|
+
}
|
|
59
|
+
? ReflectCompiled<Compiled>
|
|
60
|
+
: ReflectCompiled<DT>
|
|
61
|
+
: never;
|
|
64
62
|
|
|
65
63
|
type BuilderReflectCompiled<T> = T extends {
|
|
66
64
|
builder: {
|
|
@@ -77,14 +75,13 @@ type BuilderReflectCompiled<T> = T extends {
|
|
|
77
75
|
: never;
|
|
78
76
|
|
|
79
77
|
// @ts-expect-error
|
|
80
|
-
type BuilderReflect<T> =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
: never;
|
|
78
|
+
type BuilderReflect<T> = Defactorify<T> extends infer DT
|
|
79
|
+
? DT extends {
|
|
80
|
+
compile(...args: any[]): infer Compiled;
|
|
81
|
+
}
|
|
82
|
+
? BuilderReflectCompiled<Compiled>
|
|
83
|
+
: BuilderReflectCompiled<DT>
|
|
84
|
+
: never;
|
|
88
85
|
|
|
89
86
|
// @ts-expect-error
|
|
90
87
|
type FilterAny<T> = 0 extends 1 & T ? never : T;
|
package/dist/http/middleware.mjs
CHANGED
|
@@ -16,7 +16,7 @@ export const cors = (cors) => {
|
|
|
16
16
|
return origin;
|
|
17
17
|
return undefined;
|
|
18
18
|
}
|
|
19
|
-
:
|
|
19
|
+
: cors.allow_origins ?? [];
|
|
20
20
|
if (cors.expose_headers?.length) {
|
|
21
21
|
const headersSet = new Set(cors.expose_headers.map((h) => h.toLowerCase()));
|
|
22
22
|
if (!headersSet.has("content-location")) {
|
package/dist/semver/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as url from "node:url";
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
3
4
|
import * as semver from "semver";
|
|
4
|
-
const packageJsonPath = url.fileURLToPath(
|
|
5
|
+
const packageJsonPath = path.resolve(url.fileURLToPath(import.meta.url), "../../../package.json");
|
|
5
6
|
export async function checkSemver(packages) {
|
|
6
7
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
|
|
7
8
|
const peerDependencies = packageJson.peerDependencies ?? {};
|
package/dist/state.mjs
CHANGED
|
@@ -15,13 +15,11 @@ export const stateSnapshotToThreadState = (state) => {
|
|
|
15
15
|
path: task.path,
|
|
16
16
|
// TODO: too many type assertions, check if this is actually correct
|
|
17
17
|
checkpoint: task.state != null && "configurable" in task.state
|
|
18
|
-
?
|
|
18
|
+
? task.state.configurable ?? null
|
|
19
19
|
: null,
|
|
20
20
|
state: task.state != null && isStateSnapshot(task.state)
|
|
21
21
|
? stateSnapshotToThreadState(task.state)
|
|
22
22
|
: null,
|
|
23
|
-
// TODO: add missing result to the library
|
|
24
|
-
// @ts-expect-error
|
|
25
23
|
result: task.result ?? null,
|
|
26
24
|
})),
|
|
27
25
|
metadata: state.metadata,
|
package/dist/storage/ops.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { FileSystemPersistence } from "./persist.mjs";
|
|
|
5
5
|
export type Metadata = Record<string, unknown>;
|
|
6
6
|
export type ThreadStatus = "idle" | "busy" | "interrupted" | "error";
|
|
7
7
|
export type RunStatus = "pending" | "running" | "error" | "success" | "timeout" | "interrupted";
|
|
8
|
-
export type StreamMode = "values" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "debug";
|
|
8
|
+
export type StreamMode = "values" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "debug" | "tasks" | "checkpoints";
|
|
9
9
|
export type MultitaskStrategy = "reject" | "rollback" | "interrupt" | "enqueue";
|
|
10
10
|
export type OnConflictBehavior = "raise" | "do_nothing";
|
|
11
11
|
export type IfNotExists = "create" | "reject";
|
|
@@ -183,7 +183,7 @@ interface ThreadTask {
|
|
|
183
183
|
interrupts: Record<string, unknown>[];
|
|
184
184
|
checkpoint: Checkpoint | null;
|
|
185
185
|
state: ThreadState | null;
|
|
186
|
-
result:
|
|
186
|
+
result: unknown | null;
|
|
187
187
|
}
|
|
188
188
|
export interface ThreadState {
|
|
189
189
|
values: Record<string, unknown>;
|
package/dist/stream.mjs
CHANGED
|
@@ -103,7 +103,7 @@ export async function* streamState(run, options) {
|
|
|
103
103
|
: undefined;
|
|
104
104
|
const events = graph.streamEvents(kwargs.command != null
|
|
105
105
|
? getLangGraphCommand(kwargs.command)
|
|
106
|
-
:
|
|
106
|
+
: kwargs.input ?? null, {
|
|
107
107
|
version: "v2",
|
|
108
108
|
interruptAfter: kwargs.interrupt_after,
|
|
109
109
|
interruptBefore: kwargs.interrupt_before,
|
package/dist/ui/load.mjs
CHANGED
|
@@ -26,9 +26,10 @@ api.post("/ui/:agent", zValidator("json", z.object({ name: z.string() })), async
|
|
|
26
26
|
for (const css of files.filter((i) => path.extname(i.basename) === ".css")) {
|
|
27
27
|
result.push(`<link rel="stylesheet" href="http://${host}/ui/${agent}/${css.basename}" />`);
|
|
28
28
|
}
|
|
29
|
+
const stableName = agent.replace(/[^a-zA-Z0-9]/g, "_");
|
|
29
30
|
const js = files.find((i) => path.extname(i.basename) === ".js");
|
|
30
31
|
if (js) {
|
|
31
|
-
result.push(`<script src="http://${host}/ui/${agent}/${js.basename}" onload='__LGUI_${
|
|
32
|
+
result.push(`<script src="http://${host}/ui/${agent}/${js.basename}" onload='__LGUI_${stableName}.render(${messageName}, "{{shadowRootId}}")'></script>`);
|
|
32
33
|
}
|
|
33
34
|
return c.text(result.join("\n"), {
|
|
34
35
|
headers: { "Content-Type": "text/html" },
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { configDefaults, defineConfig } from "vitest/config";
|
|
2
|
+
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
3
|
+
export default defineConfig(() => {
|
|
4
|
+
/** @type {import("vitest/config").UserConfigExport} */
|
|
5
|
+
return {
|
|
6
|
+
test: {
|
|
7
|
+
hideSkippedTests: true,
|
|
8
|
+
testTimeout: 30_000,
|
|
9
|
+
fileParallelism: false,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^18.19.0 || >=20.16.0"
|
|
@@ -38,14 +38,13 @@
|
|
|
38
38
|
"url": "git@github.com:langchain-ai/langgraphjs-api.git"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"clean": "
|
|
42
|
-
"build": "
|
|
41
|
+
"clean": "rm -rf dist/ .turbo/ ./tests/graphs/.langgraph_api/",
|
|
42
|
+
"build": "yarn turbo:command build:internal --filter=@langchain/langgraph-api",
|
|
43
|
+
"build:internal": "yarn clean && node scripts/build.mjs",
|
|
43
44
|
"dev": "tsx ./tests/utils.server.mts --dev",
|
|
44
45
|
"prepack": "yarn run build",
|
|
45
46
|
"typecheck": "tsc --noEmit",
|
|
46
|
-
"test": "vitest",
|
|
47
|
-
"test:parser": "vitest run ./tests/parser.test.mts --testTimeout 15000",
|
|
48
|
-
"test:api": "npx -y bun scripts/test.mjs",
|
|
47
|
+
"test": "vitest run",
|
|
49
48
|
"format": "prettier --write .",
|
|
50
49
|
"format:check": "prettier --check ."
|
|
51
50
|
},
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
"@babel/code-frame": "^7.26.2",
|
|
54
53
|
"@hono/node-server": "^1.12.0",
|
|
55
54
|
"@hono/zod-validator": "^0.2.2",
|
|
56
|
-
"@langchain/langgraph-ui": "
|
|
55
|
+
"@langchain/langgraph-ui": "workspace:*",
|
|
57
56
|
"@types/json-schema": "^7.0.15",
|
|
58
57
|
"@typescript/vfs": "^1.6.0",
|
|
59
58
|
"dedent": "^1.5.3",
|
|
@@ -85,19 +84,20 @@
|
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
87
86
|
"@langchain/core": "^0.3.59",
|
|
88
|
-
"@langchain/langgraph": "
|
|
89
|
-
"@langchain/langgraph-checkpoint": "
|
|
90
|
-
"@langchain/langgraph-sdk": "
|
|
87
|
+
"@langchain/langgraph": "workspace:*",
|
|
88
|
+
"@langchain/langgraph-checkpoint": "workspace:*",
|
|
89
|
+
"@langchain/langgraph-sdk": "workspace:*",
|
|
91
90
|
"@types/babel__code-frame": "^7.0.6",
|
|
92
|
-
"@types/node": "^
|
|
91
|
+
"@types/node": "^18.15.11",
|
|
93
92
|
"@types/react": "^19.0.8",
|
|
94
93
|
"@types/react-dom": "^19.0.3",
|
|
95
94
|
"@types/semver": "^7.7.0",
|
|
96
95
|
"@types/uuid": "^10.0.0",
|
|
97
96
|
"jose": "^6.0.10",
|
|
98
97
|
"postgres": "^3.4.5",
|
|
99
|
-
"prettier": "^
|
|
100
|
-
"typescript": "^
|
|
101
|
-
"vitest": "^3.
|
|
98
|
+
"prettier": "^2.8.3",
|
|
99
|
+
"typescript": "^4.9.5 || ^5.4.5",
|
|
100
|
+
"vitest": "^3.1.2",
|
|
101
|
+
"wait-port": "^1.1.0"
|
|
102
102
|
}
|
|
103
|
-
}
|
|
103
|
+
}
|