zen-code 4.7.4 → 4.8.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.
- package/dist/app.js +271 -0
- package/dist/chunk-0fhpz98a.js +2 -0
- package/dist/chunk-15smn69q.js +31 -0
- package/dist/chunk-3ep2tag7.js +2 -0
- package/dist/chunk-3jek9sxm.js +2 -0
- package/dist/chunk-3n2b4eb4.js +2 -0
- package/dist/chunk-3znrwnd8.js +1 -0
- package/dist/chunk-4b8yaknt.js +1 -0
- package/dist/chunk-5fqt5yg1.js +81 -0
- package/dist/chunk-5nzs0q25.js +1 -0
- package/dist/chunk-5wn1nfqy.js +6 -0
- package/dist/chunk-6ty22kkt.js +4 -0
- package/dist/chunk-70a0e941.js +1 -0
- package/dist/chunk-7dp8kq2f.js +2 -0
- package/dist/chunk-8nhayyat.js +1 -0
- package/dist/chunk-9k57afdm.js +2 -0
- package/dist/chunk-9kc9cea3.js +7 -0
- package/dist/chunk-bgpcx3bm.js +2 -0
- package/dist/chunk-bjywwcgn.js +26 -0
- package/dist/chunk-c9q11tk2.js +88 -0
- package/dist/chunk-cga0m5sy.js +1 -0
- package/dist/chunk-cze71w02.js +2 -0
- package/dist/chunk-czz2fs2w.js +7 -0
- package/dist/chunk-dh3jz71n.js +1 -0
- package/dist/chunk-e0sqjq2h.js +1 -0
- package/dist/chunk-efhkdw2z.js +1 -0
- package/dist/chunk-ew7249h9.js +1 -0
- package/dist/chunk-h5nnz4dy.js +1 -0
- package/dist/chunk-hww94vjn.js +1 -0
- package/dist/chunk-j1n8jp1w.js +253 -0
- package/dist/chunk-j204fejq.js +1 -0
- package/dist/chunk-jkbtx9va.js +2 -0
- package/dist/chunk-k67epfhc.js +1 -0
- package/dist/chunk-kbs4px1b.js +6 -0
- package/dist/chunk-keqk70wm.js +2 -0
- package/dist/chunk-kxk71nn0.js +1 -0
- package/dist/chunk-mg8zpgaz.js +1 -0
- package/dist/chunk-n1d8xx5k.js +2 -0
- package/dist/chunk-ndtwq2zx.js +2 -0
- package/dist/chunk-pdkbrds7.js +1 -0
- package/dist/chunk-q8arjxg1.js +23 -0
- package/dist/chunk-rdc9pxf6.js +1 -0
- package/dist/chunk-rrkzfahh.js +91 -0
- package/dist/chunk-s3fyfrka.js +2 -0
- package/dist/chunk-sft6ep0c.js +310 -0
- package/dist/chunk-vc384abg.js +3 -0
- package/dist/chunk-vjj00e3e.js +6 -0
- package/dist/chunk-vkng13p1.js +424 -0
- package/dist/chunk-wbn1hbxf.js +1 -0
- package/dist/chunk-wwn7gw8g.js +274 -0
- package/dist/chunk-yaa4eesd.js +2 -0
- package/dist/chunk-yvhq458c.js +25 -0
- package/dist/cli.js +2 -0
- package/dist/nonInteractive.js +4 -0
- package/dist/zen-keyboard.js +3 -0
- package/package.json +88 -87
- package/LICENSE +0 -201
- package/dist/FileSystemPluginStore-ChortK7z.mjs +0 -64
- package/dist/FileSystemSkillStore-Dl5briBv.mjs +0 -108
- package/dist/MultiLineTextInput-CL8nm9nv.mjs +0 -24492
- package/dist/_commonjsHelpers-DQNKXVTB.mjs +0 -33
- package/dist/app-CK3nD8Gj.mjs +0 -22428
- package/dist/checkpoint-C5AFBYE--CczNxXBB.mjs +0 -355
- package/dist/checkpoint-DxiUsHMy-B5iaccT2.mjs +0 -394
- package/dist/cli.mjs +0 -57
- package/dist/devtools-CzaVuYnh.mjs +0 -2667
- package/dist/graphBuilder-DJoMXf6J.mjs +0 -28909
- package/dist/index-BPG5Np-8.mjs +0 -144
- package/dist/index-Dxfhvdx8.mjs +0 -23
- package/dist/index-F6_SKYUd.mjs +0 -463
- package/dist/load-iYJqYrjn.mjs +0 -119
- package/dist/memories-CaHDnBK1.mjs +0 -115
- package/dist/metadata-XVTVXthy.mjs +0 -6
- package/dist/nonInteractive.mjs +0 -55
- package/dist/pg-adapter-BFtir1GE-BbUXBpaX.mjs +0 -60
- package/dist/queue-DySatFkr-CG2GdO4P.mjs +0 -106
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +0 -157
- package/dist/shallow-G4eKoZ7M.mjs +0 -331
- package/dist/shallow-checkpoint-BEhTdp7z-DfHxnfoU.mjs +0 -383
- package/dist/sqlite-adapter-oBA95xba-BrBWorSV.mjs +0 -82
- package/dist/subTasks-DNjIN4eU.mjs +0 -18
- package/dist/zen-code.mjs +0 -3
- package/dist/zen-keyboard.mjs +0 -13
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { Kysely as L, sql as p } from "kysely";
|
|
2
|
-
import { B as S, g as x, T as f, u as O, c as R, W as v, m as C } from "./app-CK3nD8Gj.mjs";
|
|
3
|
-
import "./graphBuilder-DJoMXf6J.mjs";
|
|
4
|
-
const u = {
|
|
5
|
-
maxRetries: 3,
|
|
6
|
-
baseDelayMs: 100,
|
|
7
|
-
isRetryableError: (h) => {
|
|
8
|
-
const e = h?.message?.toLowerCase() || "";
|
|
9
|
-
return e.includes("sqlite_busy") || e.includes("database is locked") || e.includes("database disk image is malformed") || e === "sqlite_busy" || e === "database is locked";
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
async function b(h, e) {
|
|
13
|
-
let s = null;
|
|
14
|
-
for (let c = 0; c < u.maxRetries; c++)
|
|
15
|
-
try {
|
|
16
|
-
return await h();
|
|
17
|
-
} catch (t) {
|
|
18
|
-
if (s = t, !u.isRetryableError(t))
|
|
19
|
-
throw t;
|
|
20
|
-
if (c < u.maxRetries - 1) {
|
|
21
|
-
const n = u.baseDelayMs * Math.pow(2, c);
|
|
22
|
-
console.warn(
|
|
23
|
-
`SQLite lock detected${e ? ` (${e})` : ""}, retrying in ${n}ms (attempt ${c + 1}/${u.maxRetries})`
|
|
24
|
-
), await new Promise((i) => setTimeout(i, n));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
throw s;
|
|
28
|
-
}
|
|
29
|
-
function g(h) {
|
|
30
|
-
if (h === null || typeof h != "object")
|
|
31
|
-
return JSON.stringify(h);
|
|
32
|
-
if (Array.isArray(h))
|
|
33
|
-
return JSON.stringify(h.map((c) => g(c)));
|
|
34
|
-
const e = {}, s = Object.keys(h).sort();
|
|
35
|
-
for (const c of s)
|
|
36
|
-
e[c] = h[c];
|
|
37
|
-
return JSON.stringify(e, (c, t) => {
|
|
38
|
-
if (t !== null && typeof t == "object" && !Array.isArray(t)) {
|
|
39
|
-
const n = {}, i = Object.keys(t).sort();
|
|
40
|
-
for (const r of i)
|
|
41
|
-
n[r] = t[r];
|
|
42
|
-
return n;
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
class N extends S {
|
|
48
|
-
db;
|
|
49
|
-
isSetup;
|
|
50
|
-
constructor(e, s) {
|
|
51
|
-
super(s), this.db = new L({
|
|
52
|
-
dialect: e
|
|
53
|
-
}), this.isSetup = !1;
|
|
54
|
-
}
|
|
55
|
-
static async fromConnStringAsync(e) {
|
|
56
|
-
let s;
|
|
57
|
-
if (globalThis.Bun) {
|
|
58
|
-
console.log("LG | Using BunWorkerDialect " + e);
|
|
59
|
-
const { BunWorkerDialect: c } = await import("kysely-bun-worker");
|
|
60
|
-
s = new N(new c({ url: e }));
|
|
61
|
-
} else {
|
|
62
|
-
console.log("LG | Using NodeWasmDialect");
|
|
63
|
-
const { default: c } = await import("node-sqlite3-wasm"), { NodeWasmDialect: t } = await import("kysely-wasm");
|
|
64
|
-
console.log(e);
|
|
65
|
-
const n = new t({
|
|
66
|
-
database: new c.Database(e)
|
|
67
|
-
});
|
|
68
|
-
s = new N(n);
|
|
69
|
-
}
|
|
70
|
-
return await s.setup(), s;
|
|
71
|
-
}
|
|
72
|
-
async setup() {
|
|
73
|
-
this.isSetup || (await p`PRAGMA busy_timeout = 5000`.execute(this.db), await p`PRAGMA journal_mode = WAL`.execute(this.db), await p`PRAGMA synchronous = NORMAL`.execute(this.db), await p`PRAGMA wal_autocheckpoint = 1000`.execute(this.db), await p`
|
|
74
|
-
CREATE TABLE IF NOT EXISTS shallow_checkpoints (
|
|
75
|
-
thread_id TEXT NOT NULL,
|
|
76
|
-
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
77
|
-
checkpoint_id TEXT NOT NULL,
|
|
78
|
-
parent_checkpoint_id TEXT,
|
|
79
|
-
type TEXT,
|
|
80
|
-
checkpoint BLOB,
|
|
81
|
-
metadata BLOB,
|
|
82
|
-
checkpoint_ts INTEGER NOT NULL DEFAULT 0,
|
|
83
|
-
PRIMARY KEY (thread_id, checkpoint_ns)
|
|
84
|
-
)`.execute(this.db), await p`
|
|
85
|
-
CREATE INDEX IF NOT EXISTS idx_shallow_checkpoints_ts
|
|
86
|
-
ON shallow_checkpoints(checkpoint_ts DESC)`.execute(this.db), await p`
|
|
87
|
-
CREATE TABLE IF NOT EXISTS writes (
|
|
88
|
-
thread_id TEXT NOT NULL,
|
|
89
|
-
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
90
|
-
checkpoint_id TEXT NOT NULL,
|
|
91
|
-
task_id TEXT NOT NULL,
|
|
92
|
-
idx INTEGER NOT NULL,
|
|
93
|
-
channel TEXT NOT NULL,
|
|
94
|
-
type TEXT,
|
|
95
|
-
value BLOB,
|
|
96
|
-
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
|
|
97
|
-
)`.execute(this.db), this.isSetup = !0);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* 获取 checkpoint(便捷方法)
|
|
101
|
-
*/
|
|
102
|
-
async get(e) {
|
|
103
|
-
return (await this.getTuple(e))?.checkpoint;
|
|
104
|
-
}
|
|
105
|
-
async getTuple(e) {
|
|
106
|
-
await this.setup();
|
|
107
|
-
const s = e.configurable?.thread_id, c = e.configurable?.checkpoint_ns ?? "", t = x(e);
|
|
108
|
-
if (s === void 0)
|
|
109
|
-
return;
|
|
110
|
-
let n = this.db.selectFrom("shallow_checkpoints").select([
|
|
111
|
-
"thread_id",
|
|
112
|
-
"checkpoint_ns",
|
|
113
|
-
"checkpoint_id",
|
|
114
|
-
"parent_checkpoint_id",
|
|
115
|
-
"type",
|
|
116
|
-
"checkpoint",
|
|
117
|
-
"metadata",
|
|
118
|
-
"checkpoint_ts",
|
|
119
|
-
p`(
|
|
120
|
-
SELECT json_group_array(
|
|
121
|
-
json_object(
|
|
122
|
-
'task_id', pw.task_id,
|
|
123
|
-
'channel', pw.channel,
|
|
124
|
-
'type', pw.type,
|
|
125
|
-
'value', CAST(pw.value AS TEXT)
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
FROM writes as pw
|
|
129
|
-
WHERE pw.thread_id = shallow_checkpoints.thread_id
|
|
130
|
-
AND pw.checkpoint_ns = shallow_checkpoints.checkpoint_ns
|
|
131
|
-
AND pw.checkpoint_id = shallow_checkpoints.checkpoint_id
|
|
132
|
-
)`.as("pending_writes"),
|
|
133
|
-
p`(
|
|
134
|
-
SELECT json_group_array(
|
|
135
|
-
json_object(
|
|
136
|
-
'type', ps.type,
|
|
137
|
-
'value', CAST(ps.value AS TEXT)
|
|
138
|
-
)
|
|
139
|
-
)
|
|
140
|
-
FROM writes as ps
|
|
141
|
-
WHERE ps.thread_id = shallow_checkpoints.thread_id
|
|
142
|
-
AND ps.checkpoint_ns = shallow_checkpoints.checkpoint_ns
|
|
143
|
-
AND ps.checkpoint_id = shallow_checkpoints.parent_checkpoint_id
|
|
144
|
-
AND ps.channel = ${f}
|
|
145
|
-
ORDER BY ps.idx
|
|
146
|
-
)`.as("pending_sends")
|
|
147
|
-
]).where("thread_id", "=", s).where("checkpoint_ns", "=", c);
|
|
148
|
-
t && (n = n.where("checkpoint_id", "=", t));
|
|
149
|
-
const i = await n.executeTakeFirst();
|
|
150
|
-
if (!i || t && i.checkpoint_id !== t)
|
|
151
|
-
return;
|
|
152
|
-
const r = await Promise.all(
|
|
153
|
-
JSON.parse(i.pending_writes || "[]").map(async (d) => [
|
|
154
|
-
d.task_id,
|
|
155
|
-
d.channel,
|
|
156
|
-
await this.serde.loadsTyped(d.type ?? "json", d.value ?? "")
|
|
157
|
-
])
|
|
158
|
-
), a = await this.serde.loadsTyped(
|
|
159
|
-
i.type ?? "json",
|
|
160
|
-
new TextDecoder().decode(i.checkpoint)
|
|
161
|
-
);
|
|
162
|
-
a.v < 4 && i.parent_checkpoint_id != null && await this.migratePendingSends(a, i.thread_id, i.parent_checkpoint_id);
|
|
163
|
-
const _ = {
|
|
164
|
-
configurable: {
|
|
165
|
-
thread_id: i.thread_id,
|
|
166
|
-
checkpoint_ns: i.checkpoint_ns,
|
|
167
|
-
checkpoint_id: i.checkpoint_id
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
return {
|
|
171
|
-
checkpoint: a,
|
|
172
|
-
config: _,
|
|
173
|
-
metadata: await this.serde.loadsTyped(
|
|
174
|
-
i.type ?? "json",
|
|
175
|
-
new TextDecoder().decode(i.metadata)
|
|
176
|
-
),
|
|
177
|
-
parentConfig: i.parent_checkpoint_id ? {
|
|
178
|
-
configurable: {
|
|
179
|
-
thread_id: i.thread_id,
|
|
180
|
-
checkpoint_ns: i.checkpoint_ns,
|
|
181
|
-
checkpoint_id: i.parent_checkpoint_id
|
|
182
|
-
}
|
|
183
|
-
} : void 0,
|
|
184
|
-
pendingWrites: r
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
async *list(e, s) {
|
|
188
|
-
await this.setup();
|
|
189
|
-
const { limit: c, before: t, filter: n } = s ?? {}, i = e.configurable?.thread_id, r = e.configurable?.checkpoint_ns;
|
|
190
|
-
let a = this.db.selectFrom("shallow_checkpoints").select([
|
|
191
|
-
"thread_id",
|
|
192
|
-
"checkpoint_ns",
|
|
193
|
-
"checkpoint_id",
|
|
194
|
-
"parent_checkpoint_id",
|
|
195
|
-
"type",
|
|
196
|
-
"checkpoint",
|
|
197
|
-
"metadata",
|
|
198
|
-
"checkpoint_ts",
|
|
199
|
-
p`(
|
|
200
|
-
SELECT json_group_array(
|
|
201
|
-
json_object(
|
|
202
|
-
'task_id', pw.task_id,
|
|
203
|
-
'channel', pw.channel,
|
|
204
|
-
'type', pw.type,
|
|
205
|
-
'value', CAST(pw.value AS TEXT)
|
|
206
|
-
)
|
|
207
|
-
)
|
|
208
|
-
FROM writes as pw
|
|
209
|
-
WHERE pw.thread_id = shallow_checkpoints.thread_id
|
|
210
|
-
AND pw.checkpoint_ns = shallow_checkpoints.checkpoint_ns
|
|
211
|
-
AND pw.checkpoint_id = shallow_checkpoints.checkpoint_id
|
|
212
|
-
)`.as("pending_writes")
|
|
213
|
-
]);
|
|
214
|
-
i && (a = a.where("thread_id", "=", i)), r != null && (a = a.where("checkpoint_ns", "=", r)), t?.configurable?.checkpoint_id !== void 0 && (a = a.where("checkpoint_id", "<", t.configurable.checkpoint_id)), a = a.orderBy("checkpoint_ts", "desc");
|
|
215
|
-
const _ = await a.execute();
|
|
216
|
-
let d = 0;
|
|
217
|
-
for (const o of _) {
|
|
218
|
-
const w = await this.serde.loadsTyped(
|
|
219
|
-
o.type ?? "json",
|
|
220
|
-
new TextDecoder().decode(o.metadata)
|
|
221
|
-
);
|
|
222
|
-
if (n && !this._checkMetadataFilterMatch(w, n))
|
|
223
|
-
continue;
|
|
224
|
-
if (c !== void 0 && d >= c)
|
|
225
|
-
return;
|
|
226
|
-
const y = await Promise.all(
|
|
227
|
-
JSON.parse(o.pending_writes || "[]").map(async (l) => [
|
|
228
|
-
l.task_id,
|
|
229
|
-
l.channel,
|
|
230
|
-
await this.serde.loadsTyped(l.type ?? "json", l.value ?? "")
|
|
231
|
-
])
|
|
232
|
-
), k = await this.serde.loadsTyped(
|
|
233
|
-
o.type ?? "json",
|
|
234
|
-
new TextDecoder().decode(o.checkpoint)
|
|
235
|
-
);
|
|
236
|
-
k.v < 4 && o.parent_checkpoint_id != null && await this.migratePendingSends(k, o.thread_id, o.parent_checkpoint_id), d++, yield {
|
|
237
|
-
config: {
|
|
238
|
-
configurable: {
|
|
239
|
-
thread_id: o.thread_id,
|
|
240
|
-
checkpoint_ns: o.checkpoint_ns,
|
|
241
|
-
checkpoint_id: o.checkpoint_id
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
checkpoint: k,
|
|
245
|
-
metadata: w,
|
|
246
|
-
parentConfig: o.parent_checkpoint_id ? {
|
|
247
|
-
configurable: {
|
|
248
|
-
thread_id: o.thread_id,
|
|
249
|
-
checkpoint_ns: o.checkpoint_ns,
|
|
250
|
-
checkpoint_id: o.parent_checkpoint_id
|
|
251
|
-
}
|
|
252
|
-
} : void 0,
|
|
253
|
-
pendingWrites: y
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Check metadata filter matches (with deep comparison support)
|
|
259
|
-
* Matches ShallowMemorySaver behavior
|
|
260
|
-
*/
|
|
261
|
-
_checkMetadataFilterMatch(e, s) {
|
|
262
|
-
for (const [c, t] of Object.entries(s)) {
|
|
263
|
-
const n = e?.[c];
|
|
264
|
-
if (t === null) {
|
|
265
|
-
if (!(c in (e || {})) || n !== null)
|
|
266
|
-
return !1;
|
|
267
|
-
} else if (typeof t == "object" && !Array.isArray(t)) {
|
|
268
|
-
if (typeof n != "object" || n === null || g(t) !== g(n))
|
|
269
|
-
return !1;
|
|
270
|
-
} else if (n !== t)
|
|
271
|
-
return !1;
|
|
272
|
-
}
|
|
273
|
-
return !0;
|
|
274
|
-
}
|
|
275
|
-
async put(e, s, c, t) {
|
|
276
|
-
await this.setup();
|
|
277
|
-
const n = e.configurable?.thread_id, i = e.configurable?.checkpoint_ns ?? "", r = e.configurable?.checkpoint_id;
|
|
278
|
-
if (!n)
|
|
279
|
-
throw new Error("thread_id is required");
|
|
280
|
-
const a = s.id || O(0), _ = R(s), [[d, o], [w, y]] = await Promise.all([
|
|
281
|
-
this.serde.dumpsTyped(_),
|
|
282
|
-
this.serde.dumpsTyped(c)
|
|
283
|
-
]);
|
|
284
|
-
if (d !== w)
|
|
285
|
-
throw new Error("Failed to serialize checkpoint and metadata to the same type.");
|
|
286
|
-
const k = n, l = i, T = a;
|
|
287
|
-
return await b(
|
|
288
|
-
async () => {
|
|
289
|
-
await this.db.transaction().execute(async (m) => {
|
|
290
|
-
const E = await m.selectFrom("shallow_checkpoints").select(["checkpoint_id"]).where("thread_id", "=", k).where("checkpoint_ns", "=", l).executeTakeFirst();
|
|
291
|
-
E && E.checkpoint_id !== T && await m.deleteFrom("writes").where("thread_id", "=", k).where("checkpoint_ns", "=", l).where("checkpoint_id", "=", E.checkpoint_id).execute(), await m.insertInto("shallow_checkpoints").values({
|
|
292
|
-
thread_id: k,
|
|
293
|
-
checkpoint_ns: l,
|
|
294
|
-
checkpoint_id: T,
|
|
295
|
-
parent_checkpoint_id: r ?? null,
|
|
296
|
-
type: d,
|
|
297
|
-
checkpoint: new Uint8Array(Buffer.from(o)),
|
|
298
|
-
metadata: new Uint8Array(Buffer.from(y)),
|
|
299
|
-
checkpoint_ts: Date.now()
|
|
300
|
-
}).onConflict(
|
|
301
|
-
(A) => A.columns(["thread_id", "checkpoint_ns"]).doUpdateSet({
|
|
302
|
-
checkpoint_id: T,
|
|
303
|
-
parent_checkpoint_id: r ?? null,
|
|
304
|
-
type: d,
|
|
305
|
-
checkpoint: new Uint8Array(Buffer.from(o)),
|
|
306
|
-
metadata: new Uint8Array(Buffer.from(y)),
|
|
307
|
-
checkpoint_ts: Date.now()
|
|
308
|
-
})
|
|
309
|
-
).execute();
|
|
310
|
-
});
|
|
311
|
-
},
|
|
312
|
-
`put(${n}/${a})`
|
|
313
|
-
), {
|
|
314
|
-
configurable: {
|
|
315
|
-
thread_id: n,
|
|
316
|
-
checkpoint_ns: i,
|
|
317
|
-
checkpoint_id: a
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
async putWrites(e, s, c) {
|
|
322
|
-
await this.setup();
|
|
323
|
-
const t = e.configurable?.thread_id, n = e.configurable?.checkpoint_ns ?? "", i = e.configurable?.checkpoint_id;
|
|
324
|
-
if (!t || !i)
|
|
325
|
-
throw new Error("thread_id and checkpoint_id are required");
|
|
326
|
-
const r = await Promise.all(
|
|
327
|
-
s.map(async (a, _) => {
|
|
328
|
-
const [d, o] = await this.serde.dumpsTyped(a[1]);
|
|
329
|
-
return {
|
|
330
|
-
thread_id: t,
|
|
331
|
-
checkpoint_ns: n,
|
|
332
|
-
checkpoint_id: i,
|
|
333
|
-
task_id: c,
|
|
334
|
-
idx: v[a[0]] ?? _,
|
|
335
|
-
channel: a[0],
|
|
336
|
-
type: d,
|
|
337
|
-
value: new Uint8Array(Buffer.from(o))
|
|
338
|
-
};
|
|
339
|
-
})
|
|
340
|
-
);
|
|
341
|
-
r.length !== 0 && await b(
|
|
342
|
-
async () => {
|
|
343
|
-
await this.db.transaction().execute(async (a) => {
|
|
344
|
-
await a.deleteFrom("writes").where("thread_id", "=", t).where("checkpoint_ns", "=", n).where("checkpoint_id", "=", i).where("task_id", "=", c).execute();
|
|
345
|
-
for (const _ of r)
|
|
346
|
-
await a.insertInto("writes").values(_).execute();
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
`putWrites(${t}/${i}/${c})`
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
async deleteThread(e) {
|
|
353
|
-
await b(
|
|
354
|
-
async () => {
|
|
355
|
-
await this.db.transaction().execute(async (s) => {
|
|
356
|
-
await s.deleteFrom("shallow_checkpoints").where("thread_id", "=", e).execute(), await s.deleteFrom("writes").where("thread_id", "=", e).execute();
|
|
357
|
-
});
|
|
358
|
-
},
|
|
359
|
-
`deleteThread(${e})`
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
async migratePendingSends(e, s, c) {
|
|
363
|
-
const t = await this.db.selectFrom("writes as ps").select([
|
|
364
|
-
"ps.checkpoint_id",
|
|
365
|
-
p`json_group_array(
|
|
366
|
-
json_object(
|
|
367
|
-
'type', ps.type,
|
|
368
|
-
'value', CAST(ps.value AS TEXT)
|
|
369
|
-
)
|
|
370
|
-
)`.as("pending_sends")
|
|
371
|
-
]).where("ps.thread_id", "=", s).where("ps.checkpoint_id", "=", c).where("ps.channel", "=", f).orderBy("ps.idx").executeTakeFirst();
|
|
372
|
-
if (!t) return;
|
|
373
|
-
const n = e;
|
|
374
|
-
n.channel_values ??= {}, n.channel_values[f] = await Promise.all(
|
|
375
|
-
JSON.parse(t.pending_sends || "[]").map(
|
|
376
|
-
({ type: i, value: r }) => this.serde.loadsTyped(i, r)
|
|
377
|
-
)
|
|
378
|
-
), n.channel_versions[f] = Object.keys(e.channel_versions).length > 0 ? C(...Object.values(e.channel_versions)) : this.getNextVersion(void 0);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
export {
|
|
382
|
-
N as SqliteShallowSaver
|
|
383
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { sql as e } from "kysely";
|
|
2
|
-
class N {
|
|
3
|
-
db;
|
|
4
|
-
pragmaPromise = null;
|
|
5
|
-
constructor(t) {
|
|
6
|
-
this.db = t;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 设置 SQLite PRAGMA 配置,解决锁问题
|
|
10
|
-
* 使用 Promise 缓存确保并发安全且只执行一次
|
|
11
|
-
*/
|
|
12
|
-
ensurePragma() {
|
|
13
|
-
return this.pragmaPromise || (this.pragmaPromise = this.doEnsurePragma()), this.pragmaPromise;
|
|
14
|
-
}
|
|
15
|
-
async doEnsurePragma() {
|
|
16
|
-
await e`PRAGMA busy_timeout = 5000`.execute(this.db), await e`PRAGMA journal_mode = WAL`.execute(this.db), await e`PRAGMA synchronous = NORMAL`.execute(this.db), await e`PRAGMA wal_autocheckpoint = 1000`.execute(this.db);
|
|
17
|
-
}
|
|
18
|
-
dateToDb(t) {
|
|
19
|
-
return t.toISOString();
|
|
20
|
-
}
|
|
21
|
-
dbToDate(t) {
|
|
22
|
-
return new Date(t);
|
|
23
|
-
}
|
|
24
|
-
jsonToDb(t) {
|
|
25
|
-
return JSON.stringify(t);
|
|
26
|
-
}
|
|
27
|
-
dbToJson(t) {
|
|
28
|
-
if (typeof t == "string")
|
|
29
|
-
try {
|
|
30
|
-
return JSON.parse(t);
|
|
31
|
-
} catch {
|
|
32
|
-
return t;
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
}
|
|
36
|
-
buildJsonQuery(t, T, r, a) {
|
|
37
|
-
const i = `$.${r.includes("-") || r.includes(".") || r.includes(" ") ? `"${r}"` : r}`;
|
|
38
|
-
let s;
|
|
39
|
-
if (typeof a == "string" || typeof a == "number" ? s = a : typeof a == "boolean" ? s = a ? 1 : 0 : a === null ? s = null : s = JSON.stringify(a), a === null) {
|
|
40
|
-
const E = `"${r}":null`;
|
|
41
|
-
return e`
|
|
42
|
-
json_extract(${e.ref(T)}, ${e.lit(i)}) IS NULL
|
|
43
|
-
AND ${e.ref(T)} LIKE ${e.lit(`%${E}%`)}
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
return e`json_extract(${e.ref(T)}, ${e.lit(i)}) = ${e.lit(s)}`;
|
|
47
|
-
}
|
|
48
|
-
now() {
|
|
49
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
50
|
-
}
|
|
51
|
-
async createTables(t) {
|
|
52
|
-
await this.ensurePragma(), await e`
|
|
53
|
-
CREATE TABLE IF NOT EXISTS threads (
|
|
54
|
-
thread_id TEXT PRIMARY KEY,
|
|
55
|
-
created_at TEXT NOT NULL,
|
|
56
|
-
updated_at TEXT NOT NULL,
|
|
57
|
-
metadata TEXT NOT NULL DEFAULT '{}',
|
|
58
|
-
status TEXT NOT NULL DEFAULT 'idle',
|
|
59
|
-
"values" TEXT,
|
|
60
|
-
interrupts TEXT NOT NULL DEFAULT '{}'
|
|
61
|
-
)
|
|
62
|
-
`.execute(t), await e`
|
|
63
|
-
CREATE TABLE IF NOT EXISTS runs (
|
|
64
|
-
run_id TEXT PRIMARY KEY,
|
|
65
|
-
thread_id TEXT NOT NULL,
|
|
66
|
-
assistant_id TEXT NOT NULL,
|
|
67
|
-
created_at TEXT NOT NULL,
|
|
68
|
-
updated_at TEXT NOT NULL,
|
|
69
|
-
status TEXT NOT NULL DEFAULT 'pending',
|
|
70
|
-
metadata TEXT NOT NULL DEFAULT '{}',
|
|
71
|
-
multitask_strategy TEXT NOT NULL DEFAULT 'reject',
|
|
72
|
-
FOREIGN KEY (thread_id) REFERENCES threads(thread_id) ON DELETE CASCADE
|
|
73
|
-
)
|
|
74
|
-
`.execute(t);
|
|
75
|
-
}
|
|
76
|
-
async createIndexes(t) {
|
|
77
|
-
await e`CREATE INDEX IF NOT EXISTS idx_threads_status ON threads(status)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_threads_updated_at ON threads(updated_at)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_runs_thread_id ON runs(thread_id)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_runs_status ON runs(status)`.execute(t);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
N as SQLiteAdapter
|
|
82
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getAgentListFromPackage as s, SubAgentsMiddleware as g } from "@langgraph-js/standard-agent";
|
|
2
|
-
import { SubAgentsMiddleware as w, getAgentListFromPackage as S } from "@langgraph-js/standard-agent";
|
|
3
|
-
import { l as i, m as o } from "./graphBuilder-DJoMXf6J.mjs";
|
|
4
|
-
async function m(e) {
|
|
5
|
-
const t = await s(e);
|
|
6
|
-
return new g({
|
|
7
|
-
agents: t,
|
|
8
|
-
stateSchema: i,
|
|
9
|
-
async createAgent(a, r, n) {
|
|
10
|
-
return await o(r.subagent_id, e, n, {}, { parent_id: a });
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
w as SubAgentsMiddleware,
|
|
16
|
-
m as createSubAgentsMiddleware,
|
|
17
|
-
S as getAgentListFromPackage
|
|
18
|
-
};
|
package/dist/zen-code.mjs
DELETED
package/dist/zen-keyboard.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { r as a, j as n, a as c, u as f, T as x } from "./MultiLineTextInput-CL8nm9nv.mjs";
|
|
2
|
-
a(/* @__PURE__ */ n.jsx(l, {}));
|
|
3
|
-
function l() {
|
|
4
|
-
const [r, u] = c.useState(`Press any key...
|
|
5
|
-
`);
|
|
6
|
-
return f((i, o, p) => {
|
|
7
|
-
const t = ["\x1B[2J\x1B[H", "input:", JSON.stringify(i), "", "key:"], e = Object.entries(o).filter(([, s]) => s === !0);
|
|
8
|
-
for (const [s] of e)
|
|
9
|
-
t.push(` ${s}: true`);
|
|
10
|
-
e.length === 0 && t.push(" (no true values)"), t.push(JSON.stringify(p, null, 2)), u(t.join(`
|
|
11
|
-
`));
|
|
12
|
-
}), /* @__PURE__ */ n.jsx(x, { children: r });
|
|
13
|
-
}
|