@langchain/langgraph-api 0.0.19 → 0.0.21
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/assistants.mjs +38 -36
- package/dist/api/runs.mjs +72 -30
- package/dist/api/store.mjs +28 -0
- package/dist/api/threads.mjs +13 -16
- package/dist/auth/custom.mjs +58 -0
- package/dist/auth/index.d.mts +40 -0
- package/dist/auth/index.mjs +120 -0
- package/dist/cli/spawn.d.mts +4 -0
- package/dist/cli/spawn.mjs +1 -0
- package/dist/graph/load.mjs +2 -2
- package/dist/queue.mjs +1 -1
- package/dist/schemas.mjs +1 -0
- package/dist/server.mjs +17 -4
- package/dist/storage/ops.mjs +318 -115
- package/dist/ui/load.mjs +7 -8
- package/package.json +15 -9
- package/dist/ui/bundler.d.mts +0 -21
- package/dist/ui/bundler.mjs +0 -86
- package/dist/ui/render.template.mts +0 -27
package/dist/ui/load.mjs
CHANGED
|
@@ -2,17 +2,16 @@ import { z } from "zod";
|
|
|
2
2
|
import { Hono } from "hono";
|
|
3
3
|
import { getMimeType } from "hono/utils/mime";
|
|
4
4
|
import { zValidator } from "@hono/zod-validator";
|
|
5
|
+
import { watch } from "@langchain/langgraph-ui";
|
|
5
6
|
import * as path from "node:path";
|
|
6
|
-
import { watch } from "./bundler.mjs";
|
|
7
7
|
const GRAPH_UI = {};
|
|
8
8
|
export async function registerGraphUi(defs, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
return Object.fromEntries(result);
|
|
9
|
+
await watch({
|
|
10
|
+
defs,
|
|
11
|
+
cwd: options.cwd,
|
|
12
|
+
config: options.config,
|
|
13
|
+
onOutput: (graphId, files) => (GRAPH_UI[graphId] = files),
|
|
14
|
+
});
|
|
16
15
|
}
|
|
17
16
|
export const api = new Hono();
|
|
18
17
|
api.post("/ui/:agent", zValidator("json", z.object({ name: z.string() })), async (c) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^18.19.0 || >=20.16.0"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"types": "./dist/cli/spawn.d.ts",
|
|
16
16
|
"default": "./dist/cli/spawn.mjs"
|
|
17
17
|
},
|
|
18
|
-
"./
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"default": "./dist/
|
|
18
|
+
"./auth": {
|
|
19
|
+
"types": "./dist/auth/index.d.ts",
|
|
20
|
+
"default": "./dist/auth/index.mjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
@@ -39,25 +39,31 @@
|
|
|
39
39
|
"stacktrace-parser": "^0.1.10",
|
|
40
40
|
"superjson": "^2.2.2",
|
|
41
41
|
"tsx": "^4.19.3",
|
|
42
|
-
"esbuild": "^0.25.0",
|
|
43
|
-
"esbuild-plugin-tailwindcss": "^2.0.1",
|
|
44
42
|
"uuid": "^10.0.0",
|
|
45
43
|
"winston": "^3.17.0",
|
|
46
44
|
"winston-console-format": "^1.0.8",
|
|
47
|
-
"zod": "^3.23.8"
|
|
45
|
+
"zod": "^3.23.8",
|
|
46
|
+
"@langchain/langgraph-ui": "0.0.21"
|
|
48
47
|
},
|
|
49
48
|
"peerDependencies": {
|
|
50
49
|
"@langchain/core": "^0.3.42",
|
|
51
50
|
"@langchain/langgraph": "^0.2.57",
|
|
52
51
|
"@langchain/langgraph-checkpoint": "^0.0.16",
|
|
52
|
+
"@langchain/langgraph-sdk": "^0.0.66",
|
|
53
53
|
"typescript": "^5.5.4"
|
|
54
54
|
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@langchain/langgraph-sdk": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
55
60
|
"devDependencies": {
|
|
56
|
-
"@langchain/langgraph-sdk": "^0.0.
|
|
61
|
+
"@langchain/langgraph-sdk": "^0.0.66",
|
|
57
62
|
"@types/babel__code-frame": "^7.0.6",
|
|
58
63
|
"@types/react": "^19.0.8",
|
|
59
64
|
"@types/react-dom": "^19.0.3",
|
|
60
65
|
"@types/node": "^22.2.0",
|
|
66
|
+
"jose": "^6.0.10",
|
|
61
67
|
"@types/uuid": "^10.0.0",
|
|
62
68
|
"postgres": "^3.4.5",
|
|
63
69
|
"prettier": "^3.3.3",
|
|
@@ -66,7 +72,7 @@
|
|
|
66
72
|
"scripts": {
|
|
67
73
|
"clean": "npx -y bun scripts/clean.mjs",
|
|
68
74
|
"build": "npx -y bun scripts/build.mjs",
|
|
69
|
-
"dev": "tsx ./tests/utils.server.mts",
|
|
75
|
+
"dev": "tsx ./tests/utils.server.mts --dev",
|
|
70
76
|
"typecheck": "tsc --noEmit",
|
|
71
77
|
"test": "vitest",
|
|
72
78
|
"test:parser": "vitest run ./tests/parser.test.mts --testTimeout 15000",
|
package/dist/ui/bundler.d.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type BuildOptions } from "esbuild";
|
|
2
|
-
export declare function build(agentName: string, args: {
|
|
3
|
-
cwd: string;
|
|
4
|
-
userPath: string;
|
|
5
|
-
config?: {
|
|
6
|
-
shared?: string[];
|
|
7
|
-
};
|
|
8
|
-
}): Promise<{
|
|
9
|
-
basename: string;
|
|
10
|
-
contents: Uint8Array;
|
|
11
|
-
}[]>;
|
|
12
|
-
export declare function watch(agentName: string, args: {
|
|
13
|
-
cwd: string;
|
|
14
|
-
userPath: string;
|
|
15
|
-
config?: {
|
|
16
|
-
shared?: string[];
|
|
17
|
-
};
|
|
18
|
-
}, onResult: (result: {
|
|
19
|
-
basename: string;
|
|
20
|
-
contents: Uint8Array;
|
|
21
|
-
}[]) => void): Promise<import("esbuild").BuildContext<BuildOptions>>;
|
package/dist/ui/bundler.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import * as url from "node:url";
|
|
3
|
-
import * as fs from "node:fs";
|
|
4
|
-
import { build as runBuild, context as runContext, } from "esbuild";
|
|
5
|
-
import tailwind from "esbuild-plugin-tailwindcss";
|
|
6
|
-
const renderTemplate = await fs.promises.readFile(url.fileURLToPath(new URL("./render.template.mts", import.meta.url)), "utf-8");
|
|
7
|
-
function entrypointPlugin(paths) {
|
|
8
|
-
const fullPath = path.resolve(paths.cwd, paths.userPath);
|
|
9
|
-
let relativeUiPath = path
|
|
10
|
-
.relative(paths.cwd, fullPath)
|
|
11
|
-
.replaceAll(path.sep, "/");
|
|
12
|
-
if (relativeUiPath.startsWith("../")) {
|
|
13
|
-
throw new Error(`UI path must be relative to the project root. Received: "${relativeUiPath}"`);
|
|
14
|
-
}
|
|
15
|
-
if (!relativeUiPath.startsWith("./"))
|
|
16
|
-
relativeUiPath = `./${relativeUiPath}`;
|
|
17
|
-
return {
|
|
18
|
-
name: "entrypoint",
|
|
19
|
-
setup(build) {
|
|
20
|
-
build.onResolve({ filter: /^entrypoint$/ }, () => ({
|
|
21
|
-
path: path.resolve(path.dirname(fullPath), "ui.entrypoint.tsx"),
|
|
22
|
-
namespace: "entrypoint-ns",
|
|
23
|
-
}));
|
|
24
|
-
build.onLoad({ filter: /.*/, namespace: "entrypoint-ns" }, () => ({
|
|
25
|
-
resolveDir: paths.cwd,
|
|
26
|
-
contents: [
|
|
27
|
-
`import ui from "${relativeUiPath}"`,
|
|
28
|
-
renderTemplate,
|
|
29
|
-
`export const render = createRenderer(ui)`,
|
|
30
|
-
].join("\n"),
|
|
31
|
-
loader: "tsx",
|
|
32
|
-
}));
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function registerPlugin(onEnd) {
|
|
37
|
-
const textEncoder = new TextEncoder();
|
|
38
|
-
return {
|
|
39
|
-
name: "require-transform",
|
|
40
|
-
setup(build) {
|
|
41
|
-
build.onEnd(async (result) => {
|
|
42
|
-
const newResult = [];
|
|
43
|
-
for (const item of result.outputFiles ?? []) {
|
|
44
|
-
let basename = path.basename(item.path);
|
|
45
|
-
let contents = item.contents;
|
|
46
|
-
if (basename === "entrypoint.js") {
|
|
47
|
-
contents = textEncoder.encode(item.text.replaceAll(`typeof require !== "undefined" ? require`, `typeof globalThis[Symbol.for("LGUI_REQUIRE")] !== "undefined" ? globalThis[Symbol.for("LGUI_REQUIRE")]`));
|
|
48
|
-
}
|
|
49
|
-
newResult.push({ basename, contents });
|
|
50
|
-
}
|
|
51
|
-
if (newResult.length > 0)
|
|
52
|
-
onEnd(newResult);
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function setup(agentName, args, onResult) {
|
|
58
|
-
return {
|
|
59
|
-
write: false,
|
|
60
|
-
outdir: path.resolve(args.cwd, "dist"),
|
|
61
|
-
entryPoints: ["entrypoint"],
|
|
62
|
-
bundle: true,
|
|
63
|
-
platform: "browser",
|
|
64
|
-
target: "es2020",
|
|
65
|
-
jsx: "automatic",
|
|
66
|
-
external: [
|
|
67
|
-
"react",
|
|
68
|
-
"react-dom",
|
|
69
|
-
"@langchain/langgraph-sdk",
|
|
70
|
-
"@langchain/langgraph-sdk/react-ui",
|
|
71
|
-
...(args.config?.shared ?? []),
|
|
72
|
-
],
|
|
73
|
-
plugins: [tailwind(), entrypointPlugin(args), registerPlugin(onResult)],
|
|
74
|
-
globalName: `__LGUI_${agentName}`,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
export async function build(agentName, args) {
|
|
78
|
-
let results = [];
|
|
79
|
-
await runBuild(setup(agentName, args, (result) => (results = result)));
|
|
80
|
-
return results;
|
|
81
|
-
}
|
|
82
|
-
export async function watch(agentName, args, onResult) {
|
|
83
|
-
const ctx = await runContext(setup(agentName, args, onResult));
|
|
84
|
-
await ctx.watch();
|
|
85
|
-
return ctx;
|
|
86
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ComponentClass, FunctionComponent } from "react";
|
|
2
|
-
|
|
3
|
-
const STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
[STORE_SYMBOL]: {
|
|
8
|
-
respond: (
|
|
9
|
-
shadowRootId: string,
|
|
10
|
-
component: FunctionComponent | ComponentClass,
|
|
11
|
-
renderEl: HTMLElement,
|
|
12
|
-
) => void;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
function createRenderer(
|
|
19
|
-
components: Record<string, FunctionComponent | ComponentClass>,
|
|
20
|
-
) {
|
|
21
|
-
return (name: string, shadowRootId: string) => {
|
|
22
|
-
const root = document.getElementById(shadowRootId)!.shadowRoot;
|
|
23
|
-
const renderEl = document.createElement("div");
|
|
24
|
-
root!.appendChild(renderEl);
|
|
25
|
-
window[STORE_SYMBOL].respond(shadowRootId, components[name], renderEl);
|
|
26
|
-
};
|
|
27
|
-
}
|