@sesamespace/hivemind 0.5.13 → 0.5.15

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.
@@ -1,785 +1,6 @@
1
1
  import {
2
2
  SesameClient
3
3
  } from "./chunk-GPI4RU7N.js";
4
- import {
5
- __commonJS,
6
- __require,
7
- __toESM
8
- } from "./chunk-7D4SUZUM.js";
9
-
10
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/util.js
11
- var require_util = __commonJS({
12
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/util.js"(exports) {
13
- "use strict";
14
- exports.getBooleanOption = (options, key) => {
15
- let value = false;
16
- if (key in options && typeof (value = options[key]) !== "boolean") {
17
- throw new TypeError(`Expected the "${key}" option to be a boolean`);
18
- }
19
- return value;
20
- };
21
- exports.cppdb = /* @__PURE__ */ Symbol();
22
- exports.inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
23
- }
24
- });
25
-
26
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/sqlite-error.js
27
- var require_sqlite_error = __commonJS({
28
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
29
- "use strict";
30
- var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
31
- function SqliteError(message, code) {
32
- if (new.target !== SqliteError) {
33
- return new SqliteError(message, code);
34
- }
35
- if (typeof code !== "string") {
36
- throw new TypeError("Expected second argument to be a string");
37
- }
38
- Error.call(this, message);
39
- descriptor.value = "" + message;
40
- Object.defineProperty(this, "message", descriptor);
41
- Error.captureStackTrace(this, SqliteError);
42
- this.code = code;
43
- }
44
- Object.setPrototypeOf(SqliteError, Error);
45
- Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
46
- Object.defineProperty(SqliteError.prototype, "name", descriptor);
47
- module.exports = SqliteError;
48
- }
49
- });
50
-
51
- // node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js
52
- var require_file_uri_to_path = __commonJS({
53
- "node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js"(exports, module) {
54
- "use strict";
55
- var sep = __require("path").sep || "/";
56
- module.exports = fileUriToPath;
57
- function fileUriToPath(uri) {
58
- if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
59
- throw new TypeError("must pass in a file:// URI to convert to a file path");
60
- }
61
- var rest = decodeURI(uri.substring(7));
62
- var firstSlash = rest.indexOf("/");
63
- var host = rest.substring(0, firstSlash);
64
- var path = rest.substring(firstSlash + 1);
65
- if ("localhost" == host) host = "";
66
- if (host) {
67
- host = sep + sep + host;
68
- }
69
- path = path.replace(/^(.+)\|/, "$1:");
70
- if (sep == "\\") {
71
- path = path.replace(/\//g, "\\");
72
- }
73
- if (/^.+\:/.test(path)) {
74
- } else {
75
- path = sep + path;
76
- }
77
- return host + path;
78
- }
79
- }
80
- });
81
-
82
- // node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js
83
- var require_bindings = __commonJS({
84
- "node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js"(exports, module) {
85
- "use strict";
86
- var fs = __require("fs");
87
- var path = __require("path");
88
- var fileURLToPath4 = require_file_uri_to_path();
89
- var join = path.join;
90
- var dirname6 = path.dirname;
91
- var exists = fs.accessSync && function(path2) {
92
- try {
93
- fs.accessSync(path2);
94
- } catch (e) {
95
- return false;
96
- }
97
- return true;
98
- } || fs.existsSync || path.existsSync;
99
- var defaults = {
100
- arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
101
- compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
102
- platform: process.platform,
103
- arch: process.arch,
104
- nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
105
- version: process.versions.node,
106
- bindings: "bindings.node",
107
- try: [
108
- // node-gyp's linked version in the "build" dir
109
- ["module_root", "build", "bindings"],
110
- // node-waf and gyp_addon (a.k.a node-gyp)
111
- ["module_root", "build", "Debug", "bindings"],
112
- ["module_root", "build", "Release", "bindings"],
113
- // Debug files, for development (legacy behavior, remove for node v0.9)
114
- ["module_root", "out", "Debug", "bindings"],
115
- ["module_root", "Debug", "bindings"],
116
- // Release files, but manually compiled (legacy behavior, remove for node v0.9)
117
- ["module_root", "out", "Release", "bindings"],
118
- ["module_root", "Release", "bindings"],
119
- // Legacy from node-waf, node <= 0.4.x
120
- ["module_root", "build", "default", "bindings"],
121
- // Production "Release" buildtype binary (meh...)
122
- ["module_root", "compiled", "version", "platform", "arch", "bindings"],
123
- // node-qbs builds
124
- ["module_root", "addon-build", "release", "install-root", "bindings"],
125
- ["module_root", "addon-build", "debug", "install-root", "bindings"],
126
- ["module_root", "addon-build", "default", "install-root", "bindings"],
127
- // node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
128
- ["module_root", "lib", "binding", "nodePreGyp", "bindings"]
129
- ]
130
- };
131
- function bindings(opts) {
132
- if (typeof opts == "string") {
133
- opts = { bindings: opts };
134
- } else if (!opts) {
135
- opts = {};
136
- }
137
- Object.keys(defaults).map(function(i2) {
138
- if (!(i2 in opts)) opts[i2] = defaults[i2];
139
- });
140
- if (!opts.module_root) {
141
- opts.module_root = exports.getRoot(exports.getFileName());
142
- }
143
- if (path.extname(opts.bindings) != ".node") {
144
- opts.bindings += ".node";
145
- }
146
- var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
147
- var tries = [], i = 0, l = opts.try.length, n, b, err;
148
- for (; i < l; i++) {
149
- n = join.apply(
150
- null,
151
- opts.try[i].map(function(p) {
152
- return opts[p] || p;
153
- })
154
- );
155
- tries.push(n);
156
- try {
157
- b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
158
- if (!opts.path) {
159
- b.path = n;
160
- }
161
- return b;
162
- } catch (e) {
163
- if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
164
- throw e;
165
- }
166
- }
167
- }
168
- err = new Error(
169
- "Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
170
- return opts.arrow + a;
171
- }).join("\n")
172
- );
173
- err.tries = tries;
174
- throw err;
175
- }
176
- module.exports = exports = bindings;
177
- exports.getFileName = function getFileName(calling_file) {
178
- var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
179
- Error.stackTraceLimit = 10;
180
- Error.prepareStackTrace = function(e, st) {
181
- for (var i = 0, l = st.length; i < l; i++) {
182
- fileName = st[i].getFileName();
183
- if (fileName !== __filename) {
184
- if (calling_file) {
185
- if (fileName !== calling_file) {
186
- return;
187
- }
188
- } else {
189
- return;
190
- }
191
- }
192
- }
193
- };
194
- Error.captureStackTrace(dummy);
195
- dummy.stack;
196
- Error.prepareStackTrace = origPST;
197
- Error.stackTraceLimit = origSTL;
198
- var fileSchema = "file://";
199
- if (fileName.indexOf(fileSchema) === 0) {
200
- fileName = fileURLToPath4(fileName);
201
- }
202
- return fileName;
203
- };
204
- exports.getRoot = function getRoot(file) {
205
- var dir = dirname6(file), prev;
206
- while (true) {
207
- if (dir === ".") {
208
- dir = process.cwd();
209
- }
210
- if (exists(join(dir, "package.json")) || exists(join(dir, "node_modules"))) {
211
- return dir;
212
- }
213
- if (prev === dir) {
214
- throw new Error(
215
- 'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
216
- );
217
- }
218
- prev = dir;
219
- dir = join(dir, "..");
220
- }
221
- };
222
- }
223
- });
224
-
225
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/wrappers.js
226
- var require_wrappers = __commonJS({
227
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/wrappers.js"(exports) {
228
- "use strict";
229
- var { cppdb } = require_util();
230
- exports.prepare = function prepare(sql) {
231
- return this[cppdb].prepare(sql, this, false);
232
- };
233
- exports.exec = function exec(sql) {
234
- this[cppdb].exec(sql);
235
- return this;
236
- };
237
- exports.close = function close() {
238
- this[cppdb].close();
239
- return this;
240
- };
241
- exports.loadExtension = function loadExtension(...args) {
242
- this[cppdb].loadExtension(...args);
243
- return this;
244
- };
245
- exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
246
- this[cppdb].defaultSafeIntegers(...args);
247
- return this;
248
- };
249
- exports.unsafeMode = function unsafeMode(...args) {
250
- this[cppdb].unsafeMode(...args);
251
- return this;
252
- };
253
- exports.getters = {
254
- name: {
255
- get: function name() {
256
- return this[cppdb].name;
257
- },
258
- enumerable: true
259
- },
260
- open: {
261
- get: function open() {
262
- return this[cppdb].open;
263
- },
264
- enumerable: true
265
- },
266
- inTransaction: {
267
- get: function inTransaction() {
268
- return this[cppdb].inTransaction;
269
- },
270
- enumerable: true
271
- },
272
- readonly: {
273
- get: function readonly() {
274
- return this[cppdb].readonly;
275
- },
276
- enumerable: true
277
- },
278
- memory: {
279
- get: function memory() {
280
- return this[cppdb].memory;
281
- },
282
- enumerable: true
283
- }
284
- };
285
- }
286
- });
287
-
288
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/transaction.js
289
- var require_transaction = __commonJS({
290
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/transaction.js"(exports, module) {
291
- "use strict";
292
- var { cppdb } = require_util();
293
- var controllers = /* @__PURE__ */ new WeakMap();
294
- module.exports = function transaction(fn) {
295
- if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
296
- const db = this[cppdb];
297
- const controller = getController(db, this);
298
- const { apply } = Function.prototype;
299
- const properties = {
300
- default: { value: wrapTransaction(apply, fn, db, controller.default) },
301
- deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
302
- immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
303
- exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
304
- database: { value: this, enumerable: true }
305
- };
306
- Object.defineProperties(properties.default.value, properties);
307
- Object.defineProperties(properties.deferred.value, properties);
308
- Object.defineProperties(properties.immediate.value, properties);
309
- Object.defineProperties(properties.exclusive.value, properties);
310
- return properties.default.value;
311
- };
312
- var getController = (db, self) => {
313
- let controller = controllers.get(db);
314
- if (!controller) {
315
- const shared = {
316
- commit: db.prepare("COMMIT", self, false),
317
- rollback: db.prepare("ROLLBACK", self, false),
318
- savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
319
- release: db.prepare("RELEASE ` _bs3. `", self, false),
320
- rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
321
- };
322
- controllers.set(db, controller = {
323
- default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
324
- deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
325
- immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
326
- exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
327
- });
328
- }
329
- return controller;
330
- };
331
- var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
332
- let before, after, undo;
333
- if (db.inTransaction) {
334
- before = savepoint;
335
- after = release;
336
- undo = rollbackTo;
337
- } else {
338
- before = begin;
339
- after = commit;
340
- undo = rollback;
341
- }
342
- before.run();
343
- try {
344
- const result = apply.call(fn, this, arguments);
345
- if (result && typeof result.then === "function") {
346
- throw new TypeError("Transaction function cannot return a promise");
347
- }
348
- after.run();
349
- return result;
350
- } catch (ex) {
351
- if (db.inTransaction) {
352
- undo.run();
353
- if (undo !== rollback) after.run();
354
- }
355
- throw ex;
356
- }
357
- };
358
- }
359
- });
360
-
361
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/pragma.js
362
- var require_pragma = __commonJS({
363
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/pragma.js"(exports, module) {
364
- "use strict";
365
- var { getBooleanOption, cppdb } = require_util();
366
- module.exports = function pragma(source, options) {
367
- if (options == null) options = {};
368
- if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
369
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
370
- const simple = getBooleanOption(options, "simple");
371
- const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
372
- return simple ? stmt.pluck().get() : stmt.all();
373
- };
374
- }
375
- });
376
-
377
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/backup.js
378
- var require_backup = __commonJS({
379
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/backup.js"(exports, module) {
380
- "use strict";
381
- var fs = __require("fs");
382
- var path = __require("path");
383
- var { promisify } = __require("util");
384
- var { cppdb } = require_util();
385
- var fsAccess = promisify(fs.access);
386
- module.exports = async function backup(filename, options) {
387
- if (options == null) options = {};
388
- if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
389
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
390
- filename = filename.trim();
391
- const attachedName = "attached" in options ? options.attached : "main";
392
- const handler = "progress" in options ? options.progress : null;
393
- if (!filename) throw new TypeError("Backup filename cannot be an empty string");
394
- if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
395
- if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
396
- if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
397
- if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
398
- await fsAccess(path.dirname(filename)).catch(() => {
399
- throw new TypeError("Cannot save backup because the directory does not exist");
400
- });
401
- const isNewFile = await fsAccess(filename).then(() => false, () => true);
402
- return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
403
- };
404
- var runBackup = (backup, handler) => {
405
- let rate = 0;
406
- let useDefault = true;
407
- return new Promise((resolve6, reject) => {
408
- setImmediate(function step() {
409
- try {
410
- const progress = backup.transfer(rate);
411
- if (!progress.remainingPages) {
412
- backup.close();
413
- resolve6(progress);
414
- return;
415
- }
416
- if (useDefault) {
417
- useDefault = false;
418
- rate = 100;
419
- }
420
- if (handler) {
421
- const ret = handler(progress);
422
- if (ret !== void 0) {
423
- if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
424
- else throw new TypeError("Expected progress callback to return a number or undefined");
425
- }
426
- }
427
- setImmediate(step);
428
- } catch (err) {
429
- backup.close();
430
- reject(err);
431
- }
432
- });
433
- });
434
- };
435
- }
436
- });
437
-
438
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/serialize.js
439
- var require_serialize = __commonJS({
440
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/serialize.js"(exports, module) {
441
- "use strict";
442
- var { cppdb } = require_util();
443
- module.exports = function serialize(options) {
444
- if (options == null) options = {};
445
- if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
446
- const attachedName = "attached" in options ? options.attached : "main";
447
- if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
448
- if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
449
- return this[cppdb].serialize(attachedName);
450
- };
451
- }
452
- });
453
-
454
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/function.js
455
- var require_function = __commonJS({
456
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/function.js"(exports, module) {
457
- "use strict";
458
- var { getBooleanOption, cppdb } = require_util();
459
- module.exports = function defineFunction(name, options, fn) {
460
- if (options == null) options = {};
461
- if (typeof options === "function") {
462
- fn = options;
463
- options = {};
464
- }
465
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
466
- if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
467
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
468
- if (!name) throw new TypeError("User-defined function name cannot be an empty string");
469
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
470
- const deterministic = getBooleanOption(options, "deterministic");
471
- const directOnly = getBooleanOption(options, "directOnly");
472
- const varargs = getBooleanOption(options, "varargs");
473
- let argCount = -1;
474
- if (!varargs) {
475
- argCount = fn.length;
476
- if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
477
- if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
478
- }
479
- this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
480
- return this;
481
- };
482
- }
483
- });
484
-
485
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/aggregate.js
486
- var require_aggregate = __commonJS({
487
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/aggregate.js"(exports, module) {
488
- "use strict";
489
- var { getBooleanOption, cppdb } = require_util();
490
- module.exports = function defineAggregate(name, options) {
491
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
492
- if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
493
- if (!name) throw new TypeError("User-defined function name cannot be an empty string");
494
- const start = "start" in options ? options.start : null;
495
- const step = getFunctionOption(options, "step", true);
496
- const inverse = getFunctionOption(options, "inverse", false);
497
- const result = getFunctionOption(options, "result", false);
498
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
499
- const deterministic = getBooleanOption(options, "deterministic");
500
- const directOnly = getBooleanOption(options, "directOnly");
501
- const varargs = getBooleanOption(options, "varargs");
502
- let argCount = -1;
503
- if (!varargs) {
504
- argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
505
- if (argCount > 0) argCount -= 1;
506
- if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
507
- }
508
- this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
509
- return this;
510
- };
511
- var getFunctionOption = (options, key, required) => {
512
- const value = key in options ? options[key] : null;
513
- if (typeof value === "function") return value;
514
- if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
515
- if (required) throw new TypeError(`Missing required option "${key}"`);
516
- return null;
517
- };
518
- var getLength = ({ length }) => {
519
- if (Number.isInteger(length) && length >= 0) return length;
520
- throw new TypeError("Expected function.length to be a positive integer");
521
- };
522
- }
523
- });
524
-
525
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/table.js
526
- var require_table = __commonJS({
527
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/table.js"(exports, module) {
528
- "use strict";
529
- var { cppdb } = require_util();
530
- module.exports = function defineTable(name, factory) {
531
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
532
- if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
533
- let eponymous = false;
534
- if (typeof factory === "object" && factory !== null) {
535
- eponymous = true;
536
- factory = defer(parseTableDefinition(factory, "used", name));
537
- } else {
538
- if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
539
- factory = wrapFactory(factory);
540
- }
541
- this[cppdb].table(factory, name, eponymous);
542
- return this;
543
- };
544
- function wrapFactory(factory) {
545
- return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
546
- const thisObject = {
547
- module: moduleName,
548
- database: databaseName,
549
- table: tableName
550
- };
551
- const def = apply.call(factory, thisObject, args);
552
- if (typeof def !== "object" || def === null) {
553
- throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
554
- }
555
- return parseTableDefinition(def, "returned", moduleName);
556
- };
557
- }
558
- function parseTableDefinition(def, verb, moduleName) {
559
- if (!hasOwnProperty.call(def, "rows")) {
560
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
561
- }
562
- if (!hasOwnProperty.call(def, "columns")) {
563
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
564
- }
565
- const rows = def.rows;
566
- if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
567
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
568
- }
569
- let columns = def.columns;
570
- if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
571
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
572
- }
573
- if (columns.length !== new Set(columns).size) {
574
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
575
- }
576
- if (!columns.length) {
577
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
578
- }
579
- let parameters;
580
- if (hasOwnProperty.call(def, "parameters")) {
581
- parameters = def.parameters;
582
- if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
583
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
584
- }
585
- } else {
586
- parameters = inferParameters(rows);
587
- }
588
- if (parameters.length !== new Set(parameters).size) {
589
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
590
- }
591
- if (parameters.length > 32) {
592
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
593
- }
594
- for (const parameter of parameters) {
595
- if (columns.includes(parameter)) {
596
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
597
- }
598
- }
599
- let safeIntegers = 2;
600
- if (hasOwnProperty.call(def, "safeIntegers")) {
601
- const bool = def.safeIntegers;
602
- if (typeof bool !== "boolean") {
603
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
604
- }
605
- safeIntegers = +bool;
606
- }
607
- let directOnly = false;
608
- if (hasOwnProperty.call(def, "directOnly")) {
609
- directOnly = def.directOnly;
610
- if (typeof directOnly !== "boolean") {
611
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
612
- }
613
- }
614
- const columnDefinitions = [
615
- ...parameters.map(identifier).map((str) => `${str} HIDDEN`),
616
- ...columns.map(identifier)
617
- ];
618
- return [
619
- `CREATE TABLE x(${columnDefinitions.join(", ")});`,
620
- wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
621
- parameters,
622
- safeIntegers,
623
- directOnly
624
- ];
625
- }
626
- function wrapGenerator(generator, columnMap, moduleName) {
627
- return function* virtualTable(...args) {
628
- const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
629
- for (let i = 0; i < columnMap.size; ++i) {
630
- output.push(null);
631
- }
632
- for (const row of generator(...args)) {
633
- if (Array.isArray(row)) {
634
- extractRowArray(row, output, columnMap.size, moduleName);
635
- yield output;
636
- } else if (typeof row === "object" && row !== null) {
637
- extractRowObject(row, output, columnMap, moduleName);
638
- yield output;
639
- } else {
640
- throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
641
- }
642
- }
643
- };
644
- }
645
- function extractRowArray(row, output, columnCount, moduleName) {
646
- if (row.length !== columnCount) {
647
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
648
- }
649
- const offset = output.length - columnCount;
650
- for (let i = 0; i < columnCount; ++i) {
651
- output[i + offset] = row[i];
652
- }
653
- }
654
- function extractRowObject(row, output, columnMap, moduleName) {
655
- let count = 0;
656
- for (const key of Object.keys(row)) {
657
- const index = columnMap.get(key);
658
- if (index === void 0) {
659
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
660
- }
661
- output[index] = row[key];
662
- count += 1;
663
- }
664
- if (count !== columnMap.size) {
665
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
666
- }
667
- }
668
- function inferParameters({ length }) {
669
- if (!Number.isInteger(length) || length < 0) {
670
- throw new TypeError("Expected function.length to be a positive integer");
671
- }
672
- const params = [];
673
- for (let i = 0; i < length; ++i) {
674
- params.push(`$${i + 1}`);
675
- }
676
- return params;
677
- }
678
- var { hasOwnProperty } = Object.prototype;
679
- var { apply } = Function.prototype;
680
- var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
681
- });
682
- var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
683
- var defer = (x) => () => x;
684
- }
685
- });
686
-
687
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/inspect.js
688
- var require_inspect = __commonJS({
689
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
690
- "use strict";
691
- var DatabaseInspection = function Database2() {
692
- };
693
- module.exports = function inspect(depth, opts) {
694
- return Object.assign(new DatabaseInspection(), this);
695
- };
696
- }
697
- });
698
-
699
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/database.js
700
- var require_database = __commonJS({
701
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/database.js"(exports, module) {
702
- "use strict";
703
- var fs = __require("fs");
704
- var path = __require("path");
705
- var util = require_util();
706
- var SqliteError = require_sqlite_error();
707
- var DEFAULT_ADDON;
708
- function Database2(filenameGiven, options) {
709
- if (new.target == null) {
710
- return new Database2(filenameGiven, options);
711
- }
712
- let buffer;
713
- if (Buffer.isBuffer(filenameGiven)) {
714
- buffer = filenameGiven;
715
- filenameGiven = ":memory:";
716
- }
717
- if (filenameGiven == null) filenameGiven = "";
718
- if (options == null) options = {};
719
- if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
720
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
721
- if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
722
- if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
723
- const filename = filenameGiven.trim();
724
- const anonymous = filename === "" || filename === ":memory:";
725
- const readonly = util.getBooleanOption(options, "readonly");
726
- const fileMustExist = util.getBooleanOption(options, "fileMustExist");
727
- const timeout = "timeout" in options ? options.timeout : 5e3;
728
- const verbose = "verbose" in options ? options.verbose : null;
729
- const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
730
- if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
731
- if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
732
- if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
733
- if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
734
- if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
735
- let addon;
736
- if (nativeBinding == null) {
737
- addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
738
- } else if (typeof nativeBinding === "string") {
739
- const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
740
- addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
741
- } else {
742
- addon = nativeBinding;
743
- }
744
- if (!addon.isInitialized) {
745
- addon.setErrorConstructor(SqliteError);
746
- addon.isInitialized = true;
747
- }
748
- if (!anonymous && !fs.existsSync(path.dirname(filename))) {
749
- throw new TypeError("Cannot open database because the directory does not exist");
750
- }
751
- Object.defineProperties(this, {
752
- [util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
753
- ...wrappers.getters
754
- });
755
- }
756
- var wrappers = require_wrappers();
757
- Database2.prototype.prepare = wrappers.prepare;
758
- Database2.prototype.transaction = require_transaction();
759
- Database2.prototype.pragma = require_pragma();
760
- Database2.prototype.backup = require_backup();
761
- Database2.prototype.serialize = require_serialize();
762
- Database2.prototype.function = require_function();
763
- Database2.prototype.aggregate = require_aggregate();
764
- Database2.prototype.table = require_table();
765
- Database2.prototype.loadExtension = wrappers.loadExtension;
766
- Database2.prototype.exec = wrappers.exec;
767
- Database2.prototype.close = wrappers.close;
768
- Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
769
- Database2.prototype.unsafeMode = wrappers.unsafeMode;
770
- Database2.prototype[util.inspect] = require_inspect();
771
- module.exports = Database2;
772
- }
773
- });
774
-
775
- // node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/index.js
776
- var require_lib = __commonJS({
777
- "node_modules/.pnpm/better-sqlite3@11.10.0/node_modules/better-sqlite3/lib/index.js"(exports, module) {
778
- "use strict";
779
- module.exports = require_database();
780
- module.exports.SqliteError = require_sqlite_error();
781
- }
782
- });
783
4
 
