@inkeep/agents-core 0.31.6 → 0.32.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 (61) hide show
  1. package/dist/{chunk-RBUBOGX6.js → chunk-FUJJ4OQ2.js} +62 -10
  2. package/dist/chunk-SVXWB2HF.js +592 -0
  3. package/dist/{chunk-T5TTDZ6L.js → chunk-VSQY72K5.js} +133 -133
  4. package/dist/{chunk-PPBBIDK4.js → chunk-X6ZMJ3G6.js} +1 -1
  5. package/dist/client-exports.cjs +283 -224
  6. package/dist/client-exports.d.cts +4 -4
  7. package/dist/client-exports.d.ts +4 -4
  8. package/dist/client-exports.js +15 -7
  9. package/dist/db/schema.cjs +211 -211
  10. package/dist/db/schema.d.cts +3 -3
  11. package/dist/db/schema.d.ts +3 -3
  12. package/dist/db/schema.js +1 -1
  13. package/dist/index.cjs +18511 -12300
  14. package/dist/index.d.cts +161 -104
  15. package/dist/index.d.ts +161 -104
  16. package/dist/index.js +16250 -11076
  17. package/dist/nodefs-X2JO4ZHZ.js +21 -0
  18. package/dist/opfs-ahp-2UFDGV73.js +318 -0
  19. package/dist/{schema-BiVwgjkS.d.ts → schema-CuEjPQt7.d.ts} +876 -1014
  20. package/dist/{schema-DcDuYlEP.d.cts → schema-D1P8r3qm.d.cts} +876 -1014
  21. package/dist/types/index.d.cts +3 -3
  22. package/dist/types/index.d.ts +3 -3
  23. package/dist/{utility-DNsYIxBh.d.cts → utility-DF5IUC9K.d.cts} +967 -1131
  24. package/dist/{utility-DNsYIxBh.d.ts → utility-DF5IUC9K.d.ts} +967 -1131
  25. package/dist/validation/index.cjs +270 -219
  26. package/dist/validation/index.d.cts +3 -3
  27. package/dist/validation/index.d.ts +3 -3
  28. package/dist/validation/index.js +2 -2
  29. package/drizzle/0000_exotic_mysterio.sql +398 -0
  30. package/drizzle/meta/0000_snapshot.json +1683 -1223
  31. package/drizzle/meta/_journal.json +4 -102
  32. package/package.json +6 -3
  33. package/drizzle/0000_material_menace.sql +0 -326
  34. package/drizzle/0001_eminent_fixer.sql +0 -43
  35. package/drizzle/0002_bumpy_romulus.sql +0 -3
  36. package/drizzle/0003_soft_forgotten_one.sql +0 -39
  37. package/drizzle/0004_melted_omega_flight.sql +0 -3
  38. package/drizzle/0005_wide_shriek.sql +0 -127
  39. package/drizzle/0006_damp_lenny_balinger.sql +0 -52
  40. package/drizzle/0007_mighty_typhoid_mary.sql +0 -227
  41. package/drizzle/0008_mysterious_crusher_hogan.sql +0 -20
  42. package/drizzle/0009_old_black_cat.sql +0 -1
  43. package/drizzle/0010_wet_vampiro.sql +0 -2
  44. package/drizzle/0011_slippery_korg.sql +0 -36
  45. package/drizzle/0012_salty_psynapse.sql +0 -17
  46. package/drizzle/0013_shocking_blur.sql +0 -19
  47. package/drizzle/0014_broad_hellfire_club.sql +0 -29
  48. package/drizzle/meta/0001_snapshot.json +0 -2435
  49. package/drizzle/meta/0002_snapshot.json +0 -2428
  50. package/drizzle/meta/0003_snapshot.json +0 -2559
  51. package/drizzle/meta/0004_snapshot.json +0 -2547
  52. package/drizzle/meta/0005_snapshot.json +0 -2558
  53. package/drizzle/meta/0006_snapshot.json +0 -2751
  54. package/drizzle/meta/0007_snapshot.json +0 -2766
  55. package/drizzle/meta/0008_snapshot.json +0 -2753
  56. package/drizzle/meta/0009_snapshot.json +0 -2744
  57. package/drizzle/meta/0010_snapshot.json +0 -2751
  58. package/drizzle/meta/0011_snapshot.json +0 -2849
  59. package/drizzle/meta/0012_snapshot.json +0 -2985
  60. package/drizzle/meta/0013_snapshot.json +0 -2988
  61. package/drizzle/meta/0014_snapshot.json +0 -2992
