@langchain/langgraph-cli 0.0.3 → 0.0.5
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/runs.mjs +3 -3
- package/dist/graph/load.mjs +1 -0
- package/dist/server.mjs +11 -0
- package/dist/storage/ops.mjs +10 -7
- package/package.json +1 -1
package/dist/api/runs.mjs
CHANGED
|
@@ -102,7 +102,7 @@ api.post("/threads/:thread_id/runs/crons", zValidator("param", z.object({ thread
|
|
|
102
102
|
throw new HTTPException(500, { message: "Not implemented" });
|
|
103
103
|
});
|
|
104
104
|
api.post("/runs/stream", zValidator("json", schemas.RunCreate), async (c) => {
|
|
105
|
-
// Stream Run
|
|
105
|
+
// Stream Stateless Run
|
|
106
106
|
const payload = c.req.valid("json");
|
|
107
107
|
const run = await createValidRun(undefined, payload);
|
|
108
108
|
return streamSSE(c, async (stream) => {
|
|
@@ -110,7 +110,7 @@ api.post("/runs/stream", zValidator("json", schemas.RunCreate), async (c) => {
|
|
|
110
110
|
? getDisconnectAbortSignal(c, stream)
|
|
111
111
|
: undefined;
|
|
112
112
|
try {
|
|
113
|
-
for await (const { event, data } of Runs.Stream.join(run.run_id, undefined, { cancelOnDisconnect })) {
|
|
113
|
+
for await (const { event, data } of Runs.Stream.join(run.run_id, undefined, { cancelOnDisconnect, ignore404: true })) {
|
|
114
114
|
await stream.writeSSE({ data: serialiseAsDict(data), event });
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -120,7 +120,7 @@ api.post("/runs/stream", zValidator("json", schemas.RunCreate), async (c) => {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
api.post("/runs/wait", zValidator("json", schemas.RunCreate), async (c) => {
|
|
123
|
-
// Wait Run
|
|
123
|
+
// Wait Stateless Run
|
|
124
124
|
const payload = c.req.valid("json");
|
|
125
125
|
const run = await createValidRun(undefined, payload);
|
|
126
126
|
return waitKeepAlive(c, Runs.wait(run.run_id, undefined));
|
package/dist/graph/load.mjs
CHANGED
package/dist/server.mjs
CHANGED
|
@@ -14,6 +14,17 @@ import { logger, requestLogger } from "./logging.mjs";
|
|
|
14
14
|
import { checkpointer } from "./storage/checkpoint.mjs";
|
|
15
15
|
import { store as graphStore } from "./storage/store.mjs";
|
|
16
16
|
const app = new Hono();
|
|
17
|
+
// This is used to match the behavior of the original LangGraph API
|
|
18
|
+
// where the content-type is not being validated. Might be nice
|
|
19
|
+
// to warn about this in the future and throw an error instead.
|
|
20
|
+
app.use(async (c, next) => {
|
|
21
|
+
if (c.req.header("content-type")?.startsWith("text/plain") &&
|
|
22
|
+
c.req.method !== "GET" &&
|
|
23
|
+
c.req.method !== "OPTIONS") {
|
|
24
|
+
c.req.raw.headers.set("content-type", "application/json");
|
|
25
|
+
}
|
|
26
|
+
await next();
|
|
27
|
+
});
|
|
17
28
|
app.use(cors());
|
|
18
29
|
app.use(requestLogger());
|
|
19
30
|
app.route("/", assistants);
|
package/dist/storage/ops.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPException } from "hono/http-exception";
|
|
2
|
-
import { v4 as uuid4 } from "uuid";
|
|
3
|
-
import { getGraph } from "../graph/load.mjs";
|
|
2
|
+
import { v4 as uuid4, v5 as uuid5 } from "uuid";
|
|
3
|
+
import { getGraph, NAMESPACE_GRAPH } from "../graph/load.mjs";
|
|
4
4
|
import { checkpointer } from "./checkpoint.mjs";
|
|
5
5
|
import { store } from "./store.mjs";
|
|
6
6
|
import { logger } from "../logging.mjs";
|
|
@@ -99,8 +99,8 @@ export const truncate = (flags) => {
|
|
|
99
99
|
if (flags.threads)
|
|
100
100
|
STORE.threads = {};
|
|
101
101
|
if (flags.assistants) {
|
|
102
|
-
STORE.assistants = Object.fromEntries(Object.entries(STORE.assistants).filter(([
|
|
103
|
-
assistant.
|
|
102
|
+
STORE.assistants = Object.fromEntries(Object.entries(STORE.assistants).filter(([key, assistant]) => assistant.metadata?.created_by === "system" &&
|
|
103
|
+
uuid5(assistant.graph_id, NAMESPACE_GRAPH) === key));
|
|
104
104
|
}
|
|
105
105
|
if (flags.checkpointer)
|
|
106
106
|
checkpointer.clear();
|
|
@@ -148,7 +148,7 @@ export class Assistants {
|
|
|
148
148
|
return bCreatedAt - aCreatedAt;
|
|
149
149
|
});
|
|
150
150
|
for (const assistant of filtered.slice(options.offset, options.offset + options.limit)) {
|
|
151
|
-
yield assistant;
|
|
151
|
+
yield { ...assistant, name: assistant.name ?? assistant.graph_id };
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
}
|
|
@@ -157,7 +157,7 @@ export class Assistants {
|
|
|
157
157
|
const result = STORE.assistants[assistantId];
|
|
158
158
|
if (result == null)
|
|
159
159
|
throw new HTTPException(404, { message: "Assistant not found" });
|
|
160
|
-
return result;
|
|
160
|
+
return { ...result, name: result.name ?? result.graph_id };
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
static async put(assistantId, options) {
|
|
@@ -177,7 +177,7 @@ export class Assistants {
|
|
|
177
177
|
updated_at: now,
|
|
178
178
|
graph_id: options.graph_id,
|
|
179
179
|
metadata: options.metadata ?? {},
|
|
180
|
-
name: options.name,
|
|
180
|
+
name: options.name || options.graph_id,
|
|
181
181
|
};
|
|
182
182
|
STORE.assistant_versions.push({
|
|
183
183
|
assistant_id: assistantId,
|
|
@@ -186,6 +186,7 @@ export class Assistants {
|
|
|
186
186
|
config: options.config ?? {},
|
|
187
187
|
metadata: options.metadata ?? {},
|
|
188
188
|
created_at: now,
|
|
189
|
+
name: options.name || options.graph_id,
|
|
189
190
|
});
|
|
190
191
|
return STORE.assistants[assistantId];
|
|
191
192
|
});
|
|
@@ -224,6 +225,7 @@ export class Assistants {
|
|
|
224
225
|
version: newVersion,
|
|
225
226
|
graph_id: options?.graph_id ?? assistant["graph_id"],
|
|
226
227
|
config: options?.config ?? assistant["config"],
|
|
228
|
+
name: options?.name ?? assistant["name"],
|
|
227
229
|
metadata: metadata ?? assistant["metadata"],
|
|
228
230
|
created_at: now,
|
|
229
231
|
};
|
|
@@ -263,6 +265,7 @@ export class Assistants {
|
|
|
263
265
|
config: assistantVersion["config"],
|
|
264
266
|
metadata: assistantVersion["metadata"],
|
|
265
267
|
version: assistantVersion["version"],
|
|
268
|
+
name: assistantVersion["name"],
|
|
266
269
|
updated_at: now,
|
|
267
270
|
};
|
|
268
271
|
return STORE.assistants[assistantId];
|