@langchain/langgraph-checkpoint 0.1.0 → 1.0.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  3. package/dist/base.cjs +74 -88
  4. package/dist/base.cjs.map +1 -0
  5. package/dist/base.d.cts +95 -0
  6. package/dist/base.d.cts.map +1 -0
  7. package/dist/base.d.ts +79 -73
  8. package/dist/base.d.ts.map +1 -0
  9. package/dist/base.js +69 -80
  10. package/dist/base.js.map +1 -1
  11. package/dist/cache/base.cjs +17 -21
  12. package/dist/cache/base.cjs.map +1 -0
  13. package/dist/cache/base.d.cts +43 -0
  14. package/dist/cache/base.d.cts.map +1 -0
  15. package/dist/cache/base.d.ts +41 -36
  16. package/dist/cache/base.d.ts.map +1 -0
  17. package/dist/cache/base.js +16 -16
  18. package/dist/cache/base.js.map +1 -1
  19. package/dist/cache/index.cjs +2 -19
  20. package/dist/cache/index.js +4 -3
  21. package/dist/cache/memory.cjs +53 -58
  22. package/dist/cache/memory.cjs.map +1 -0
  23. package/dist/cache/memory.d.cts +19 -0
  24. package/dist/cache/memory.d.cts.map +1 -0
  25. package/dist/cache/memory.d.ts +18 -13
  26. package/dist/cache/memory.d.ts.map +1 -0
  27. package/dist/cache/memory.js +52 -53
  28. package/dist/cache/memory.js.map +1 -1
  29. package/dist/id.cjs +12 -16
  30. package/dist/id.cjs.map +1 -0
  31. package/dist/id.d.cts +10 -0
  32. package/dist/id.d.cts.map +1 -0
  33. package/dist/id.d.ts +10 -2
  34. package/dist/id.d.ts.map +1 -0
  35. package/dist/id.js +10 -12
  36. package/dist/id.js.map +1 -1
  37. package/dist/index.cjs +36 -27
  38. package/dist/index.d.cts +12 -0
  39. package/dist/index.d.ts +12 -8
  40. package/dist/index.js +12 -9
  41. package/dist/memory.cjs +194 -268
  42. package/dist/memory.cjs.map +1 -0
  43. package/dist/memory.d.cts +22 -0
  44. package/dist/memory.d.cts.map +1 -0
  45. package/dist/memory.d.ts +19 -12
  46. package/dist/memory.d.ts.map +1 -0
  47. package/dist/memory.js +193 -263
  48. package/dist/memory.js.map +1 -1
  49. package/dist/serde/base.d.cts +10 -0
  50. package/dist/serde/base.d.cts.map +1 -0
  51. package/dist/serde/base.d.ts +9 -3
  52. package/dist/serde/base.d.ts.map +1 -0
  53. package/dist/serde/jsonplus.cjs +92 -141
  54. package/dist/serde/jsonplus.cjs.map +1 -0
  55. package/dist/serde/jsonplus.js +90 -136
  56. package/dist/serde/jsonplus.js.map +1 -1
  57. package/dist/serde/types.cjs +15 -9
  58. package/dist/serde/types.cjs.map +1 -0
  59. package/dist/serde/types.d.cts +55 -0
  60. package/dist/serde/types.d.cts.map +1 -0
  61. package/dist/serde/types.d.ts +53 -47
  62. package/dist/serde/types.d.ts.map +1 -0
  63. package/dist/serde/types.js +9 -5
  64. package/dist/serde/types.js.map +1 -1
  65. package/dist/serde/utils/fast-safe-stringify/index.cjs +88 -208
  66. package/dist/serde/utils/fast-safe-stringify/index.cjs.map +1 -0
  67. package/dist/serde/utils/fast-safe-stringify/index.js +87 -205
  68. package/dist/serde/utils/fast-safe-stringify/index.js.map +1 -1
  69. package/dist/store/base.cjs +200 -209
  70. package/dist/store/base.cjs.map +1 -0
  71. package/dist/store/base.d.cts +392 -0
  72. package/dist/store/base.d.cts.map +1 -0
  73. package/dist/store/base.d.ts +336 -332
  74. package/dist/store/base.d.ts.map +1 -0
  75. package/dist/store/base.js +198 -204
  76. package/dist/store/base.js.map +1 -1
  77. package/dist/store/batch.cjs +116 -147
  78. package/dist/store/batch.cjs.map +1 -0
  79. package/dist/store/batch.d.cts +49 -0
  80. package/dist/store/batch.d.cts.map +1 -0
  81. package/dist/store/batch.d.ts +48 -40
  82. package/dist/store/batch.d.ts.map +1 -0
  83. package/dist/store/batch.js +116 -143
  84. package/dist/store/batch.js.map +1 -1
  85. package/dist/store/memory.cjs +262 -363
  86. package/dist/store/memory.cjs.map +1 -0
  87. package/dist/store/memory.d.cts +64 -0
  88. package/dist/store/memory.d.cts.map +1 -0
  89. package/dist/store/memory.d.ts +30 -24
  90. package/dist/store/memory.d.ts.map +1 -0
  91. package/dist/store/memory.js +261 -358
  92. package/dist/store/memory.js.map +1 -1
  93. package/dist/store/utils.cjs +141 -249
  94. package/dist/store/utils.cjs.map +1 -0
  95. package/dist/store/utils.js +140 -245
  96. package/dist/store/utils.js.map +1 -1
  97. package/dist/types.d.cts +35 -0
  98. package/dist/types.d.cts.map +1 -0
  99. package/dist/types.d.ts +29 -28
  100. package/dist/types.d.ts.map +1 -0
  101. package/package.json +16 -18
  102. package/dist/cache/index.d.ts +0 -2
  103. package/dist/cache/index.js.map +0 -1
  104. package/dist/index.js.map +0 -1
  105. package/dist/serde/base.cjs +0 -3
  106. package/dist/serde/base.js +0 -2
  107. package/dist/serde/base.js.map +0 -1
  108. package/dist/serde/jsonplus.d.ts +0 -7
  109. package/dist/serde/utils/fast-safe-stringify/index.d.ts +0 -1
  110. package/dist/store/index.cjs +0 -20
  111. package/dist/store/index.d.ts +0 -3
  112. package/dist/store/index.js +0 -4
  113. package/dist/store/index.js.map +0 -1
  114. package/dist/store/utils.d.ts +0 -26
  115. package/dist/types.cjs +0 -3
  116. package/dist/types.js +0 -2
  117. package/dist/types.js.map +0 -1
  118. package/index.cjs +0 -1
  119. package/index.d.cts +0 -1
  120. package/index.d.ts +0 -1
  121. package/index.js +0 -1
