tracer-sh 0.2.7 → 0.3.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/README.md +58 -6
- package/bin/tracer.mjs +80 -2
- package/package.json +4 -3
- package/packages/server/dist/index.js +1126 -33
- package/packages/web/dist/assets/{SearchableSelect-BPzDtKhB.js → SearchableSelect-ClBD3uDN.js} +1 -1
- package/packages/web/dist/assets/Settings-DqYpr-dx.js +1 -0
- package/packages/web/dist/assets/{highlighted-body-OFNGDK62-tPjSIaIA.js → highlighted-body-OFNGDK62-ClhPAwAu.js} +1 -1
- package/packages/web/dist/assets/{index-IihLiR83.js → index-BfsXwolP.js} +9 -9
- package/packages/web/dist/assets/{mermaid-GHXKKRXX-C9jh9K1i.js → mermaid-GHXKKRXX-BP9XJxn7.js} +3 -3
- package/packages/web/dist/index.html +1 -1
- package/packages/web/dist/assets/Settings-ntDADPDR.js +0 -1
|
@@ -24,9 +24,784 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
__commonJS,
|
|
26
26
|
__export,
|
|
27
|
+
__require,
|
|
27
28
|
__toESM
|
|
28
29
|
} from "./chunk-WOL2ZWU7.js";
|
|
29
30
|
|
|
31
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/util.js
|
|
32
|
+
var require_util = __commonJS({
|
|
33
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/util.js"(exports) {
|
|
34
|
+
"use strict";
|
|
35
|
+
exports.getBooleanOption = (options, key) => {
|
|
36
|
+
let value = false;
|
|
37
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
38
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
exports.cppdb = /* @__PURE__ */ Symbol();
|
|
43
|
+
exports.inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/sqlite-error.js
|
|
48
|
+
var require_sqlite_error = __commonJS({
|
|
49
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
|
|
50
|
+
"use strict";
|
|
51
|
+
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
52
|
+
function SqliteError(message, code) {
|
|
53
|
+
if (new.target !== SqliteError) {
|
|
54
|
+
return new SqliteError(message, code);
|
|
55
|
+
}
|
|
56
|
+
if (typeof code !== "string") {
|
|
57
|
+
throw new TypeError("Expected second argument to be a string");
|
|
58
|
+
}
|
|
59
|
+
Error.call(this, message);
|
|
60
|
+
descriptor.value = "" + message;
|
|
61
|
+
Object.defineProperty(this, "message", descriptor);
|
|
62
|
+
Error.captureStackTrace(this, SqliteError);
|
|
63
|
+
this.code = code;
|
|
64
|
+
}
|
|
65
|
+
Object.setPrototypeOf(SqliteError, Error);
|
|
66
|
+
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
67
|
+
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
68
|
+
module.exports = SqliteError;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// ../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js
|
|
73
|
+
var require_file_uri_to_path = __commonJS({
|
|
74
|
+
"../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js"(exports, module) {
|
|
75
|
+
"use strict";
|
|
76
|
+
var sep2 = __require("path").sep || "/";
|
|
77
|
+
module.exports = fileUriToPath;
|
|
78
|
+
function fileUriToPath(uri) {
|
|
79
|
+
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
80
|
+
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
81
|
+
}
|
|
82
|
+
var rest = decodeURI(uri.substring(7));
|
|
83
|
+
var firstSlash = rest.indexOf("/");
|
|
84
|
+
var host = rest.substring(0, firstSlash);
|
|
85
|
+
var path = rest.substring(firstSlash + 1);
|
|
86
|
+
if ("localhost" == host) host = "";
|
|
87
|
+
if (host) {
|
|
88
|
+
host = sep2 + sep2 + host;
|
|
89
|
+
}
|
|
90
|
+
path = path.replace(/^(.+)\|/, "$1:");
|
|
91
|
+
if (sep2 == "\\") {
|
|
92
|
+
path = path.replace(/\//g, "\\");
|
|
93
|
+
}
|
|
94
|
+
if (/^.+\:/.test(path)) {
|
|
95
|
+
} else {
|
|
96
|
+
path = sep2 + path;
|
|
97
|
+
}
|
|
98
|
+
return host + path;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// ../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js
|
|
104
|
+
var require_bindings = __commonJS({
|
|
105
|
+
"../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js"(exports, module) {
|
|
106
|
+
"use strict";
|
|
107
|
+
var fs = __require("fs");
|
|
108
|
+
var path = __require("path");
|
|
109
|
+
var fileURLToPath3 = require_file_uri_to_path();
|
|
110
|
+
var join5 = path.join;
|
|
111
|
+
var dirname4 = path.dirname;
|
|
112
|
+
var exists2 = fs.accessSync && function(path2) {
|
|
113
|
+
try {
|
|
114
|
+
fs.accessSync(path2);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
} || fs.existsSync || path.existsSync;
|
|
120
|
+
var defaults = {
|
|
121
|
+
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
122
|
+
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
123
|
+
platform: process.platform,
|
|
124
|
+
arch: process.arch,
|
|
125
|
+
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
126
|
+
version: process.versions.node,
|
|
127
|
+
bindings: "bindings.node",
|
|
128
|
+
try: [
|
|
129
|
+
// node-gyp's linked version in the "build" dir
|
|
130
|
+
["module_root", "build", "bindings"],
|
|
131
|
+
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
132
|
+
["module_root", "build", "Debug", "bindings"],
|
|
133
|
+
["module_root", "build", "Release", "bindings"],
|
|
134
|
+
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
135
|
+
["module_root", "out", "Debug", "bindings"],
|
|
136
|
+
["module_root", "Debug", "bindings"],
|
|
137
|
+
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
138
|
+
["module_root", "out", "Release", "bindings"],
|
|
139
|
+
["module_root", "Release", "bindings"],
|
|
140
|
+
// Legacy from node-waf, node <= 0.4.x
|
|
141
|
+
["module_root", "build", "default", "bindings"],
|
|
142
|
+
// Production "Release" buildtype binary (meh...)
|
|
143
|
+
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
144
|
+
// node-qbs builds
|
|
145
|
+
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
146
|
+
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
147
|
+
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
148
|
+
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
149
|
+
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
function bindings(opts) {
|
|
153
|
+
if (typeof opts == "string") {
|
|
154
|
+
opts = { bindings: opts };
|
|
155
|
+
} else if (!opts) {
|
|
156
|
+
opts = {};
|
|
157
|
+
}
|
|
158
|
+
Object.keys(defaults).map(function(i2) {
|
|
159
|
+
if (!(i2 in opts)) opts[i2] = defaults[i2];
|
|
160
|
+
});
|
|
161
|
+
if (!opts.module_root) {
|
|
162
|
+
opts.module_root = exports.getRoot(exports.getFileName());
|
|
163
|
+
}
|
|
164
|
+
if (path.extname(opts.bindings) != ".node") {
|
|
165
|
+
opts.bindings += ".node";
|
|
166
|
+
}
|
|
167
|
+
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
168
|
+
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
169
|
+
for (; i < l; i++) {
|
|
170
|
+
n = join5.apply(
|
|
171
|
+
null,
|
|
172
|
+
opts.try[i].map(function(p) {
|
|
173
|
+
return opts[p] || p;
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
tries.push(n);
|
|
177
|
+
try {
|
|
178
|
+
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
179
|
+
if (!opts.path) {
|
|
180
|
+
b.path = n;
|
|
181
|
+
}
|
|
182
|
+
return b;
|
|
183
|
+
} catch (e) {
|
|
184
|
+
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
err = new Error(
|
|
190
|
+
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
191
|
+
return opts.arrow + a;
|
|
192
|
+
}).join("\n")
|
|
193
|
+
);
|
|
194
|
+
err.tries = tries;
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
module.exports = exports = bindings;
|
|
198
|
+
exports.getFileName = function getFileName(calling_file) {
|
|
199
|
+
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
200
|
+
Error.stackTraceLimit = 10;
|
|
201
|
+
Error.prepareStackTrace = function(e, st) {
|
|
202
|
+
for (var i = 0, l = st.length; i < l; i++) {
|
|
203
|
+
fileName = st[i].getFileName();
|
|
204
|
+
if (fileName !== __filename) {
|
|
205
|
+
if (calling_file) {
|
|
206
|
+
if (fileName !== calling_file) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
Error.captureStackTrace(dummy);
|
|
216
|
+
dummy.stack;
|
|
217
|
+
Error.prepareStackTrace = origPST;
|
|
218
|
+
Error.stackTraceLimit = origSTL;
|
|
219
|
+
var fileSchema = "file://";
|
|
220
|
+
if (fileName.indexOf(fileSchema) === 0) {
|
|
221
|
+
fileName = fileURLToPath3(fileName);
|
|
222
|
+
}
|
|
223
|
+
return fileName;
|
|
224
|
+
};
|
|
225
|
+
exports.getRoot = function getRoot(file2) {
|
|
226
|
+
var dir = dirname4(file2), prev;
|
|
227
|
+
while (true) {
|
|
228
|
+
if (dir === ".") {
|
|
229
|
+
dir = process.cwd();
|
|
230
|
+
}
|
|
231
|
+
if (exists2(join5(dir, "package.json")) || exists2(join5(dir, "node_modules"))) {
|
|
232
|
+
return dir;
|
|
233
|
+
}
|
|
234
|
+
if (prev === dir) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
'Could not find module root given file: "' + file2 + '". Do you have a `package.json` file? '
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
prev = dir;
|
|
240
|
+
dir = join5(dir, "..");
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
247
|
+
var require_wrappers = __commonJS({
|
|
248
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/wrappers.js"(exports) {
|
|
249
|
+
"use strict";
|
|
250
|
+
var { cppdb } = require_util();
|
|
251
|
+
exports.prepare = function prepare(sql2) {
|
|
252
|
+
return this[cppdb].prepare(sql2, this, false);
|
|
253
|
+
};
|
|
254
|
+
exports.exec = function exec2(sql2) {
|
|
255
|
+
this[cppdb].exec(sql2);
|
|
256
|
+
return this;
|
|
257
|
+
};
|
|
258
|
+
exports.close = function close() {
|
|
259
|
+
this[cppdb].close();
|
|
260
|
+
return this;
|
|
261
|
+
};
|
|
262
|
+
exports.loadExtension = function loadExtension(...args) {
|
|
263
|
+
this[cppdb].loadExtension(...args);
|
|
264
|
+
return this;
|
|
265
|
+
};
|
|
266
|
+
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
267
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
268
|
+
return this;
|
|
269
|
+
};
|
|
270
|
+
exports.unsafeMode = function unsafeMode(...args) {
|
|
271
|
+
this[cppdb].unsafeMode(...args);
|
|
272
|
+
return this;
|
|
273
|
+
};
|
|
274
|
+
exports.getters = {
|
|
275
|
+
name: {
|
|
276
|
+
get: function name26() {
|
|
277
|
+
return this[cppdb].name;
|
|
278
|
+
},
|
|
279
|
+
enumerable: true
|
|
280
|
+
},
|
|
281
|
+
open: {
|
|
282
|
+
get: function open() {
|
|
283
|
+
return this[cppdb].open;
|
|
284
|
+
},
|
|
285
|
+
enumerable: true
|
|
286
|
+
},
|
|
287
|
+
inTransaction: {
|
|
288
|
+
get: function inTransaction() {
|
|
289
|
+
return this[cppdb].inTransaction;
|
|
290
|
+
},
|
|
291
|
+
enumerable: true
|
|
292
|
+
},
|
|
293
|
+
readonly: {
|
|
294
|
+
get: function readonly2() {
|
|
295
|
+
return this[cppdb].readonly;
|
|
296
|
+
},
|
|
297
|
+
enumerable: true
|
|
298
|
+
},
|
|
299
|
+
memory: {
|
|
300
|
+
get: function memory() {
|
|
301
|
+
return this[cppdb].memory;
|
|
302
|
+
},
|
|
303
|
+
enumerable: true
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/transaction.js
|
|
310
|
+
var require_transaction = __commonJS({
|
|
311
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/transaction.js"(exports, module) {
|
|
312
|
+
"use strict";
|
|
313
|
+
var { cppdb } = require_util();
|
|
314
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
315
|
+
module.exports = function transaction(fn) {
|
|
316
|
+
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
317
|
+
const db2 = this[cppdb];
|
|
318
|
+
const controller = getController(db2, this);
|
|
319
|
+
const { apply } = Function.prototype;
|
|
320
|
+
const properties = {
|
|
321
|
+
default: { value: wrapTransaction(apply, fn, db2, controller.default) },
|
|
322
|
+
deferred: { value: wrapTransaction(apply, fn, db2, controller.deferred) },
|
|
323
|
+
immediate: { value: wrapTransaction(apply, fn, db2, controller.immediate) },
|
|
324
|
+
exclusive: { value: wrapTransaction(apply, fn, db2, controller.exclusive) },
|
|
325
|
+
database: { value: this, enumerable: true }
|
|
326
|
+
};
|
|
327
|
+
Object.defineProperties(properties.default.value, properties);
|
|
328
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
329
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
330
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
331
|
+
return properties.default.value;
|
|
332
|
+
};
|
|
333
|
+
var getController = (db2, self) => {
|
|
334
|
+
let controller = controllers.get(db2);
|
|
335
|
+
if (!controller) {
|
|
336
|
+
const shared = {
|
|
337
|
+
commit: db2.prepare("COMMIT", self, false),
|
|
338
|
+
rollback: db2.prepare("ROLLBACK", self, false),
|
|
339
|
+
savepoint: db2.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
340
|
+
release: db2.prepare("RELEASE ` _bs3. `", self, false),
|
|
341
|
+
rollbackTo: db2.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
342
|
+
};
|
|
343
|
+
controllers.set(db2, controller = {
|
|
344
|
+
default: Object.assign({ begin: db2.prepare("BEGIN", self, false) }, shared),
|
|
345
|
+
deferred: Object.assign({ begin: db2.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
346
|
+
immediate: Object.assign({ begin: db2.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
347
|
+
exclusive: Object.assign({ begin: db2.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return controller;
|
|
351
|
+
};
|
|
352
|
+
var wrapTransaction = (apply, fn, db2, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
353
|
+
let before, after, undo;
|
|
354
|
+
if (db2.inTransaction) {
|
|
355
|
+
before = savepoint;
|
|
356
|
+
after = release;
|
|
357
|
+
undo = rollbackTo;
|
|
358
|
+
} else {
|
|
359
|
+
before = begin;
|
|
360
|
+
after = commit;
|
|
361
|
+
undo = rollback;
|
|
362
|
+
}
|
|
363
|
+
before.run();
|
|
364
|
+
try {
|
|
365
|
+
const result = apply.call(fn, this, arguments);
|
|
366
|
+
if (result && typeof result.then === "function") {
|
|
367
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
368
|
+
}
|
|
369
|
+
after.run();
|
|
370
|
+
return result;
|
|
371
|
+
} catch (ex) {
|
|
372
|
+
if (db2.inTransaction) {
|
|
373
|
+
undo.run();
|
|
374
|
+
if (undo !== rollback) after.run();
|
|
375
|
+
}
|
|
376
|
+
throw ex;
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/pragma.js
|
|
383
|
+
var require_pragma = __commonJS({
|
|
384
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/pragma.js"(exports, module) {
|
|
385
|
+
"use strict";
|
|
386
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
387
|
+
module.exports = function pragma(source, options) {
|
|
388
|
+
if (options == null) options = {};
|
|
389
|
+
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
390
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
391
|
+
const simple = getBooleanOption(options, "simple");
|
|
392
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
393
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/backup.js
|
|
399
|
+
var require_backup = __commonJS({
|
|
400
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/backup.js"(exports, module) {
|
|
401
|
+
"use strict";
|
|
402
|
+
var fs = __require("fs");
|
|
403
|
+
var path = __require("path");
|
|
404
|
+
var { promisify } = __require("util");
|
|
405
|
+
var { cppdb } = require_util();
|
|
406
|
+
var fsAccess = promisify(fs.access);
|
|
407
|
+
module.exports = async function backup(filename, options) {
|
|
408
|
+
if (options == null) options = {};
|
|
409
|
+
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
410
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
411
|
+
filename = filename.trim();
|
|
412
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
413
|
+
const handler = "progress" in options ? options.progress : null;
|
|
414
|
+
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
415
|
+
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
416
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
417
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
418
|
+
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
419
|
+
await fsAccess(path.dirname(filename)).catch(() => {
|
|
420
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
421
|
+
});
|
|
422
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
423
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
424
|
+
};
|
|
425
|
+
var runBackup = (backup, handler) => {
|
|
426
|
+
let rate = 0;
|
|
427
|
+
let useDefault = true;
|
|
428
|
+
return new Promise((resolve4, reject) => {
|
|
429
|
+
setImmediate(function step() {
|
|
430
|
+
try {
|
|
431
|
+
const progress = backup.transfer(rate);
|
|
432
|
+
if (!progress.remainingPages) {
|
|
433
|
+
backup.close();
|
|
434
|
+
resolve4(progress);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (useDefault) {
|
|
438
|
+
useDefault = false;
|
|
439
|
+
rate = 100;
|
|
440
|
+
}
|
|
441
|
+
if (handler) {
|
|
442
|
+
const ret = handler(progress);
|
|
443
|
+
if (ret !== void 0) {
|
|
444
|
+
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
445
|
+
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
setImmediate(step);
|
|
449
|
+
} catch (err) {
|
|
450
|
+
backup.close();
|
|
451
|
+
reject(err);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/serialize.js
|
|
460
|
+
var require_serialize = __commonJS({
|
|
461
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/serialize.js"(exports, module) {
|
|
462
|
+
"use strict";
|
|
463
|
+
var { cppdb } = require_util();
|
|
464
|
+
module.exports = function serialize2(options) {
|
|
465
|
+
if (options == null) options = {};
|
|
466
|
+
if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
|
|
467
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
468
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
469
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
470
|
+
return this[cppdb].serialize(attachedName);
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/function.js
|
|
476
|
+
var require_function = __commonJS({
|
|
477
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/function.js"(exports, module) {
|
|
478
|
+
"use strict";
|
|
479
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
480
|
+
module.exports = function defineFunction(name26, options, fn) {
|
|
481
|
+
if (options == null) options = {};
|
|
482
|
+
if (typeof options === "function") {
|
|
483
|
+
fn = options;
|
|
484
|
+
options = {};
|
|
485
|
+
}
|
|
486
|
+
if (typeof name26 !== "string") throw new TypeError("Expected first argument to be a string");
|
|
487
|
+
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
488
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
489
|
+
if (!name26) throw new TypeError("User-defined function name cannot be an empty string");
|
|
490
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
491
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
492
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
493
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
494
|
+
let argCount = -1;
|
|
495
|
+
if (!varargs) {
|
|
496
|
+
argCount = fn.length;
|
|
497
|
+
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
498
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
499
|
+
}
|
|
500
|
+
this[cppdb].function(fn, name26, argCount, safeIntegers, deterministic, directOnly);
|
|
501
|
+
return this;
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
507
|
+
var require_aggregate = __commonJS({
|
|
508
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/aggregate.js"(exports, module) {
|
|
509
|
+
"use strict";
|
|
510
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
511
|
+
module.exports = function defineAggregate(name26, options) {
|
|
512
|
+
if (typeof name26 !== "string") throw new TypeError("Expected first argument to be a string");
|
|
513
|
+
if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
|
|
514
|
+
if (!name26) throw new TypeError("User-defined function name cannot be an empty string");
|
|
515
|
+
const start = "start" in options ? options.start : null;
|
|
516
|
+
const step = getFunctionOption(options, "step", true);
|
|
517
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
518
|
+
const result = getFunctionOption(options, "result", false);
|
|
519
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
520
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
521
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
522
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
523
|
+
let argCount = -1;
|
|
524
|
+
if (!varargs) {
|
|
525
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
526
|
+
if (argCount > 0) argCount -= 1;
|
|
527
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
528
|
+
}
|
|
529
|
+
this[cppdb].aggregate(start, step, inverse, result, name26, argCount, safeIntegers, deterministic, directOnly);
|
|
530
|
+
return this;
|
|
531
|
+
};
|
|
532
|
+
var getFunctionOption = (options, key, required2) => {
|
|
533
|
+
const value = key in options ? options[key] : null;
|
|
534
|
+
if (typeof value === "function") return value;
|
|
535
|
+
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
536
|
+
if (required2) throw new TypeError(`Missing required option "${key}"`);
|
|
537
|
+
return null;
|
|
538
|
+
};
|
|
539
|
+
var getLength = ({ length }) => {
|
|
540
|
+
if (Number.isInteger(length) && length >= 0) return length;
|
|
541
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/table.js
|
|
547
|
+
var require_table = __commonJS({
|
|
548
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/table.js"(exports, module) {
|
|
549
|
+
"use strict";
|
|
550
|
+
var { cppdb } = require_util();
|
|
551
|
+
module.exports = function defineTable(name26, factory11) {
|
|
552
|
+
if (typeof name26 !== "string") throw new TypeError("Expected first argument to be a string");
|
|
553
|
+
if (!name26) throw new TypeError("Virtual table module name cannot be an empty string");
|
|
554
|
+
let eponymous = false;
|
|
555
|
+
if (typeof factory11 === "object" && factory11 !== null) {
|
|
556
|
+
eponymous = true;
|
|
557
|
+
factory11 = defer(parseTableDefinition(factory11, "used", name26));
|
|
558
|
+
} else {
|
|
559
|
+
if (typeof factory11 !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
560
|
+
factory11 = wrapFactory(factory11);
|
|
561
|
+
}
|
|
562
|
+
this[cppdb].table(factory11, name26, eponymous);
|
|
563
|
+
return this;
|
|
564
|
+
};
|
|
565
|
+
function wrapFactory(factory11) {
|
|
566
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
567
|
+
const thisObject = {
|
|
568
|
+
module: moduleName,
|
|
569
|
+
database: databaseName,
|
|
570
|
+
table: tableName
|
|
571
|
+
};
|
|
572
|
+
const def = apply.call(factory11, thisObject, args);
|
|
573
|
+
if (typeof def !== "object" || def === null) {
|
|
574
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
575
|
+
}
|
|
576
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
580
|
+
if (!hasOwnProperty.call(def, "rows")) {
|
|
581
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
582
|
+
}
|
|
583
|
+
if (!hasOwnProperty.call(def, "columns")) {
|
|
584
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
585
|
+
}
|
|
586
|
+
const rows = def.rows;
|
|
587
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
588
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
589
|
+
}
|
|
590
|
+
let columns = def.columns;
|
|
591
|
+
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
592
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
593
|
+
}
|
|
594
|
+
if (columns.length !== new Set(columns).size) {
|
|
595
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
596
|
+
}
|
|
597
|
+
if (!columns.length) {
|
|
598
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
599
|
+
}
|
|
600
|
+
let parameters;
|
|
601
|
+
if (hasOwnProperty.call(def, "parameters")) {
|
|
602
|
+
parameters = def.parameters;
|
|
603
|
+
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
604
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
parameters = inferParameters(rows);
|
|
608
|
+
}
|
|
609
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
610
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
611
|
+
}
|
|
612
|
+
if (parameters.length > 32) {
|
|
613
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
614
|
+
}
|
|
615
|
+
for (const parameter of parameters) {
|
|
616
|
+
if (columns.includes(parameter)) {
|
|
617
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
let safeIntegers = 2;
|
|
621
|
+
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
622
|
+
const bool = def.safeIntegers;
|
|
623
|
+
if (typeof bool !== "boolean") {
|
|
624
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
625
|
+
}
|
|
626
|
+
safeIntegers = +bool;
|
|
627
|
+
}
|
|
628
|
+
let directOnly = false;
|
|
629
|
+
if (hasOwnProperty.call(def, "directOnly")) {
|
|
630
|
+
directOnly = def.directOnly;
|
|
631
|
+
if (typeof directOnly !== "boolean") {
|
|
632
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const columnDefinitions = [
|
|
636
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
637
|
+
...columns.map(identifier)
|
|
638
|
+
];
|
|
639
|
+
return [
|
|
640
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
641
|
+
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
642
|
+
parameters,
|
|
643
|
+
safeIntegers,
|
|
644
|
+
directOnly
|
|
645
|
+
];
|
|
646
|
+
}
|
|
647
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
648
|
+
return function* virtualTable(...args) {
|
|
649
|
+
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
650
|
+
for (let i = 0; i < columnMap.size; ++i) {
|
|
651
|
+
output.push(null);
|
|
652
|
+
}
|
|
653
|
+
for (const row of generator(...args)) {
|
|
654
|
+
if (Array.isArray(row)) {
|
|
655
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
656
|
+
yield output;
|
|
657
|
+
} else if (typeof row === "object" && row !== null) {
|
|
658
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
659
|
+
yield output;
|
|
660
|
+
} else {
|
|
661
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
667
|
+
if (row.length !== columnCount) {
|
|
668
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
669
|
+
}
|
|
670
|
+
const offset = output.length - columnCount;
|
|
671
|
+
for (let i = 0; i < columnCount; ++i) {
|
|
672
|
+
output[i + offset] = row[i];
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
676
|
+
let count = 0;
|
|
677
|
+
for (const key of Object.keys(row)) {
|
|
678
|
+
const index2 = columnMap.get(key);
|
|
679
|
+
if (index2 === void 0) {
|
|
680
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
681
|
+
}
|
|
682
|
+
output[index2] = row[key];
|
|
683
|
+
count += 1;
|
|
684
|
+
}
|
|
685
|
+
if (count !== columnMap.size) {
|
|
686
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function inferParameters({ length }) {
|
|
690
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
691
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
692
|
+
}
|
|
693
|
+
const params = [];
|
|
694
|
+
for (let i = 0; i < length; ++i) {
|
|
695
|
+
params.push(`$${i + 1}`);
|
|
696
|
+
}
|
|
697
|
+
return params;
|
|
698
|
+
}
|
|
699
|
+
var { hasOwnProperty } = Object.prototype;
|
|
700
|
+
var { apply } = Function.prototype;
|
|
701
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
702
|
+
});
|
|
703
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
704
|
+
var defer = (x) => () => x;
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/inspect.js
|
|
709
|
+
var require_inspect = __commonJS({
|
|
710
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
|
|
711
|
+
"use strict";
|
|
712
|
+
var DatabaseInspection = function Database3() {
|
|
713
|
+
};
|
|
714
|
+
module.exports = function inspect(depth, opts) {
|
|
715
|
+
return Object.assign(new DatabaseInspection(), this);
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/database.js
|
|
721
|
+
var require_database = __commonJS({
|
|
722
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/database.js"(exports, module) {
|
|
723
|
+
"use strict";
|
|
724
|
+
var fs = __require("fs");
|
|
725
|
+
var path = __require("path");
|
|
726
|
+
var util2 = require_util();
|
|
727
|
+
var SqliteError = require_sqlite_error();
|
|
728
|
+
var DEFAULT_ADDON;
|
|
729
|
+
function Database3(filenameGiven, options) {
|
|
730
|
+
if (new.target == null) {
|
|
731
|
+
return new Database3(filenameGiven, options);
|
|
732
|
+
}
|
|
733
|
+
let buffer;
|
|
734
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
735
|
+
buffer = filenameGiven;
|
|
736
|
+
filenameGiven = ":memory:";
|
|
737
|
+
}
|
|
738
|
+
if (filenameGiven == null) filenameGiven = "";
|
|
739
|
+
if (options == null) options = {};
|
|
740
|
+
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
741
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
742
|
+
if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
743
|
+
if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
744
|
+
const filename = filenameGiven.trim();
|
|
745
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
746
|
+
const readonly2 = util2.getBooleanOption(options, "readonly");
|
|
747
|
+
const fileMustExist = util2.getBooleanOption(options, "fileMustExist");
|
|
748
|
+
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
749
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
750
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
751
|
+
if (readonly2 && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
752
|
+
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
753
|
+
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
754
|
+
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
755
|
+
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
756
|
+
let addon;
|
|
757
|
+
if (nativeBinding == null) {
|
|
758
|
+
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
759
|
+
} else if (typeof nativeBinding === "string") {
|
|
760
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
761
|
+
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
762
|
+
} else {
|
|
763
|
+
addon = nativeBinding;
|
|
764
|
+
}
|
|
765
|
+
if (!addon.isInitialized) {
|
|
766
|
+
addon.setErrorConstructor(SqliteError);
|
|
767
|
+
addon.isInitialized = true;
|
|
768
|
+
}
|
|
769
|
+
if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
|
|
770
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
771
|
+
}
|
|
772
|
+
Object.defineProperties(this, {
|
|
773
|
+
[util2.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly2, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
774
|
+
...wrappers.getters
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
var wrappers = require_wrappers();
|
|
778
|
+
Database3.prototype.prepare = wrappers.prepare;
|
|
779
|
+
Database3.prototype.transaction = require_transaction();
|
|
780
|
+
Database3.prototype.pragma = require_pragma();
|
|
781
|
+
Database3.prototype.backup = require_backup();
|
|
782
|
+
Database3.prototype.serialize = require_serialize();
|
|
783
|
+
Database3.prototype.function = require_function();
|
|
784
|
+
Database3.prototype.aggregate = require_aggregate();
|
|
785
|
+
Database3.prototype.table = require_table();
|
|
786
|
+
Database3.prototype.loadExtension = wrappers.loadExtension;
|
|
787
|
+
Database3.prototype.exec = wrappers.exec;
|
|
788
|
+
Database3.prototype.close = wrappers.close;
|
|
789
|
+
Database3.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
790
|
+
Database3.prototype.unsafeMode = wrappers.unsafeMode;
|
|
791
|
+
Database3.prototype[util2.inspect] = require_inspect();
|
|
792
|
+
module.exports = Database3;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// ../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/index.js
|
|
797
|
+
var require_lib = __commonJS({
|
|
798
|
+
"../../node_modules/.pnpm/better-sqlite3@12.9.0/node_modules/better-sqlite3/lib/index.js"(exports, module) {
|
|
799
|
+
"use strict";
|
|
800
|
+
module.exports = require_database();
|
|
801
|
+
module.exports.SqliteError = require_sqlite_error();
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
30
805
|
// ../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
|
|
31
806
|
var require_get_context = __commonJS({
|
|
32
807
|
"../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
|
|
@@ -1842,7 +2617,7 @@ function sql(strings, ...params) {
|
|
|
1842
2617
|
return new SQL([new StringChunk(str)]);
|
|
1843
2618
|
}
|
|
1844
2619
|
sql2.raw = raw2;
|
|
1845
|
-
function
|
|
2620
|
+
function join5(chunks, separator) {
|
|
1846
2621
|
const result = [];
|
|
1847
2622
|
for (const [i, chunk] of chunks.entries()) {
|
|
1848
2623
|
if (i > 0 && separator !== void 0) {
|
|
@@ -1852,7 +2627,7 @@ function sql(strings, ...params) {
|
|
|
1852
2627
|
}
|
|
1853
2628
|
return new SQL(result);
|
|
1854
2629
|
}
|
|
1855
|
-
sql2.join =
|
|
2630
|
+
sql2.join = join5;
|
|
1856
2631
|
function identifier(value) {
|
|
1857
2632
|
return new Name(value);
|
|
1858
2633
|
}
|
|
@@ -16761,7 +17536,7 @@ function checkForUpdateBackground() {
|
|
|
16761
17536
|
const available = isNewerVersion(latest, current);
|
|
16762
17537
|
cachedStatus = { available, currentVersion: current, latestVersion: latest, method };
|
|
16763
17538
|
if (available) {
|
|
16764
|
-
const hint = method === "global" ? "click the version in the sidebar to update from the app" : method === "npx" ? "re-run: npx tracer-sh@latest" : "git pull
|
|
17539
|
+
const hint = method === "global" ? "click the version in the sidebar to update from the app" : method === "npx" ? "re-run: npx tracer-sh@latest" : "git pull, then restart tracer-sh \u2014 the launcher rebuilds automatically";
|
|
16765
17540
|
console.log(`Update available: v${current} \u2192 v${latest} (${hint})`);
|
|
16766
17541
|
}
|
|
16767
17542
|
}).catch(() => {
|
|
@@ -16804,12 +17579,12 @@ function requestRestart() {
|
|
|
16804
17579
|
|
|
16805
17580
|
// src/db/client.ts
|
|
16806
17581
|
import { homedir } from "os";
|
|
16807
|
-
import { join as
|
|
17582
|
+
import { join as join3 } from "path";
|
|
16808
17583
|
import { chmodSync, mkdirSync } from "fs";
|
|
16809
|
-
import
|
|
17584
|
+
import Database2 from "better-sqlite3-multiple-ciphers";
|
|
16810
17585
|
|
|
16811
17586
|
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_better-sqlite3@12.9.0/node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
16812
|
-
|
|
17587
|
+
var import_better_sqlite3 = __toESM(require_lib(), 1);
|
|
16813
17588
|
|
|
16814
17589
|
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_better-sqlite3@12.9.0/node_modules/drizzle-orm/selection-proxy.js
|
|
16815
17590
|
var SelectionProxyHandler = class _SelectionProxyHandler {
|
|
@@ -18495,7 +19270,7 @@ var SQLiteSelectQueryBuilderBase = class extends TypedQueryBuilder {
|
|
|
18495
19270
|
const baseTableName = this.tableName;
|
|
18496
19271
|
const tableName = getTableLikeName(table);
|
|
18497
19272
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
18498
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
19273
|
+
if (typeof tableName === "string" && this.config.joins?.some((join5) => join5.alias === tableName)) {
|
|
18499
19274
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
18500
19275
|
}
|
|
18501
19276
|
if (!this.isPartialSelect) {
|
|
@@ -19354,7 +20129,7 @@ var SQLiteUpdateBase = class extends QueryPromise {
|
|
|
19354
20129
|
createJoin(joinType) {
|
|
19355
20130
|
return (table, on) => {
|
|
19356
20131
|
const tableName = getTableLikeName(table);
|
|
19357
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
20132
|
+
if (typeof tableName === "string" && this.config.joins.some((join5) => join5.alias === tableName)) {
|
|
19358
20133
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
19359
20134
|
}
|
|
19360
20135
|
if (typeof on === "function") {
|
|
@@ -20349,7 +21124,7 @@ function construct(client, config2 = {}) {
|
|
|
20349
21124
|
}
|
|
20350
21125
|
function drizzle(...params) {
|
|
20351
21126
|
if (params[0] === void 0 || typeof params[0] === "string") {
|
|
20352
|
-
const instance = params[0] === void 0 ? new
|
|
21127
|
+
const instance = params[0] === void 0 ? new import_better_sqlite3.default() : new import_better_sqlite3.default(params[0]);
|
|
20353
21128
|
return construct(instance, params[1]);
|
|
20354
21129
|
}
|
|
20355
21130
|
if (isConfig(params[0])) {
|
|
@@ -20357,10 +21132,10 @@ function drizzle(...params) {
|
|
|
20357
21132
|
if (client) return construct(client, drizzleConfig);
|
|
20358
21133
|
if (typeof connection === "object") {
|
|
20359
21134
|
const { source, ...options } = connection;
|
|
20360
|
-
const instance2 = new
|
|
21135
|
+
const instance2 = new import_better_sqlite3.default(source, options);
|
|
20361
21136
|
return construct(instance2, drizzleConfig);
|
|
20362
21137
|
}
|
|
20363
|
-
const instance = new
|
|
21138
|
+
const instance = new import_better_sqlite3.default(connection);
|
|
20364
21139
|
return construct(instance, drizzleConfig);
|
|
20365
21140
|
}
|
|
20366
21141
|
return construct(params[0], params[1]);
|
|
@@ -20522,13 +21297,145 @@ var agentRuns = sqliteTable("agent_runs", {
|
|
|
20522
21297
|
index("idx_agent_runs_type").on(t2.agentType)
|
|
20523
21298
|
]);
|
|
20524
21299
|
|
|
21300
|
+
// src/db/db-key.ts
|
|
21301
|
+
import { createRequire } from "module";
|
|
21302
|
+
import { join as join2 } from "path";
|
|
21303
|
+
import { randomBytes } from "crypto";
|
|
21304
|
+
import { existsSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
21305
|
+
var requireCjs = createRequire(import.meta.url);
|
|
21306
|
+
var SERVICE = "tracer-sh";
|
|
21307
|
+
var ACCOUNT = "db-key";
|
|
21308
|
+
function isValidKeyHex(value) {
|
|
21309
|
+
return /^[0-9a-f]{64}$/i.test(value);
|
|
21310
|
+
}
|
|
21311
|
+
function generateKeyHex() {
|
|
21312
|
+
return randomBytes(32).toString("hex");
|
|
21313
|
+
}
|
|
21314
|
+
function resolveDbKey(tracerHome) {
|
|
21315
|
+
const envKey = process.env.TRACER_DB_KEY?.trim();
|
|
21316
|
+
if (envKey) {
|
|
21317
|
+
if (!isValidKeyHex(envKey)) {
|
|
21318
|
+
throw new Error("TRACER_DB_KEY must be 64 hex characters (a 32-byte key).");
|
|
21319
|
+
}
|
|
21320
|
+
return envKey.toLowerCase();
|
|
21321
|
+
}
|
|
21322
|
+
return tryKeychain() ?? resolveKeyFile(tracerHome);
|
|
21323
|
+
}
|
|
21324
|
+
function tryKeychain() {
|
|
21325
|
+
try {
|
|
21326
|
+
const { Entry } = requireCjs("@napi-rs/keyring");
|
|
21327
|
+
const entry = new Entry(SERVICE, ACCOUNT);
|
|
21328
|
+
let existing = null;
|
|
21329
|
+
try {
|
|
21330
|
+
existing = entry.getPassword();
|
|
21331
|
+
} catch {
|
|
21332
|
+
existing = null;
|
|
21333
|
+
}
|
|
21334
|
+
if (existing && isValidKeyHex(existing)) return existing.toLowerCase();
|
|
21335
|
+
const fresh = generateKeyHex();
|
|
21336
|
+
entry.setPassword(fresh);
|
|
21337
|
+
return fresh;
|
|
21338
|
+
} catch {
|
|
21339
|
+
return null;
|
|
21340
|
+
}
|
|
21341
|
+
}
|
|
21342
|
+
function resolveKeyFile(tracerHome) {
|
|
21343
|
+
const keyPath = join2(tracerHome, "db-key");
|
|
21344
|
+
if (existsSync(keyPath)) {
|
|
21345
|
+
const fromFile = readFileSync2(keyPath, "utf8").trim();
|
|
21346
|
+
if (isValidKeyHex(fromFile)) {
|
|
21347
|
+
warnKeyFile(keyPath);
|
|
21348
|
+
return fromFile.toLowerCase();
|
|
21349
|
+
}
|
|
21350
|
+
}
|
|
21351
|
+
const fresh = generateKeyHex();
|
|
21352
|
+
writeFileSync(keyPath, fresh, { mode: 384 });
|
|
21353
|
+
warnKeyFile(keyPath);
|
|
21354
|
+
return fresh;
|
|
21355
|
+
}
|
|
21356
|
+
function warnKeyFile(keyPath) {
|
|
21357
|
+
console.warn(
|
|
21358
|
+
`[tracer] OS keychain unavailable \u2014 storing the database encryption key in a file at ${keyPath}. It is created owner-only (0600) on macOS/Linux; on Windows it relies on the data directory's ACLs. Anyone who can read this file can read the database \u2014 set TRACER_DB_KEY to supply the key yourself instead.`
|
|
21359
|
+
);
|
|
21360
|
+
}
|
|
21361
|
+
|
|
21362
|
+
// src/db/db-encryption.ts
|
|
21363
|
+
import { renameSync, rmSync, existsSync as existsSync2, copyFileSync, openSync, readSync, closeSync } from "fs";
|
|
21364
|
+
import Database from "better-sqlite3-multiple-ciphers";
|
|
21365
|
+
var SQLITE_MAGIC = "SQLite format 3\0";
|
|
21366
|
+
function applyKey(conn, keyHex2) {
|
|
21367
|
+
conn.pragma("cipher='sqlcipher'");
|
|
21368
|
+
conn.pragma(`key="x'${keyHex2}'"`);
|
|
21369
|
+
}
|
|
21370
|
+
function isPlaintext(dbPath2) {
|
|
21371
|
+
if (!existsSync2(dbPath2)) return false;
|
|
21372
|
+
let fd;
|
|
21373
|
+
try {
|
|
21374
|
+
fd = openSync(dbPath2, "r");
|
|
21375
|
+
const header = Buffer.alloc(16);
|
|
21376
|
+
const bytes = readSync(fd, header, 0, 16, 0);
|
|
21377
|
+
return bytes === 16 && header.toString("latin1") === SQLITE_MAGIC;
|
|
21378
|
+
} finally {
|
|
21379
|
+
if (fd !== void 0) closeSync(fd);
|
|
21380
|
+
}
|
|
21381
|
+
}
|
|
21382
|
+
function migratePlaintextToEncrypted(dbPath2, keyHex2) {
|
|
21383
|
+
const tmpPath = `${dbPath2}.enc.tmp`;
|
|
21384
|
+
cleanupTmp(tmpPath);
|
|
21385
|
+
const plain = new Database(dbPath2);
|
|
21386
|
+
try {
|
|
21387
|
+
plain.pragma("wal_checkpoint(TRUNCATE)");
|
|
21388
|
+
} finally {
|
|
21389
|
+
plain.close();
|
|
21390
|
+
}
|
|
21391
|
+
try {
|
|
21392
|
+
copyFileSync(dbPath2, tmpPath);
|
|
21393
|
+
const enc = new Database(tmpPath);
|
|
21394
|
+
enc.pragma("cipher='sqlcipher'");
|
|
21395
|
+
enc.pragma(`rekey="x'${keyHex2}'"`);
|
|
21396
|
+
enc.pragma("wal_checkpoint(TRUNCATE)");
|
|
21397
|
+
enc.close();
|
|
21398
|
+
} catch (err) {
|
|
21399
|
+
cleanupTmp(tmpPath);
|
|
21400
|
+
throw new Error(`Database encryption migration failed: ${err.message}`);
|
|
21401
|
+
}
|
|
21402
|
+
try {
|
|
21403
|
+
if (isPlaintext(tmpPath)) throw new Error("encrypted copy is still readable as plaintext");
|
|
21404
|
+
const verify = new Database(tmpPath);
|
|
21405
|
+
applyKey(verify, keyHex2);
|
|
21406
|
+
const result = verify.pragma("integrity_check", { simple: true });
|
|
21407
|
+
verify.close();
|
|
21408
|
+
if (result !== "ok") throw new Error(`integrity check returned "${String(result)}"`);
|
|
21409
|
+
} catch (err) {
|
|
21410
|
+
cleanupTmp(tmpPath);
|
|
21411
|
+
throw new Error(`Database encryption verification failed: ${err.message}`);
|
|
21412
|
+
}
|
|
21413
|
+
rmSync(`${dbPath2}-wal`, { force: true });
|
|
21414
|
+
rmSync(`${dbPath2}-shm`, { force: true });
|
|
21415
|
+
rmSync(`${dbPath2}-journal`, { force: true });
|
|
21416
|
+
renameSync(tmpPath, dbPath2);
|
|
21417
|
+
rmSync(`${tmpPath}-wal`, { force: true });
|
|
21418
|
+
rmSync(`${tmpPath}-shm`, { force: true });
|
|
21419
|
+
}
|
|
21420
|
+
function cleanupTmp(tmpPath) {
|
|
21421
|
+
rmSync(tmpPath, { force: true });
|
|
21422
|
+
rmSync(`${tmpPath}-wal`, { force: true });
|
|
21423
|
+
rmSync(`${tmpPath}-shm`, { force: true });
|
|
21424
|
+
}
|
|
21425
|
+
|
|
20525
21426
|
// src/db/client.ts
|
|
20526
|
-
var TRACER_HOME = process.env.TRACER_HOME ||
|
|
20527
|
-
var dataDir =
|
|
21427
|
+
var TRACER_HOME = process.env.TRACER_HOME || join3(homedir(), ".tracer");
|
|
21428
|
+
var dataDir = join3(TRACER_HOME, "data");
|
|
20528
21429
|
mkdirSync(dataDir, { recursive: true });
|
|
20529
21430
|
chmodSync(TRACER_HOME, 448);
|
|
20530
21431
|
chmodSync(dataDir, 448);
|
|
20531
|
-
var
|
|
21432
|
+
var dbPath = join3(dataDir, "tracer.db");
|
|
21433
|
+
var keyHex = resolveDbKey(TRACER_HOME);
|
|
21434
|
+
if (isPlaintext(dbPath)) {
|
|
21435
|
+
migratePlaintextToEncrypted(dbPath, keyHex);
|
|
21436
|
+
}
|
|
21437
|
+
var sqlite = new Database2(dbPath);
|
|
21438
|
+
applyKey(sqlite, keyHex);
|
|
20532
21439
|
sqlite.pragma("journal_mode = WAL");
|
|
20533
21440
|
sqlite.pragma("synchronous = NORMAL");
|
|
20534
21441
|
sqlite.pragma("busy_timeout = 5000");
|
|
@@ -46952,8 +47859,8 @@ var NewRelicProvider = class extends BaseProvider {
|
|
|
46952
47859
|
};
|
|
46953
47860
|
|
|
46954
47861
|
// src/mcp/mcp-provider.ts
|
|
46955
|
-
import { createRequire } from "module";
|
|
46956
|
-
import { readFileSync as
|
|
47862
|
+
import { createRequire as createRequire2 } from "module";
|
|
47863
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
46957
47864
|
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
46958
47865
|
|
|
46959
47866
|
// ../../node_modules/.pnpm/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.node.js
|
|
@@ -46969,8 +47876,8 @@ async function random(size) {
|
|
|
46969
47876
|
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
46970
47877
|
let result = "";
|
|
46971
47878
|
while (result.length < size) {
|
|
46972
|
-
const
|
|
46973
|
-
for (const randomByte of
|
|
47879
|
+
const randomBytes2 = await getRandomValues(size - result.length);
|
|
47880
|
+
for (const randomByte of randomBytes2) {
|
|
46974
47881
|
if (randomByte < evenDistCutoff) {
|
|
46975
47882
|
result += mask[randomByte % mask.length];
|
|
46976
47883
|
}
|
|
@@ -49702,11 +50609,11 @@ var McpProvider = class extends BaseProvider {
|
|
|
49702
50609
|
this.clients = [];
|
|
49703
50610
|
}
|
|
49704
50611
|
};
|
|
49705
|
-
var require2 =
|
|
50612
|
+
var require2 = createRequire2(import.meta.url);
|
|
49706
50613
|
function resolveLocalBin(pkg) {
|
|
49707
50614
|
try {
|
|
49708
50615
|
const pkgJsonPath = require2.resolve(`${pkg}/package.json`);
|
|
49709
|
-
const pkgJson = JSON.parse(
|
|
50616
|
+
const pkgJson = JSON.parse(readFileSync3(pkgJsonPath, "utf-8"));
|
|
49710
50617
|
const bin = pkgJson.bin;
|
|
49711
50618
|
if (!bin) return null;
|
|
49712
50619
|
const entry = typeof bin === "string" ? bin : Object.values(bin)[0];
|
|
@@ -49977,8 +50884,8 @@ function isTransportError(err) {
|
|
|
49977
50884
|
}
|
|
49978
50885
|
|
|
49979
50886
|
// src/providers/gcp/gcp-auth.ts
|
|
49980
|
-
import { readFileSync as
|
|
49981
|
-
import { join as
|
|
50887
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
50888
|
+
import { join as join4 } from "path";
|
|
49982
50889
|
var REAUTH_CMD = "Run: gcloud auth application-default login";
|
|
49983
50890
|
var TOKEN_TTL_MS = 55 * 60 * 1e3;
|
|
49984
50891
|
var tokenCache = null;
|
|
@@ -49989,10 +50896,10 @@ async function getGcpAuth() {
|
|
|
49989
50896
|
if (tokenCache && Date.now() < tokenCache.expiresAt) {
|
|
49990
50897
|
return { ok: true, token: tokenCache.token };
|
|
49991
50898
|
}
|
|
49992
|
-
const credPath = process.env.GOOGLE_APPLICATION_CREDENTIALS ||
|
|
50899
|
+
const credPath = process.env.GOOGLE_APPLICATION_CREDENTIALS || join4(process.env.HOME ?? "", ".config", "gcloud", "application_default_credentials.json");
|
|
49993
50900
|
let creds;
|
|
49994
50901
|
try {
|
|
49995
|
-
creds = JSON.parse(
|
|
50902
|
+
creds = JSON.parse(readFileSync4(credPath, "utf-8"));
|
|
49996
50903
|
} catch {
|
|
49997
50904
|
return { ok: false, code: "no_credentials", message: `No GCP credentials found. ${REAUTH_CMD}` };
|
|
49998
50905
|
}
|
|
@@ -57355,9 +58262,144 @@ var updateRouter = router({
|
|
|
57355
58262
|
})
|
|
57356
58263
|
});
|
|
57357
58264
|
|
|
58265
|
+
// src/integrations/jira/jira.client.ts
|
|
58266
|
+
function normalizeJiraDomain(raw2) {
|
|
58267
|
+
return raw2.trim().replace(/^https?:\/\//i, "").replace(/\/+$/, "").replace(/\.atlassian\.net$/i, "");
|
|
58268
|
+
}
|
|
58269
|
+
function toPlainText(value) {
|
|
58270
|
+
if (value == null) return null;
|
|
58271
|
+
if (typeof value === "string") return value;
|
|
58272
|
+
const parts = [];
|
|
58273
|
+
const walk = (node) => {
|
|
58274
|
+
if (!node || typeof node !== "object") return;
|
|
58275
|
+
const n = node;
|
|
58276
|
+
if (typeof n.text === "string") parts.push(n.text);
|
|
58277
|
+
if (Array.isArray(n.content)) n.content.forEach(walk);
|
|
58278
|
+
};
|
|
58279
|
+
walk(value);
|
|
58280
|
+
return parts.join("") || null;
|
|
58281
|
+
}
|
|
58282
|
+
var JiraClient = class {
|
|
58283
|
+
baseUrl;
|
|
58284
|
+
authHeader;
|
|
58285
|
+
constructor({ domain: domain2, email: email3, apiToken }) {
|
|
58286
|
+
this.baseUrl = `https://${normalizeJiraDomain(domain2)}.atlassian.net`;
|
|
58287
|
+
this.authHeader = "Basic " + Buffer.from(`${email3}:${apiToken}`).toString("base64");
|
|
58288
|
+
}
|
|
58289
|
+
async request(path, init) {
|
|
58290
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
58291
|
+
...init,
|
|
58292
|
+
headers: {
|
|
58293
|
+
Authorization: this.authHeader,
|
|
58294
|
+
Accept: "application/json",
|
|
58295
|
+
...init?.body ? { "Content-Type": "application/json" } : {},
|
|
58296
|
+
...init?.headers
|
|
58297
|
+
},
|
|
58298
|
+
signal: AbortSignal.timeout(15e3)
|
|
58299
|
+
});
|
|
58300
|
+
if (!res.ok) {
|
|
58301
|
+
const text3 = await res.text().catch(() => "");
|
|
58302
|
+
throw new Error(`Jira ${res.status}: ${text3.slice(0, 300) || res.statusText}`);
|
|
58303
|
+
}
|
|
58304
|
+
return res;
|
|
58305
|
+
}
|
|
58306
|
+
/** Validate credentials by fetching the current user. */
|
|
58307
|
+
async validate() {
|
|
58308
|
+
try {
|
|
58309
|
+
await this.request("/rest/api/2/myself");
|
|
58310
|
+
return { ok: true };
|
|
58311
|
+
} catch (err) {
|
|
58312
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
58313
|
+
}
|
|
58314
|
+
}
|
|
58315
|
+
async getIssue(key) {
|
|
58316
|
+
const res = await this.request(
|
|
58317
|
+
`/rest/api/2/issue/${encodeURIComponent(key)}?fields=summary,description,status`
|
|
58318
|
+
);
|
|
58319
|
+
const data = await res.json();
|
|
58320
|
+
const fields = data.fields ?? {};
|
|
58321
|
+
return {
|
|
58322
|
+
key: data.key ?? key,
|
|
58323
|
+
summary: fields.summary ?? "",
|
|
58324
|
+
description: toPlainText(fields.description),
|
|
58325
|
+
status: fields.status?.name ?? "Unknown"
|
|
58326
|
+
};
|
|
58327
|
+
}
|
|
58328
|
+
async addComment(key, body) {
|
|
58329
|
+
const res = await this.request(`/rest/api/2/issue/${encodeURIComponent(key)}/comment`, {
|
|
58330
|
+
method: "POST",
|
|
58331
|
+
body: JSON.stringify({ body })
|
|
58332
|
+
});
|
|
58333
|
+
const data = await res.json().catch(() => ({}));
|
|
58334
|
+
const id = data.id ?? null;
|
|
58335
|
+
return {
|
|
58336
|
+
id,
|
|
58337
|
+
url: id ? `${this.baseUrl}/browse/${key}?focusedCommentId=${id}` : `${this.baseUrl}/browse/${key}`
|
|
58338
|
+
};
|
|
58339
|
+
}
|
|
58340
|
+
};
|
|
58341
|
+
|
|
58342
|
+
// src/integrations/jira/config.ts
|
|
58343
|
+
var JIRA_CONFIG_KEY = "integration:jira";
|
|
58344
|
+
function readJiraConfig(db2) {
|
|
58345
|
+
return readAppSetting(db2, JIRA_CONFIG_KEY);
|
|
58346
|
+
}
|
|
58347
|
+
function writeJiraConfig(db2, config2) {
|
|
58348
|
+
writeAppSetting(db2, JIRA_CONFIG_KEY, config2);
|
|
58349
|
+
}
|
|
58350
|
+
function deleteJiraConfig(db2) {
|
|
58351
|
+
db2.delete(appSettings).where(eq(appSettings.key, JIRA_CONFIG_KEY)).run();
|
|
58352
|
+
}
|
|
58353
|
+
|
|
58354
|
+
// src/trpc/routers/integrations.router.ts
|
|
58355
|
+
function maskToken(token) {
|
|
58356
|
+
return token.length <= 4 ? "\u2022\u2022\u2022\u2022" : "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" + token.slice(-4);
|
|
58357
|
+
}
|
|
58358
|
+
var integrationsRouter = router({
|
|
58359
|
+
getJira: publicProcedure.query(({ ctx }) => {
|
|
58360
|
+
const config2 = readJiraConfig(ctx.db);
|
|
58361
|
+
if (!config2) return { configured: false, config: null };
|
|
58362
|
+
return {
|
|
58363
|
+
configured: true,
|
|
58364
|
+
config: {
|
|
58365
|
+
domain: config2.domain,
|
|
58366
|
+
email: config2.email,
|
|
58367
|
+
apiToken: maskToken(config2.apiToken)
|
|
58368
|
+
}
|
|
58369
|
+
};
|
|
58370
|
+
}),
|
|
58371
|
+
saveJira: publicProcedure.input(
|
|
58372
|
+
external_exports.object({
|
|
58373
|
+
domain: external_exports.string().min(1),
|
|
58374
|
+
email: external_exports.string().min(1),
|
|
58375
|
+
apiToken: external_exports.string().min(1)
|
|
58376
|
+
})
|
|
58377
|
+
).mutation(async ({ ctx, input }) => {
|
|
58378
|
+
const domain2 = normalizeJiraDomain(input.domain);
|
|
58379
|
+
if (!/^[a-z0-9][a-z0-9-]*$/i.test(domain2)) {
|
|
58380
|
+
return {
|
|
58381
|
+
success: false,
|
|
58382
|
+
error: 'Enter just your Jira site name, e.g. "yourco" for yourco.atlassian.net'
|
|
58383
|
+
};
|
|
58384
|
+
}
|
|
58385
|
+
const config2 = { domain: domain2, email: input.email.trim(), apiToken: input.apiToken.trim() };
|
|
58386
|
+
const result = await new JiraClient(config2).validate();
|
|
58387
|
+
if (!result.ok) {
|
|
58388
|
+
return { success: false, error: result.error ?? "Connection failed" };
|
|
58389
|
+
}
|
|
58390
|
+
writeJiraConfig(ctx.db, config2);
|
|
58391
|
+
return { success: true };
|
|
58392
|
+
}),
|
|
58393
|
+
removeJira: publicProcedure.mutation(({ ctx }) => {
|
|
58394
|
+
deleteJiraConfig(ctx.db);
|
|
58395
|
+
return { success: true };
|
|
58396
|
+
})
|
|
58397
|
+
});
|
|
58398
|
+
|
|
57358
58399
|
// src/trpc/router.ts
|
|
57359
58400
|
var appRouter = router({
|
|
57360
58401
|
provider: providerRouter,
|
|
58402
|
+
integrations: integrationsRouter,
|
|
57361
58403
|
settings: settingsRouter,
|
|
57362
58404
|
memory: memoryRouter,
|
|
57363
58405
|
sessions: sessionsRouter,
|
|
@@ -58036,8 +59078,51 @@ async function runChatAgent({ sessionId, messages, summary, summaryUpTo, context
|
|
|
58036
59078
|
return { stream: stream2 };
|
|
58037
59079
|
}
|
|
58038
59080
|
|
|
59081
|
+
// src/integrations/jira/tools.ts
|
|
59082
|
+
var JIRA_PROMPT_FRAGMENT = `## Jira
|
|
59083
|
+
You can read Jira issues and post comments via the jira tools.
|
|
59084
|
+
- Use get_jira_issue when the user references a ticket key (LETTERS-NUMBER, e.g. PROJ-123) or asks what a ticket says.
|
|
59085
|
+
- Use add_jira_comment ONLY when the user explicitly asks to comment on, post to, or update a ticket. Never post proactively or as a side effect of analysis.
|
|
59086
|
+
- Before posting, show the exact comment text and target issue key. Comment bodies are plain text. Report the resulting comment URL on success.`;
|
|
59087
|
+
function getJiraChatTools(db2) {
|
|
59088
|
+
const config2 = readJiraConfig(db2);
|
|
59089
|
+
if (!config2) return null;
|
|
59090
|
+
const client = new JiraClient(config2);
|
|
59091
|
+
const tools = {
|
|
59092
|
+
get_jira_issue: tool({
|
|
59093
|
+
description: "Read a Jira issue's summary, description, and status by its issue key (e.g. PROJ-123).",
|
|
59094
|
+
inputSchema: external_exports.object({
|
|
59095
|
+
issueKey: external_exports.string().describe("Jira issue key, e.g. PROJ-123")
|
|
59096
|
+
}),
|
|
59097
|
+
execute: async ({ issueKey }) => {
|
|
59098
|
+
try {
|
|
59099
|
+
return { issue: await client.getIssue(issueKey) };
|
|
59100
|
+
} catch (err) {
|
|
59101
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
59102
|
+
}
|
|
59103
|
+
}
|
|
59104
|
+
}),
|
|
59105
|
+
add_jira_comment: tool({
|
|
59106
|
+
description: "Post a plain-text comment to a Jira issue. Only call when the user explicitly asks to comment on or update a ticket.",
|
|
59107
|
+
inputSchema: external_exports.object({
|
|
59108
|
+
issueKey: external_exports.string().describe("Jira issue key, e.g. PROJ-123"),
|
|
59109
|
+
body: external_exports.string().min(1).describe("Plain-text comment body")
|
|
59110
|
+
}),
|
|
59111
|
+
execute: async ({ issueKey, body }) => {
|
|
59112
|
+
try {
|
|
59113
|
+
const result = await client.addComment(issueKey, body);
|
|
59114
|
+
return { posted: true, commentId: result.id, url: result.url };
|
|
59115
|
+
} catch (err) {
|
|
59116
|
+
return { posted: false, error: err instanceof Error ? err.message : String(err) };
|
|
59117
|
+
}
|
|
59118
|
+
}
|
|
59119
|
+
})
|
|
59120
|
+
};
|
|
59121
|
+
return { tools, promptFragment: JIRA_PROMPT_FRAGMENT };
|
|
59122
|
+
}
|
|
59123
|
+
|
|
58039
59124
|
// src/tools/shared-tool-setup.ts
|
|
58040
|
-
function collectBaseTools(registry2, db2, writer, mode, activeProvider) {
|
|
59125
|
+
function collectBaseTools(registry2, db2, writer, mode, activeProvider, includeIntegrations = false) {
|
|
58041
59126
|
const memories = db2.select().from(toolMemories).all();
|
|
58042
59127
|
const tools = {};
|
|
58043
59128
|
const promptFragments = [];
|
|
@@ -58070,7 +59155,12 @@ function collectBaseTools(registry2, db2, writer, mode, activeProvider) {
|
|
|
58070
59155
|
}
|
|
58071
59156
|
}
|
|
58072
59157
|
}
|
|
58073
|
-
const
|
|
59158
|
+
const jiraKit = includeIntegrations ? getJiraChatTools(db2) : null;
|
|
59159
|
+
if (jiraKit) {
|
|
59160
|
+
Object.assign(tools, jiraKit.tools);
|
|
59161
|
+
promptFragments.push(jiraKit.promptFragment);
|
|
59162
|
+
}
|
|
59163
|
+
let systemPrompt = mode === "unified" ? promptFragments.length > 0 ? injectMemories(
|
|
58074
59164
|
buildUnifiedModePrompt(promptFragments, maxSteps ?? DEFAULTS.directModeMaxSteps),
|
|
58075
59165
|
// Unified holds every connected provider's tools, so surface all their memories
|
|
58076
59166
|
// (direct mode injects the active provider's memories via its own systemPrompt).
|
|
@@ -58079,6 +59169,9 @@ function collectBaseTools(registry2, db2, writer, mode, activeProvider) {
|
|
|
58079
59169
|
existingMemories: memories.filter((m) => connectedProviders.some((p) => p.type === m.toolName))
|
|
58080
59170
|
}
|
|
58081
59171
|
) : void 0 : systemPrompts.length > 0 ? systemPrompts.join("\n\n---\n\n") : void 0;
|
|
59172
|
+
if (mode !== "unified" && jiraKit && systemPrompt) {
|
|
59173
|
+
systemPrompt += "\n\n" + jiraKit.promptFragment;
|
|
59174
|
+
}
|
|
58082
59175
|
const afterComplete = afterCompleteCallbacks.length > 0 ? (params) => {
|
|
58083
59176
|
for (const cb of afterCompleteCallbacks) cb(params);
|
|
58084
59177
|
} : void 0;
|
|
@@ -58087,8 +59180,8 @@ function collectBaseTools(registry2, db2, writer, mode, activeProvider) {
|
|
|
58087
59180
|
|
|
58088
59181
|
// src/tools/chat-tools.ts
|
|
58089
59182
|
function collectChatTools(registry2, db2, writer, activeProvider, mode = DEFAULT_CHAT_MODE) {
|
|
58090
|
-
const { tools, promptFragments, systemPrompt, maxSteps, afterComplete, connectedProviders } = collectBaseTools(registry2, db2, writer, mode, activeProvider);
|
|
58091
|
-
if (connectedProviders.length === 0) {
|
|
59183
|
+
const { tools, promptFragments, systemPrompt, maxSteps, afterComplete, connectedProviders } = collectBaseTools(registry2, db2, writer, mode, activeProvider, true);
|
|
59184
|
+
if (connectedProviders.length === 0 && (!tools || Object.keys(tools).length === 0)) {
|
|
58092
59185
|
return { tools: void 0, promptFragments: [] };
|
|
58093
59186
|
}
|
|
58094
59187
|
return { tools, promptFragments, systemPrompt, maxSteps, afterComplete };
|
|
@@ -59054,7 +60147,7 @@ function registerApiRoutes(app, context2) {
|
|
|
59054
60147
|
}
|
|
59055
60148
|
|
|
59056
60149
|
// src/http/static.ts
|
|
59057
|
-
import { readFileSync as
|
|
60150
|
+
import { readFileSync as readFileSync5, existsSync as existsSync3, statSync } from "fs";
|
|
59058
60151
|
import { resolve as resolve3, dirname as dirname3, extname } from "path";
|
|
59059
60152
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
59060
60153
|
var MIME_TYPES = {
|
|
@@ -59076,9 +60169,9 @@ function mountStaticFiles(app) {
|
|
|
59076
60169
|
resolve3(process.cwd(), "packages/web/dist")
|
|
59077
60170
|
// dev production build from repo root
|
|
59078
60171
|
];
|
|
59079
|
-
const webRoot = webCandidates.find((d) =>
|
|
60172
|
+
const webRoot = webCandidates.find((d) => existsSync3(resolve3(d, "index.html")));
|
|
59080
60173
|
if (!webRoot) return;
|
|
59081
|
-
const indexHtml =
|
|
60174
|
+
const indexHtml = readFileSync5(resolve3(webRoot, "index.html"), "utf-8");
|
|
59082
60175
|
const fileCache = /* @__PURE__ */ new Map();
|
|
59083
60176
|
app.use("*", async (c, next) => {
|
|
59084
60177
|
const reqPath = c.req.path.slice(1);
|
|
@@ -59089,7 +60182,7 @@ function mountStaticFiles(app) {
|
|
|
59089
60182
|
let file2 = fileCache.get(reqPath);
|
|
59090
60183
|
if (!file2) {
|
|
59091
60184
|
const filePath = resolve3(webRoot, reqPath);
|
|
59092
|
-
if (!filePath.startsWith(webRoot) || !
|
|
60185
|
+
if (!filePath.startsWith(webRoot) || !existsSync3(filePath) || statSync(filePath).isDirectory()) {
|
|
59093
60186
|
await next();
|
|
59094
60187
|
return;
|
|
59095
60188
|
}
|
|
@@ -59098,7 +60191,7 @@ function mountStaticFiles(app) {
|
|
|
59098
60191
|
if (reqPath.startsWith("assets/")) {
|
|
59099
60192
|
headers["Cache-Control"] = "public, max-age=31536000, immutable";
|
|
59100
60193
|
}
|
|
59101
|
-
file2 = { body:
|
|
60194
|
+
file2 = { body: readFileSync5(filePath), headers };
|
|
59102
60195
|
fileCache.set(reqPath, file2);
|
|
59103
60196
|
}
|
|
59104
60197
|
return c.body(file2.body, { headers: file2.headers });
|