@langgraph-js/ui 4.0.0 → 4.0.2

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.
Binary file
Binary file
Binary file
package/cli.mjs CHANGED
@@ -18,7 +18,7 @@ console.log("启动 LangGraph UI...");
18
18
  console.log(`命令: vite preview ${args.join(" ")}`);
19
19
 
20
20
  // 使用 spawn 而不是 exec,以便更好地处理输入/输出流和参数
21
- const childProcess = spawn("npx", ["vite", "preview", ...args], {
21
+ const childProcess = spawn("npx", ["vite", "preview", "--config", "vite.config.preview.ts", ...args], {
22
22
  stdio: "inherit", // 继承父进程的 stdio,使输出直接显示在控制台
23
23
  shell: true,
24
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langgraph-js/ui",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -0,0 +1,38 @@
1
+ import { Plugin } from "vite";
2
+ import { Readable } from "stream";
3
+ import { app } from "@langgraph-js/open-smith/dist/app.js";
4
+ export const OpenSmithPlugin = () =>
5
+ ({
6
+ name: "open-smith",
7
+ configureServer(server) {
8
+ server.middlewares.use("/api/open-smith", async (req, res, next) => {
9
+ try {
10
+ const body = Readable.toWeb(req);
11
+ // Build a compatible Request for Fetch API
12
+ const url = `http://localhost${req.url}`;
13
+ const fetchRequest = new Request(url, {
14
+ method: req.method,
15
+ headers: req.headers as any,
16
+ body: req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? (body as any) : undefined,
17
+ ...(req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? { duplex: "half" as const } : {}),
18
+ });
19
+
20
+ // Proxy the request to app.basePath handler
21
+ const response = await app.basePath("/api/open-smith").fetch(fetchRequest);
22
+
23
+ // Set status and headers
24
+ res.statusCode = response.status;
25
+ // @ts-ignore
26
+ for (const [key, value] of response.headers.entries()) {
27
+ res.setHeader(key, value);
28
+ }
29
+
30
+ // Send the response body
31
+ const arrayBuffer = await response.arrayBuffer();
32
+ res.end(Buffer.from(arrayBuffer));
33
+ } catch (error) {
34
+ console.log(error);
35
+ }
36
+ });
37
+ },
38
+ }) as Plugin;
@@ -5,5 +5,5 @@
5
5
  "moduleResolution": "bundler",
6
6
  "allowSyntheticDefaultImports": true
7
7
  },
8
- "include": ["vite.config.ts"]
8
+ "include": ["vite.config.ts", "src/OpenSmithPlugin.ts"]
9
9
  }
@@ -0,0 +1,35 @@
1
+ import { defineConfig, Plugin } from "vite";
2
+ import basicSsl from "@vitejs/plugin-basic-ssl";
3
+ import { OpenSmithPlugin } from "./src/OpenSmithPlugin";
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig(({ mode }) => {
7
+ const isHttps = mode === "https";
8
+ return {
9
+ plugins: [isHttps ? basicSsl() : undefined, OpenSmithPlugin()],
10
+ resolve: {
11
+ alias: {
12
+ "@langgraph-js/sdk": new URL("../langgraph-client/src", import.meta.url).pathname,
13
+ "@/": new URL("./src/", import.meta.url).pathname,
14
+ },
15
+ },
16
+ optimizeDeps: {
17
+ exclude: ["@langgraph-js/ui", "@langgraph-js/sdk"],
18
+ },
19
+ server: {
20
+ proxy: {
21
+ "/api/langgraph": {
22
+ target: "http://localhost:8123",
23
+ changeOrigin: true,
24
+ rewrite: (path) => path.replace(/^\/api\/langgraph/, ""),
25
+ },
26
+ },
27
+ // headers: {
28
+ // "Cross-Origin-Opener-Policy": "same-origin",
29
+ // "Cross-Origin-Embedder-Policy": "require-corp",
30
+ // "cross-origin-resource-policy": "cross-origin",
31
+ // },
32
+ port: 1111,
33
+ },
34
+ };
35
+ });
package/vite.config.ts CHANGED
@@ -2,50 +2,13 @@ import react from "@vitejs/plugin-react";
2
2
  import { defineConfig, Plugin } from "vite";
3
3
  import basicSsl from "@vitejs/plugin-basic-ssl";
4
4
  import tailwindcss from "@tailwindcss/vite";
5
- import { app } from "@langgraph-js/open-smith/dist/app.js";
6
- import { Readable } from "stream";
7
- const OpenSmithPlugin = () =>
8
- ({
9
- name: "open-smith",
10
- configureServer(server) {
11
- process.env.NODE_ENV === "development" &&
12
- server.middlewares.use("/api/open-smith", async (req, res, next) => {
13
- try {
14
- const body = Readable.toWeb(req);
15
- // Build a compatible Request for Fetch API
16
- const url = `http://localhost${req.url}`;
17
- const fetchRequest = new Request(url, {
18
- method: req.method,
19
- headers: req.headers as any,
20
- body: req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? body : undefined,
21
- ...(req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? { duplex: "half" as const } : {}),
22
- });
23
-
24
- // Proxy the request to app.basePath handler
25
- const response = await app.basePath("/api/open-smith").fetch(fetchRequest);
26
-
27
- // Set status and headers
28
- res.statusCode = response.status;
29
- // @ts-ignore
30
- for (const [key, value] of response.headers.entries()) {
31
- res.setHeader(key, value);
32
- }
33
-
34
- // Send the response body
35
- const arrayBuffer = await response.arrayBuffer();
36
- res.end(Buffer.from(arrayBuffer));
37
- } catch (error) {
38
- console.log(error);
39
- }
40
- });
41
- },
42
- }) as Plugin;
5
+ import { OpenSmithPlugin } from "./src/OpenSmithPlugin";
43
6
 
44
7
  // https://vitejs.dev/config/
45
8
  export default defineConfig(({ mode }) => {
46
9
  const isHttps = mode === "https";
47
10
  return {
48
- plugins: [react(), tailwindcss(), isHttps ? basicSsl() : undefined, OpenSmithPlugin()],
11
+ plugins: [react(), tailwindcss(), isHttps ? basicSsl() : undefined],
49
12
  resolve: {
50
13
  alias: {
51
14
  "@langgraph-js/sdk": new URL("../langgraph-client/src", import.meta.url).pathname,