@langchain/langgraph-api 1.4.6-rc.0 → 1.5.0
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 +9 -3
- package/dist/graph/api.d.mts +1 -0
- package/dist/graph/load.d.mts +3 -1
- package/dist/graph/load.mjs +5 -2
- package/dist/graph/load.utils.d.mts +11 -4
- package/dist/graph/load.utils.mjs +2 -2
- package/dist/storage/ops.mjs +4 -0
- package/dist/stream.d.mts +5 -0
- package/dist/stream.mjs +2 -0
- package/package.json +6 -6
package/dist/api/assistants.mjs
CHANGED
|
@@ -104,7 +104,9 @@ api.get("/assistants/:assistant_id/graph", zValidator("query", z.object({ xray:
|
|
|
104
104
|
const assistant = await assistants().get(assistantId, c.var.auth);
|
|
105
105
|
const { xray } = c.req.valid("query");
|
|
106
106
|
const config = getRunnableConfig(assistant.config);
|
|
107
|
-
const graph = await getGraph(assistant.graph_id, config
|
|
107
|
+
const graph = await getGraph(assistant.graph_id, config, {
|
|
108
|
+
accessContext: "assistants.read",
|
|
109
|
+
});
|
|
108
110
|
const drawable = await graph.getGraphAsync({
|
|
109
111
|
...config,
|
|
110
112
|
xray: xray ?? undefined,
|
|
@@ -117,7 +119,9 @@ api.get("/assistants/:assistant_id/schemas", zValidator("json", z.object({ confi
|
|
|
117
119
|
const assistantId = getAssistantId(c.req.param("assistant_id"));
|
|
118
120
|
const assistant = await assistants().get(assistantId, c.var.auth);
|
|
119
121
|
const config = getRunnableConfig(json.config);
|
|
120
|
-
const graph = await getGraph(assistant.graph_id, config
|
|
122
|
+
const graph = await getGraph(assistant.graph_id, config, {
|
|
123
|
+
accessContext: "assistants.read",
|
|
124
|
+
});
|
|
121
125
|
const schema = await (async () => {
|
|
122
126
|
const runtimeSchema = await getRuntimeGraphSchema(graph);
|
|
123
127
|
if (runtimeSchema)
|
|
@@ -146,7 +150,9 @@ api.get("/assistants/:assistant_id/subgraphs/:namespace?", zValidator("param", z
|
|
|
146
150
|
const assistantId = getAssistantId(assistant_id);
|
|
147
151
|
const assistant = await assistants().get(assistantId, c.var.auth);
|
|
148
152
|
const config = getRunnableConfig(assistant.config);
|
|
149
|
-
const graph = await getGraph(assistant.graph_id, config
|
|
153
|
+
const graph = await getGraph(assistant.graph_id, config, {
|
|
154
|
+
accessContext: "assistants.read",
|
|
155
|
+
});
|
|
150
156
|
const result = [];
|
|
151
157
|
const subgraphsGenerator = "getSubgraphsAsync" in graph
|
|
152
158
|
? graph.getSubgraphsAsync.bind(graph)
|
package/dist/graph/api.d.mts
CHANGED
package/dist/graph/load.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AssistantsRepo } from "../storage/types.mjs";
|
|
2
2
|
import type { BaseCheckpointSaver, BaseStore, CompiledGraph, LangGraphRunnableConfig } from "@langchain/langgraph";
|
|
3
|
-
import { type CompiledGraphFactory } from "./load.utils.mjs";
|
|
3
|
+
import { type CompiledGraphFactory, type ServerRuntime } from "./load.utils.mjs";
|
|
4
4
|
import type { GraphSchema, GraphSpec } from "./parser/index.mjs";
|
|
5
5
|
export declare const GRAPHS: Record<string, CompiledGraph<string> | CompiledGraphFactory<string>>;
|
|
6
6
|
export declare const GRAPH_SPEC: Record<string, GraphSpec>;
|
|
@@ -13,6 +13,8 @@ export declare function registerFromEnv(assistants: AssistantsRepo, specs: Recor
|
|
|
13
13
|
export declare function getGraph(graphId: string, config: LangGraphRunnableConfig | undefined, options?: {
|
|
14
14
|
checkpointer?: BaseCheckpointSaver | null;
|
|
15
15
|
store?: BaseStore;
|
|
16
|
+
accessContext?: ServerRuntime["accessContext"];
|
|
17
|
+
context?: unknown;
|
|
16
18
|
}): Promise<CompiledGraph<string, any, any, Record<string, any>, any, any, unknown, unknown, any, []>>;
|
|
17
19
|
export declare function assertGraphExists(graphId: string): void;
|
|
18
20
|
export declare function getGraphKeys(): string[];
|
package/dist/graph/load.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod/v3";
|
|
2
2
|
import * as uuid from "@langchain/core/utils/uuid";
|
|
3
3
|
import { HTTPException } from "hono/http-exception";
|
|
4
|
-
import { resolveGraph } from "./load.utils.mjs";
|
|
4
|
+
import { resolveGraph, } from "./load.utils.mjs";
|
|
5
5
|
import { getStaticGraphSchema } from "./parser/index.mjs";
|
|
6
6
|
import { checkpointer } from "../storage/checkpoint.mjs";
|
|
7
7
|
import { store } from "../storage/store.mjs";
|
|
@@ -44,8 +44,11 @@ export async function registerFromEnv(assistants, specs, options) {
|
|
|
44
44
|
}
|
|
45
45
|
export async function getGraph(graphId, config, options) {
|
|
46
46
|
assertGraphExists(graphId);
|
|
47
|
+
const accessContext = options?.accessContext ?? "assistants.read";
|
|
47
48
|
const compiled = typeof GRAPHS[graphId] === "function"
|
|
48
|
-
? await GRAPHS[graphId](config ?? { configurable: {} }
|
|
49
|
+
? await GRAPHS[graphId](config ?? { configurable: {} }, accessContext === "threads.create_run"
|
|
50
|
+
? { accessContext, executionRuntime: { context: options?.context } }
|
|
51
|
+
: { accessContext, executionRuntime: null })
|
|
49
52
|
: GRAPHS[graphId];
|
|
50
53
|
if (typeof options?.checkpointer !== "undefined") {
|
|
51
54
|
compiled.checkpointer = options?.checkpointer ?? undefined;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import type { CompiledGraph } from "@langchain/langgraph";
|
|
1
|
+
import type { CompiledGraph, LangGraphRunnableConfig } from "@langchain/langgraph";
|
|
2
2
|
export declare const GRAPHS: Record<string, CompiledGraph<string>>;
|
|
3
3
|
export declare const NAMESPACE_GRAPH: Uint8Array<ArrayBuffer>;
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export type ServerRuntime<Context = unknown> = {
|
|
5
|
+
accessContext: "threads.create_run";
|
|
6
|
+
executionRuntime: {
|
|
7
|
+
context: Context | undefined;
|
|
8
|
+
};
|
|
9
|
+
} | {
|
|
10
|
+
accessContext: "assistants.read" | "threads.read" | "threads.update";
|
|
11
|
+
executionRuntime: null;
|
|
12
|
+
};
|
|
13
|
+
export type CompiledGraphFactory<T extends string> = (config: LangGraphRunnableConfig, runtime: ServerRuntime) => Promise<CompiledGraph<T>>;
|
|
7
14
|
export declare function resolveGraph(spec: string, options: {
|
|
8
15
|
cwd: string;
|
|
9
16
|
onlyFilePresence?: false;
|
|
@@ -48,8 +48,8 @@ export async function resolveGraph(spec, options) {
|
|
|
48
48
|
return graph;
|
|
49
49
|
};
|
|
50
50
|
if (typeof graph === "function") {
|
|
51
|
-
return async (config) => {
|
|
52
|
-
const graphLike = await graph(config);
|
|
51
|
+
return async (config, runtime) => {
|
|
52
|
+
const graphLike = await graph(config, runtime);
|
|
53
53
|
return afterResolve(graphLike);
|
|
54
54
|
};
|
|
55
55
|
}
|
package/dist/storage/ops.mjs
CHANGED
|
@@ -728,6 +728,7 @@ export class FileSystemThreads {
|
|
|
728
728
|
const graph = await getGraph(graphId, thread.config, {
|
|
729
729
|
checkpointer,
|
|
730
730
|
store,
|
|
731
|
+
accessContext: "threads.read",
|
|
731
732
|
});
|
|
732
733
|
const result = await graph.getState(config, { subgraphs });
|
|
733
734
|
if (result.metadata != null &&
|
|
@@ -770,6 +771,7 @@ export class FileSystemThreads {
|
|
|
770
771
|
const graph = await getGraph(graphId, thread.config, {
|
|
771
772
|
checkpointer,
|
|
772
773
|
store,
|
|
774
|
+
accessContext: "threads.update",
|
|
773
775
|
});
|
|
774
776
|
const updateConfig = structuredClone(config);
|
|
775
777
|
updateConfig.configurable ??= {};
|
|
@@ -809,6 +811,7 @@ export class FileSystemThreads {
|
|
|
809
811
|
const graph = await getGraph(graphId, thread.config, {
|
|
810
812
|
checkpointer,
|
|
811
813
|
store,
|
|
814
|
+
accessContext: "threads.update",
|
|
812
815
|
});
|
|
813
816
|
const updateConfig = structuredClone(config);
|
|
814
817
|
updateConfig.configurable ??= {};
|
|
@@ -847,6 +850,7 @@ export class FileSystemThreads {
|
|
|
847
850
|
const graph = await getGraph(graphId, thread.config, {
|
|
848
851
|
checkpointer,
|
|
849
852
|
store,
|
|
853
|
+
accessContext: "threads.read",
|
|
850
854
|
});
|
|
851
855
|
const before = typeof options?.before === "string"
|
|
852
856
|
? { configurable: { checkpoint_id: options.before } }
|
package/dist/stream.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseCheckpointSaver, LangGraphRunnableConfig, CheckpointMetadata, Interrupt, StateSnapshot } from "@langchain/langgraph";
|
|
2
2
|
import type { Pregel } from "@langchain/langgraph/pregel";
|
|
3
|
+
import type { ServerRuntime } from "./graph/load.utils.mjs";
|
|
3
4
|
import type { SourceStreamEvent } from "./protocol/types.mjs";
|
|
4
5
|
import type { Checkpoint, Run, RunnableConfig } from "./storage/types.mjs";
|
|
5
6
|
interface DebugTask {
|
|
@@ -33,6 +34,8 @@ export declare function streamState(run: Run, options: {
|
|
|
33
34
|
attempt: number;
|
|
34
35
|
getGraph: (graphId: string, config: LangGraphRunnableConfig | undefined, options?: {
|
|
35
36
|
checkpointer?: BaseCheckpointSaver | null;
|
|
37
|
+
accessContext?: ServerRuntime["accessContext"];
|
|
38
|
+
context?: unknown;
|
|
36
39
|
}) => Promise<Pregel<any, any, any, any, any>>;
|
|
37
40
|
onCheckpoint?: (checkpoint: StreamCheckpoint) => void;
|
|
38
41
|
onTaskResult?: (taskResult: StreamTaskResult) => void;
|
|
@@ -56,6 +59,8 @@ export declare function streamStateV2(run: Run, options: {
|
|
|
56
59
|
graph: Pregel<any, any, any, any, any>;
|
|
57
60
|
getGraph: (graphId: string, config: LangGraphRunnableConfig | undefined, options?: {
|
|
58
61
|
checkpointer?: BaseCheckpointSaver | null;
|
|
62
|
+
accessContext?: ServerRuntime["accessContext"];
|
|
63
|
+
context?: unknown;
|
|
59
64
|
}) => Promise<Pregel<any, any, any, any, any>>;
|
|
60
65
|
onCheckpoint?: (checkpoint: StreamCheckpoint) => void;
|
|
61
66
|
onTaskResult?: (taskResult: StreamTaskResult) => void;
|
package/dist/stream.mjs
CHANGED
|
@@ -63,6 +63,8 @@ export async function* streamState(run, options) {
|
|
|
63
63
|
}
|
|
64
64
|
const graph = await options.getGraph(graphId, kwargs.config, {
|
|
65
65
|
checkpointer: kwargs.temporary ? null : undefined,
|
|
66
|
+
accessContext: "threads.create_run",
|
|
67
|
+
context: kwargs.context,
|
|
66
68
|
});
|
|
67
69
|
// Only v2 protocol entrypoints opt into `streamStateV2`.
|
|
68
70
|
// Legacy run/stream endpoints stay on the existing `streamEvents`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^18.19.0 || >=20.16.0"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"dedent": "^1.5.3",
|
|
62
62
|
"dotenv": "^16.4.7",
|
|
63
63
|
"exit-hook": "^4.0.0",
|
|
64
|
-
"hono": "^4.
|
|
64
|
+
"hono": "^4.13.5",
|
|
65
65
|
"langsmith": ">=0.5.19 <1.0.0",
|
|
66
66
|
"open": "^10.1.0",
|
|
67
67
|
"semver": "^7.7.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"winston": "^3.17.0",
|
|
72
72
|
"winston-console-format": "^1.0.8",
|
|
73
73
|
"zod": "^3.25.76 || ^4",
|
|
74
|
-
"@langchain/langgraph-ui": "1.
|
|
74
|
+
"@langchain/langgraph-ui": "1.5.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@langchain/core": "^1.1.48",
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
"postgres": "^3.4.5",
|
|
103
103
|
"ts-node": "^10.9.2",
|
|
104
104
|
"typescript": "^4.9.5 || ^5.4.5",
|
|
105
|
-
"vitest": "^4.1.
|
|
105
|
+
"vitest": "^4.1.11",
|
|
106
106
|
"wait-port": "^1.1.0",
|
|
107
|
+
"@langchain/langgraph": "1.4.16",
|
|
107
108
|
"@langchain/langgraph-checkpoint": "1.1.5",
|
|
108
|
-
"@langchain/langgraph": "1.
|
|
109
|
-
"@langchain/langgraph-sdk": "1.10.3-rc.0"
|
|
109
|
+
"@langchain/langgraph-sdk": "1.11.1"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"clean": "rm -rf dist/ .turbo/ ./tests/graphs/.langgraph_api/ ./tests/protocol-v2/graphs/.langgraph_api/",
|