@@ -1,147 +1,120 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { BaseStore, } from "./base.js";
1
+ import { BaseStore } from "./base.js";
2
+
3
+ //#region src/store/batch.ts
3
4
  /**
4
- * Extracts and returns the underlying store from an `AsyncBatchedStore`,
5
- * or returns the input if it is not an `AsyncBatchedStore`.
6
- */
5
+ * Extracts and returns the underlying store from an `AsyncBatchedStore`,
6
+ * or returns the input if it is not an `AsyncBatchedStore`.
7
+ */
7
8
  const extractStore = (input) => {
8
- if ("lg_name" in input && input.lg_name === "AsyncBatchedStore") {
9
- // @ts-expect-error is a protected property
10
- return input.store;
11
- }
12
- return input;
9
+ if ("lg_name" in input && input.lg_name === "AsyncBatchedStore") return input.store;
10
+ return input;
13
11
  };
14
- export class AsyncBatchedStore extends BaseStore {
15
- constructor(store) {
16
- super();
17
- Object.defineProperty(this, "lg_name", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: "AsyncBatchedStore"
22
- });
23
- Object.defineProperty(this, "store", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: void 0
28
- });
29
- Object.defineProperty(this, "queue", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: new Map()
34
- });
35
- Object.defineProperty(this, "nextKey", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: 0
40
- });
41
- Object.defineProperty(this, "running", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: false
46
- });
47
- Object.defineProperty(this, "processingTask", {
48
- enumerable: true,
49
- configurable: true,
50
- writable: true,
51
- value: null
52
- });
53
- this.store = extractStore(store);
54
- }
55
- get isRunning() {
56
- return this.running;
57
- }
58
- /**
59
- * @ignore
60
- * Batch is not implemented here as we're only extending `BaseStore`
61
- * to allow it to be passed where `BaseStore` is expected, and implement
62
- * the convenience methods (get, search, put, delete).
63
- */
64
- async batch(_operations) {
65
- throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`." +
66
- "\n Instead, it calls the `batch` method on the wrapped store." +
67
- "\n If you are seeing this error, something is wrong.");
68
- }
69
- async get(namespace, key) {
70
- return this.enqueueOperation({ namespace, key });
71
- }
72
- async search(namespacePrefix, options) {
73
- const { filter, limit = 10, offset = 0, query } = options || {};
74
- return this.enqueueOperation({
75
- namespacePrefix,
76
- filter,
77
- limit,
78
- offset,
79
- query,
80
- });
81
- }
82
- async put(namespace, key, value) {
83
- return this.enqueueOperation({ namespace, key, value });
84
- }
85
- async delete(namespace, key) {
86
- return this.enqueueOperation({
87
- namespace,
88
- key,
89
- value: null,
90
- });
91
- }
92
- start() {
93
- if (!this.running) {
94
- this.running = true;
95
- this.processingTask = this.processBatchQueue();
96
- }
97
- }
98
- async stop() {
99
- this.running = false;
100
- if (this.processingTask) {
101
- await this.processingTask;
102
- }
103
- }
104
- enqueueOperation(operation) {
105
- return new Promise((resolve, reject) => {
106
- const key = this.nextKey;
107
- this.nextKey += 1;
108
- this.queue.set(key, { operation, resolve, reject });
109
- });
110
- }
111
- async processBatchQueue() {
112
- while (this.running) {
113
- await new Promise((resolve) => {
114
- setTimeout(resolve, 0);
115
- });
116
- if (this.queue.size === 0)
117
- continue;
118
- const batch = new Map(this.queue);
119
- this.queue.clear();
120
- try {
121
- const operations = Array.from(batch.values()).map(({ operation }) => operation);
122
- const results = await this.store.batch(operations);
123
- batch.forEach(({ resolve }, key) => {
124
- const index = Array.from(batch.keys()).indexOf(key);
125
- resolve(results[index]);
126
- });
127
- }
128
- catch (e) {
129
- batch.forEach(({ reject }) => {
130
- reject(e);
131
- });
132
- }
133
- }
134
- }
135
- // AsyncBatchedStore is internal and gets passed as args into traced tasks
136
- // some BaseStores contain circular references so just serialize without it
137
- // as this causes warnings when tracing with LangSmith.
138
- toJSON() {
139
- return {
140
- queue: this.queue,
141
- nextKey: this.nextKey,
142
- running: this.running,
143
- store: "[LangGraphStore]",
144
- };
145
- }
146
- }
12
+ var AsyncBatchedStore = class extends BaseStore {
13
+ lg_name = "AsyncBatchedStore";
14
+ store;
15
+ queue = /* @__PURE__ */ new Map();
16
+ nextKey = 0;
17
+ running = false;
18
+ processingTask = null;
19
+ constructor(store) {
20
+ super();
21
+ this.store = extractStore(store);
22
+ }
23
+ get isRunning() {
24
+ return this.running;
25
+ }
26
+ /**
27
+ * @ignore
28
+ * Batch is not implemented here as we're only extending `BaseStore`
29
+ * to allow it to be passed where `BaseStore` is expected, and implement
30
+ * the convenience methods (get, search, put, delete).
31
+ */
32
+ async batch(_operations) {
33
+ throw new Error("The `batch` method is not implemented on `AsyncBatchedStore`.\n Instead, it calls the `batch` method on the wrapped store.\n If you are seeing this error, something is wrong.");
34
+ }
35
+ async get(namespace, key) {
36
+ return this.enqueueOperation({
37
+ namespace,
38
+ key
39
+ });
40
+ }
41
+ async search(namespacePrefix, options) {
42
+ const { filter, limit = 10, offset = 0, query } = options || {};
43
+ return this.enqueueOperation({
44
+ namespacePrefix,
45
+ filter,
46
+ limit,
47
+ offset,
48
+ query
49
+ });
50
+ }
51
+ async put(namespace, key, value) {
52
+ return this.enqueueOperation({
53
+ namespace,
54
+ key,
55
+ value
56
+ });
57
+ }
58
+ async delete(namespace, key) {
59
+ return this.enqueueOperation({
60
+ namespace,
61
+ key,
62
+ value: null
63
+ });
64
+ }
65
+ start() {
66
+ if (!this.running) {
67
+ this.running = true;
68
+ this.processingTask = this.processBatchQueue();
69
+ }
70
+ }
71
+ async stop() {
72
+ this.running = false;
73
+ if (this.processingTask) await this.processingTask;
74
+ }
75
+ enqueueOperation(operation) {
76
+ return new Promise((resolve, reject) => {
77
+ const key = this.nextKey;
78
+ this.nextKey += 1;
79
+ this.queue.set(key, {
80
+ operation,
81
+ resolve,
82
+ reject
83
+ });
84
+ });
85
+ }
86
+ async processBatchQueue() {
87
+ while (this.running) {
88
+ await new Promise((resolve) => {
89
+ setTimeout(resolve, 0);
90
+ });
91
+ if (this.queue.size === 0) continue;
92
+ const batch = new Map(this.queue);
93
+ this.queue.clear();
94
+ try {
95
+ const operations = Array.from(batch.values()).map(({ operation }) => operation);
96
+ const results = await this.store.batch(operations);
97
+ batch.forEach(({ resolve }, key) => {
98
+ const index = Array.from(batch.keys()).indexOf(key);
99
+ resolve(results[index]);
100
+ });
101
+ } catch (e) {
102
+ batch.forEach(({ reject }) => {
103
+ reject(e);
104
+ });
105
+ }
106
+ }
107
+ }
108
+ toJSON() {
109
+ return {
110
+ queue: this.queue,
111
+ nextKey: this.nextKey,
112
+ running: this.running,
113
+ store: "[LangGraphStore]"
114
+ };
115
+ }
116
+ };
117
+
118
+ //#endregion
119
+ export { AsyncBatchedStore };
147
120
  //# sourceMappingURL=batch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/store/batch.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EACL,SAAS,GAOV,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAa,EAAE;IACvE,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAC;QAChE,2CAA2C;QAC3C,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAoB9C,YAAY,KAAgB;QAC1B,KAAK,EAAE,CAAC;QApBV;;;;mBAAU,mBAAmB;WAAC;QAEpB;;;;;WAAiB;QAEnB;;;;mBAOJ,IAAI,GAAG,EAAE;WAAC;QAEN;;;;mBAAkB,CAAC;WAAC;QAEpB;;;;mBAAU,KAAK;WAAC;QAEhB;;;;mBAAuC,IAAI;WAAC;QAIlD,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CACT,WAAe;QAEf,MAAM,IAAI,KAAK,CACb,+DAA+D;YAC7D,+DAA+D;YAC/D,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,SAAmB,EAAE,GAAW;QACxC,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAkB,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,MAAM,CACV,eAAyB,EACzB,OAKC;QAED,MAAM,EAAE,M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AAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,kBAAkB;SAC1B,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"batch.js","names":[],"sources":["../../src/store/batch.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n BaseStore,\n type Item,\n type SearchOperation,\n type PutOperation,\n type GetOperation,\n type Operation,\n OperationResults,\n} from \"./base.js\";\n\n/**\n * Extracts and returns the underlying store from an `AsyncBatchedStore`,\n * or returns the input if it is not an `AsyncBatchedStore`.\n */\nconst extractStore = (input: BaseStore | AsyncBatchedStore): BaseStore => {\n if (\"lg_name\" in input && input.lg_name === \"AsyncBatchedStore\") {\n // @ts-expect-error is a protected property\n return input.store;\n }\n return input;\n};\n\nexport class AsyncBatchedStore extends BaseStore {\n lg_name = \"AsyncBatchedStore\";\n\n protected store: BaseStore;\n\n private queue: Map<\n number,\n {\n operation: Operation;\n resolve: (value: any) => void;\n reject: (reason?: any) => void;\n }\n > = new Map();\n\n private nextKey: number = 0;\n\n private running = false;\n\n private processingTask: Promise<void> | null = null;\n\n constructor(store: BaseStore) {\n super();\n this.store = extractStore(store);\n }\n\n get isRunning(): boolean {\n return this.running;\n }\n\n /**\n * @ignore\n * Batch is not implemented here as we're only extending `BaseStore`\n * to allow it to be passed where `BaseStore` is expected, and implement\n * the convenience methods (get, search, put, delete).\n */\n async batch<Op extends Operation[]>(\n _operations: Op\n ): Promise<OperationResults<Op>> {\n throw new Error(\n \"The `batch` method is not implemented on `AsyncBatchedStore`.\" +\n \"\\n Instead, it calls the `batch` method on the wrapped store.\" +\n \"\\n If you are seeing this error, something is wrong.\"\n );\n }\n\n async get(namespace: string[], key: string): Promise<Item | null> {\n return this.enqueueOperation({ namespace, key } as GetOperation);\n }\n\n async search(\n namespacePrefix: string[],\n options?: {\n filter?: Record<string, any>;\n limit?: number;\n offset?: number;\n query?: string;\n }\n ): Promise<Item[]> {\n const { filter, limit = 10, offset = 0, query } = options || {};\n return this.enqueueOperation({\n namespacePrefix,\n filter,\n limit,\n offset,\n query,\n } as SearchOperation);\n }\n\n async put(\n namespace: string[],\n key: string,\n value: Record<string, any>\n ): Promise<void> {\n return this.enqueueOperation({ namespace, key, value } as PutOperation);\n }\n\n async delete(namespace: string[], key: string): Promise<void> {\n return this.enqueueOperation({\n namespace,\n key,\n value: null,\n } as PutOperation);\n }\n\n start(): void {\n if (!this.running) {\n this.running = true;\n this.processingTask = this.processBatchQueue();\n }\n }\n\n async stop(): Promise<void> {\n this.running = false;\n if (this.processingTask) {\n await this.processingTask;\n }\n }\n\n private enqueueOperation<T>(operation: Operation): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const key = this.nextKey;\n this.nextKey += 1;\n this.queue.set(key, { operation, resolve, reject });\n });\n }\n\n private async processBatchQueue(): Promise<void> {\n while (this.running) {\n await new Promise((resolve) => {\n setTimeout(resolve, 0);\n });\n if (this.queue.size === 0) continue;\n\n const batch = new Map(this.queue);\n this.queue.clear();\n\n try {\n const operations = Array.from(batch.values()).map(\n ({ operation }) => operation\n );\n const results = await this.store.batch(operations);\n\n batch.forEach(({ resolve }, key) => {\n const index = Array.from(batch.keys()).indexOf(key);\n resolve(results[index]);\n });\n } catch (e) {\n batch.forEach(({ reject }) => {\n reject(e);\n });\n }\n }\n }\n\n // AsyncBatchedStore is internal and gets passed as args into traced tasks\n // some BaseStores contain circular references so just serialize without it\n // as this causes warnings when tracing with LangSmith.\n toJSON() {\n return {\n queue: this.queue,\n nextKey: this.nextKey,\n running: this.running,\n store: \"[LangGraphStore]\",\n };\n }\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,gBAAgB,UAAoD;AACxE,KAAI,aAAa,SAAS,MAAM,YAAY,oBAE1C,QAAO,MAAM;AAEf,QAAO;;AAGT,IAAa,oBAAb,cAAuC,UAAU;CAC/C,UAAU;CAEV,AAAU;CAEV,AAAQ,wBAOJ,IA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