@langchain/langgraph-ui 0.0.19 → 0.0.20-dev.1

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.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ export declare function build(options: {
2
+ output: string;
3
+ }): Promise<void>;
4
+ export declare function watch(options: {
5
+ output: string;
6
+ }): Promise<void>;
package/dist/api.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ import * as fs from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ import * as bundler from "./bundler.mjs";
5
+ export async function build(options) {
6
+ const cwd = process.cwd();
7
+ const defs = z
8
+ .record(z.string(), z.string())
9
+ .parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
10
+ const config = z
11
+ .object({ shared: z.array(z.string()).optional() })
12
+ .parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
13
+ const fullPath = path.resolve(cwd, options.output);
14
+ const publicPath = path.resolve(fullPath, "ui");
15
+ const schemasPath = path.resolve(fullPath, "client.ui.schemas.json");
16
+ const schemas = {};
17
+ await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
18
+ const folder = path.resolve(publicPath, graphId);
19
+ await fs.mkdir(folder, { recursive: true });
20
+ const files = await bundler.build(graphId, { userPath, cwd, config });
21
+ await Promise.all(files.map(async (item) => {
22
+ const target = path.resolve(folder, item.basename);
23
+ await fs.writeFile(target, item.contents);
24
+ schemas[graphId] ??= { assets: [], name: graphId };
25
+ schemas[graphId].assets.push(path.relative(folder, target));
26
+ }));
27
+ }));
28
+ await fs.writeFile(schemasPath, JSON.stringify(schemas), {
29
+ encoding: "utf-8",
30
+ });
31
+ }
32
+ export async function watch(options) {
33
+ const cwd = process.cwd();
34
+ const defs = z
35
+ .record(z.string(), z.string())
36
+ .parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
37
+ const config = z
38
+ .object({ shared: z.array(z.string()).optional() })
39
+ .parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
40
+ const fullPath = path.resolve(cwd, options.output);
41
+ const publicPath = path.resolve(fullPath, "public");
42
+ const schemasPath = path.resolve(fullPath, "schemas.json");
43
+ const schemas = {};
44
+ let promiseSeq = Promise.resolve();
45
+ await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
46
+ const folder = path.resolve(publicPath, graphId);
47
+ await fs.mkdir(folder, { recursive: true });
48
+ await bundler.watch(graphId, { cwd, userPath, config }, (files) => {
49
+ promiseSeq = promiseSeq.then(async () => {
50
+ await Promise.all(files.map(async ({ basename, contents }) => {
51
+ const target = path.resolve(folder, basename);
52
+ await fs.writeFile(target, contents);
53
+ schemas[graphId] ??= { assets: [], name: graphId };
54
+ schemas[graphId].assets.push(path.relative(folder, target));
55
+ }));
56
+ await fs.writeFile(schemasPath, JSON.stringify(schemas), {
57
+ encoding: "utf-8",
58
+ });
59
+ }, (e) => console.error(e));
60
+ });
61
+ }));
62
+ }
package/dist/cli.mjs CHANGED
@@ -1,32 +1,13 @@
1
- import { watch } from "./bundler.mjs";
2
- import * as fs from "node:fs/promises";
3
- import * as url from "node:url";
4
- import * as path from "node:path";
5
- import { z } from "zod";
6
- const cmd = process.argv.at(-1);
7
- if (cmd !== "dev")
8
- throw new Error(`Invalid command "${cmd}"`);
9
- const cwd = process.cwd();
10
- const defs = z
11
- .record(z.string(), z.string())
12
- .parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
13
- const config = z
14
- .object({ shared: z.array(z.string()).optional() })
15
- .parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
16
- const UI_DIR = url.fileURLToPath(new URL("../../ui", import.meta.url));
17
- // clear the files in the ui directory
18
- await fs.rm(UI_DIR, { recursive: true, force: true });
19
- // watch the files in the ui directory
20
- await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
21
- const folder = path.resolve(UI_DIR, graphId);
22
- await fs.mkdir(folder, { recursive: true });
23
- let promiseSeq = Promise.resolve();
24
- await watch(graphId, { cwd, userPath, config }, (files) => {
25
- promiseSeq = promiseSeq.then(async () => {
26
- await Promise.all(files.map(async ({ basename, contents }) => {
27
- const target = path.join(folder, basename);
28
- await fs.writeFile(target, contents);
29
- }));
30
- }, (e) => console.error(e));
31
- });
32
- }));
1
+ #!/usr/bin/env node
2
+ import { Command } from "@commander-js/extra-typings";
3
+ import * as api from "./api.mjs";
4
+ const builder = new Command().name("langgraphjs-ui");
5
+ builder
6
+ .command("build")
7
+ .requiredOption("-o, --output <string>", "Output directory")
8
+ .action(api.build);
9
+ builder
10
+ .command("watch")
11
+ .requiredOption("-o, --output <string>", "Output directory")
12
+ .action(api.watch);
13
+ builder.parse();
package/dist/index.d.mts CHANGED
@@ -1 +1 @@
1
- export { build, watch } from "./bundler.mjs";
1
+ export { build, watch } from "./api.mjs";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { build, watch } from "./bundler.mjs";
1
+ export { build, watch } from "./api.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-ui",
3
- "version": "0.0.19",
3
+ "version": "0.0.20-dev.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^18.19.0 || >=20.16.0"
@@ -20,7 +20,9 @@
20
20
  "dependencies": {
21
21
  "zod": "^3.23.8",
22
22
  "esbuild": "^0.25.0",
23
- "esbuild-plugin-tailwindcss": "^2.0.1"
23
+ "esbuild-plugin-tailwindcss": "^2.0.1",
24
+ "@commander-js/extra-typings": "^13.0.0",
25
+ "commander": "^13.0.0"
24
26
  },
25
27
  "devDependencies": {
26
28
  "@types/react": "^19.0.8",