exoagent 0.0.12 → 0.0.13
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/README.md +7 -10
- package/dist/code-mode.d.ts +2 -24
- package/dist/exoeval/builtins.d.ts +173 -0
- package/dist/exoeval/evaluator.d.ts +59 -0
- package/dist/exoeval/expr.d.ts +50 -0
- package/dist/exoeval/index.d.ts +6 -0
- package/dist/exoeval/scope.d.ts +13 -0
- package/dist/exoeval/tool.d.ts +44 -0
- package/dist/exoeval/utils.d.ts +9 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.mjs +8128 -197
- package/dist/rpc-toolset-test-helpers.d.ts +2 -5
- package/dist/sql/builder.d.ts +6 -7
- package/dist/sql/expression.d.ts +1 -2
- package/dist/sql.mjs +61 -77
- package/dist/tool-DGs9ZxVn.js +175 -0
- package/dist/tool-wrapper.d.ts +6 -13
- package/package.json +6 -10
- package/dist/capnweb/LICENSE.txt +0 -21
- package/dist/capnweb/README.md +0 -734
- package/dist/capnweb/dist/index-workers.cjs +0 -2791
- package/dist/capnweb/dist/index-workers.cjs.map +0 -1
- package/dist/capnweb/dist/index-workers.d.cts +0 -2
- package/dist/capnweb/dist/index-workers.d.ts +0 -2
- package/dist/capnweb/dist/index-workers.js +0 -2754
- package/dist/capnweb/dist/index-workers.js.map +0 -1
- package/dist/capnweb/dist/index.cjs +0 -2768
- package/dist/capnweb/dist/index.cjs.map +0 -1
- package/dist/capnweb/dist/index.d.cts +0 -383
- package/dist/capnweb/dist/index.d.ts +0 -383
- package/dist/capnweb/dist/index.js +0 -2751
- package/dist/capnweb/dist/index.js.map +0 -1
- package/dist/capnweb/package.json +0 -59
- package/dist/capnweb-test-helpers.d.ts +0 -25
- package/dist/chunk-VBDAOXYI-BhoIkhUn.mjs +0 -831
- package/dist/code-mode-deno.d.ts +0 -13
- package/dist/code-mode-runtime.d.ts +0 -1
- package/dist/nodefs-C8H-6XZ_.mjs +0 -26
- package/dist/opfs-ahp-Dy9HQOrY.mjs +0 -367
- package/dist/rpc-toolset-BnC2BXPq.js +0 -146
- package/dist/rpc-toolset-test-helpers.d.mts +0 -254
- package/dist/rpc-toolset-test-helpers.mjs +0 -10364
- package/dist/rpc-toolset.d.ts +0 -34
- package/dist/stream-transport.d.ts +0 -11
package/dist/code-mode-deno.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SafeEvalContext } from './code-mode.js';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a SafeEvalContext that uses Deno as the sandbox runtime.
|
|
4
|
-
*
|
|
5
|
-
* @param options - Configuration options for Deno sandbox
|
|
6
|
-
* @param options.args - Deno custom arguments (default: [])
|
|
7
|
-
* @param options.denoPath - Path to deno executable (default: 'deno')
|
|
8
|
-
* @returns A SafeEvalContext configured for Deno
|
|
9
|
-
*/
|
|
10
|
-
export declare function createDenoSandbox<R>(options?: {
|
|
11
|
-
args?: string[];
|
|
12
|
-
denoPath?: string;
|
|
13
|
-
}): SafeEvalContext<R>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/nodefs-C8H-6XZ_.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { h as u, s as ur, t as C } from "./chunk-VBDAOXYI-BhoIkhUn.mjs";
|
|
2
|
-
import * as s from "fs";
|
|
3
|
-
import * as o from "path";
|
|
4
|
-
|
|
5
|
-
//#region node_modules/@electric-sql/pglite/dist/fs/nodefs.js
|
|
6
|
-
u();
|
|
7
|
-
var m = class extends ur {
|
|
8
|
-
constructor(t) {
|
|
9
|
-
super(t), this.rootDir = o.resolve(t), s.existsSync(o.join(this.rootDir)) || s.mkdirSync(this.rootDir);
|
|
10
|
-
}
|
|
11
|
-
async init(t, e) {
|
|
12
|
-
return this.pg = t, { emscriptenOpts: {
|
|
13
|
-
...e,
|
|
14
|
-
preRun: [...e.preRun || [], (r) => {
|
|
15
|
-
let c = r.FS.filesystems.NODEFS;
|
|
16
|
-
r.FS.mkdir(C), r.FS.mount(c, { root: this.rootDir }, C);
|
|
17
|
-
}]
|
|
18
|
-
} };
|
|
19
|
-
}
|
|
20
|
-
async closeFs() {
|
|
21
|
-
this.pg.Module.FS.quit();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { m as NodeFS };
|
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { d as R, f as T, g as x, h as u, i as cr, m as h, o as pr, p as U } from "./chunk-VBDAOXYI-BhoIkhUn.mjs";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/@electric-sql/pglite/dist/fs/opfs-ahp.js
|
|
4
|
-
u();
|
|
5
|
-
var $ = "state.txt", G = "data", T$1 = {
|
|
6
|
-
DIR: 16384,
|
|
7
|
-
FILE: 32768
|
|
8
|
-
}, H, v, F, M, y, b, m, x$1, P, D, S, n, C, O, k, w, f, I, W, j, L = class extends cr {
|
|
9
|
-
constructor(e, { initialPoolSize: t = 1e3, maintainedPoolSize: o = 100, debug: i = !1 } = {}) {
|
|
10
|
-
super(e, { debug: i });
|
|
11
|
-
R(this, n);
|
|
12
|
-
R(this, H);
|
|
13
|
-
R(this, v);
|
|
14
|
-
R(this, F);
|
|
15
|
-
R(this, M);
|
|
16
|
-
R(this, y);
|
|
17
|
-
R(this, b, /* @__PURE__ */ new Map());
|
|
18
|
-
R(this, m, /* @__PURE__ */ new Map());
|
|
19
|
-
R(this, x$1, 0);
|
|
20
|
-
R(this, P, /* @__PURE__ */ new Map());
|
|
21
|
-
R(this, D, /* @__PURE__ */ new Map());
|
|
22
|
-
this.lastCheckpoint = 0;
|
|
23
|
-
this.checkpointInterval = 1e3 * 60;
|
|
24
|
-
this.poolCounter = 0;
|
|
25
|
-
R(this, S, /* @__PURE__ */ new Set());
|
|
26
|
-
this.initialPoolSize = t, this.maintainedPoolSize = o;
|
|
27
|
-
}
|
|
28
|
-
async init(e, t) {
|
|
29
|
-
return await T(this, n, C).call(this), super.init(e, t);
|
|
30
|
-
}
|
|
31
|
-
async syncToFs(e = !1) {
|
|
32
|
-
await this.maybeCheckpointState(), await this.maintainPool(), e || this.flush();
|
|
33
|
-
}
|
|
34
|
-
async closeFs() {
|
|
35
|
-
for (let e of h(this, m).values()) e.close();
|
|
36
|
-
h(this, y).flush(), h(this, y).close(), this.pg.Module.FS.quit();
|
|
37
|
-
}
|
|
38
|
-
async maintainPool(e) {
|
|
39
|
-
e = e || this.maintainedPoolSize;
|
|
40
|
-
let t = e - this.state.pool.length, o = [];
|
|
41
|
-
for (let i = 0; i < t; i++) o.push(new Promise(async (c) => {
|
|
42
|
-
++this.poolCounter;
|
|
43
|
-
let a = `${(Date.now() - 1704063600).toString(16).padStart(8, "0")}-${this.poolCounter.toString(16).padStart(8, "0")}`, h$1 = await h(this, F).getFileHandle(a, { create: !0 }), d = await h$1.createSyncAccessHandle();
|
|
44
|
-
h(this, b).set(a, h$1), h(this, m).set(a, d), T(this, n, k).call(this, {
|
|
45
|
-
opp: "createPoolFile",
|
|
46
|
-
args: [a]
|
|
47
|
-
}), this.state.pool.push(a), c();
|
|
48
|
-
}));
|
|
49
|
-
for (let i = 0; i > t; i--) o.push(new Promise(async (c) => {
|
|
50
|
-
let a = this.state.pool.pop();
|
|
51
|
-
T(this, n, k).call(this, {
|
|
52
|
-
opp: "deletePoolFile",
|
|
53
|
-
args: [a]
|
|
54
|
-
});
|
|
55
|
-
let h$1 = h(this, b).get(a);
|
|
56
|
-
h(this, m).get(a)?.close(), await h(this, F).removeEntry(h$1.name), h(this, b).delete(a), h(this, m).delete(a), c();
|
|
57
|
-
}));
|
|
58
|
-
await Promise.all(o);
|
|
59
|
-
}
|
|
60
|
-
_createPoolFileState(e) {
|
|
61
|
-
this.state.pool.push(e);
|
|
62
|
-
}
|
|
63
|
-
_deletePoolFileState(e) {
|
|
64
|
-
let t = this.state.pool.indexOf(e);
|
|
65
|
-
t > -1 && this.state.pool.splice(t, 1);
|
|
66
|
-
}
|
|
67
|
-
async maybeCheckpointState() {
|
|
68
|
-
Date.now() - this.lastCheckpoint > this.checkpointInterval && await this.checkpointState();
|
|
69
|
-
}
|
|
70
|
-
async checkpointState() {
|
|
71
|
-
let e = new TextEncoder().encode(JSON.stringify(this.state));
|
|
72
|
-
h(this, y).truncate(0), h(this, y).write(e, { at: 0 }), h(this, y).flush(), this.lastCheckpoint = Date.now();
|
|
73
|
-
}
|
|
74
|
-
flush() {
|
|
75
|
-
for (let e of h(this, S)) try {
|
|
76
|
-
e.flush();
|
|
77
|
-
} catch {}
|
|
78
|
-
h(this, S).clear();
|
|
79
|
-
}
|
|
80
|
-
chmod(e, t) {
|
|
81
|
-
T(this, n, O).call(this, {
|
|
82
|
-
opp: "chmod",
|
|
83
|
-
args: [e, t]
|
|
84
|
-
}, () => {
|
|
85
|
-
this._chmodState(e, t);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
_chmodState(e, t) {
|
|
89
|
-
let o = T(this, n, f).call(this, e);
|
|
90
|
-
o.mode = t;
|
|
91
|
-
}
|
|
92
|
-
close(e) {
|
|
93
|
-
let t = T(this, n, I).call(this, e);
|
|
94
|
-
h(this, P).delete(e), h(this, D).delete(t);
|
|
95
|
-
}
|
|
96
|
-
fstat(e) {
|
|
97
|
-
let t = T(this, n, I).call(this, e);
|
|
98
|
-
return this.lstat(t);
|
|
99
|
-
}
|
|
100
|
-
lstat(e) {
|
|
101
|
-
let t = T(this, n, f).call(this, e), o = t.type === "file" ? h(this, m).get(t.backingFilename).getSize() : 0, i = 4096;
|
|
102
|
-
return {
|
|
103
|
-
dev: 0,
|
|
104
|
-
ino: 0,
|
|
105
|
-
mode: t.mode,
|
|
106
|
-
nlink: 1,
|
|
107
|
-
uid: 0,
|
|
108
|
-
gid: 0,
|
|
109
|
-
rdev: 0,
|
|
110
|
-
size: o,
|
|
111
|
-
blksize: i,
|
|
112
|
-
blocks: Math.ceil(o / i),
|
|
113
|
-
atime: t.lastModified,
|
|
114
|
-
mtime: t.lastModified,
|
|
115
|
-
ctime: t.lastModified
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
mkdir(e, t) {
|
|
119
|
-
T(this, n, O).call(this, {
|
|
120
|
-
opp: "mkdir",
|
|
121
|
-
args: [e, t]
|
|
122
|
-
}, () => {
|
|
123
|
-
this._mkdirState(e, t);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
_mkdirState(e, t) {
|
|
127
|
-
let o = T(this, n, w).call(this, e), i = o.pop(), c = [], a = this.state.root;
|
|
128
|
-
for (let d of o) {
|
|
129
|
-
if (c.push(e), !Object.prototype.hasOwnProperty.call(a.children, d)) if (t?.recursive) this.mkdir(c.join("/"));
|
|
130
|
-
else throw new p("ENOENT", "No such file or directory");
|
|
131
|
-
if (a.children[d].type !== "directory") throw new p("ENOTDIR", "Not a directory");
|
|
132
|
-
a = a.children[d];
|
|
133
|
-
}
|
|
134
|
-
if (Object.prototype.hasOwnProperty.call(a.children, i)) throw new p("EEXIST", "File exists");
|
|
135
|
-
let h$1 = {
|
|
136
|
-
type: "directory",
|
|
137
|
-
lastModified: Date.now(),
|
|
138
|
-
mode: t?.mode || T$1.DIR,
|
|
139
|
-
children: {}
|
|
140
|
-
};
|
|
141
|
-
a.children[i] = h$1;
|
|
142
|
-
}
|
|
143
|
-
open(e, t, o) {
|
|
144
|
-
if (T(this, n, f).call(this, e).type !== "file") throw new p("EISDIR", "Is a directory");
|
|
145
|
-
let c = T(this, n, W).call(this);
|
|
146
|
-
return h(this, P).set(c, e), h(this, D).set(e, c), c;
|
|
147
|
-
}
|
|
148
|
-
readdir(e) {
|
|
149
|
-
let t = T(this, n, f).call(this, e);
|
|
150
|
-
if (t.type !== "directory") throw new p("ENOTDIR", "Not a directory");
|
|
151
|
-
return Object.keys(t.children);
|
|
152
|
-
}
|
|
153
|
-
read(e, t, o, i, c) {
|
|
154
|
-
let a = T(this, n, I).call(this, e), h$1 = T(this, n, f).call(this, a);
|
|
155
|
-
if (h$1.type !== "file") throw new p("EISDIR", "Is a directory");
|
|
156
|
-
return h(this, m).get(h$1.backingFilename).read(new Uint8Array(t.buffer, o, i), { at: c });
|
|
157
|
-
}
|
|
158
|
-
rename(e, t) {
|
|
159
|
-
T(this, n, O).call(this, {
|
|
160
|
-
opp: "rename",
|
|
161
|
-
args: [e, t]
|
|
162
|
-
}, () => {
|
|
163
|
-
this._renameState(e, t, !0);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
_renameState(e, t, o = !1) {
|
|
167
|
-
let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
|
|
168
|
-
if (!Object.prototype.hasOwnProperty.call(a.children, c)) throw new p("ENOENT", "No such file or directory");
|
|
169
|
-
let h$1 = T(this, n, w).call(this, t), d = h$1.pop(), l = T(this, n, f).call(this, h$1.join("/"));
|
|
170
|
-
if (o && Object.prototype.hasOwnProperty.call(l.children, d)) {
|
|
171
|
-
let u$1 = l.children[d];
|
|
172
|
-
h(this, m).get(u$1.backingFilename).truncate(0), this.state.pool.push(u$1.backingFilename);
|
|
173
|
-
}
|
|
174
|
-
l.children[d] = a.children[c], delete a.children[c];
|
|
175
|
-
}
|
|
176
|
-
rmdir(e) {
|
|
177
|
-
T(this, n, O).call(this, {
|
|
178
|
-
opp: "rmdir",
|
|
179
|
-
args: [e]
|
|
180
|
-
}, () => {
|
|
181
|
-
this._rmdirState(e);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
_rmdirState(e) {
|
|
185
|
-
let t = T(this, n, w).call(this, e), o = t.pop(), i = T(this, n, f).call(this, t.join("/"));
|
|
186
|
-
if (!Object.prototype.hasOwnProperty.call(i.children, o)) throw new p("ENOENT", "No such file or directory");
|
|
187
|
-
let c = i.children[o];
|
|
188
|
-
if (c.type !== "directory") throw new p("ENOTDIR", "Not a directory");
|
|
189
|
-
if (Object.keys(c.children).length > 0) throw new p("ENOTEMPTY", "Directory not empty");
|
|
190
|
-
delete i.children[o];
|
|
191
|
-
}
|
|
192
|
-
truncate(e, t = 0) {
|
|
193
|
-
let o = T(this, n, f).call(this, e);
|
|
194
|
-
if (o.type !== "file") throw new p("EISDIR", "Is a directory");
|
|
195
|
-
let i = h(this, m).get(o.backingFilename);
|
|
196
|
-
if (!i) throw new p("ENOENT", "No such file or directory");
|
|
197
|
-
i.truncate(t), h(this, S).add(i);
|
|
198
|
-
}
|
|
199
|
-
unlink(e) {
|
|
200
|
-
T(this, n, O).call(this, {
|
|
201
|
-
opp: "unlink",
|
|
202
|
-
args: [e]
|
|
203
|
-
}, () => {
|
|
204
|
-
this._unlinkState(e, !0);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
_unlinkState(e, t = !1) {
|
|
208
|
-
let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
|
|
209
|
-
if (!Object.prototype.hasOwnProperty.call(c.children, i)) throw new p("ENOENT", "No such file or directory");
|
|
210
|
-
let a = c.children[i];
|
|
211
|
-
if (a.type !== "file") throw new p("EISDIR", "Is a directory");
|
|
212
|
-
if (delete c.children[i], t) {
|
|
213
|
-
let h$1 = h(this, m).get(a.backingFilename);
|
|
214
|
-
h$1?.truncate(0), h(this, S).add(h$1), h(this, D).has(e) && (h(this, P).delete(h(this, D).get(e)), h(this, D).delete(e));
|
|
215
|
-
}
|
|
216
|
-
this.state.pool.push(a.backingFilename);
|
|
217
|
-
}
|
|
218
|
-
utimes(e, t, o) {
|
|
219
|
-
T(this, n, O).call(this, {
|
|
220
|
-
opp: "utimes",
|
|
221
|
-
args: [
|
|
222
|
-
e,
|
|
223
|
-
t,
|
|
224
|
-
o
|
|
225
|
-
]
|
|
226
|
-
}, () => {
|
|
227
|
-
this._utimesState(e, t, o);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
_utimesState(e, t, o) {
|
|
231
|
-
let i = T(this, n, f).call(this, e);
|
|
232
|
-
i.lastModified = o;
|
|
233
|
-
}
|
|
234
|
-
writeFile(e, t, o) {
|
|
235
|
-
let i = T(this, n, w).call(this, e), c = i.pop(), a = T(this, n, f).call(this, i.join("/"));
|
|
236
|
-
if (Object.prototype.hasOwnProperty.call(a.children, c)) {
|
|
237
|
-
let l = a.children[c];
|
|
238
|
-
l.lastModified = Date.now(), T(this, n, k).call(this, {
|
|
239
|
-
opp: "setLastModified",
|
|
240
|
-
args: [e, l.lastModified]
|
|
241
|
-
});
|
|
242
|
-
} else {
|
|
243
|
-
if (this.state.pool.length === 0) throw new Error("No more file handles available in the pool");
|
|
244
|
-
let l = {
|
|
245
|
-
type: "file",
|
|
246
|
-
lastModified: Date.now(),
|
|
247
|
-
mode: o?.mode || T$1.FILE,
|
|
248
|
-
backingFilename: this.state.pool.pop()
|
|
249
|
-
};
|
|
250
|
-
a.children[c] = l, T(this, n, k).call(this, {
|
|
251
|
-
opp: "createFileNode",
|
|
252
|
-
args: [e, l]
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
let h$1 = a.children[c], d = h(this, m).get(h$1.backingFilename);
|
|
256
|
-
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));
|
|
257
|
-
}
|
|
258
|
-
_createFileNodeState(e, t) {
|
|
259
|
-
let o = T(this, n, w).call(this, e), i = o.pop(), c = T(this, n, f).call(this, o.join("/"));
|
|
260
|
-
c.children[i] = t;
|
|
261
|
-
let a = this.state.pool.indexOf(t.backingFilename);
|
|
262
|
-
return a > -1 && this.state.pool.splice(a, 1), t;
|
|
263
|
-
}
|
|
264
|
-
_setLastModifiedState(e, t) {
|
|
265
|
-
let o = T(this, n, f).call(this, e);
|
|
266
|
-
o.lastModified = t;
|
|
267
|
-
}
|
|
268
|
-
write(e, t, o, i, c) {
|
|
269
|
-
let a = T(this, n, I).call(this, e), h$1 = T(this, n, f).call(this, a);
|
|
270
|
-
if (h$1.type !== "file") throw new p("EISDIR", "Is a directory");
|
|
271
|
-
let d = h(this, m).get(h$1.backingFilename);
|
|
272
|
-
if (!d) throw new p("EBADF", "Bad file descriptor");
|
|
273
|
-
let l = d.write(new Uint8Array(t, o, i), { at: c });
|
|
274
|
-
return a.startsWith("/pg_wal") && h(this, S).add(d), l;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
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(), x$1 = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakSet(), C = async function() {
|
|
278
|
-
x(this, H, await navigator.storage.getDirectory()), x(this, v, await T(this, n, j).call(this, this.dataDir, { create: !0 })), x(this, F, await T(this, n, j).call(this, G, {
|
|
279
|
-
from: h(this, v),
|
|
280
|
-
create: !0
|
|
281
|
-
})), x(this, M, await h(this, v).getFileHandle($, { create: !0 })), x(this, y, await h(this, M).createSyncAccessHandle());
|
|
282
|
-
let e = new ArrayBuffer(h(this, y).getSize());
|
|
283
|
-
h(this, y).read(e, { at: 0 });
|
|
284
|
-
let t, o = new TextDecoder().decode(e).split(`
|
|
285
|
-
`), i = !1;
|
|
286
|
-
try {
|
|
287
|
-
t = JSON.parse(o[0]);
|
|
288
|
-
} catch {
|
|
289
|
-
t = {
|
|
290
|
-
root: {
|
|
291
|
-
type: "directory",
|
|
292
|
-
lastModified: Date.now(),
|
|
293
|
-
mode: T$1.DIR,
|
|
294
|
-
children: {}
|
|
295
|
-
},
|
|
296
|
-
pool: []
|
|
297
|
-
}, h(this, y).truncate(0), h(this, y).write(new TextEncoder().encode(JSON.stringify(t)), { at: 0 }), i = !0;
|
|
298
|
-
}
|
|
299
|
-
this.state = t;
|
|
300
|
-
let c = o.slice(1).filter(Boolean).map((l) => JSON.parse(l));
|
|
301
|
-
for (let l of c) {
|
|
302
|
-
let u$1 = `_${l.opp}State`;
|
|
303
|
-
if (typeof this[u$1] == "function") try {
|
|
304
|
-
this[u$1].bind(this)(...l.args);
|
|
305
|
-
} catch (N) {
|
|
306
|
-
console.warn("Error applying OPFS AHP WAL entry", l, N);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
let a = [], h$1 = async (l) => {
|
|
310
|
-
if (l.type === "file") try {
|
|
311
|
-
let u$1 = await h(this, F).getFileHandle(l.backingFilename), N = await u$1.createSyncAccessHandle();
|
|
312
|
-
h(this, b).set(l.backingFilename, u$1), h(this, m).set(l.backingFilename, N);
|
|
313
|
-
} catch (u$1) {
|
|
314
|
-
console.error("Error opening file handle for node", l, u$1);
|
|
315
|
-
}
|
|
316
|
-
else for (let u$1 of Object.values(l.children)) a.push(h$1(u$1));
|
|
317
|
-
};
|
|
318
|
-
await h$1(this.state.root);
|
|
319
|
-
let d = [];
|
|
320
|
-
for (let l of this.state.pool) d.push(new Promise(async (u$1) => {
|
|
321
|
-
h(this, b).has(l) && console.warn("File handle already exists for pool file", l);
|
|
322
|
-
let N = await h(this, F).getFileHandle(l), U$1 = await N.createSyncAccessHandle();
|
|
323
|
-
h(this, b).set(l, N), h(this, m).set(l, U$1), u$1();
|
|
324
|
-
}));
|
|
325
|
-
await Promise.all([...a, ...d]), await this.maintainPool(i ? this.initialPoolSize : this.maintainedPoolSize);
|
|
326
|
-
}, O = function(e, t) {
|
|
327
|
-
let o = T(this, n, k).call(this, e);
|
|
328
|
-
try {
|
|
329
|
-
t();
|
|
330
|
-
} catch (i) {
|
|
331
|
-
throw h(this, y).truncate(o), i;
|
|
332
|
-
}
|
|
333
|
-
}, k = function(e) {
|
|
334
|
-
let t = JSON.stringify(e), o = new TextEncoder().encode(`
|
|
335
|
-
${t}`), i = h(this, y).getSize();
|
|
336
|
-
return h(this, y).write(o, { at: i }), h(this, S).add(h(this, y)), i;
|
|
337
|
-
}, w = function(e) {
|
|
338
|
-
return e.split("/").filter(Boolean);
|
|
339
|
-
}, f = function(e, t) {
|
|
340
|
-
let o = T(this, n, w).call(this, e), i = t || this.state.root;
|
|
341
|
-
for (let c of o) {
|
|
342
|
-
if (i.type !== "directory") throw new p("ENOTDIR", "Not a directory");
|
|
343
|
-
if (!Object.prototype.hasOwnProperty.call(i.children, c)) throw new p("ENOENT", "No such file or directory");
|
|
344
|
-
i = i.children[c];
|
|
345
|
-
}
|
|
346
|
-
return i;
|
|
347
|
-
}, I = function(e) {
|
|
348
|
-
let t = h(this, P).get(e);
|
|
349
|
-
if (!t) throw new p("EBADF", "Bad file descriptor");
|
|
350
|
-
return t;
|
|
351
|
-
}, W = function() {
|
|
352
|
-
let e = ++U(this, x$1)._;
|
|
353
|
-
for (; h(this, P).has(e);) U(this, x$1)._++;
|
|
354
|
-
return e;
|
|
355
|
-
}, j = async function(e, t) {
|
|
356
|
-
let o = T(this, n, w).call(this, e), i = t?.from || h(this, H);
|
|
357
|
-
for (let c of o) i = await i.getDirectoryHandle(c, { create: t?.create });
|
|
358
|
-
return i;
|
|
359
|
-
};
|
|
360
|
-
var p = class extends Error {
|
|
361
|
-
constructor(A, e) {
|
|
362
|
-
super(e), typeof A == "number" ? this.code = A : typeof A == "string" && (this.code = pr[A]);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
//#endregion
|
|
367
|
-
export { L as OpfsAhpFS };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { inspect } from "node:util";
|
|
2
|
-
import { RpcTarget } from "capnweb";
|
|
3
|
-
const validate = (schema, value) => {
|
|
4
|
-
if ("~standard" in schema) {
|
|
5
|
-
const validation = schema["~standard"].validate(value);
|
|
6
|
-
if (validation instanceof Promise) {
|
|
7
|
-
throw new TypeError(`Validation must be synchronous`);
|
|
8
|
-
}
|
|
9
|
-
if (validation.issues) {
|
|
10
|
-
throw new Error(`Invalid value: ${validation.issues.map((e) => e.message).join(", ")}`);
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
if (!schema(value)) {
|
|
14
|
-
throw new Error(`Invalid value: ${inspect(value)} (expected ${schema.name || schema.toString()})`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const toolMetadataKey = Symbol("toolMetadata");
|
|
19
|
-
const setToolMetadata = (target, metadata) => {
|
|
20
|
-
const meta = target;
|
|
21
|
-
meta[toolMetadataKey] = {
|
|
22
|
-
...meta[toolMetadataKey],
|
|
23
|
-
...metadata
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
function toolDef(inputSchema) {
|
|
27
|
-
return (target, context) => {
|
|
28
|
-
if (context.kind !== "method") {
|
|
29
|
-
throw new Error(`Tool decorator can only be used on methods`);
|
|
30
|
-
}
|
|
31
|
-
const methodName = String(context.name);
|
|
32
|
-
const replacementMethod = function(...args) {
|
|
33
|
-
const expectedArgs = inputSchema ? 1 : 0;
|
|
34
|
-
if (args.length > expectedArgs) {
|
|
35
|
-
throw new Error(`Tool ${methodName} got too many arguments: ${args.length} provided (expected ${expectedArgs})`);
|
|
36
|
-
}
|
|
37
|
-
if (inputSchema) {
|
|
38
|
-
const arg = args[0];
|
|
39
|
-
validate(inputSchema, arg);
|
|
40
|
-
return target.call(this, arg);
|
|
41
|
-
} else {
|
|
42
|
-
return target.call(this);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
setToolMetadata(replacementMethod, { runtimeValidationEnabled: true });
|
|
46
|
-
return replacementMethod;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function toolUnsafeNoValidation() {
|
|
50
|
-
return (target, context) => {
|
|
51
|
-
if (context.kind !== "method") {
|
|
52
|
-
throw new Error(`Tool decorator can only be used on methods`);
|
|
53
|
-
}
|
|
54
|
-
setToolMetadata(target, { runtimeValidationEnabled: true });
|
|
55
|
-
return target;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const callbackMetadataKey = Symbol("callbackMetadata");
|
|
59
|
-
function callbackTool() {
|
|
60
|
-
return (target, context) => {
|
|
61
|
-
if (context.kind !== "method") {
|
|
62
|
-
throw new Error(`Tool decorator can only be used on methods`);
|
|
63
|
-
}
|
|
64
|
-
const methodName = String(context.name);
|
|
65
|
-
const replacementMethod = function(...args) {
|
|
66
|
-
if (args.length !== 1) {
|
|
67
|
-
throw new Error(`Tool ${methodName} got too many arguments: ${args.length} provided (expected 1)`);
|
|
68
|
-
}
|
|
69
|
-
const callback = args[0];
|
|
70
|
-
if (typeof callback !== "function") {
|
|
71
|
-
throw new TypeError(`Callback for tool ${methodName} must be a function`);
|
|
72
|
-
}
|
|
73
|
-
const callbackWrapped = (() => {
|
|
74
|
-
throw new Error(`Callback for tool ${methodName} must be wrapped with \`tool.unwrapCallback\``);
|
|
75
|
-
});
|
|
76
|
-
callbackWrapped[callbackMetadataKey] = {
|
|
77
|
-
callback
|
|
78
|
-
};
|
|
79
|
-
return target.call(this, callbackWrapped);
|
|
80
|
-
};
|
|
81
|
-
setToolMetadata(replacementMethod, { runtimeValidationEnabled: true });
|
|
82
|
-
return replacementMethod;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
const unwrapCallback = (toolCallback, returnSchema) => (arg, then, opts) => {
|
|
86
|
-
const callback = callbackMetadataKey in toolCallback ? toolCallback[callbackMetadataKey].callback : toolCallback;
|
|
87
|
-
let isPromise = false;
|
|
88
|
-
try {
|
|
89
|
-
const result = callback(arg);
|
|
90
|
-
if (result instanceof Promise) {
|
|
91
|
-
isPromise = true;
|
|
92
|
-
let ret;
|
|
93
|
-
ret = result.then(async (r) => {
|
|
94
|
-
validate(returnSchema, r);
|
|
95
|
-
return then(r);
|
|
96
|
-
}, opts?.catch);
|
|
97
|
-
if (opts?.finally) {
|
|
98
|
-
ret = ret.finally(opts.finally);
|
|
99
|
-
}
|
|
100
|
-
return ret;
|
|
101
|
-
}
|
|
102
|
-
validate(returnSchema, result);
|
|
103
|
-
return then(result);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (opts?.catch) {
|
|
106
|
-
return opts.catch(error);
|
|
107
|
-
}
|
|
108
|
-
throw error;
|
|
109
|
-
} finally {
|
|
110
|
-
if (!isPromise) {
|
|
111
|
-
opts?.finally?.();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const tool = toolDef;
|
|
116
|
-
tool.callback = callbackTool;
|
|
117
|
-
tool.unwrap = unwrapCallback;
|
|
118
|
-
tool.unsafeNoValidation = toolUnsafeNoValidation;
|
|
119
|
-
class RpcToolset extends RpcTarget {
|
|
120
|
-
constructor() {
|
|
121
|
-
super();
|
|
122
|
-
let prototype = Object.getPrototypeOf(this);
|
|
123
|
-
while (prototype !== null && prototype !== RpcToolset.prototype) {
|
|
124
|
-
for (const key of Object.getOwnPropertyNames(prototype)) {
|
|
125
|
-
if (key === "constructor") {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
|
129
|
-
const fn = descriptor?.value ?? descriptor?.get;
|
|
130
|
-
if (!fn || typeof fn !== "function") {
|
|
131
|
-
throw new Error(`RpcToolset prototype must be methods or getters: ${key} is not`);
|
|
132
|
-
}
|
|
133
|
-
const meta = fn;
|
|
134
|
-
if (!meta[toolMetadataKey]?.runtimeValidationEnabled) {
|
|
135
|
-
throw new Error(`Prototype method \`${key}\` is not a tool. Did you forget to use the @tool decorator?`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
export {
|
|
143
|
-
RpcToolset as R,
|
|
144
|
-
setToolMetadata as s,
|
|
145
|
-
tool as t
|
|
146
|
-
};
|