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 +0,0 @@
1
- (function(){"use strict";function u(e){return e==null?void 0:BigInt(e)}function f(e,r){const n=r?"query":"prepare",t=(s,a)=>e[n](s,a);return{db:e,query:(s,a,o)=>{const c=t(a,o);if(c.columnNames.length>0)return{rows:c.all()};{const{changes:i,lastInsertRowid:l}=c.run();return{numAffectedRows:u(i),insertId:u(l),rows:[]}}},close:()=>e.close(),iterator:(s,a,o)=>w(t(a),o)}}async function*w(e,r){if(!("iterate"in e))throw new Error("Streaming not supported, please upgrade to Bun@1.1.31 or later");for(const n of e.iterate(...r||[]))yield n}var g={},v="0",b="1",d="2",h="3",E="4";function k(e,r,n){let t;return async([s,a,o,c])=>{const i=[s,null,null];try{switch(s){case v:{t=await e(a);break}case b:{i[1]=await t.query(a,o,c);break}case d:{await t.close();break}case h:{if(!t.iterator)throw new Error("streamQuery() is not supported.");const l=t.iterator(a,o,c);for await(const q of l)r([s,q,null]);i[0]=E;break}default:}}catch(l){i[2]=l}r(i)}}function p(e,r){const n=k(e,t=>globalThis.postMessage(t),r);globalThis.onmessage=({data:t})=>n(t)}var y=(e,r)=>new g(e,r);function m(e,r){p(async({cache:n,fileName:t,opt:s})=>{const a=await e(t,s);return f(a,n)},r)}m(y)})();
@@ -1,319 +0,0 @@
1
- import { K as T } from "./kysely-Bchvsze0.mjs";
2
- import { F as r } from "./sql-CJsUpKEQ.mjs";
3
- import { B as f, T as l, c as y, m } from "./app-CM8R0ZR6.mjs";
4
- import "./graphBuilder-mpLrx9tk.mjs";
5
- const g = ["source", "step", "parents"];
6
- const E = g;
7
- class w extends f {
8
- db;
9
- isSetup;
10
- constructor(e, n) {
11
- super(n), this.db = new T({
12
- dialect: e
13
- }), this.isSetup = !1;
14
- }
15
- static async fromConnStringAsync(e) {
16
- let n;
17
- if (globalThis.Bun) {
18
- console.log("LG | Using BunWorkerDialect " + e);
19
- const { BunWorkerDialect: o } = await import("./index-BUGHAUbY.mjs");
20
- n = new w(new o({ url: e }));
21
- } else {
22
- console.log("LG | Using NodeWasmDialect");
23
- const { default: o } = await import("node-sqlite3-wasm"), { NodeWasmDialect: s } = await import("./index-C5j-48Ft.mjs");
24
- console.log(e);
25
- const a = new s({
26
- database: new o.Database(e)
27
- });
28
- n = new w(a);
29
- }
30
- return await n.setup(), n;
31
- }
32
- async setup() {
33
- this.isSetup || (await r`PRAGMA journal_mode = WAL`.execute(this.db), await r`
34
- CREATE TABLE IF NOT EXISTS checkpoints (
35
- thread_id TEXT NOT NULL,
36
- checkpoint_ns TEXT NOT NULL DEFAULT '',
37
- checkpoint_id TEXT NOT NULL,
38
- parent_checkpoint_id TEXT,
39
- type TEXT,
40
- checkpoint BLOB,
41
- metadata BLOB,
42
- PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
43
- )`.execute(this.db), await r`
44
- CREATE TABLE IF NOT EXISTS writes (
45
- thread_id TEXT NOT NULL,
46
- checkpoint_ns TEXT NOT NULL DEFAULT '',
47
- checkpoint_id TEXT NOT NULL,
48
- task_id TEXT NOT NULL,
49
- idx INTEGER NOT NULL,
50
- channel TEXT NOT NULL,
51
- type TEXT,
52
- value BLOB,
53
- PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
54
- )`.execute(this.db), this.isSetup = !0);
55
- }
56
- async getTuple(e) {
57
- await this.setup();
58
- const { thread_id: n, checkpoint_ns: o = "", checkpoint_id: s } = e.configurable ?? {};
59
- let a = this.db.selectFrom("checkpoints").select([
60
- "thread_id",
61
- "checkpoint_ns",
62
- "checkpoint_id",
63
- "parent_checkpoint_id",
64
- "type",
65
- "checkpoint",
66
- "metadata",
67
- r`(
68
- SELECT json_group_array(
69
- json_object(
70
- 'task_id', pw.task_id,
71
- 'channel', pw.channel,
72
- 'type', pw.type,
73
- 'value', CAST(pw.value AS TEXT)
74
- )
75
- )
76
- FROM writes as pw
77
- WHERE pw.thread_id = checkpoints.thread_id
78
- AND pw.checkpoint_ns = checkpoints.checkpoint_ns
79
- AND pw.checkpoint_id = checkpoints.checkpoint_id
80
- )`.as("pending_writes"),
81
- r`(
82
- SELECT json_group_array(
83
- json_object(
84
- 'type', ps.type,
85
- 'value', CAST(ps.value AS TEXT)
86
- )
87
- )
88
- FROM writes as ps
89
- WHERE ps.thread_id = checkpoints.thread_id
90
- AND ps.checkpoint_ns = checkpoints.checkpoint_ns
91
- AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
92
- AND ps.channel = ${l}
93
- ORDER BY ps.idx
94
- )`.as("pending_sends")
95
- ]).where("thread_id", "=", n).where("checkpoint_ns", "=", o);
96
- s ? a = a.where("checkpoint_id", "=", s) : a = a.orderBy("checkpoint_id", "desc").limit(1);
97
- const t = await a.executeTakeFirst();
98
- if (!t) return;
99
- let d = e;
100
- if (s || (d = {
101
- configurable: {
102
- thread_id: t.thread_id,
103
- checkpoint_ns: o,
104
- checkpoint_id: t.checkpoint_id
105
- }
106
- }), d.configurable?.thread_id === void 0 || d.configurable?.checkpoint_id === void 0)
107
- throw new Error("Missing thread_id or checkpoint_id");
108
- const c = await Promise.all(
109
- JSON.parse(t.pending_writes).map(async (h) => [
110
- h.task_id,
111
- h.channel,
112
- await this.serde.loadsTyped(h.type ?? "json", h.value ?? "")
113
- ])
114
- ), p = await this.serde.loadsTyped(
115
- t.type ?? "json",
116
- new TextDecoder().decode(t.checkpoint)
117
- );
118
- return p.v < 4 && t.parent_checkpoint_id != null && await this.migratePendingSends(p, t.thread_id, t.parent_checkpoint_id), {
119
- checkpoint: p,
120
- config: d,
121
- metadata: await this.serde.loadsTyped(
122
- t.type ?? "json",
123
- new TextDecoder().decode(t.metadata)
124
- ),
125
- parentConfig: t.parent_checkpoint_id ? {
126
- configurable: {
127
- thread_id: t.thread_id,
128
- checkpoint_ns: o,
129
- checkpoint_id: t.parent_checkpoint_id
130
- }
131
- } : void 0,
132
- pendingWrites: c
133
- };
134
- }
135
- async *list(e, n) {
136
- const { limit: o, before: s, filter: a } = n ?? {};
137
- await this.setup();
138
- const t = e.configurable?.thread_id, d = e.configurable?.checkpoint_ns;
139
- let c = this.db.selectFrom("checkpoints").select([
140
- "thread_id",
141
- "checkpoint_ns",
142
- "checkpoint_id",
143
- "parent_checkpoint_id",
144
- "type",
145
- "checkpoint",
146
- "metadata",
147
- r`(
148
- SELECT json_group_array(
149
- json_object(
150
- 'task_id', pw.task_id,
151
- 'channel', pw.channel,
152
- 'type', pw.type,
153
- 'value', CAST(pw.value AS TEXT)
154
- )
155
- )
156
- FROM writes as pw
157
- WHERE pw.thread_id = checkpoints.thread_id
158
- AND pw.checkpoint_ns = checkpoints.checkpoint_ns
159
- AND pw.checkpoint_id = checkpoints.checkpoint_id
160
- )`.as("pending_writes"),
161
- r`(
162
- SELECT json_group_array(
163
- json_object(
164
- 'type', ps.type,
165
- 'value', CAST(ps.value AS TEXT)
166
- )
167
- )
168
- FROM writes as ps
169
- WHERE ps.thread_id = checkpoints.thread_id
170
- AND ps.checkpoint_ns = checkpoints.checkpoint_ns
171
- AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
172
- AND ps.channel = ${l}
173
- ORDER BY ps.idx
174
- )`.as("pending_sends")
175
- ]);
176
- t && (c = c.where("thread_id", "=", t)), d != null && (c = c.where("checkpoint_ns", "=", d)), s?.configurable?.checkpoint_id !== void 0 && (c = c.where("checkpoint_id", "<", s.configurable.checkpoint_id));
177
- const p = Object.fromEntries(
178
- Object.entries(a ?? {}).filter(
179
- ([i, _]) => _ !== void 0 && E.includes(i)
180
- )
181
- );
182
- for (const [i, _] of Object.entries(p))
183
- c = c.where(
184
- r`json_extract(CAST(metadata AS TEXT), ${r.lit("$." + i)})`,
185
- "=",
186
- r.lit(JSON.stringify(_))
187
- );
188
- c = c.orderBy("checkpoint_id", "desc"), o && (c = c.limit(parseInt(o, 10)));
189
- const h = await c.execute();
190
- for (const i of h) {
191
- const _ = await Promise.all(
192
- JSON.parse(i.pending_writes).map(async (k) => [
193
- k.task_id,
194
- k.channel,
195
- await this.serde.loadsTyped(k.type ?? "json", k.value ?? "")
196
- ])
197
- ), u = await this.serde.loadsTyped(
198
- i.type ?? "json",
199
- new TextDecoder().decode(i.checkpoint)
200
- );
201
- u.v < 4 && i.parent_checkpoint_id != null && await this.migratePendingSends(u, i.thread_id, i.parent_checkpoint_id), yield {
202
- config: {
203
- configurable: {
204
- thread_id: i.thread_id,
205
- checkpoint_ns: i.checkpoint_ns,
206
- checkpoint_id: i.checkpoint_id
207
- }
208
- },
209
- checkpoint: u,
210
- metadata: await this.serde.loadsTyped(
211
- i.type ?? "json",
212
- new TextDecoder().decode(i.metadata)
213
- ),
214
- parentConfig: i.parent_checkpoint_id ? {
215
- configurable: {
216
- thread_id: i.thread_id,
217
- checkpoint_ns: i.checkpoint_ns,
218
- checkpoint_id: i.parent_checkpoint_id
219
- }
220
- } : void 0,
221
- pendingWrites: _
222
- };
223
- }
224
- }
225
- async put(e, n, o) {
226
- if (await this.setup(), !e.configurable)
227
- throw new Error("Empty configuration supplied.");
228
- const s = e.configurable?.thread_id, a = e.configurable?.checkpoint_ns ?? "", t = e.configurable?.checkpoint_id;
229
- if (!s)
230
- throw new Error('Missing "thread_id" field in passed "config.configurable".');
231
- const d = y(n), [[c, p], [h, i]] = await Promise.all([
232
- this.serde.dumpsTyped(d),
233
- this.serde.dumpsTyped(o)
234
- ]);
235
- if (c !== h)
236
- throw new Error("Failed to serialized checkpoint and metadata to the same type.");
237
- return await this.db.insertInto("checkpoints").values({
238
- thread_id: s,
239
- checkpoint_ns: a,
240
- checkpoint_id: n.id,
241
- parent_checkpoint_id: t ?? null,
242
- type: c,
243
- checkpoint: new Uint8Array(Buffer.from(p)),
244
- metadata: new Uint8Array(Buffer.from(i))
245
- }).onConflict(
246
- (_) => _.columns(["thread_id", "checkpoint_ns", "checkpoint_id"]).doUpdateSet({
247
- parent_checkpoint_id: t ?? null,
248
- type: c,
249
- checkpoint: new Uint8Array(Buffer.from(p)),
250
- metadata: new Uint8Array(Buffer.from(i))
251
- })
252
- ).execute(), {
253
- configurable: {
254
- thread_id: s,
255
- checkpoint_ns: a,
256
- checkpoint_id: n.id
257
- }
258
- };
259
- }
260
- async putWrites(e, n, o) {
261
- if (await this.setup(), !e.configurable)
262
- throw new Error("Empty configuration supplied.");
263
- if (!e.configurable?.thread_id)
264
- throw new Error("Missing thread_id field in config.configurable.");
265
- if (!e.configurable?.checkpoint_id)
266
- throw new Error("Missing checkpoint_id field in config.configurable.");
267
- const s = await Promise.all(
268
- n.map(async (a, t) => {
269
- const [d, c] = await this.serde.dumpsTyped(a[1]);
270
- return {
271
- thread_id: e.configurable.thread_id,
272
- checkpoint_ns: e.configurable.checkpoint_ns ?? "",
273
- checkpoint_id: e.configurable.checkpoint_id,
274
- task_id: o,
275
- idx: t,
276
- channel: a[0],
277
- type: d,
278
- value: new Uint8Array(Buffer.from(c))
279
- };
280
- })
281
- );
282
- s.length > 0 && await this.db.transaction().execute(async (a) => {
283
- for (const t of s)
284
- await a.insertInto("writes").values(t).onConflict(
285
- (d) => d.columns(["thread_id", "checkpoint_ns", "checkpoint_id", "task_id", "idx"]).doUpdateSet({
286
- channel: t.channel,
287
- type: t.type,
288
- value: t.value
289
- })
290
- ).execute();
291
- });
292
- }
293
- async deleteThread(e) {
294
- await this.db.transaction().execute(async (n) => {
295
- await n.deleteFrom("checkpoints").where("thread_id", "=", e).execute(), await n.deleteFrom("writes").where("thread_id", "=", e).execute();
296
- });
297
- }
298
- async migratePendingSends(e, n, o) {
299
- const s = await this.db.selectFrom("writes as ps").select([
300
- "ps.checkpoint_id",
301
- r`json_group_array(
302
- json_object(
303
- 'type', ps.type,
304
- 'value', CAST(ps.value AS TEXT)
305
- )
306
- )`.as("pending_sends")
307
- ]).where("ps.thread_id", "=", n).where("ps.checkpoint_id", "=", o).where("ps.channel", "=", l).orderBy("ps.idx").executeTakeFirst();
308
- if (!s) return;
309
- const a = e;
310
- a.channel_values ??= {}, a.channel_values[l] = await Promise.all(
311
- JSON.parse(s.pending_sends).map(
312
- ({ type: t, value: d }) => this.serde.loadsTyped(t, d)
313
- )
314
- ), a.channel_versions[l] = Object.keys(e.channel_versions).length > 0 ? m(...Object.values(e.channel_versions)) : this.getNextVersion(void 0);
315
- }
316
- }
317
- export {
318
- w as SqliteSaver
319
- };