@langchain/langgraph-checkpoint 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -81,7 +81,6 @@ const checkpoint = {
81
81
  }
82
82
  },
83
83
  pending_sends: [],
84
- current_tasks: {}
85
84
  }
86
85
 
87
86
  // store checkpoint
package/dist/base.cjs CHANGED
@@ -16,6 +16,7 @@ function deepCopy(obj) {
16
16
  return newObj;
17
17
  }
18
18
  exports.deepCopy = deepCopy;
19
+ /** @hidden */
19
20
  function emptyCheckpoint() {
20
21
  return {
21
22
  v: 1,
@@ -28,6 +29,7 @@ function emptyCheckpoint() {
28
29
  };
29
30
  }
30
31
  exports.emptyCheckpoint = emptyCheckpoint;
32
+ /** @hidden */
31
33
  function copyCheckpoint(checkpoint) {
32
34
  return {
33
35
  v: checkpoint.v,
package/dist/base.d.ts CHANGED
@@ -40,7 +40,9 @@ export interface ReadonlyCheckpoint extends Readonly<Checkpoint> {
40
40
  readonly versions_seen: Readonly<Record<string, Readonly<Record<string, number>>>>;
41
41
  }
42
42
  export declare function deepCopy<T>(obj: T): T;
43
+ /** @hidden */
43
44
  export declare function emptyCheckpoint(): Checkpoint;
45
+ /** @hidden */
44
46
  export declare function copyCheckpoint(checkpoint: ReadonlyCheckpoint): Checkpoint;
45
47
  export interface CheckpointTuple {
46
48
  config: RunnableConfig;
package/dist/base.js CHANGED
@@ -12,6 +12,7 @@ export function deepCopy(obj) {
12
12
  }
13
13
  return newObj;
14
14
  }
15
+ /** @hidden */
15
16
  export function emptyCheckpoint() {
16
17
  return {
17
18
  v: 1,
@@ -23,6 +24,7 @@ export function emptyCheckpoint() {
23
24
  pending_sends: [],
24
25
  };
25
26
  }
27
+ /** @hidden */
26
28
  export function copyCheckpoint(checkpoint) {
27
29
  return {
28
30
  v: checkpoint.v,
package/dist/memory.cjs CHANGED
@@ -39,22 +39,22 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
39
39
  await this.serde.loadsTyped("json", value),
40
40
  ];
41
41
  }));
42
- const parentConfig = parentCheckpointId !== undefined
43
- ? {
44
- configurable: {
45
- thread_id,
46
- checkpoint_ns,
47
- checkpoint_id,
48
- },
49
- }
50
- : undefined;
51
- return {
42
+ const checkpointTuple = {
52
43
  config,
53
44
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
54
45
  metadata: (await this.serde.loadsTyped("json", metadata)),
55
46
  pendingWrites,
56
- parentConfig,
57
47
  };
48
+ if (parentCheckpointId !== undefined) {
49
+ checkpointTuple.parentConfig = {
50
+ configurable: {
51
+ thread_id,
52
+ checkpoint_ns,
53
+ checkpoint_id,
54
+ },
55
+ };
56
+ }
57
+ return checkpointTuple;
58
58
  }
59
59
  }
60
60
  else {
@@ -73,16 +73,7 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
73
73
  await this.serde.loadsTyped("json", value),
74
74
  ];
75
75
  }));
76
- const parentConfig = parentCheckpointId !== undefined
77
- ? {
78
- configurable: {
79
- thread_id,
80
- checkpoint_ns,
81
- checkpoint_id: parentCheckpointId,
82
- },
83
- }
84
- : undefined;
85
- return {
76
+ const checkpointTuple = {
86
77
  config: {
87
78
  configurable: {
88
79
  thread_id,
@@ -93,8 +84,17 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
93
84
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
94
85
  metadata: (await this.serde.loadsTyped("json", metadata)),
95
86
  pendingWrites,
96
- parentConfig,
97
87
  };
88
+ if (parentCheckpointId !== undefined) {
89
+ checkpointTuple.parentConfig = {
90
+ configurable: {
91
+ thread_id,
92
+ checkpoint_ns,
93
+ checkpoint_id: parentCheckpointId,
94
+ },
95
+ };
96
+ }
97
+ return checkpointTuple;
98
98
  }
99
99
  }
100
100
  return undefined;
@@ -133,7 +133,7 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
133
133
  await this.serde.loadsTyped("json", value),
134
134
  ];