784
5
  // packages/runtime/src/llm-client.ts
785
6
  var LLMClient = class {
@@ -2776,58 +1997,42 @@ var HEALTH_PORT = 9484;
2776
1997
  var HEALTH_PATH = "/health";
2777
1998
 
2778
1999
  // packages/runtime/src/request-logger.ts
2779
- var import_better_sqlite3 = __toESM(require_lib(), 1);
2780
2000
  import { randomUUID } from "crypto";
2781
- import { mkdirSync, existsSync as existsSync3 } from "fs";
2001
+ import { mkdirSync, existsSync as existsSync3, appendFileSync, readFileSync as readFileSync4, writeFileSync } from "fs";
2782
2002
  import { dirname as dirname3 } from "path";
2783
2003
  var RequestLogger = class {
2784
- db;
2004
+ logPath;
2005
+ maxAgeDays = 7;
2785
2006
  constructor(dbPath) {
2786
- const dir = dirname3(dbPath);
2007
+ this.logPath = dbPath.replace(/\.db$/, ".jsonl");
2008
+ if (this.logPath === dbPath) this.logPath = dbPath + ".jsonl";
2009
+ const dir = dirname3(this.logPath);
2787
2010
  if (!existsSync3(dir)) mkdirSync(dir, { recursive: true });
2788
- this.db = new import_better_sqlite3.default(dbPath);
2789
- this.db.pragma("journal_mode = WAL");
2790
- this.db.pragma("synchronous = NORMAL");
2791
- this.init();
2792
2011
  this.prune();
2793
2012
  }
2794
- init() {
2795
- this.db.exec(`
2796
- CREATE TABLE IF NOT EXISTS request_logs (
2797
- id TEXT PRIMARY KEY,
2798
- timestamp TEXT NOT NULL,
2799
- context TEXT NOT NULL,
2800
- context_switched INTEGER NOT NULL DEFAULT 0,
2801
- routing_reason TEXT NOT NULL DEFAULT '',
2802
- channel_id TEXT NOT NULL DEFAULT '',
2803
- channel_kind TEXT NOT NULL DEFAULT '',
2804
- sender_handle TEXT NOT NULL DEFAULT '',
2805
- raw_message TEXT NOT NULL,
2806
- system_prompt_components TEXT NOT NULL,
2807
- conversation_history TEXT NOT NULL,
2808
- user_message TEXT NOT NULL,
2809
- response_content TEXT NOT NULL,
2810
- response_model TEXT NOT NULL,
2811
- response_latency_ms INTEGER NOT NULL,
2812
- response_skipped INTEGER NOT NULL DEFAULT 0,
2813
- config_snapshot TEXT NOT NULL,
2814
- token_est_system INTEGER NOT NULL DEFAULT 0,
2815
- token_est_history INTEGER NOT NULL DEFAULT 0,
2816
- token_est_user INTEGER NOT NULL DEFAULT 0,
2817
- token_est_total INTEGER NOT NULL DEFAULT 0
2818
- )
2819
- `);
2820
- this.db.exec(`
2821
- CREATE INDEX IF NOT EXISTS idx_request_logs_timestamp ON request_logs(timestamp DESC);
2822
- CREATE INDEX IF NOT EXISTS idx_request_logs_context ON request_logs(context);
2823
- CREATE INDEX IF NOT EXISTS idx_request_logs_sender ON request_logs(sender_handle);
2824
- `);
2825
- }
2826
2013
  prune() {
2827
- const cutoff = new Date(Date.now() - 7 * 24 * 60 * 60 * 1e3).toISOString();
2828
- const result = this.db.prepare("DELETE FROM request_logs WHERE timestamp < ?").run(cutoff);
2829
- if (result.changes > 0) {
2830
- console.log(`[dashboard] Pruned ${result.changes} old request logs`);
2014
+ if (!existsSync3(this.logPath)) return;
2015
+ const cutoff = new Date(Date.now() - this.maxAgeDays * 24 * 60 * 60 * 1e3).toISOString();
2016
+ try {
2017
+ const lines = readFileSync4(this.logPath, "utf-8").split("\n").filter(Boolean);
2018
+ const kept = [];
2019
+ let pruned = 0;
2020
+ for (const line of lines) {
2021
+ try {
2022
+ const entry = JSON.parse(line);
2023
+ if (entry.timestamp >= cutoff) {
2024
+ kept.push(line);
2025
+ } else {
2026
+ pruned++;
2027
+ }
2028
+ } catch {
2029
+ }
2030
+ }
2031
+ if (pruned > 0) {
2032
+ writeFileSync(this.logPath, kept.join("\n") + (kept.length > 0 ? "\n" : ""));
2033
+ console.log(`[dashboard] Pruned ${pruned} old request logs`);
2034
+ }
2035
+ } catch {
2831
2036
  }
2832
2037
  }
2833
2038
  log(entry) {
@@ -2838,78 +2043,73 @@ var RequestLogger = class {
2838
2043
  entry.conversationHistory.reduce((sum, m) => sum + m.content.length, 0) / 4
2839
2044
  );
2840
2045
  const userTokens = Math.ceil(entry.userMessage.length / 4);
2841
- this.db.prepare(
2842
- `INSERT INTO request_logs (
2843
- id, timestamp, context, context_switched, routing_reason,
2844
- channel_id, channel_kind, sender_handle, raw_message,
2845
- system_prompt_components, conversation_history, user_message,
2846
- response_content, response_model, response_latency_ms, response_skipped,
2847
- config_snapshot,
2848
- token_est_system, token_est_history, token_est_user, token_est_total
2849
- ) VALUES (
2850
- ?, ?, ?, ?, ?,
2851
- ?, ?, ?, ?,
2852
- ?, ?, ?,
2853
- ?, ?, ?, ?,
2854
- ?,
2855
- ?, ?, ?, ?
2856
- )`
2857
- ).run(
2046
+ const record = {
2858
2047
  id,
2859
2048
  timestamp,
2860
- entry.context,
2861
- entry.contextSwitched ? 1 : 0,
2862
- entry.routingReason,
2863
- entry.channelId ?? "",
2864
- entry.channelKind ?? "",
2865
- entry.senderHandle ?? "",
2866
- entry.rawMessage,
2867
- JSON.stringify(entry.systemPromptComponents),
2868
- JSON.stringify(entry.conversationHistory),
2869
- entry.userMessage,
2870
- entry.response.content,
2871
- entry.response.model,
2872
- entry.response.latencyMs,
2873
- entry.response.skipped ? 1 : 0,
2874
- JSON.stringify(entry.config),
2875
- sysTokens,
2876
- histTokens,
2877
- userTokens,
2878
- sysTokens + histTokens + userTokens
2879
- );
2049
+ context: entry.context,
2050
+ context_switched: entry.contextSwitched,
2051
+ routing_reason: entry.routingReason,
2052
+ channel_id: entry.channelId ?? "",
2053
+ channel_kind: entry.channelKind ?? "",
2054
+ sender_handle: entry.senderHandle ?? "",
2055
+ raw_message: entry.rawMessage,
2056
+ system_prompt_components: JSON.stringify(entry.systemPromptComponents),
2057
+ conversation_history: JSON.stringify(entry.conversationHistory),
2058
+ user_message: entry.userMessage,
2059
+ response_content: entry.response.content,
2060
+ response_model: entry.response.model,
2061
+ response_latency_ms: entry.response.latencyMs,
2062
+ response_skipped: entry.response.skipped,
2063
+ config_snapshot: JSON.stringify(entry.config),
2064
+ token_est_system: sysTokens,
2065
+ token_est_history: histTokens,
2066
+ token_est_user: userTokens,
2067
+ token_est_total: sysTokens + histTokens + userTokens
2068
+ };
2069
+ appendFileSync(this.logPath, JSON.stringify(record) + "\n");
2880
2070
  return id;
2881
2071
  }
2882
2072
  getRequests(opts = {}) {
2883
2073
  const limit = opts.limit ?? 50;
2884
2074
  const offset = opts.offset ?? 0;
2885
- const conditions = [];
2886
- const params = [];
2075
+ let entries = this.readAll();
2887
2076
  if (opts.context) {
2888
- conditions.push("context = ?");
2889
- params.push(opts.context);
2077
+ entries = entries.filter((e) => e.context === opts.context);
2890
2078
  }
2891
2079
  if (opts.sender) {
2892
- conditions.push("sender_handle = ?");
2893
- params.push(opts.sender);
2894
- }
2895
- const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
2896
- const total = this.db.prepare(`SELECT COUNT(*) as count FROM request_logs ${where}`).get(...params).count;
2897
- const requests = this.db.prepare(
2898
- `SELECT * FROM request_logs ${where} ORDER BY timestamp DESC LIMIT ? OFFSET ?`
2899
- ).all(...params, limit, offset);
2080
+ entries = entries.filter((e) => e.sender_handle === opts.sender);
2081
+ }
2082
+ entries.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
2083
+ const total = entries.length;
2084
+ const requests = entries.slice(offset, offset + limit);
2900
2085
  return { requests, total };
2901
2086
  }
2902
2087
  getRequest(id) {
2903
- return this.db.prepare("SELECT * FROM request_logs WHERE id = ?").get(id);
2088
+ return this.readAll().find((e) => e.id === id);
2904
2089
  }
2905
2090
  close() {
2906
- this.db.close();
2091
+ }
2092
+ readAll() {
2093
+ if (!existsSync3(this.logPath)) return [];
2094
+ try {
2095
+ const lines = readFileSync4(this.logPath, "utf-8").split("\n").filter(Boolean);
2096
+ const entries = [];
2097
+ for (const line of lines) {
2098
+ try {
2099
+ entries.push(JSON.parse(line));
2100
+ } catch {
2101
+ }
2102
+ }
2103
+ return entries;
2104
+ } catch {
2105
+ return [];
2106
+ }
2907
2107
  }
2908
2108
  };
2909
2109
 
2910
2110
  // packages/runtime/src/dashboard.ts
2911
2111
  import { createServer } from "http";
2912
- import { readFileSync as readFileSync4 } from "fs";
2112
+ import { readFileSync as readFileSync5 } from "fs";
2913
2113
  import { resolve as resolve4, dirname as dirname4 } from "path";
2914
2114
  import { fileURLToPath as fileURLToPath2 } from "url";
2915
2115
  var __dirname = dirname4(fileURLToPath2(import.meta.url));
@@ -2919,7 +2119,7 @@ function getSpaHtml() {
2919
2119
  if (!spaHtml) {
2920
2120
  for (const dir of [__dirname, resolve4(__dirname, "../src")]) {
2921
2121
  try {
2922
- spaHtml = readFileSync4(resolve4(dir, "dashboard.html"), "utf-8");
2122
+ spaHtml = readFileSync5(resolve4(dir, "dashboard.html"), "utf-8");
2923
2123
  break;
2924
2124
  } catch {
2925
2125
  }
@@ -3041,13 +2241,13 @@ function startDashboardServer(requestLogger, memoryConfig) {
3041
2241
  }
3042
2242
 
3043
2243
  // packages/runtime/src/pipeline.ts
3044
- import { readFileSync as readFileSync5, writeFileSync, unlinkSync } from "fs";
2244
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync2, unlinkSync } from "fs";
3045
2245
  import { resolve as resolve5, dirname as dirname5 } from "path";
3046
2246
  import { fileURLToPath as fileURLToPath3 } from "url";
3047
2247
  var PACKAGE_VERSION = "unknown";
3048
2248
  try {
3049
2249
  const __dirname2 = dirname5(fileURLToPath3(import.meta.url));
3050
- const pkg = JSON.parse(readFileSync5(resolve5(__dirname2, "../package.json"), "utf-8"));
2250
+ const pkg = JSON.parse(readFileSync6(resolve5(__dirname2, "../package.json"), "utf-8"));
3051
2251
  PACKAGE_VERSION = pkg.version ?? "unknown";
3052
2252
  } catch {
3053
2253
  }
@@ -3078,7 +2278,7 @@ function startHealthServer(port) {
3078
2278
  return server;
3079
2279
  }
3080
2280
  function writePidFile(path) {
3081
- writeFileSync(path, String(process.pid));
2281
+ writeFileSync2(path, String(process.pid));
3082
2282
  console.log(`[hivemind] PID file written: ${path}`);
3083
2283
  }
3084
2284
  function cleanupPidFile(path) {
@@ -3723,4 +2923,4 @@ smol-toml/dist/index.js:
3723
2923
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3724
2924
  *)
3725
2925
  */
3726
- //# sourceMappingURL=chunk-MKE2NVOC.js.map
2926
+ //# sourceMappingURL=chunk-MKVGEXKO.js.map