diff --git a/.changeset/little-tips-check.md b/.changeset/little-tips-check.md
new file mode 100644
index 000000000..68ac42b62
--- /dev/null
+++ b/.changeset/little-tips-check.md
@@ -0,0 +1,7 @@
+---
+"@langchain/langgraph-api": patch
+"@langchain/langgraph-cli": patch
+"@langchain/langgraph-ui": patch
+---
+
+Support gen UI components namespaced with a hyphen
diff --git a/libs/langgraph-api/src/ui/load.mts b/libs/langgraph-api/src/ui/load.mts
index b70f6837a..91bd0e61a 100644
--- a/libs/langgraph-api/src/ui/load.mts
+++ b/libs/langgraph-api/src/ui/load.mts
@@ -44,10 +44,11 @@ api.post(
);
}
+ const stableName = agent.replace(/[^a-zA-Z0-9]/g, "_");
const js = files.find((i) => path.extname(i.basename) === ".js");
if (js) {
result.push(
- ``
+ ``
);
}
diff --git a/libs/langgraph-api/tests/api.test.mts b/libs/langgraph-api/tests/api.test.mts
index ee6a73460..b159dde44 100644
--- a/libs/langgraph-api/tests/api.test.mts
+++ b/libs/langgraph-api/tests/api.test.mts
@@ -2532,9 +2532,12 @@ it("dynamic graph", async () => {
});
it("generative ui", async () => {
- const ui = await client["~ui"].getComponent("agent", "weather-component");
+ const ui = await client["~ui"].getComponent(
+ "agent-alias",
+ "weather-component"
+ );
expect(ui).toContain(
- ``
+ ``
);
const match = /src="(?[^"]+)"/.exec(ui);
diff --git a/libs/langgraph-api/tests/graphs/langgraph.json b/libs/langgraph-api/tests/graphs/langgraph.json
index ea8f8540c..9a8107791 100644
--- a/libs/langgraph-api/tests/graphs/langgraph.json
+++ b/libs/langgraph-api/tests/graphs/langgraph.json
@@ -10,7 +10,7 @@
"agent_simple": "./agent_simple.mts:graph"
},
"ui": {
- "agent": "./agent/ui.tsx"
+ "agent-alias": "./agent/ui.tsx"
},
"http": {
"app": "./http.mts:app"
diff --git a/libs/langgraph-ui/src/bundler.mts b/libs/langgraph-ui/src/bundler.mts
index ef5b17630..15d6d2c2c 100644
--- a/libs/langgraph-ui/src/bundler.mts
+++ b/libs/langgraph-ui/src/bundler.mts
@@ -102,7 +102,7 @@ function setup(
...(args.config?.shared ?? []),
],
plugins: [tailwind(), entrypointPlugin(args), registerPlugin(onResult)],
- globalName: `__LGUI_${agentName}`,
+ globalName: `__LGUI_${agentName.replace(/[^a-zA-Z0-9]/g, "_")}`,
};
}