chore: add installed langgraph version to js server (#1465)

Co-authored-by: Tat Dat Duong <david@duong.cz>
This commit is contained in:
lc-arjun
2025-07-30 06:54:06 -07:00
committed by GitHub
parent 7054a6aa59
commit 77b21d534a
3 changed files with 18 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@langchain/langgraph-api": patch
---
add installed langgraph version to info endpoint for js server
+12
View File
@@ -12,6 +12,7 @@ const packageJsonPath = path.resolve(
);
let version: string;
let langgraph_js_version: string;
try {
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
version = packageJson.version;
@@ -19,6 +20,16 @@ try {
console.warn("Could not determine version of langgraph-api");
}
// Get the installed version of @langchain/langgraph
try {
const langgraphPkg = await import("@langchain/langgraph/package.json");
if (langgraphPkg?.default?.version) {
langgraph_js_version = langgraphPkg.default.version;
}
} catch {
console.warn("Could not determine version of @langchain/langgraph");
}
// read env variable
const env = process.env;
@@ -42,6 +53,7 @@ api.get("/info", (c) => {
})();
return c.json({
version,
langgraph_js_version,
context: "js",
flags: {
assistants: true,
+1 -3
View File
@@ -27,6 +27,7 @@ import { registerHttp } from "./http/custom.mjs";
import { cors, ensureContentType } from "./http/middleware.mjs";
import { bindLoopbackFetch } from "./loopback.mjs";
import { checkLangGraphSemver } from "./semver/index.mjs";
import { getConfig } from "@langchain/langgraph";
export const StartServerSchema = z.object({
port: z.number(),
@@ -99,9 +100,6 @@ export async function startServer(options: z.infer<typeof StartServerSchema>) {
logger.info(`Registering graphs from ${options.cwd}`);
await registerFromEnv(options.graphs, { cwd: options.cwd });
// Make sure to register the runtime formatter after we've loaded the graphs
// to ensure that we're not loading `@langchain/langgraph` from different path.
const { getConfig } = await import("@langchain/langgraph");
registerRuntimeLogFormatter((info) => {
const config = getConfig();
if (config == null) return info;