@langchain/langgraph 0.0.14 → 0.0.15

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseCheckpointSaver = exports.copyCheckpoint = exports.emptyCheckpoint = exports.deepCopy = void 0;
4
+ const base_js_1 = require("../serde/base.cjs");
4
5
  const id_js_1 = require("./id.cjs");
5
6
  function deepCopy(obj) {
6
7
  if (typeof obj !== "object" || obj === null) {
@@ -43,7 +44,7 @@ class BaseCheckpointSaver {
43
44
  enumerable: true,
44
45
  configurable: true,
45
46
  writable: true,
46
- value: JSON
47
+ value: base_js_1.DefaultSerializer
47
48
  });
48
49
  this.serde = serde || this.serde;
49
50
  }
@@ -1,3 +1,4 @@
1
+ import { DefaultSerializer } from "../serde/base.js";
1
2
  import { uuid6 } from "./id.js";
2
3
  export function deepCopy(obj) {
3
4
  if (typeof obj !== "object" || obj === null) {
@@ -37,7 +38,7 @@ export class BaseCheckpointSaver {
37
38
  enumerable: true,
38
39
  configurable: true,
39
40
  writable: true,
40
- value: JSON
41
+ value: DefaultSerializer
41
42
  });
42
43
  this.serde = serde || this.serde;
43
44
  }
@@ -22,8 +22,8 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
22
22
  if (checkpoint) {
23
23
  return {
24
24
  config,
25
- checkpoint: this.serde.parse(checkpoint[0]),
26
- metadata: this.serde.parse(checkpoint[1]),
25
+ checkpoint: (await this.serde.parse(checkpoint[0])),
26
+ metadata: (await this.serde.parse(checkpoint[1])),
27
27
  };
28
28
  }
29
29
  }
@@ -33,8 +33,8 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
33
33
  const checkpoint = checkpoints[maxThreadTs];
34
34
  return {
35
35
  config: { configurable: { thread_id, checkpoint_id: maxThreadTs } },
36
- checkpoint: this.serde.parse(checkpoint[0]),
37
- metadata: this.serde.parse(checkpoint[1]),
36
+ checkpoint: (await this.serde.parse(checkpoint[0])),
37
+ metadata: (await this.serde.parse(checkpoint[1])),
38
38
  };
39
39
  }
40
40
  }
@@ -50,8 +50,8 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
50
50
  .slice(0, limit)) {
51
51
  yield {
52
52
  config: { configurable: { thread_id, checkpoint_id } },
53
- checkpoint: this.serde.parse(checkpoint[0]),
54
- metadata: this.serde.parse(checkpoint[1]),
53
+ checkpoint: (await this.serde.parse(checkpoint[0])),
54
+ metadata: (await this.serde.parse(checkpoint[1])),
55
55
  };
56
56
  }
57
57
  }
@@ -19,8 +19,8 @@ export class MemorySaver extends BaseCheckpointSaver {
19
19
  if (checkpoint) {
20
20
  return {
21
21
  config,
22
- checkpoint: this.serde.parse(checkpoint[0]),
23
- metadata: this.serde.parse(checkpoint[1]),
22
+ checkpoint: (await this.serde.parse(checkpoint[0])),
23
+ metadata: (await this.serde.parse(checkpoint[1])),
24
24
  };
25
25
  }
26
26
  }
@@ -30,8 +30,8 @@ export class MemorySaver extends BaseCheckpointSaver {
30
30
  const checkpoint = checkpoints[maxThreadTs];
31
31
  return {
32
32
  config: { configurable: { thread_id, checkpoint_id: maxThreadTs } },
33
- checkpoint: this.serde.parse(checkpoint[0]),
34
- metadata: this.serde.parse(checkpoint[1]),
33
+ checkpoint: (await this.serde.parse(checkpoint[0])),
34
+ metadata: (await this.serde.parse(checkpoint[1])),
35
35
  };
36
36
  }
37
37
  }
