@langchain/langgraph-cli 0.0.9 → 0.0.10

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.
Files changed (40) hide show
  1. package/LICENSE +21 -93
  2. package/dist/cli/build.mjs +1 -1
  3. package/dist/cli/cli.mjs +0 -0
  4. package/dist/cli/dev.mjs +3 -3
  5. package/dist/cli/dev.python.mjs +1 -1
  6. package/dist/cli/docker.mjs +1 -1
  7. package/dist/cli/up.mjs +1 -1
  8. package/dist/{logging.mjs → utils/logging.mjs} +0 -4
  9. package/package.json +16 -32
  10. package/dist/api/assistants.mjs +0 -144
  11. package/dist/api/runs.mjs +0 -239
  12. package/dist/api/store.mjs +0 -83
  13. package/dist/api/threads.mjs +0 -143
  14. package/dist/cli/dev.node.entrypoint.mjs +0 -42
  15. package/dist/cli/dev.node.mjs +0 -35
  16. package/dist/cli/utils/ipc/client.mjs +0 -47
  17. package/dist/graph/load.hooks.mjs +0 -17
  18. package/dist/graph/load.mjs +0 -72
  19. package/dist/graph/load.utils.mjs +0 -50
  20. package/dist/graph/parser/parser.mjs +0 -308
  21. package/dist/graph/parser/parser.worker.mjs +0 -7
  22. package/dist/graph/parser/schema/types.mjs +0 -1607
  23. package/dist/graph/parser/schema/types.template.mts +0 -83
  24. package/dist/preload.mjs +0 -3
  25. package/dist/queue.mjs +0 -93
  26. package/dist/schemas.mjs +0 -407
  27. package/dist/server.mjs +0 -74
  28. package/dist/state.mjs +0 -32
  29. package/dist/storage/checkpoint.mjs +0 -127
  30. package/dist/storage/importMap.mjs +0 -55
  31. package/dist/storage/ops.mjs +0 -792
  32. package/dist/storage/persist.mjs +0 -79
  33. package/dist/storage/store.mjs +0 -41
  34. package/dist/stream.mjs +0 -215
  35. package/dist/utils/abort.mjs +0 -8
  36. package/dist/utils/error.mjs +0 -1
  37. package/dist/utils/hono.mjs +0 -27
  38. package/dist/utils/importMap.mjs +0 -55
  39. package/dist/utils/runnableConfig.mjs +0 -45
  40. package/dist/utils/serde.mjs +0 -20
