@langchain/langgraph-api 0.0.37 → 0.0.39

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.
@@ -1,12 +1,12 @@
1
- import { Hono } from "hono";
2
1
  import { zValidator } from "@hono/zod-validator";
2
+ import { Hono } from "hono";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import { z } from "zod";
5
- import { getAssistantId, getGraph, getCachedStaticGraphSchema, } from "../graph/load.mjs";
5
+ import { getAssistantId, getCachedStaticGraphSchema, getGraph, } from "../graph/load.mjs";
6
6
  import { getRuntimeGraphSchema } from "../graph/parser/index.mjs";
7
- import { Assistants } from "../storage/ops.mjs";
8
- import * as schemas from "../schemas.mjs";
9
7
  import { HTTPException } from "hono/http-exception";
8
+ import * as schemas from "../schemas.mjs";
9
+ import { Assistants } from "../storage/ops.mjs";
10
10
  const api = new Hono();
11
11
  const RunnableConfigSchema = z.object({
12
12
  tags: z.array(z.string()).optional(),
@@ -46,14 +46,19 @@ api.post("/assistants/search", zValidator("json", schemas.AssistantSearchRequest
46
46
  // Search Assistants
47
47
  const payload = c.req.valid("json");
48
48
  const result = [];
49
+ let total = 0;
49
50
  for await (const item of Assistants.search({
50
51
  graph_id: payload.graph_id,
51
52
  metadata: payload.metadata,
52
53
  limit: payload.limit ?? 10,
53
54
  offset: payload.offset ?? 0,
54
55
  }, c.var.auth)) {
55
- result.push(item);
56
+ result.push(item.assistant);
57
+ if (total === 0) {
58
+ total = item.total;
59
+ }
56
60
  }
61
+ c.res.headers.set("X-Pagination-Total", total.toString());
57
62
  return c.json(result);
58
63
  });
59
64
  api.get("/assistants/:assistant_id", async (c) => {
package/dist/api/meta.mjs CHANGED
@@ -1,5 +1,26 @@
1
1
  import { Hono } from "hono";
2
2
  const api = new Hono();
3
- api.get("/info", (c) => c.json({ flags: { assistants: true, crons: false } }));
3
+ // read env variable
4
+ const env = process.env;
5
+ api.get("/info", (c) => {
6
+ const langsmithApiKey = env["LANGSMITH_API_KEY"] || env["LANGCHAIN_API_KEY"];
7
+ const langsmithTracing = (() => {
8
+ if (langsmithApiKey) {
9
+ // Check if any tracing variable is explicitly set to "false"
10
+ const tracingVars = [
11
+ env["LANGCHAIN_TRACING_V2"],
12
+ env["LANGCHAIN_TRACING"],
13
+ env["LANGSMITH_TRACING_V2"],
14
+ env["LANGSMITH_TRACING"],
15
+ ];
16
+ // Return true unless explicitly disabled
17
+ return !tracingVars.some((val) => val === "false" || val === "False");
18
+ }
19
+ return undefined;
20
+ })();
21
+ return c.json({
22
+ flags: { assistants: true, crons: false, langsmith: !!langsmithTracing },
23
+ });
24
+ });
4
25
  api.get("/ok", (c) => c.json({ ok: true }));
5
26
  export default api;
@@ -1,6 +1,6 @@
1
1
  import { HTTPException } from "hono/http-exception";
2
2
  import * as url from "node:url";
3
- import * as path from "path";
3
+ import * as path from "node:path";
4
4
  let CUSTOM_AUTH;
5
5
  let DISABLE_STUDIO_AUTH = false;
6
6
  export const isAuthRegistered = () => CUSTOM_AUTH != null;
@@ -4,7 +4,7 @@ import type { GraphSchema, GraphSpec } from "./parser/index.mjs";
4
4
  export declare const GRAPHS: Record<string, CompiledGraph<string> | CompiledGraphFactory<string>>;
5
5
  export declare const GRAPH_SPEC: Record<string, GraphSpec>;
6
6
  export declare const GRAPH_SCHEMA: Record<string, Record<string, GraphSchema>>;
7
- export declare const NAMESPACE_GRAPH: Uint8Array;
7
+ export declare const NAMESPACE_GRAPH: Uint8Array<ArrayBufferLike>;
8
8
  export declare const getAssistantId: (graphId: string) => string;
9
9
  export declare function registerFromEnv(specs: Record<string, string>, options: {
10
10
  cwd: string;
@@ -1,6 +1,6 @@
1
1
  import type { CompiledGraph } from "@langchain/langgraph";
2
2
  export declare const GRAPHS: Record<string, CompiledGraph<string>>;
3
- export declare const NAMESPACE_GRAPH: Uint8Array;
3
+ export declare const NAMESPACE_GRAPH: Uint8Array<ArrayBufferLike>;
4
4
  export type CompiledGraphFactory<T extends string> = (config: {
5
5
  configurable?: Record<string, unknown>;
6
6
  }) => Promise<CompiledGraph<T>>;
@@ -3,7 +3,7 @@ export const cors = (cors) => {
3
3
  if (cors == null) {
4
4
  return honoCors({
5
5
  origin: "*",
6
- exposeHeaders: ["content-location"],
6
+ exposeHeaders: ["content-location", "x-pagination-total"],
7
7
  });
8
8
  }
9
9
  const originRegex = cors.allow_origin_regex
@@ -17,10 +17,16 @@ export const cors = (cors) => {
17
17
  return undefined;
18
18
  }
19
19
  : (cors.allow_origins ?? []);
20
- if (!!cors.expose_headers?.length &&
21
- cors.expose_headers.some((i) => i.toLocaleLowerCase() === "content-location")) {
22
- console.warn("Adding missing `Content-Location` header in `cors.expose_headers`.");
23
- cors.expose_headers.push("content-location");
20
+ if (cors.expose_headers?.length) {
21
+ const headersSet = new Set(cors.expose_headers.map((h) => h.toLowerCase()));
22
+ if (!headersSet.has("content-location")) {
23
+ console.warn("Adding missing `Content-Location` header in `cors.expose_headers`.");
24
+ cors.expose_headers.push("content-location");
25
+ }
26
+ if (!headersSet.has("x-pagination-total")) {
27
+ console.warn("Adding missing `X-Pagination-Total` header in `cors.expose_headers`.");
28
+ cors.expose_headers.push("x-pagination-total");
29
+ }
24
30
  }
25
31
  // TODO: handle `cors.allow_credentials`
26
32
  return honoCors({
package/dist/logging.mjs CHANGED
@@ -2,7 +2,7 @@ import { createLogger, format, transports } from "winston";
2
2
  import { logger as honoLogger } from "hono/logger";
3
3
  import { consoleFormat } from "winston-console-format";
4
4
  import { parse as stacktraceParser } from "stacktrace-parser";
5
- import { readFileSync } from "fs";
5
+ import { readFileSync } from "node:fs";
6
6
  import { codeFrameColumns } from "@babel/code-frame";
7
7
  import path from "node:path";
8
8
  const LOG_JSON = process.env.LOG_JSON === "true";
@@ -119,7 +119,10 @@ export declare class Assistants {
119
119
  metadata?: Metadata;
120
120
  limit: number;
121
121
  offset: number;
122
- }, auth: AuthContext | undefined): AsyncGenerator<any, void, unknown>;
122
+ }, auth: AuthContext | undefined): AsyncGenerator<{
123
+ assistant: Assistant;
124
+ total: number;
125
+ }>;
123
126
  static get(assistant_id: string, auth: AuthContext | undefined): Promise<Assistant>;
124
127
  static put(assistant_id: string, options: {
125
128
  config: RunnableConfig;
@@ -177,8 +177,16 @@ export class Assistants {
177
177
  const bCreatedAt = b["created_at"]?.getTime() ?? 0;
178
178
  return bCreatedAt - aCreatedAt;
179
179
  });
180
+ // Calculate total count before pagination
181
+ const total = filtered.length;
180
182
  for (const assistant of filtered.slice(options.offset, options.offset + options.limit)) {
181
- yield { ...assistant, name: assistant.name ?? assistant.graph_id };
183
+ yield {
184
+ assistant: {
185
+ ...assistant,
186
+ name: assistant.name ?? assistant.graph_id,
187
+ },
188
+ total,
189
+ };
182
190
  }
183
191
  });
184
192
  }
@@ -14,5 +14,5 @@ export declare class FileSystemPersistence<Schema> {
14
14
  with<T>(fn: (data: Schema) => T): Promise<T>;
15
15
  withGenerator<T extends AsyncGenerator<any>>(fn: ((data: Schema, options: {
16
16
  schedulePersist: () => void;
17
- }) => T) | T): AsyncGenerator<any, void, unknown>;
17
+ }) => T) | T): AsyncGenerator<any, void, any>;
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-api",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^18.19.0 || >=20.16.0"
@@ -33,10 +33,23 @@
33
33
  "type": "git",
34
34
  "url": "git@github.com:langchain-ai/langgraphjs-api.git"
35
35
  },
36
+ "scripts": {
37
+ "clean": "npx -y bun scripts/clean.mjs",
38
+ "build": "npx -y bun scripts/build.mjs",
39
+ "dev": "tsx ./tests/utils.server.mts --dev",
40
+ "prepack": "yarn run build",
41
+ "typecheck": "tsc --noEmit",
42
+ "test": "vitest",
43
+ "test:parser": "vitest run ./tests/parser.test.mts --testTimeout 15000",
44
+ "test:api": "npx -y bun scripts/test.mjs",
45
+ "format": "prettier --write .",
46
+ "format:check": "prettier --check ."
47
+ },
36
48
  "dependencies": {
37
49
  "@babel/code-frame": "^7.26.2",
38
50
  "@hono/node-server": "^1.12.0",
39
51
  "@hono/zod-validator": "^0.2.2",
52
+ "@langchain/langgraph-ui": "0.0.39",
40
53
  "@types/json-schema": "^7.0.15",
41
54
  "@typescript/vfs": "^1.6.0",
42
55
  "dedent": "^1.5.3",
@@ -52,12 +65,11 @@
52
65
  "uuid": "^10.0.0",
53
66
  "winston": "^3.17.0",
54
67
  "winston-console-format": "^1.0.8",
55
- "zod": "^3.23.8",
56
- "@langchain/langgraph-ui": "0.0.37"
68
+ "zod": "^3.23.8"
57
69
  },
58
70
  "peerDependencies": {
59
71
  "@langchain/core": "^0.3.42",
60
- "@langchain/langgraph": "^0.2.57",
72
+ "@langchain/langgraph": "^0.2.57 || ^0.3.0",
61
73
  "@langchain/langgraph-checkpoint": "~0.0.16",
62
74
  "@langchain/langgraph-sdk": "~0.0.70",
63
75
  "typescript": "^5.5.4"
@@ -68,7 +80,9 @@
68
80
  }
69
81
  },
