@langchain/langgraph-api 0.0.14-experimental.0 → 0.0.14-experimental.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/ui/load.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import tailwind from "esbuild-plugin-tailwindcss";
|
|
|
10
10
|
const GRAPH_UI = {};
|
|
11
11
|
export async function registerGraphUi(defs, options) {
|
|
12
12
|
const textEncoder = new TextEncoder();
|
|
13
|
-
const renderTemplate = await fs.promises.readFile(path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./render.mts"), "utf-8");
|
|
13
|
+
const renderTemplate = await fs.promises.readFile(path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./render.template.mts"), "utf-8");
|
|
14
14
|
const projectDir = options.cwd;
|
|
15
15
|
const result = await Promise.all(Object.entries(defs).map(async ([agentName, uiUserPath]) => {
|
|
16
16
|
const ctx = await context({
|
|
@@ -20,7 +20,12 @@ export async function registerGraphUi(defs, options) {
|
|
|
20
20
|
platform: "browser",
|
|
21
21
|
target: "es2020",
|
|
22
22
|
jsx: "automatic",
|
|
23
|
-
external: [
|
|
23
|
+
external: [
|
|
24
|
+
"react",
|
|
25
|
+
"react-dom",
|
|
26
|
+
"@langchain/langgraph-sdk",
|
|
27
|
+
"@langchain/langgraph-sdk/react-ui",
|
|
28
|
+
],
|
|
24
29
|
plugins: [
|
|
25
30
|
{
|
|
26
31
|
name: "entrypoint",
|
|
@@ -70,22 +75,21 @@ export async function registerGraphUi(defs, options) {
|
|
|
70
75
|
return Object.fromEntries(result);
|
|
71
76
|
}
|
|
72
77
|
const api = new Hono();
|
|
73
|
-
api.post("/ui/:agent", zValidator("json", z.object({ name: z.string()
|
|
78
|
+
api.post("/ui/:agent", zValidator("json", z.object({ name: z.string() })), async (c) => {
|
|
74
79
|
const agent = c.req.param("agent");
|
|
75
80
|
const host = c.req.header("host");
|
|
76
|
-
const
|
|
81
|
+
const message = await c.req.valid("json");
|
|
77
82
|
const files = GRAPH_UI[agent];
|
|
78
83
|
if (!files?.length)
|
|
79
84
|
return c.text(`UI not found for agent "${agent}"`, 404);
|
|
80
|
-
const
|
|
81
|
-
const strRootId = JSON.stringify(body.shadowRootId);
|
|
85
|
+
const messageName = JSON.stringify(message.name);
|
|
82
86
|
const result = [];
|
|
83
87
|
for (const css of files.filter((i) => path.extname(i.basename) === ".css")) {
|
|
84
88
|
result.push(`<link rel="stylesheet" href="http://${host}/ui/${agent}/${css.basename}" />`);
|
|
85
89
|
}
|
|
86
90
|
const js = files.find((i) => path.extname(i.basename) === ".js");
|
|
87
91
|
if (js) {
|
|
88
|
-
result.push(`<script src="http://${host}/ui/${agent}/${js.basename}" onload='__LGUI_${agent}.render(${
|
|
92
|
+
result.push(`<script src="http://${host}/ui/${agent}/${js.basename}" onload='__LGUI_${agent}.render(${messageName}, "{{shadowRootId}}")'></script>`);
|
|
89
93
|
}
|
|
90
94
|
return c.text(result.join("\n"), {
|
|
91
95
|
headers: { "Content-Type": "text/html" },
|
package/package.json
CHANGED
|
File without changes
|