135
135
  }));
136
- yield {
136
+ const checkpointTuple = {
137
137
  config: {
138
138
  configurable: {
139
139
  thread_id: threadId,
@@ -144,16 +144,17 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
144
144
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
145
145
  metadata,
146
146
  pendingWrites,
147
- parentConfig: parentCheckpointId
148
- ? {
149
- configurable: {
150
- thread_id: threadId,
151
- checkpoint_ns: checkpointNamespace,
152
- checkpoint_id: parentCheckpointId,
153
- },
154
- }
155
- : undefined,
156
147
  };
148
+ if (parentCheckpointId !== undefined) {
149
+ checkpointTuple.parentConfig = {
150
+ configurable: {
151
+ thread_id: threadId,
152
+ checkpoint_ns: checkpointNamespace,
153
+ checkpoint_id: parentCheckpointId,
154
+ },
155
+ };
156
+ }
157
+ yield checkpointTuple;
157
158
  }
158
159
  }
159
160
  }
package/dist/memory.js CHANGED
@@ -36,22 +36,22 @@ export class MemorySaver extends BaseCheckpointSaver {
36
36
  await this.serde.loadsTyped("json", value),
37
37
  ];
38
38
  }));
39
- const parentConfig = parentCheckpointId !== undefined
40
- ? {
41
- configurable: {
42
- thread_id,
43
- checkpoint_ns,
44
- checkpoint_id,
45
- },
46
- }
47
- : undefined;
48
- return {
39
+ const checkpointTuple = {
49
40
  config,
50
41
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
51
42
  metadata: (await this.serde.loadsTyped("json", metadata)),
52
43
  pendingWrites,
53
- parentConfig,
54
44
  };
45
+ if (parentCheckpointId !== undefined) {
46
+ checkpointTuple.parentConfig = {
47
+ configurable: {
48
+ thread_id,
49
+ checkpoint_ns,
50
+ checkpoint_id,
51
+ },
52
+ };
53
+ }
54
+ return checkpointTuple;
55
55
  }
56
56
  }
57
57
  else {
@@ -70,16 +70,7 @@ export class MemorySaver extends BaseCheckpointSaver {
70
70
  await this.serde.loadsTyped("json", value),
71
71
  ];
72
72
  }));
73
- const parentConfig = parentCheckpointId !== undefined
74
- ? {
75
- configurable: {
76
- thread_id,
77
- checkpoint_ns,
78
- checkpoint_id: parentCheckpointId,
79
- },
80
- }
81
- : undefined;
82
- return {
73
+ const checkpointTuple = {
83
74
  config: {
84
75
  configurable: {
85
76
  thread_id,
@@ -90,8 +81,17 @@ export class MemorySaver extends BaseCheckpointSaver {
90
81
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
91
82
  metadata: (await this.serde.loadsTyped("json", metadata)),
92
83
  pendingWrites,
93
- parentConfig,
94
84
  };
85
+ if (parentCheckpointId !== undefined) {
86
+ checkpointTuple.parentConfig = {
87
+ configurable: {
88
+ thread_id,
89
+ checkpoint_ns,
90
+ checkpoint_id: parentCheckpointId,
91
+ },
92
+ };
93
+ }
94
+ return checkpointTuple;
95
95
  }
96
96
  }
97
97
  return undefined;
@@ -130,7 +130,7 @@ export class MemorySaver extends BaseCheckpointSaver {
130
130
  await this.serde.loadsTyped("json", value),
131
131
  ];
132
132
  }));