70
82
  "devDependencies": {
71
- "typescript": "^5.5.4",
83
+ "@langchain/core": "^0.3.42",
84
+ "@langchain/langgraph": "^0.2.57",
85
+ "@langchain/langgraph-checkpoint": "~0.0.16",
72
86
  "@langchain/langgraph-sdk": "^0.0.77",
73
87
  "@types/babel__code-frame": "^7.0.6",
74
88
  "@types/node": "^22.2.0",
@@ -79,17 +93,7 @@
79
93
  "jose": "^6.0.10",
80
94
  "postgres": "^3.4.5",
81
95
  "prettier": "^3.3.3",
96
+ "typescript": "^5.5.4",
82
97
  "vitest": "^3.0.5"
83
- },
84
- "scripts": {
85
- "clean": "npx -y bun scripts/clean.mjs",
86
- "build": "npx -y bun scripts/build.mjs",
87
- "dev": "tsx ./tests/utils.server.mts --dev",
88
- "typecheck": "tsc --noEmit",
89
- "test": "vitest",
90
- "test:parser": "vitest run ./tests/parser.test.mts --testTimeout 15000",
91
- "test:api": "npx -y bun scripts/test.mjs",
92
- "format": "prettier --write .",
93
- "format:check": "prettier --check ."
94
98
  }
95
99
  }