@langgraph-js/ui 4.0.1 → 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.
- package/.langgraph_api/trace.db-shm +0 -0
- package/.langgraph_api/trace.db-wal +0 -0
- package/cli.mjs +1 -1
- package/package.json +1 -1
- package/src/OpenSmithPlugin.ts +38 -0
- package/tsconfig.node.json +1 -1
- package/vite.config.preview.ts +35 -0
- package/vite.config.ts +2 -38
|
Binary file
|
|
File without changes
|
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
|
@@ -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;
|
package/tsconfig.node.json
CHANGED
|
@@ -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,49 +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 {
|
|
6
|
-
const OpenSmithPlugin = () =>
|
|
7
|
-
({
|
|
8
|
-
name: "open-smith",
|
|
9
|
-
configureServer(server) {
|
|
10
|
-
server.middlewares.use("/api/open-smith", async (req, res, next) => {
|
|
11
|
-
const { app } = await import("@langgraph-js/open-smith/dist/app.js");
|
|
12
|
-
try {
|
|
13
|
-
const body = Readable.toWeb(req);
|
|
14
|
-
// Build a compatible Request for Fetch API
|
|
15
|
-
const url = `http://localhost${req.url}`;
|
|
16
|
-
const fetchRequest = new Request(url, {
|
|
17
|
-
method: req.method,
|
|
18
|
-
headers: req.headers as any,
|
|
19
|
-
body: req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? body : undefined,
|
|
20
|
-
...(req.method && !["GET", "HEAD"].includes(req.method.toUpperCase()) && body ? { duplex: "half" as const } : {}),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Proxy the request to app.basePath handler
|
|
24
|
-
const response = await app.basePath("/api/open-smith").fetch(fetchRequest);
|
|
25
|
-
|
|
26
|
-
// Set status and headers
|
|
27
|
-
res.statusCode = response.status;
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
for (const [key, value] of response.headers.entries()) {
|
|
30
|
-
res.setHeader(key, value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Send the response body
|
|
34
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
35
|
-
res.end(Buffer.from(arrayBuffer));
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.log(error);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
}) as Plugin;
|
|
5
|
+
import { OpenSmithPlugin } from "./src/OpenSmithPlugin";
|
|
42
6
|
|
|
43
7
|
// https://vitejs.dev/config/
|
|
44
8
|
export default defineConfig(({ mode }) => {
|
|
45
9
|
const isHttps = mode === "https";
|
|
46
10
|
return {
|
|
47
|
-
plugins: [react(), tailwindcss(), isHttps ? basicSsl() : undefined
|
|
11
|
+
plugins: [react(), tailwindcss(), isHttps ? basicSsl() : undefined],
|
|
48
12
|
resolve: {
|
|
49
13
|
alias: {
|
|
50
14
|
"@langgraph-js/sdk": new URL("../langgraph-client/src", import.meta.url).pathname,
|