133
- yield {
133
+ const checkpointTuple = {
134
134
  config: {
135
135
  configurable: {
136
136
  thread_id: threadId,
@@ -141,16 +141,17 @@ export class MemorySaver extends BaseCheckpointSaver {
141
141
  checkpoint: (await this.serde.loadsTyped("json", checkpoint)),
142
142
  metadata,
143
143
  pendingWrites,
144
- parentConfig: parentCheckpointId
145
- ? {
146
- configurable: {
147
- thread_id: threadId,
148
- checkpoint_ns: checkpointNamespace,
149
- checkpoint_id: parentCheckpointId,
150
- },
151
- }
152
- : undefined,
153
144
  };
145
+ if (parentCheckpointId !== undefined) {
146
+ checkpointTuple.parentConfig = {
147
+ configurable: {
148
+ thread_id: threadId,
149
+ checkpoint_ns: checkpointNamespace,
150
+ checkpoint_id: parentCheckpointId,
151
+ },
152
+ };
153
+ }
154
+ yield checkpointTuple;
154
155
  }
155
156
  }
156
157
  }
@@ -6,7 +6,10 @@ exports.JsonPlusSerializer = void 0;
6
6
  const load_1 = require("@langchain/core/load");
7
7
  async function _reviver(value) {
8
8
  if (value && typeof value === "object") {
9
- if (value.lc === 2 &&
9
+ if (value.lc === 2 && value.type === "undefined") {
10
+ return undefined;
11
+ }
12
+ else if (value.lc === 2 &&
10
13
  value.type === "constructor" &&
11
14
  Array.isArray(value.id)) {
12
15
  try {
@@ -62,13 +65,19 @@ constructor, method, args, kwargs) {
62
65
  lc: 2,
63
66
  type: "constructor",
64
67
  id: [constructor.name],
65
- method,
68
+ method: method ?? null,
66
69
  args: args ?? [],
67
70
  kwargs: kwargs ?? {},
68
71
  };
69
72
  }
70
73
  function _default(_key, obj) {
71
- if (obj instanceof Set || obj instanceof Map) {
74
+ if (obj === undefined) {
75
+ return {
76
+ lc: 2,
77
+ type: "undefined",
78
+ };
79
+ }
80
+ else if (obj instanceof Set || obj instanceof Map) {
72
81
  return _encodeConstructorArgs(obj.constructor, undefined, [
73
82
  Array.from(obj),
74
83
  ]);
@@ -3,7 +3,10 @@
3
3
  import { load } from "@langchain/core/load";
4
4
  async function _reviver(value) {
5
5
  if (value && typeof value === "object") {
6
- if (value.lc === 2 &&
6
+ if (value.lc === 2 && value.type === "undefined") {
7
+ return undefined;
8
+ }
9
+ else if (value.lc === 2 &&
7
10
  value.type === "constructor" &&
8
11
  Array.isArray(value.id)) {
9
12
  try {
@@ -59,13 +62,19 @@ constructor, method, args, kwargs) {
59
62
  lc: 2,
60
63
  type: "constructor",
61
64
  id: [constructor.name],
62
- method,
65
+ method: method ?? null,
63
66
  args: args ?? [],
64
67
  kwargs: kwargs ?? {},
65
68
  };
66
69
  }
67
70
  function _default(_key, obj) {
68
- if (obj instanceof Set || obj instanceof Map) {
71
+ if (obj === undefined) {
72
+ return {
73
+ lc: 2,
74
+ type: "undefined",
75
+ };
76
+ }
77
+ else if (obj instanceof Set || obj instanceof Map) {
69
78
  return _encodeConstructorArgs(obj.constructor, undefined, [
70
79
  Array.from(obj),
71
80
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-checkpoint",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Library with base interfaces for LangGraph checkpoint savers.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "scripts": {
16
16
  "build": "yarn turbo:command build:internal --filter=@langchain/langgraph-checkpoint",
17
- "build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
17
+ "build:internal": "yarn clean && yarn lc_build --create-entrypoints --pre --tree-shaking",
18
+ "clean": "rm -rf dist/ dist-cjs/ .turbo/",
18
19
  "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
19
20
  "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
20
21
  "lint": "yarn lint:eslint && yarn lint:dpdm",
@@ -37,7 +38,7 @@
37
38
  },
38
39
  "devDependencies": {
39
40
  "@jest/globals": "^29.5.0",
40
- "@langchain/scripts": ">=0.1.0 <0.2.0",
41
+ "@langchain/scripts": ">=0.1.2 <0.2.0",
41
42
  "@swc/core": "^1.3.90",
42
43
  "@swc/jest": "^0.2.29",
43
44
  "@tsconfig/recommended": "^1.0.3",