@langchain/langgraph-api 0.0.38 → 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.
- package/dist/api/assistants.mjs +10 -5
- package/dist/api/meta.mjs +22 -1
- package/dist/auth/index.mjs +1 -1
- package/dist/http/middleware.mjs +11 -5
- package/dist/logging.mjs +1 -1
- package/dist/storage/ops.d.mts +4 -1
- package/dist/storage/ops.mjs +9 -1
- package/package.json +15 -14
package/dist/api/assistants.mjs
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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;
|
package/dist/auth/index.mjs
CHANGED
|
@@ -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;
|
package/dist/http/middleware.mjs
CHANGED
|
@@ -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 (
|
|
21
|
-
cors.expose_headers.
|
|
22
|
-
|
|
23
|
-
|
|
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";
|
package/dist/storage/ops.d.mts
CHANGED
|
@@ -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<
|
|
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;
|
package/dist/storage/ops.mjs
CHANGED
|
@@ -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 {
|
|
183
|
+
yield {
|
|
184
|
+
assistant: {
|
|
185
|
+
...assistant,
|
|
186
|
+
name: assistant.name ?? assistant.graph_id,
|
|
187
|
+
},
|
|
188
|
+
total,
|
|
189
|
+
};
|
|
182
190
|
}
|
|
183
191
|
});
|
|
184
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-api",
|
|
3
|
-
"version": "0.0.
|
|
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,8 +65,7 @@
|
|
|
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.38"
|
|
68
|
+
"zod": "^3.23.8"
|
|
57
69
|
},
|
|
58
70
|
"peerDependencies": {
|
|
59
71
|
"@langchain/core": "^0.3.42",
|
|
@@ -83,16 +95,5 @@
|
|
|
83
95
|
"prettier": "^3.3.3",
|
|
84
96
|
"typescript": "^5.5.4",
|
|
85
97
|
"vitest": "^3.0.5"
|
|
86
|
-
},
|
|
87
|
-
"scripts": {
|
|
88
|
-
"clean": "npx -y bun scripts/clean.mjs",
|
|
89
|
-
"build": "npx -y bun scripts/build.mjs",
|
|
90
|
-
"dev": "tsx ./tests/utils.server.mts --dev",
|
|
91
|
-
"typecheck": "tsc --noEmit",
|
|
92
|
-
"test": "vitest",
|
|
93
|
-
"test:parser": "vitest run ./tests/parser.test.mts --testTimeout 15000",
|
|
94
|
-
"test:api": "npx -y bun scripts/test.mjs",
|
|
95
|
-
"format": "prettier --write .",
|
|
96
|
-
"format:check": "prettier --check ."
|
|
97
98
|
}
|
|
98
99
|
}
|