@@ -47,8 +47,8 @@ export class MemorySaver extends BaseCheckpointSaver {
47
47
  .slice(0, limit)) {
48
48
  yield {
49
49
  config: { configurable: { thread_id, checkpoint_id } },
50
- checkpoint: this.serde.parse(checkpoint[0]),
51
- metadata: this.serde.parse(checkpoint[1]),
50
+ checkpoint: (await this.serde.parse(checkpoint[0])),
51
+ metadata: (await this.serde.parse(checkpoint[1])),
52
52
  };
53
53
  }
54
54
  }
@@ -61,8 +61,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
61
61
  if (row) {
62
62
  return {
63
63
  config,
64
- checkpoint: this.serde.parse(row.checkpoint),
65
- metadata: this.serde.parse(row.metadata),
64
+ checkpoint: (await this.serde.parse(row.checkpoint)),
65
+ metadata: (await this.serde.parse(row.metadata)),
66
66
  parentConfig: row.parent_id
67
67
  ? {
68
68
  configurable: {
@@ -91,8 +91,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
91
91
  checkpoint_id: row.checkpoint_id,
92
92
  },
93
93
  },
94
- checkpoint: this.serde.parse(row.checkpoint),
95
- metadata: this.serde.parse(row.metadata),
94
+ checkpoint: (await this.serde.parse(row.checkpoint)),
95
+ metadata: (await this.serde.parse(row.metadata)),
96
96
  parentConfig: row.parent_id
97
97
  ? {
98
98
  configurable: {
@@ -125,8 +125,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
125
125
  checkpoint_id: row.checkpoint_id,
126
126
  },
127
127
  },
128
- checkpoint: this.serde.parse(row.checkpoint),
129
- metadata: this.serde.parse(row.metadata),
128
+ checkpoint: (await this.serde.parse(row.checkpoint)),
129
+ metadata: (await this.serde.parse(row.metadata)),
130
130
  parentConfig: row.parent_id
131
131
  ? {
132
132
  configurable: {
@@ -55,8 +55,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
55
55
  if (row) {
56
56
  return {
57
57
  config,
58
- checkpoint: this.serde.parse(row.checkpoint),
59
- metadata: this.serde.parse(row.metadata),
58
+ checkpoint: (await this.serde.parse(row.checkpoint)),
59
+ metadata: (await this.serde.parse(row.metadata)),
60
60
  parentConfig: row.parent_id
61
61
  ? {
62
62
  configurable: {
@@ -85,8 +85,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
85
85
  checkpoint_id: row.checkpoint_id,
86
86
  },
87
87
  },
88
- checkpoint: this.serde.parse(row.checkpoint),
89
- metadata: this.serde.parse(row.metadata),
88
+ checkpoint: (await this.serde.parse(row.checkpoint)),
89
+ metadata: (await this.serde.parse(row.metadata)),
90
90
  parentConfig: row.parent_id
91
91
  ? {
92
92
  configurable: {
@@ -119,8 +119,8 @@ CREATE TABLE IF NOT EXISTS checkpoints (
119
119
  checkpoint_id: row.checkpoint_id,
120
120
  },
121
121
  },
122
- checkpoint: this.serde.parse(row.checkpoint),
123
- metadata: this.serde.parse(row.metadata),
122
+ checkpoint: (await this.serde.parse(row.checkpoint)),
123
+ metadata: (await this.serde.parse(row.metadata)),
124
124
  parentConfig: row.parent_id
125
125
  ? {
126
126
  configurable: {
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultSerializer = void 0;
4
+ const load_1 = require("@langchain/core/load");
5
+ exports.DefaultSerializer = {
6
+ stringify: JSON.stringify,
7
+ parse: load_1.load,
8
+ };
@@ -1,4 +1,12 @@
1
+ import { load } from "@langchain/core/load";
1
2
  export interface SerializerProtocol<D> {
2
3
  stringify(obj: D): string;
3
- parse(data: string): D;
4
+ parse(data: string): Promise<D>;
4
5
  }
6
+ export declare const DefaultSerializer: {
7
+ stringify: {
8
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
9
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
10
+ };
11
+ parse: typeof load;
12
+ };
@@ -1 +1,5 @@
1
- export {};
1
+ import { load } from "@langchain/core/load";
2
+ export const DefaultSerializer = {
3
+ stringify: JSON.stringify,
4
+ parse: load,
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {