zen-code 4.6.0 → 4.6.1

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 (33) hide show
  1. package/dist/MultiLineTextInput-B4NEXnFm.mjs +23343 -0
  2. package/dist/devtools-BHqoL8a6.mjs +11653 -0
  3. package/dist/graphBuilder-B3IJ7dB2.mjs +2641 -0
  4. package/dist/{index-B6kFMamn.mjs → index-DEcMgCTj.mjs} +1 -1
  5. package/dist/{memories-DirsFRdm.mjs → memories-rSGKIPk5.mjs} +1 -1
  6. package/dist/nonInteractive.mjs +7 -6
  7. package/dist/{subTasks-Bt97OwvY.mjs → subTasks-5KLIr9iy.mjs} +2 -2
  8. package/dist/zen-code.mjs +8654 -2
  9. package/dist/zen-keyboard.mjs +7 -6
  10. package/package.json +7 -9
  11. package/dist/MultiLineTextInput-e7hD79Wp.mjs +0 -24631
  12. package/dist/app-CM8R0ZR6.mjs +0 -16249
  13. package/dist/assets/worker-I4QjJYba.js +0 -1
  14. package/dist/checkpoint-1sAx_j1E-DrVPlSLR.mjs +0 -319
  15. package/dist/checkpoint-DxiUsHMy-Cjy5WGNC.mjs +0 -394
  16. package/dist/chunk-YWE62C55-DID9N9eS.mjs +0 -193
  17. package/dist/devtools-CzaVuYnh.mjs +0 -2667
  18. package/dist/graphBuilder-mpLrx9tk.mjs +0 -49189
  19. package/dist/index-BUGHAUbY.mjs +0 -117
  20. package/dist/index-C5j-48Ft.mjs +0 -75
  21. package/dist/index-ChCbbHFS.mjs +0 -463
  22. package/dist/index-DS5HVciX.mjs +0 -216
  23. package/dist/index-FHDPQ2Qk.mjs +0 -211
  24. package/dist/kysely-Bchvsze0.mjs +0 -4316
  25. package/dist/load-Cjl9cJ0o.mjs +0 -105
  26. package/dist/migrator-BatO36Tk.mjs +0 -592
  27. package/dist/pg-adapter-BFtir1GE-BU2H39HC.mjs +0 -62
  28. package/dist/postgres-dialect-DaHvQ_AZ.mjs +0 -211
  29. package/dist/queue-Cu_nO_wt-ChzSaooi.mjs +0 -106
  30. package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +0 -157
  31. package/dist/shallow-tfhh5rlz.mjs +0 -331
  32. package/dist/sql-CJsUpKEQ.mjs +0 -8106
  33. package/dist/sqlite-adapter-BKOLSdoL-BlGKN04G.mjs +0 -71