@@ -0,0 +1,21 @@
1
+ import { u, ur, C } from './chunk-SVXWB2HF.js';
2
+ import * as s from 'fs';
3
+ import * as o from 'path';
4
+
5
+ u();
6
+ var m = class extends ur {
7
+ constructor(t) {
8
+ super(t), this.rootDir = o.resolve(t), s.existsSync(o.join(this.rootDir)) || s.mkdirSync(this.rootDir);
9
+ }
10
+ async init(t, e) {
11
+ return this.pg = t, { emscriptenOpts: { ...e, preRun: [...e.preRun || [], (r) => {
12
+ let c = r.FS.filesystems.NODEFS;
13
+ r.FS.mkdir(C), r.FS.mount(c, { root: this.rootDir }, C);
14
+ }] } };
15
+ }
16
+ async closeFs() {
17
+ this.pg.Module.FS.quit();
18
+ }
19
+ };
20
+
21
+ export { m as NodeFS };
@@ -0,0 +1,318 @@
1
+ import { u, cr, R, T, h, x, U, pr } from './chunk-SVXWB2HF.js';
2
+
3
+ // ../../node_modules/.pnpm/@electric-sql+pglite@0.3.13/node_modules/@electric-sql/pglite/dist/fs/opfs-ahp.js
4
+ u();
5
+ var $ = "state.txt";
6
+ var G = "data";
7
+ var T2 = { DIR: 16384, FILE: 32768 };
8
+ var H;
9
+ var v;
10
+ var F;
11
+ var M;
12
+ var y;
13
+ var b;
14
+ var m;
15
+ var x2;
16
+ var P;
17
+ var D;
18
+ var S;
19
+ var n;
20
+ var C;
21
+ var O;
22
+ var k;
23
+ var w;
24
+ var f;
25
+ var I;
26
+ var W;
27
+ var j;
28
+ var L = class extends cr {
29
+ constructor(e, { initialPoolSize: t = 1e3, maintainedPoolSize: o = 100, debug: i = false } = {}) {
30
+ super(e, { debug: i });
31
+ R(this, n);
32
+ R(this, H);
33
+ R(this, v);
34
+ R(this, F);
35
+ R(this, M);
36
+ R(this, y);
37
+ R(this, b, /* @__PURE__ */ new Map());
38
+ R(this, m, /* @__PURE__ */ new Map());
39
+ R(this, x2, 0);
40
+ R(this, P, /* @__PURE__ */ new Map());
41
+ R(this, D, /* @__PURE__ */ new Map());
42
+ this.lastCheckpoint = 0;
43
+ this.checkpointInterval = 1e3 * 60;
44
+ this.poolCounter = 0;
45
+ R(this, S, /* @__PURE__ */ new Set());
46
+ this.initialPoolSize = t, this.maintainedPoolSize = o;
47
+ }
48
+ async init(e, t) {
49
+ return await T(this, n, C).call(this), super.init(e, t);
50
+ }
51
+ async syncToFs(e = false) {
52
+ await this.maybeCheckpointState(), await this.maintainPool(), e || this.flush();
53
+ }
54
+ async closeFs() {
55
+ for (let e of h(this, m).values()) e.close();
56
+ h(this, y).flush(), h(this, y).close(), this.pg.Module.FS.quit();
57
+ }
58
+ async maintainPool(e) {
59
+ e = e || this.maintainedPoolSize;
60
+ let t = e - this.state.pool.length, o = [];
61
+ for (let i = 0; i < t; i++) o.push(new Promise(async (c) => {
62
+ ++this.poolCounter;
63
+ let a = `${(Date.now() - 1704063600).toString(16).padStart(8, "0")}-${this.poolCounter.toString(16).padStart(8, "0")}`, h2 = await h(this, F).getFileHandle(a, { create: true }), d = await h2.createSyncAccessHandle();
64
+ h(this, b).set(a, h2), h(this, m).set(a, d), T(this, n, k).call(this, { opp: "createPoolFile", args: [a] }), this.state.pool.push(a), c();
65
+ }));
66
+ for (let i = 0; i > t; i--) o.push(new Promise(async (c) => {
67
+ let a = this.state.pool.pop();
68
+ T(this, n, k).call(this, { opp: "deletePoolFile", args: [a] });
69
+ let h2 = h(this, b).get(a);
70
+ h(this, m).get(a)?.close(), await h(this, F).removeEntry(h2.name), h(this, b).delete(a), h(this, m).delete(a), c();
71
+ }));
72
+ await Promise.all(o);
73
+ }
74
+ _createPoolFileState(e) {
75
+ this.state.pool.push(e);
76
+ }
77
+ _deletePoolFileState(e) {
78
+ let t = this.state.pool.indexOf(e);
79
+ t > -1 && this.state.pool.splice(t, 1);
80
+ }
81
+ async maybeCheckpointState() {
82
+ Date.now() - this.lastCheckpoint > this.checkpointInterval && await this.checkpointState();
83
+ }
84
+ async checkpointState() {
85
+ let e = new TextEncoder().encode(JSON.stringify(this.state));
86
+ h(this, y).truncate(0), h(this, y).write(e, { at: 0 }), h(this, y).flush(), this.lastCheckpoint = Date.now();
87
+ }
88
+ flush() {
89
+ for (let e of h(this, S)) try {
90
+ e.flush();
91
+ } catch {
92
+ }
93
+ h(this, S).clear();
94
+ }
95
+ chmod(e, t) {
96
+ T(this, n, O).call(this, { opp: "chmod", args: [e, t] }, () => {
97
+ this._chmodState(e, t);
98
+ });
99
+ }
100
+ _chmodState(e, t) {
101
+ let o = T(this, n, f).call(this, e);
102
+ o.mode = t;
103
+ }
104
+ close(e) {
105
+ let t = T(this, n, I).call(this, e);
106
+ h(this, P).delete(e), h(this, D).delete(t);
107
+ }
108
+ fstat(e) {
109
+ let t = T(this, n, I).call(this, e);
110
+ return this.lstat(t);
111
+ }
112
+ lstat(e) {
113
+ let t = T(this, n, f).call(this, e), o = t.type === "file" ? h(this, m).get(t.backingFilename).getSize() : 0, i = 4096;
114
+ return { dev: 0, ino: 0, mode: t.mode, nlink: 1, uid: 0, gid: 0, rdev: 0, size: o, blksize: i, blocks: Math.ceil(o / i), atime: t.lastModified, mtime: t.lastModified, ctime: t.lastModified };
115
+ }
116
+ mkdir(e, t) {
117
+ T(this, n, O).call(this, { opp: "mkdir", args: [e, t] }, () => {
118
+ this._mkdirState(e, t);
119
+ });
120
+ }
121
+ _mkdirState(e, t) {
122
+ let o = T(this, n, w).call(this, e), i = o.pop(), c = [], a = this.state.root;
123
+ for (let d of o) {
124
+ if (c.push(e), !Object.prototype.hasOwnProperty.call(a.children, d)) if (t?.recursive) this.mkdir(c.join("/"));
125
+ else throw new p("ENOENT", "No such file or directory");
126
+ if (a.children[d].type !== "directory") throw new p("ENOTDIR", "Not a directory");
127
+ a = a.children[d];
128
+ }
129
+ if (Object.prototype.hasOwnProperty.call(a.children, i)) throw new p("EEXIST", "File exists");
130
+ let h2 = { type: "directory", lastModified: Date.now(), mode: t?.mode || T2.DIR, children: {} };
131
+ a.children[i] = h2;
132
+ }
133
+ open(e, t, o) {
134
+ if (T(this, n, f).call(this, e).type !== "file") throw new p("EISDIR", "Is a directory");
135
+ let c = T(this, n, W).call(this);
136
+ return h(this, P).set(c, e), h(this, D).set(e, c), c;
137
+ }
138
+ readdir(e) {
139
+ let t = T(this, n, f).call(this, e);
140
+ if (t.type !== "directory") throw new p("ENOTDIR", "Not a directory");
141
+ return Object.keys(t.children);
142
+ }
143
+ read(e, t, o, i, c) {
144
+ let a = T(this, n, I).call(this, e), h2 = T(this, n, f).call(this, a);
145
+ if (h2.type !== "file") throw new p("EISDIR", "Is a directory");
146
+ return h(this, m).get(h2.backingFilename).read(new Uint8Array(t.buffer, o, i), { at: c });
147
+ }
148
+ rename(e, t) {
149
+ T(this, n, O).call(this, { opp: "rename", args: [e, t] }, () => {
150
+ this._renameState(e, t, true);
151
+ });
152
+ }
153
+ _renameState(e, t, o = false) {
154
+ let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
155
+ if (!Object.prototype.hasOwnProperty.call(a.children, c)) throw new p("ENOENT", "No such file or directory");
156
+ let h2 = T(this, n, w).call(this, t), d = h2.pop(), l = T(this, n, f).call(this, h2.join("/"));
157
+ if (o && Object.prototype.hasOwnProperty.call(l.children, d)) {
158
+ let u2 = l.children[d];
159
+ h(this, m).get(u2.backingFilename).truncate(0), this.state.pool.push(u2.backingFilename);
160
+ }
161
+ l.children[d] = a.children[c], delete a.children[c];
162
+ }
163
+ rmdir(e) {
164
+ T(this, n, O).call(this, { opp: "rmdir", args: [e] }, () => {
165
+ this._rmdirState(e);
166
+ });
167
+ }
168
+ _rmdirState(e) {
169
+ let t = T(this, n, w).call(this, e), o = t.pop(), i = T(this, n, f).call(this, t.join("/"));
170
+ if (!Object.prototype.hasOwnProperty.call(i.children, o)) throw new p("ENOENT", "No such file or directory");
171
+ let c = i.children[o];
172
+ if (c.type !== "directory") throw new p("ENOTDIR", "Not a directory");
173
+ if (Object.keys(c.children).length > 0) throw new p("ENOTEMPTY", "Directory not empty");
174
+ delete i.children[o];
175
+ }
176
+ truncate(e, t = 0) {
177
+ let o = T(this, n, f).call(this, e);
178
+ if (o.type !== "file") throw new p("EISDIR", "Is a directory");
179
+ let i = h(this, m).get(o.backingFilename);
180
+ if (!i) throw new p("ENOENT", "No such file or directory");
181
+ i.truncate(t), h(this, S).add(i);
182
+ }
183
+ unlink(e) {
184
+ T(this, n, O).call(this, { opp: "unlink", args: [e] }, () => {
185
+ this._unlinkState(e, true);
186
+ });
187
+ }
188
+ _unlinkState(e, t = false) {
189
+ let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
190
+ if (!Object.prototype.hasOwnProperty.call(c.children, i)) throw new p("ENOENT", "No such file or directory");
191
+ let a = c.children[i];
192
+ if (a.type !== "file") throw new p("EISDIR", "Is a directory");
193
+ if (delete c.children[i], t) {
194
+ let h2 = h(this, m).get(a.backingFilename);
195
+ h2?.truncate(0), h(this, S).add(h2), h(this, D).has(e) && (h(this, P).delete(h(this, D).get(e)), h(this, D).delete(e));
196
+ }
197
+ this.state.pool.push(a.backingFilename);
198
+ }
199
+ utimes(e, t, o) {
200
+ T(this, n, O).call(this, { opp: "utimes", args: [e, t, o] }, () => {
201
+ this._utimesState(e, t, o);
202
+ });
203
+ }
204
+ _utimesState(e, t, o) {
205
+ let i = T(this, n, f).call(this, e);
206
+ i.lastModified = o;
207
+ }
208
+ writeFile(e, t, o) {
209
+ let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
210
+ if (Object.prototype.hasOwnProperty.call(a.children, c)) {
211
+ let l = a.children[c];
212
+ l.lastModified = Date.now(), T(this, n, k).call(this, { opp: "setLastModified", args: [e, l.lastModified] });
213
+ } else {
214
+ if (this.state.pool.length === 0) throw new Error("No more file handles available in the pool");
215
+ let l = { type: "file", lastModified: Date.now(), mode: o?.mode || T2.FILE, backingFilename: this.state.pool.pop() };
216
+ a.children[c] = l, T(this, n, k).call(this, { opp: "createFileNode", args: [e, l] });
217
+ }
218
+ let h2 = a.children[c], d = h(this, m).get(h2.backingFilename);
219
+ t.length > 0 && (d.write(typeof t == "string" ? new TextEncoder().encode(t) : new Uint8Array(t), { at: 0 }), e.startsWith("/pg_wal") && h(this, S).add(d));
220
+ }
221
+ _createFileNodeState(e, t) {
222
+ let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
223
+ c.children[i] = t;
224
+ let a = this.state.pool.indexOf(t.backingFilename);
225
+ return a > -1 && this.state.pool.splice(a, 1), t;
226
+ }
227
+ _setLastModifiedState(e, t) {
228
+ let o = T(this, n, f).call(this, e);
229
+ o.lastModified = t;
230
+ }
231
+ write(e, t, o, i, c) {
232
+ let a = T(this, n, I).call(this, e), h2 = T(this, n, f).call(this, a);
233
+ if (h2.type !== "file") throw new p("EISDIR", "Is a directory");
234
+ let d = h(this, m).get(h2.backingFilename);
235
+ if (!d) throw new p("EBADF", "Bad file descriptor");
236
+ let l = d.write(new Uint8Array(t, o, i), { at: c });
237
+ return a.startsWith("/pg_wal") && h(this, S).add(d), l;
238
+ }
239
+ };
240
+ H = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), x2 = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakSet(), C = async function() {
241
+ x(this, H, await navigator.storage.getDirectory()), x(this, v, await T(this, n, j).call(this, this.dataDir, { create: true })), x(this, F, await T(this, n, j).call(this, G, { from: h(this, v), create: true })), x(this, M, await h(this, v).getFileHandle($, { create: true })), x(this, y, await h(this, M).createSyncAccessHandle());
242
+ let e = new ArrayBuffer(h(this, y).getSize());
243
+ h(this, y).read(e, { at: 0 });
244
+ let t, o = new TextDecoder().decode(e).split(`
245
+ `), i = false;
246
+ try {
247
+ t = JSON.parse(o[0]);
248
+ } catch {
249
+ t = { root: { type: "directory", lastModified: Date.now(), mode: T2.DIR, children: {} }, pool: [] }, h(this, y).truncate(0), h(this, y).write(new TextEncoder().encode(JSON.stringify(t)), { at: 0 }), i = true;
250
+ }
251
+ this.state = t;
252
+ let c = o.slice(1).filter(Boolean).map((l) => JSON.parse(l));
253
+ for (let l of c) {
254
+ let u2 = `_${l.opp}State`;
255
+ if (typeof this[u2] == "function") try {
256
+ this[u2].bind(this)(...l.args);
257
+ } catch (N) {
258
+ console.warn("Error applying OPFS AHP WAL entry", l, N);
259
+ }
260
+ }
261
+ let a = [], h2 = async (l) => {
262
+ if (l.type === "file") try {
263
+ let u2 = await h(this, F).getFileHandle(l.backingFilename), N = await u2.createSyncAccessHandle();
264
+ h(this, b).set(l.backingFilename, u2), h(this, m).set(l.backingFilename, N);
265
+ } catch (u2) {
266
+ console.error("Error opening file handle for node", l, u2);
267
+ }
268
+ else for (let u2 of Object.values(l.children)) a.push(h2(u2));
269
+ };
270
+ await h2(this.state.root);
271
+ let d = [];
272
+ for (let l of this.state.pool) d.push(new Promise(async (u2) => {
273
+ h(this, b).has(l) && console.warn("File handle already exists for pool file", l);
274
+ let N = await h(this, F).getFileHandle(l), U2 = await N.createSyncAccessHandle();
275
+ h(this, b).set(l, N), h(this, m).set(l, U2), u2();
276
+ }));
277
+ await Promise.all([...a, ...d]), await this.maintainPool(i ? this.initialPoolSize : this.maintainedPoolSize);
278
+ }, O = function(e, t) {
279
+ let o = T(this, n, k).call(this, e);
280
+ try {
281
+ t();
282
+ } catch (i) {
283
+ throw h(this, y).truncate(o), i;
284
+ }
285
+ }, k = function(e) {
286
+ let t = JSON.stringify(e), o = new TextEncoder().encode(`
287
+ ${t}`), i = h(this, y).getSize();
288
+ return h(this, y).write(o, { at: i }), h(this, S).add(h(this, y)), i;
289
+ }, w = function(e) {
290
+ return e.split("/").filter(Boolean);
291
+ }, f = function(e, t) {
292
+ let o = T(this, n, w).call(this, e), i = t || this.state.root;
293
+ for (let c of o) {
294
+ if (i.type !== "directory") throw new p("ENOTDIR", "Not a directory");
295
+ if (!Object.prototype.hasOwnProperty.call(i.children, c)) throw new p("ENOENT", "No such file or directory");
296
+ i = i.children[c];
297
+ }
298
+ return i;
299
+ }, I = function(e) {
300
+ let t = h(this, P).get(e);
301
+ if (!t) throw new p("EBADF", "Bad file descriptor");
302
+ return t;
303
+ }, W = function() {
304
+ let e = ++U(this, x2)._;
305
+ for (; h(this, P).has(e); ) U(this, x2)._++;
306
+ return e;
307
+ }, j = async function(e, t) {
308
+ let o = T(this, n, w).call(this, e), i = t?.from || h(this, H);
309
+ for (let c of o) i = await i.getDirectoryHandle(c, { create: t?.create });
310
+ return i;
311
+ };
312
+ var p = class extends Error {
313
+ constructor(A, e) {
314
+ super(e), typeof A == "number" ? this.code = A : typeof A == "string" && (this.code = pr[A]);
315
+ }
316
+ };
317
+
318
+ export { L as OpfsAhpFS };