@@ -1,127 +0,0 @@
1
- import { MemorySaver, } from "@langchain/langgraph";
2
- import { FileSystemPersistence } from "./persist.mjs";
3
- const EXCLUDED_KEYS = ["checkpoint_ns", "checkpoint_id", "run_id", "thread_id"];
4
- const textDecoder = new TextDecoder();
5
- const textEncoder = new TextEncoder();
6
- const WriteKey = {
7
- serialize: (key) => {
8
- return JSON.stringify(key);
9
- },
10
- deserialize: (key) => {
11
- const [threadId, checkpointNamespace, checkpointId] = JSON.parse(key);
12
- return [threadId, checkpointNamespace, checkpointId];
13
- },
14
- };
15
- const conn = new FileSystemPersistence(".langgraphjs_api.checkpointer.json", () => ({
16
- storage: {},
17
- writes: {},
18
- }));
19
- class InMemorySaver extends MemorySaver {
20
- async initialize(cwd) {
21
- await conn.initialize(cwd);
22
- await conn.with(({ storage, writes }) => {
23
- this.storage = storage;
24
- this.writes = writes;
25
- });
26
- return conn;
27
- }
28
- clear() {
29
- // { [threadId: string]: { [checkpointNs: string]: { [checkpointId]: [checkpoint, metadata, parentId] } }}
30
- this.storage = {};
31
- // { [WriteKey]: CheckpointPendingWrite[] }
32
- this.writes = {};
33
- }
34
- // Patch every method that has access to this.storage or this.writes
35
- // to also persist the changes to the filesystem in a non-blocking manner
36
- async getTuple(...args) {
37
- return await conn.with(() => super.getTuple(...args));
38
- }
39
- async *list(...args) {
40
- yield* conn.withGenerator(super.list(...args));
41
- }
42
- async putWrites(...args) {
43
- return await conn.with(() => super.putWrites(...args));
44
- }
45
- async put(config, checkpoint, metadata) {
46
- return await conn.with(() => super.put(config, checkpoint, {
47
- ...Object.fromEntries(Object.entries(config.configurable ?? {}).filter(([key]) => !key.startsWith("__") && !EXCLUDED_KEYS.includes(key))),
48
- ...config.metadata,
49
- ...metadata,
50
- }));
51
- }
52
- async delete(threadId, runId) {
53
- if (this.storage[threadId] == null)
54
- return;
55
- return await conn.with(() => {
56
- if (runId != null) {
57
- const writeKeysToDelete = [];
58
- for (const ns of Object.keys(this.storage[threadId])) {
59
- for (const id of Object.keys(this.storage[threadId][ns])) {
60
- const [_checkpoint, metadata, _parentId] = this.storage[threadId][ns][id];
61
- const jsonMetadata = JSON.parse(textDecoder.decode(metadata));
62
- if (jsonMetadata.run_id === runId) {
63
- delete this.storage[threadId][ns][id];
64
- writeKeysToDelete.push(WriteKey.serialize([threadId, ns, id]));
65
- if (Object.keys(this.storage[threadId][ns]).length === 0) {
66
- delete this.storage[threadId][ns];
67
- }
68
- }
69
- }
70
- }
71
- for (const key of writeKeysToDelete) {
72
- delete this.writes[key];
73
- }
74
- }
75
- else {
76
- delete this.storage[threadId];
77
- // delete all writes for this thread
78
- const writeKeys = Object.keys(this.writes);
79
- for (const key of writeKeys) {
80
- const [writeThreadId] = WriteKey.deserialize(key);
81
- if (writeThreadId === threadId)
82
- delete this.writes[key];
83
- }
84
- }
85
- });
86
- }
87
- async copy(threadId, newThreadId) {
88
- return await conn.with(() => {
89
- // copy storage over
90
- const newThreadCheckpoints = {};
91
- for (const oldNs of Object.keys(this.storage[threadId] ?? {})) {
92
- const newNs = oldNs.replace(threadId, newThreadId);
93
- for (const oldId of Object.keys(this.storage[threadId][oldNs])) {
94
- const newId = oldId.replace(threadId, newThreadId);
95
- const [checkpoint, metadata, oldParentId] = this.storage[threadId][oldNs][oldId];
96
- const newParentId = oldParentId?.replace(threadId, newThreadId);
97
- const rawMetadata = textDecoder
98
- .decode(metadata)
99
- .replaceAll(threadId, newThreadId);
100
- newThreadCheckpoints[newNs] ??= {};
101
- newThreadCheckpoints[newNs][newId] = [
102
- checkpoint,
103
- textEncoder.encode(rawMetadata),
104
- newParentId,
105
- ];
106
- }
107
- }
108
- this.storage[newThreadId] = newThreadCheckpoints;
109
- // copy writes over (if any)
110
- const outerKeys = [];
111
- for (const keyJson of Object.keys(this.writes)) {
112
- const key = WriteKey.deserialize(keyJson);
113
- if (key[0] === threadId)
114
- outerKeys.push(keyJson);
115
- }
116
- for (const keyJson of outerKeys) {
117
- const [_threadId, checkpointNamespace, checkpointId] = WriteKey.deserialize(keyJson);
118
- this.writes[WriteKey.serialize([newThreadId, checkpointNamespace, checkpointId])] = structuredClone(this.writes[keyJson]);
119
- }
120
- });
121
- }
122
- toJSON() {
123
- // Prevent serialization of internal state
124
- return "[InMemorySaver]";
125
- }
126
- }
127
- export const checkpointer = new InMemorySaver();
@@ -1,55 +0,0 @@
1
- import { PromptTemplate, AIMessagePromptTemplate, ChatMessagePromptTemplate, ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, ImagePromptTemplate, PipelinePromptTemplate, } from "@langchain/core/prompts";
2
- import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ChatMessage, ChatMessageChunk, FunctionMessage, FunctionMessageChunk, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, } from "@langchain/core/messages";
3
- import { StringPromptValue } from "@langchain/core/prompt_values";
4
- export const prompts__prompt = {
5
- PromptTemplate,
6
- };
7
- export const schema__messages = {
8
- AIMessage,
9
- AIMessageChunk,
10
- BaseMessage,
11
- BaseMessageChunk,
12
- ChatMessage,
13
- ChatMessageChunk,
14
- FunctionMessage,
15
- FunctionMessageChunk,
16
- HumanMessage,
17
- HumanMessageChunk,
18
- SystemMessage,
19
- SystemMessageChunk,
20
- ToolMessage,
21
- ToolMessageChunk,
22
- };
23
- export const schema = {
24
- AIMessage,
25
- AIMessageChunk,
26
- BaseMessage,
27
- BaseMessageChunk,
28
- ChatMessage,
29
- ChatMessageChunk,
30
- FunctionMessage,
31
- FunctionMessageChunk,
32
- HumanMessage,
33
- HumanMessageChunk,
34
- SystemMessage,
35
- SystemMessageChunk,
36
- ToolMessage,
37
- ToolMessageChunk,
38
- };
39
- export const prompts__chat = {
40
- AIMessagePromptTemplate,
41
- ChatMessagePromptTemplate,
42
- ChatPromptTemplate,
43
- HumanMessagePromptTemplate,
44
- MessagesPlaceholder,
45
- SystemMessagePromptTemplate,
46
- };
47
- export const prompts__image = {
48
- ImagePromptTemplate,
49
- };
50
- export const prompts__pipeline = {
51
- PipelinePromptTemplate,
52
- };
53
- export const prompts__base = {
54
- StringPromptValue,
55
- };