@@ -1,117 +0,0 @@
1
- import "bun:sqlite";
2
- import { B as f, c as k } from "./chunk-YWE62C55-DID9N9eS.mjs";
3
- import { aY as m } from "./sql-CJsUpKEQ.mjs";
4
- import { EventEmitter as p } from "node:events";
5
- var l = "0", h = "1", w = "2", c = "3", u = "4", y = (e, t) => e.onmessage = ({ data: r }) => t(r), E = class extends k {
6
- worker;
7
- mitt;
8
- constructor(e, t) {
9
- super(async () => {
10
- const r = await e();
11
- this.mitt = r.mitt, this.worker = r.worker, r.handle(
12
- this.worker,
13
- ([s, ...i]) => this.mitt.emit(s, ...i)
14
- ), this.worker.postMessage([
15
- l,
16
- r.data || {}
17
- ]), await new Promise((s, i) => {
18
- this.mitt.once(l, (a, o) => o ? i(o) : s());
19
- }), this.conn = new W(this.worker, this.mitt), await t?.(this.conn);
20
- });
21
- }
22
- async destroy() {
23
- if (this.worker)
24
- return this.worker.postMessage([w]), new Promise(
25
- (e, t) => this.mitt?.once(
26
- w,
27
- (r, s) => s ? t(s) : e()
28
- )
29
- ).finally(() => {
30
- this.worker?.terminate(), this.mitt?.off(), this.mitt = this.worker = void 0;
31
- });
32
- }
33
- }, W = class {
34
- constructor(e, t) {
35
- this.worker = e, this.mitt = t;
36
- }
37
- async *streamQuery({ parameters: e, sql: t, query: r }) {
38
- this.worker.postMessage([
39
- c,
40
- m.is(r),
41
- t,
42
- e
43
- ]);
44
- let s = !1, i, a;
45
- for (this.mitt.on(c, (o, n) => {
46
- n ? a(n) : i([{ rows: [o] }, !1]);
47
- }), this.mitt.on(u, (o, n) => {
48
- n ? a(n) : i([void 0, !0]);
49
- }); !s; ) {
50
- const [o, n] = await new Promise((v, d) => {
51
- i = v, a = d;
52
- });
53
- n ? (s = !0, this.mitt?.off(c), this.mitt?.off(u)) : yield o;
54
- }
55
- }
56
- async executeQuery(e) {
57
- const { parameters: t, sql: r, query: s } = e;
58
- return this.worker.postMessage([
59
- h,
60
- m.is(s),
61
- r,
62
- t
63
- ]), await new Promise((i, a) => {
64
- this.mitt || a(new Error("kysely instance has been destroyed")), this.mitt.once(h, (o, n) => !n && o ? i(o) : a(n));
65
- });
66
- }
67
- }, q = class extends f {
68
- /**
69
- * Dialect for generic SQLite that run SQLs in worker thread
70
- *
71
- * @param executor function to create {@link IGenericSqliteWorkerExecutor}
72
- * @param onCreateConnection optional callback after connection created
73
- */
74
- constructor(e, t) {
75
- super(() => new E(e, t));
76
- }
77
- }, x = class extends p {
78
- off(e) {
79
- return this.removeAllListeners(e);
80
- }
81
- };
82
- function S() {
83
- return new x();
84
- }
85
- var B = class extends q {
86
- /**
87
- * dialect for `bun:sqlite`, run sql in worker
88
- */
89
- constructor(e) {
90
- const {
91
- url: t = ":memory:",
92
- cacheStatment: r = !1,
93
- onCreateConnection: s,
94
- worker: i = new Worker(
95
- new URL(
96
- /* @vite-ignore */
97
- "/assets/worker-I4QjJYba.js",
98
- import.meta.url
99
- ),
100
- { type: "module" }
101
- ),
102
- dbOptions: a = { create: !0 }
103
- } = e || {};
104
- super(
105
- () => ({
106
- data: { cache: r, fileName: t, opt: a },
107
- mitt: S(),
108
- handle: y,
109
- worker: i
110
- }),
111
- s
112
- );
113
- }
114
- };
115
- export {
116
- B as BunWorkerDialect
117
- };
@@ -1,75 +0,0 @@
1
- import { B as i, c as o, d as c } from "./chunk-YWE62C55-DID9N9eS.mjs";
2
- import { aY as a } from "./sql-CJsUpKEQ.mjs";
3
- var u = class extends o {
4
- db;
5
- constructor(t, e) {
6
- super(async () => {
7
- this.db = await t(), this.conn = new l(this.db), await e?.(this.conn);
8
- });
9
- }
10
- async destroy() {
11
- await this.db?.close();
12
- }
13
- }, l = class {
14
- constructor(t) {
15
- this.db = t;
16
- }
17
- async *streamQuery({ parameters: t, query: e, sql: r }) {
18
- if (!this.db.iterator)
19
- throw new Error("streamQuery() is not supported.");
20
- const s = this.db.iterator(a.is(e), r, t);
21
- for await (const n of s)
22
- yield { rows: [n] };
23
- }
24
- async executeQuery({ parameters: t, query: e, sql: r }) {
25
- return await this.db.query(a.is(e), r, t);
26
- }
27
- }, d = class extends i {
28
- /**
29
- * Dialect for generic SQLite that run SQLs in current thread
30
- *
31
- * @param executor function to create {@link IGenericSqlite}
32
- * @param onCreateConnection optional callback after connection created
33
- */
34
- constructor(t, e) {
35
- super(() => new u(t, e));
36
- }
37
- };
38
- async function y(t) {
39
- return typeof t == "function" ? await t() : t;
40
- }
41
- var h = class extends d {
42
- /**
43
- * dialect for [node sqlite3 wasm](https://github.com/tndrle/node-sqlite3-wasm)
44
- */
45
- constructor(t) {
46
- super(
47
- async () => {
48
- const e = await y(t.database);
49
- return {
50
- db: e,
51
- close: () => e.close(),
52
- query: c({
53
- all: (r, s) => e.all(r, s),
54
- run: (r) => {
55
- const { changes: s, lastInsertRowid: n } = e.run(r);
56
- return {
57
- insertId: BigInt(n),
58
- numAffectedRows: BigInt(s)
59
- };
60
- }
61
- }),
62
- iterator: (r, s, n) => {
63
- if (!r)
64
- throw new Error("Only support select query");
65
- return e.prepare(s).iterate(n);
66
- }
67
- };
68
- },
69
- t.onCreateConnection
70
- );
71
- }
72
- };
73
- export {
74
- h as NodeWasmDialect
75
- };
@@ -1,463 +0,0 @@
1
- import { B as C, u as v, c as x, T as $, m as I } from "./app-CM8R0ZR6.mjs";
2
- import "./graphBuilder-mpLrx9tk.mjs";
3
- import { createClient as O, createCluster as N } from "redis";
4
- const W = [
5
- {
6
- index: "checkpoints",
7
- prefix: "checkpoint:",
8
- schema: {
9
- "$.thread_id": {
10
- type: "TAG",
11
- AS: "thread_id"
12
- },
13
- "$.checkpoint_ns": {
14
- type: "TAG",
15
- AS: "checkpoint_ns"
16
- },
17
- "$.checkpoint_id": {
18
- type: "TAG",
19
- AS: "checkpoint_id"
20
- },
21
- "$.parent_checkpoint_id": {
22
- type: "TAG",
23
- AS: "parent_checkpoint_id"
24
- },
25
- "$.checkpoint_ts": {
26
- type: "NUMERIC",
27
- AS: "checkpoint_ts"
28
- },
29
- "$.has_writes": {
30
- type: "TAG",
31
- AS: "has_writes"
32
- },
33
- "$.source": {
34
- type: "TAG",
35
- AS: "source"
36
- },
37
- "$.step": {
38
- type: "NUMERIC",
39
- AS: "step"
40
- }
41
- }
42
- },
43
- {
44
- index: "checkpoint_blobs",
45
- prefix: "checkpoint_blob:",
46
- schema: {
47
- "$.thread_id": {
48
- type: "TAG",
49
- AS: "thread_id"
50
- },
51
- "$.checkpoint_ns": {
52
- type: "TAG",
53
- AS: "checkpoint_ns"
54
- },
55
- "$.checkpoint_id": {
56
- type: "TAG",
57
- AS: "checkpoint_id"
58
- },
59
- "$.channel": {
60
- type: "TAG",
61
- AS: "channel"
62
- },
63
- "$.version": {
64
- type: "TAG",
65
- AS: "version"
66
- },
67
- "$.type": {
68
- type: "TAG",
69
- AS: "type"
70
- }
71
- }
72
- },
73
- {
74
- index: "checkpoint_writes",
75
- prefix: "checkpoint_write:",
76
- schema: {
77
- "$.thread_id": {
78
- type: "TAG",
79
- AS: "thread_id"
80
- },
81
- "$.checkpoint_ns": {
82
- type: "TAG",
83
- AS: "checkpoint_ns"
84
- },
85
- "$.checkpoint_id": {
86
- type: "TAG",
87
- AS: "checkpoint_id"
88
- },
89
- "$.task_id": {
90
- type: "TAG",
91
- AS: "task_id"
92
- },
93
- "$.idx": {
94
- type: "NUMERIC",
95
- AS: "idx"
96
- },
97
- "$.channel": {
98
- type: "TAG",
99
- AS: "channel"
100
- },
101
- "$.type": {
102
- type: "TAG",
103
- AS: "type"
104
- }
105
- }
106
- }
107
- ];
108
- var E = class T extends C {
109
- client;
110
- ttlConfig;
111
- constructor(e, t) {
112
- super(), this.client = e, this.ttlConfig = t;
113
- }
114
- static async fromUrl(e, t) {
115
- const s = O({ url: e });
116
- await s.connect();
117
- const i = new T(s, t);
118
- return await i.ensureIndexes(), i;
119
- }
120
- static async fromCluster(e, t) {
121
- const s = N({ rootNodes: e });
122
- await s.connect();
123
- const i = new T(s, t);
124
- return await i.ensureIndexes(), i;
125
- }
126
- async get(e) {
127
- return (await this.getTuple(e))?.checkpoint;
128
- }
129
- async getTuple(e) {
130
- const t = e.configurable?.thread_id, s = e.configurable?.checkpoint_ns ?? "", i = e.configurable?.checkpoint_id;
131
- if (!t) return;
132
- let c, o;
133
- if (i)
134
- c = `checkpoint:${t}:${s}:${i}`, o = await this.client.json.get(c);
135
- else {
136
- const r = `checkpoint:${t}:${s}:*`, p = await this.client.keys(r);
137
- if (p.length === 0) return;
138
- p.sort(), c = p[p.length - 1], o = await this.client.json.get(c);
139
- }
140
- if (!o) return;
141
- this.ttlConfig?.refreshOnRead && this.ttlConfig?.defaultTTL && await this.applyTTL(c);
142
- const { checkpoint: f, pendingWrites: n } = await this.loadCheckpointWithWrites(o);
143
- return await this.createCheckpointTuple(o, f, n);
144
- }
145
- async put(e, t, s, i) {
146
- await this.ensureIndexes();
147
- const c = e.configurable?.thread_id, o = e.configurable?.checkpoint_ns ?? "", f = e.configurable?.checkpoint_id;
148
- if (!c) throw new Error("thread_id is required");
149
- const n = t.id || v(0), r = `checkpoint:${c}:${o}:${n}`, p = x(t);
150
- if (p.channel_values && i !== void 0) if (Object.keys(i).length === 0) p.channel_values = {};
151
- else {
152
- const u = {};
153
- for (const a of Object.keys(i)) a in p.channel_values && (u[a] = p.channel_values[a]);
154
- p.channel_values = u;
155
- }
156
- const l = {
157
- thread_id: c,
158
- checkpoint_ns: o === "" ? "__empty__" : o,
159
- checkpoint_id: n,
160
- parent_checkpoint_id: f || null,
161
- checkpoint: p,
162
- metadata: s,
163
- checkpoint_ts: Date.now(),
164
- has_writes: "false"
165
- };
166
- return this.addSearchableMetadataFields(l, s), await this.client.json.set(r, "$", l), this.ttlConfig?.defaultTTL && await this.applyTTL(r), { configurable: {
167
- thread_id: c,
168
- checkpoint_ns: o,
169
- checkpoint_id: n
170
- } };
171
- }
172
- async *list(e, t) {
173
- if (await this.ensureIndexes(), t?.filter !== void 0) {
174
- const i = Object.values(t.filter).some((n) => n === null), c = [];
175
- if (e?.configurable?.thread_id) {
176
- const n = e.configurable.thread_id.replace(/[-.@]/g, "\\$&");
177
- c.push(`(@thread_id:{${n}})`);
178
- }
179
- if (e?.configurable?.checkpoint_ns !== void 0) {
180
- const n = e.configurable.checkpoint_ns;
181
- if (n === "") c.push("(@checkpoint_ns:{__empty__})");
182
- else {
183
- const r = n.replace(/[-.@]/g, "\\$&");
184
- c.push(`(@checkpoint_ns:{${r}})`);
185
- }
186
- }
187
- if (!t?.before && t?.filter)
188
- for (const [n, r] of Object.entries(t.filter)) r === void 0 || r === null || (typeof r == "string" ? c.push(`(@${n}:{${r}})`) : typeof r == "number" ? c.push(`(@${n}:[${r} ${r}])`) : typeof r == "object" && Object.keys(r).length);
189
- c.length === 0 && c.push("*");
190
- const o = c.join(" "), f = t?.limit ?? 10;
191
- try {
192
- const n = t?.before && !e?.configurable?.thread_id ? 1e3 : t?.before ? f * 10 : f;
193
- let p = (await this.client.ft.search("checkpoints", o, {
194
- LIMIT: {
195
- from: 0,
196
- size: n
197
- },
198
- SORTBY: {
199
- BY: "checkpoint_ts",
200
- DIRECTION: "DESC"
201
- }
202
- })).documents, l = 0;
203
- for (const u of p) {
204
- if (l >= f) break;
205
- if (t?.before?.configurable?.checkpoint_id) {
206
- const k = u.value.checkpoint_id, d = t.before.configurable.checkpoint_id;
207
- if (k >= d) continue;
208
- }
209
- const a = u.value;
210
- let h = !0;
211
- if ((i || t?.before) && t?.filter) {
212
- for (const [k, d] of Object.entries(t.filter)) if (d === null) {
213
- if (a.metadata?.[k] !== null) {
214
- h = !1;
215
- break;
216
- }
217
- } else if (d !== void 0) {
218
- const b = a.metadata?.[k];
219
- if (typeof d == "object" && d !== null) {
220
- if (g(b) !== g(d)) {
221
- h = !1;
222
- break;
223
- }
224
- } else if (b !== d) {
225
- h = !1;
226
- break;
227
- }
228
- }
229
- if (!h) continue;
230
- }
231
- const { checkpoint: y, pendingWrites: _ } = await this.loadCheckpointWithWrites(a);
232
- yield await this.createCheckpointTuple(a, y, _), l++;
233
- }
234
- return;
235
- } catch (n) {
236
- if (!n.message?.includes("no such index")) throw n;
237
- }
238
- if (e?.configurable?.thread_id) {
239
- const n = e.configurable.thread_id, r = e.configurable.checkpoint_ns ?? "", p = `checkpoint:${n}:${r}:*`, l = await this.client.keys(p);
240
- l.sort().reverse();
241
- let u = l;
242
- if (t?.before?.configurable?.checkpoint_id) {
243
- const y = t.before.configurable.thread_id || n, _ = t.before.configurable.checkpoint_ns ?? r, k = `checkpoint:${y}:${_}:${t.before.configurable.checkpoint_id}`, d = l.indexOf(k);
244
- d > 0 ? u = l.slice(d + 1) : d === 0 && (u = []);
245
- }
246
- const a = t?.limit ?? 10, h = u.slice(0, a);
247
- for (const y of h) {
248
- const _ = await this.client.json.get(y);
249
- if (_) {
250
- let k = !0;
251
- for (const [S, m] of Object.entries(t.filter)) {
252
- const A = _.metadata?.[S];
253
- if (m === null) {
254
- if (A !== null) {
255
- k = !1;
256
- break;
257
- }
258
- } else if (A !== m) {
259
- k = !1;
260
- break;
261
- }
262
- }
263
- if (!k) continue;
264
- const { checkpoint: d, pendingWrites: b } = await this.loadCheckpointWithWrites(_);
265
- yield await this.createCheckpointTuple(_, d, b);
266
- }
267
- }
268
- } else {
269
- const n = e?.configurable?.checkpoint_ns !== void 0 ? `checkpoint:*:${e.configurable.checkpoint_ns === "" ? "__empty__" : e.configurable.checkpoint_ns}:*` : "checkpoint:*", r = await this.client.keys(n), p = [];
270
- for (const a of r) {
271
- const h = await this.client.json.get(a);
272
- h && p.push({
273
- key: a,
274
- doc: h
275
- });
276
- }
277
- p.sort((a, h) => h.doc.checkpoint_ts - a.doc.checkpoint_ts);
278
- let l = 0;
279
- const u = t?.limit ?? 10;
280
- for (const { doc: a } of p) {
281
- if (l >= u) break;
282
- if (t?.before?.configurable?.checkpoint_id) {
283
- const k = a.checkpoint_id, d = t.before.configurable.checkpoint_id;
284
- if (k >= d) continue;
285
- }
286
- let h = !0;
287
- if (t?.filter) {
288
- for (const [k, d] of Object.entries(t.filter)) if (d === null) {
289
- if (a.metadata?.[k] !== null) {
290
- h = !1;
291
- break;
292
- }
293
- } else if (d !== void 0) {
294
- const b = a.metadata?.[k];
295
- if (typeof d == "object" && d !== null) {
296
- if (g(b) !== g(d)) {
297
- h = !1;
298
- break;
299
- }
300
- } else if (b !== d) {
301
- h = !1;
302
- break;
303
- }
304
- }
305
- if (!h) continue;
306
- }
307
- const { checkpoint: y, pendingWrites: _ } = await this.loadCheckpointWithWrites(a);
308
- yield await this.createCheckpointTuple(a, y, _), l++;
309
- }
310
- }
311
- return;
312
- }
313
- const s = {
314
- ...t,
315
- filter: {}
316
- };
317
- yield* this.list(e, s);
318
- }
319
- async putWrites(e, t, s) {
320
- await this.ensureIndexes();
321
- const i = e.configurable?.thread_id, c = e.configurable?.checkpoint_ns ?? "", o = e.configurable?.checkpoint_id;
322
- if (!i || !o) throw new Error("thread_id and checkpoint_id are required");
323
- const f = [], n = performance.now() * 1e3;
324
- for (let l = 0; l < t.length; l++) {
325
- const [u, a] = t[l], h = `checkpoint_write:${i}:${c}:${o}:${s}:${l}`;
326
- f.push(h);
327
- const y = {
328
- thread_id: i,
329
- checkpoint_ns: c,
330
- checkpoint_id: o,
331
- task_id: s,
332
- idx: l,
333
- channel: u,
334
- type: typeof a == "object" ? "json" : "string",
335
- value: a,
336
- timestamp: n,
337
- global_idx: n + l
338
- };
339
- await this.client.json.set(h, "$", y);
340
- }
341
- if (f.length > 0) {
342
- const l = `write_keys_zset:${i}:${c}:${o}`, u = {};
343
- f.forEach((a, h) => {
344
- u[a] = n + h;
345
- }), await this.client.zAdd(l, Object.entries(u).map(([a, h]) => ({
346
- score: h,
347
- value: a
348
- }))), this.ttlConfig?.defaultTTL && await this.applyTTL(...f, l);
349
- }
350
- const r = `checkpoint:${i}:${c}:${o}`;
351
- if (await this.client.exists(r)) {
352
- const l = await this.client.json.get(r);
353
- l && (l.has_writes = "true", await this.client.json.set(r, "$", l));
354
- }
355
- }
356
- async deleteThread(e) {
357
- const t = `checkpoint:${e}:*`, s = await this.client.keys(t);
358
- s.length > 0 && await this.client.del(s);
359
- const i = `writes:${e}:*`, c = await this.client.keys(i);
360
- c.length > 0 && await this.client.del(c);
361
- }
362
- async end() {
363
- await this.client.quit();
364
- }
365
- async loadPendingWrites(e, t, s) {
366
- const i = `checkpoint_write:${e}:${t}:${s}:*`, c = await this.client.keys(i);
367
- if (c.length === 0) return;
368
- const o = [];
369
- for (const n of c) {
370
- const r = await this.client.json.get(n);
371
- r && o.push(r);
372
- }
373
- o.sort((n, r) => (n.global_idx || 0) - (r.global_idx || 0));
374
- const f = [];
375
- for (const n of o) {
376
- const r = await this.serde.loadsTyped("json", JSON.stringify(n.value));
377
- f.push([
378
- n.task_id,
379
- n.channel,
380
- r
381
- ]);
382
- }
383
- return f;
384
- }
385
- async loadCheckpointWithWrites(e) {
386
- const t = await this.serde.loadsTyped("json", JSON.stringify(e.checkpoint));
387
- if (t.v < 4 && e.parent_checkpoint_id != null) {
388
- const i = e.checkpoint_ns === "__empty__" ? "" : e.checkpoint_ns;
389
- await this.migratePendingSends(t, e.thread_id, i, e.parent_checkpoint_id);
390
- }
391
- let s;
392
- if (e.has_writes === "true") {
393
- const i = e.checkpoint_ns === "__empty__" ? "" : e.checkpoint_ns;
394
- s = await this.loadPendingWrites(e.thread_id, i, e.checkpoint_id);
395
- }
396
- return {
397
- checkpoint: t,
398
- pendingWrites: s
399
- };
400
- }
401
- async migratePendingSends(e, t, s, i) {
402
- const c = await this.loadPendingWrites(t, s, i);
403
- if (!c || c.length === 0) return;
404
- const o = c.filter(([, n]) => n === $);
405
- if (o.length === 0) return;
406
- const f = [];
407
- for (const [, , n] of o) f.push(n);
408
- e.channel_values ??= {}, e.channel_values[$] = f, e.channel_versions[$] = Object.keys(e.channel_versions).length > 0 ? I(...Object.values(e.channel_versions)) : 1;
409
- }
410
- async createCheckpointTuple(e, t, s) {
411
- const i = e.checkpoint_ns === "__empty__" ? "" : e.checkpoint_ns, c = await this.serde.loadsTyped("json", JSON.stringify(e.metadata));
412
- return {
413
- config: { configurable: {
414
- thread_id: e.thread_id,
415
- checkpoint_ns: i,
416
- checkpoint_id: e.checkpoint_id
417
- } },
418
- checkpoint: t,
419
- metadata: c,
420
- parentConfig: e.parent_checkpoint_id ? { configurable: {
421
- thread_id: e.thread_id,
422
- checkpoint_ns: i,
423
- checkpoint_id: e.parent_checkpoint_id
424
- } } : void 0,
425
- pendingWrites: s
426
- };
427
- }
428
- addSearchableMetadataFields(e, t) {
429
- t && ("source" in t && (e.source = t.source), "step" in t && (e.step = t.step), "writes" in t && (e.writes = typeof t.writes == "object" ? JSON.stringify(t.writes) : t.writes), "score" in t && (e.score = t.score));
430
- }
431
- async applyTTL(...e) {
432
- if (!this.ttlConfig?.defaultTTL) return;
433
- const t = Math.floor(this.ttlConfig.defaultTTL * 60), s = await Promise.allSettled(e.map((i) => this.client.expire(i, t)));
434
- for (let i = 0; i < s.length; i++) s[i].status === "rejected" && console.warn(`Failed to set TTL for key ${e[i]}:`, s[i].reason);
435
- }
436
- async ensureIndexes() {
437
- for (const e of W) try {
438
- await this.client.ft.create(e.index, e.schema, {
439
- ON: "JSON",
440
- PREFIX: e.prefix
441
- });
442
- } catch (t) {
443
- t.message?.includes("Index already exists") || console.error(`Failed to create index ${e.index}:`, t.message);
444
- }
445
- }
446
- };
447
- function g(w) {
448
- if (w === null || typeof w != "object") return JSON.stringify(w);
449
- if (Array.isArray(w)) return JSON.stringify(w.map((s) => g(s)));
450
- const e = {}, t = Object.keys(w).sort();
451
- for (const s of t) e[s] = w[s];
452
- return JSON.stringify(e, (s, i) => {
453
- if (i !== null && typeof i == "object" && !Array.isArray(i)) {
454
- const c = {}, o = Object.keys(i).sort();
455
- for (const f of o) c[f] = i[f];
456
- return c;
457
- }
458
- return i;
459
- });
460
- }
461
- export {
462
- E as RedisSaver
463
- };