@langchain/langgraph-api 0.0.32 → 0.0.34

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/server.mjs CHANGED
@@ -90,6 +90,8 @@ export async function startServer(options) {
90
90
  truncate({ runs, threads, assistants, checkpointer, store });
91
91
  return c.json({ ok: true });
92
92
  });
93
+ app.use(cors(options.http?.cors));
94
+ app.use(requestLogger());
93
95
  if (options.auth?.path) {
94
96
  logger.info(`Loading auth from ${options.auth.path}`);
95
97
  await registerAuth(options.auth, { cwd: options.cwd });
@@ -100,8 +102,6 @@ export async function startServer(options) {
100
102
  const { api } = await registerHttp(options.http.app, { cwd: options.cwd });
101
103
  app.route("/", api);
102
104
  }
103
- app.use(cors(options.http?.cors));
104
- app.use(requestLogger());
105
105
  app.use(ensureContentType());
106
106
  if (!options.http?.disable_meta)
107
107
  app.route("/", meta);
@@ -256,7 +256,7 @@ export declare class Runs {
256
256
  static get(runId: string, thread_id: string | undefined, auth: AuthContext | undefined): Promise<Run | null>;
257
257
  static delete(run_id: string, thread_id: string | undefined, auth: AuthContext | undefined): Promise<string | null>;
258
258
  static wait(runId: string, threadId: string | undefined, auth: AuthContext | undefined): Promise<unknown>;
259
- static join(runId: string, threadId: string, auth: AuthContext | undefined): Promise<{} | undefined>;
259
+ static join(runId: string, threadId: string, auth: AuthContext | undefined): Promise<{} | null>;
260
260
  static cancel(threadId: string | undefined, runIds: string[], options: {
261
261
  action?: "interrupt" | "rollback";
262
262
  }, auth: AuthContext | undefined): Promise<void>;
@@ -596,6 +596,13 @@ export class Threads {
596
596
  if (!isAuthMatching(thread["metadata"], filters)) {
597
597
  throw new HTTPException(403);
598
598
  }
599
+ // do a check if there are no pending runs
600
+ await conn.with(async (STORE) => {
601
+ if (Object.values(STORE.runs).some((run) => run.thread_id === threadId &&
602
+ (run.status === "pending" || run.status === "running"))) {
603
+ throw new HTTPException(409, { message: "Thread is busy" });
604
+ }
605
+ });
599
606
  const graphId = thread.metadata?.graph_id;
600
607
  if (graphId == null) {
601
608
  throw new HTTPException(400, {
@@ -903,7 +910,7 @@ export class Runs {
903
910
  if (lastChunk != null)
904
911
  return lastChunk;
905
912
  const thread = await Threads.get(threadId, auth);
906
- return thread.values;
913
+ return thread.values ?? null;
907
914
  }
908
915
  static async cancel(threadId, runIds, options, auth) {
909
916
  return conn.with(async (STORE) => {
@@ -932,6 +939,11 @@ export class Runs {
932
939
  if (control || action !== "rollback") {
933
940
  run.status = "interrupted";
934
941
  run.updated_at = new Date();
942
+ const thread = STORE.threads[run.thread_id];
943
+ if (thread) {
944
+ thread.status = "idle";
945
+ thread.updated_at = new Date();
946
+ }
935
947
  }
936
948
  else {
937
949
  logger.info("Eagerly deleting unscheduled run with rollback action", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-api",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^18.19.0 || >=20.16.0"
@@ -53,7 +53,7 @@
53
53
  "winston": "^3.17.0",
54
54
  "winston-console-format": "^1.0.8",
55
55
  "zod": "^3.23.8",
56
- "@langchain/langgraph-ui": "0.0.32"
56
+ "@langchain/langgraph-ui": "0.0.34"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@langchain/core": "^0.3.42",