openclaw-telegram-manager 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/commands/autopilot.d.ts +3 -0
  2. package/dist/commands/autopilot.d.ts.map +1 -0
  3. package/dist/commands/autopilot.js +128 -0
  4. package/dist/commands/autopilot.js.map +1 -0
  5. package/dist/commands/doctor-all.d.ts.map +1 -1
  6. package/dist/commands/doctor-all.js +44 -6
  7. package/dist/commands/doctor-all.js.map +1 -1
  8. package/dist/commands/doctor.d.ts.map +1 -1
  9. package/dist/commands/doctor.js +1 -1
  10. package/dist/commands/doctor.js.map +1 -1
  11. package/dist/commands/init.d.ts +6 -1
  12. package/dist/commands/init.d.ts.map +1 -1
  13. package/dist/commands/init.js +69 -19
  14. package/dist/commands/init.js.map +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +41 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/lib/auth.d.ts.map +1 -1
  19. package/dist/lib/auth.js +1 -0
  20. package/dist/lib/auth.js.map +1 -1
  21. package/dist/lib/capsule.d.ts.map +1 -1
  22. package/dist/lib/capsule.js +3 -2
  23. package/dist/lib/capsule.js.map +1 -1
  24. package/dist/lib/doctor-checks.d.ts.map +1 -1
  25. package/dist/lib/doctor-checks.js +5 -11
  26. package/dist/lib/doctor-checks.js.map +1 -1
  27. package/dist/lib/include-generator.d.ts.map +1 -1
  28. package/dist/lib/include-generator.js +11 -2
  29. package/dist/lib/include-generator.js.map +1 -1
  30. package/dist/lib/registry.d.ts.map +1 -1
  31. package/dist/lib/registry.js +7 -0
  32. package/dist/lib/registry.js.map +1 -1
  33. package/dist/lib/security.d.ts +7 -3
  34. package/dist/lib/security.d.ts.map +1 -1
  35. package/dist/lib/security.js +13 -10
  36. package/dist/lib/security.js.map +1 -1
  37. package/dist/lib/telegram.d.ts +7 -2
  38. package/dist/lib/telegram.d.ts.map +1 -1
  39. package/dist/lib/telegram.js +44 -22
  40. package/dist/lib/telegram.js.map +1 -1
  41. package/dist/lib/types.d.ts +5 -3
  42. package/dist/lib/types.d.ts.map +1 -1
  43. package/dist/lib/types.js +4 -2
  44. package/dist/lib/types.js.map +1 -1
  45. package/dist/plugin.js +979 -624
  46. package/dist/tool.d.ts +2 -0
  47. package/dist/tool.d.ts.map +1 -1
  48. package/dist/tool.js +55 -11
  49. package/dist/tool.js.map +1 -1
  50. package/package.json +1 -1
  51. package/skills/tm/SKILL.md +12 -1
package/dist/plugin.js CHANGED
@@ -60,54 +60,54 @@ var require_polyfills = __commonJS({
60
60
  }
61
61
  var chdir;
62
62
  module.exports = patch;
63
- function patch(fs12) {
63
+ function patch(fs13) {
64
64
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
65
- patchLchmod(fs12);
66
- }
67
- if (!fs12.lutimes) {
68
- patchLutimes(fs12);
69
- }
70
- fs12.chown = chownFix(fs12.chown);
71
- fs12.fchown = chownFix(fs12.fchown);
72
- fs12.lchown = chownFix(fs12.lchown);
73
- fs12.chmod = chmodFix(fs12.chmod);
74
- fs12.fchmod = chmodFix(fs12.fchmod);
75
- fs12.lchmod = chmodFix(fs12.lchmod);
76
- fs12.chownSync = chownFixSync(fs12.chownSync);
77
- fs12.fchownSync = chownFixSync(fs12.fchownSync);
78
- fs12.lchownSync = chownFixSync(fs12.lchownSync);
79
- fs12.chmodSync = chmodFixSync(fs12.chmodSync);
80
- fs12.fchmodSync = chmodFixSync(fs12.fchmodSync);
81
- fs12.lchmodSync = chmodFixSync(fs12.lchmodSync);
82
- fs12.stat = statFix(fs12.stat);
83
- fs12.fstat = statFix(fs12.fstat);
84
- fs12.lstat = statFix(fs12.lstat);
85
- fs12.statSync = statFixSync(fs12.statSync);
86
- fs12.fstatSync = statFixSync(fs12.fstatSync);
87
- fs12.lstatSync = statFixSync(fs12.lstatSync);
88
- if (fs12.chmod && !fs12.lchmod) {
89
- fs12.lchmod = function(path13, mode, cb) {
65
+ patchLchmod(fs13);
66
+ }
67
+ if (!fs13.lutimes) {
68
+ patchLutimes(fs13);
69
+ }
70
+ fs13.chown = chownFix(fs13.chown);
71
+ fs13.fchown = chownFix(fs13.fchown);
72
+ fs13.lchown = chownFix(fs13.lchown);
73
+ fs13.chmod = chmodFix(fs13.chmod);
74
+ fs13.fchmod = chmodFix(fs13.fchmod);
75
+ fs13.lchmod = chmodFix(fs13.lchmod);
76
+ fs13.chownSync = chownFixSync(fs13.chownSync);
77
+ fs13.fchownSync = chownFixSync(fs13.fchownSync);
78
+ fs13.lchownSync = chownFixSync(fs13.lchownSync);
79
+ fs13.chmodSync = chmodFixSync(fs13.chmodSync);
80
+ fs13.fchmodSync = chmodFixSync(fs13.fchmodSync);
81
+ fs13.lchmodSync = chmodFixSync(fs13.lchmodSync);
82
+ fs13.stat = statFix(fs13.stat);
83
+ fs13.fstat = statFix(fs13.fstat);
84
+ fs13.lstat = statFix(fs13.lstat);
85
+ fs13.statSync = statFixSync(fs13.statSync);
86
+ fs13.fstatSync = statFixSync(fs13.fstatSync);
87
+ fs13.lstatSync = statFixSync(fs13.lstatSync);
88
+ if (fs13.chmod && !fs13.lchmod) {
89
+ fs13.lchmod = function(path14, mode, cb) {
90
90
  if (cb) process.nextTick(cb);
91
91
  };
92
- fs12.lchmodSync = function() {
92
+ fs13.lchmodSync = function() {
93
93
  };
94
94
  }
95
- if (fs12.chown && !fs12.lchown) {
96
- fs12.lchown = function(path13, uid, gid, cb) {
95
+ if (fs13.chown && !fs13.lchown) {
96
+ fs13.lchown = function(path14, uid, gid, cb) {
97
97
  if (cb) process.nextTick(cb);
98
98
  };
99
- fs12.lchownSync = function() {
99
+ fs13.lchownSync = function() {
100
100
  };
101
101
  }
102
102
  if (platform === "win32") {
103
- fs12.rename = typeof fs12.rename !== "function" ? fs12.rename : (function(fs$rename) {
103
+ fs13.rename = typeof fs13.rename !== "function" ? fs13.rename : (function(fs$rename) {
104
104
  function rename(from, to, cb) {
105
105
  var start = Date.now();
106
106
  var backoff = 0;
107
107
  fs$rename(from, to, function CB(er) {
108
108
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
109
109
  setTimeout(function() {
110
- fs12.stat(to, function(stater, st) {
110
+ fs13.stat(to, function(stater, st) {
111
111
  if (stater && stater.code === "ENOENT")
112
112
  fs$rename(from, to, CB);
113
113
  else
@@ -123,9 +123,9 @@ var require_polyfills = __commonJS({
123
123
  }
124
124
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
125
125
  return rename;
126
- })(fs12.rename);
126
+ })(fs13.rename);
127
127
  }
128
- fs12.read = typeof fs12.read !== "function" ? fs12.read : (function(fs$read) {
128
+ fs13.read = typeof fs13.read !== "function" ? fs13.read : (function(fs$read) {
129
129
  function read(fd, buffer, offset, length, position, callback_) {
130
130
  var callback;
131
131
  if (callback_ && typeof callback_ === "function") {
@@ -133,22 +133,22 @@ var require_polyfills = __commonJS({
133
133
  callback = function(er, _, __) {
134
134
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
135
135
  eagCounter++;
136
- return fs$read.call(fs12, fd, buffer, offset, length, position, callback);
136
+ return fs$read.call(fs13, fd, buffer, offset, length, position, callback);
137
137
  }
138
138
  callback_.apply(this, arguments);
139
139
  };
140
140
  }
141
- return fs$read.call(fs12, fd, buffer, offset, length, position, callback);
141
+ return fs$read.call(fs13, fd, buffer, offset, length, position, callback);
142
142
  }
143
143
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
144
144
  return read;
145
- })(fs12.read);
146
- fs12.readSync = typeof fs12.readSync !== "function" ? fs12.readSync : /* @__PURE__ */ (function(fs$readSync) {
145
+ })(fs13.read);
146
+ fs13.readSync = typeof fs13.readSync !== "function" ? fs13.readSync : /* @__PURE__ */ (function(fs$readSync) {
147
147
  return function(fd, buffer, offset, length, position) {
148
148
  var eagCounter = 0;
149
149
  while (true) {
150
150
  try {
151
- return fs$readSync.call(fs12, fd, buffer, offset, length, position);
151
+ return fs$readSync.call(fs13, fd, buffer, offset, length, position);
152
152
  } catch (er) {
153
153
  if (er.code === "EAGAIN" && eagCounter < 10) {
154
154
  eagCounter++;
@@ -158,11 +158,11 @@ var require_polyfills = __commonJS({
158
158
  }
159
159
  }
160
160
  };
161
- })(fs12.readSync);
162
- function patchLchmod(fs13) {
163
- fs13.lchmod = function(path13, mode, callback) {
164
- fs13.open(
165
- path13,
161
+ })(fs13.readSync);
162
+ function patchLchmod(fs14) {
163
+ fs14.lchmod = function(path14, mode, callback) {
164
+ fs14.open(
165
+ path14,
166
166
  constants.O_WRONLY | constants.O_SYMLINK,
167
167
  mode,
168
168
  function(err, fd) {
@@ -170,80 +170,80 @@ var require_polyfills = __commonJS({
170
170
  if (callback) callback(err);
171
171
  return;
172
172
  }
173
- fs13.fchmod(fd, mode, function(err2) {
174
- fs13.close(fd, function(err22) {
173
+ fs14.fchmod(fd, mode, function(err2) {
174
+ fs14.close(fd, function(err22) {
175
175
  if (callback) callback(err2 || err22);
176
176
  });
177
177
  });
178
178
  }
179
179
  );
180
180
  };
181
- fs13.lchmodSync = function(path13, mode) {
182
- var fd = fs13.openSync(path13, constants.O_WRONLY | constants.O_SYMLINK, mode);
181
+ fs14.lchmodSync = function(path14, mode) {
182
+ var fd = fs14.openSync(path14, constants.O_WRONLY | constants.O_SYMLINK, mode);
183
183
  var threw = true;
184
184
  var ret;
185
185
  try {
186
- ret = fs13.fchmodSync(fd, mode);
186
+ ret = fs14.fchmodSync(fd, mode);
187
187
  threw = false;
188
188
  } finally {
189
189
  if (threw) {
190
190
  try {
191
- fs13.closeSync(fd);
191
+ fs14.closeSync(fd);
192
192
  } catch (er) {
193
193
  }
194
194
  } else {
195
- fs13.closeSync(fd);
195
+ fs14.closeSync(fd);
196
196
  }
197
197
  }
198
198
  return ret;
199
199
  };
200
200
  }
201
- function patchLutimes(fs13) {
202
- if (constants.hasOwnProperty("O_SYMLINK") && fs13.futimes) {
203
- fs13.lutimes = function(path13, at, mt, cb) {
204
- fs13.open(path13, constants.O_SYMLINK, function(er, fd) {
201
+ function patchLutimes(fs14) {
202
+ if (constants.hasOwnProperty("O_SYMLINK") && fs14.futimes) {
203
+ fs14.lutimes = function(path14, at, mt, cb) {
204
+ fs14.open(path14, constants.O_SYMLINK, function(er, fd) {
205
205
  if (er) {
206
206
  if (cb) cb(er);
207
207
  return;
208
208
  }
209
- fs13.futimes(fd, at, mt, function(er2) {
210
- fs13.close(fd, function(er22) {
209
+ fs14.futimes(fd, at, mt, function(er2) {
210
+ fs14.close(fd, function(er22) {
211
211
  if (cb) cb(er2 || er22);
212
212
  });
213
213
  });
214
214
  });
215
215
  };
216
- fs13.lutimesSync = function(path13, at, mt) {
217
- var fd = fs13.openSync(path13, constants.O_SYMLINK);
216
+ fs14.lutimesSync = function(path14, at, mt) {
217
+ var fd = fs14.openSync(path14, constants.O_SYMLINK);
218
218
  var ret;
219
219
  var threw = true;
220
220
  try {
221
- ret = fs13.futimesSync(fd, at, mt);
221
+ ret = fs14.futimesSync(fd, at, mt);
222
222
  threw = false;
223
223
  } finally {
224
224
  if (threw) {
225
225
  try {
226
- fs13.closeSync(fd);
226
+ fs14.closeSync(fd);
227
227
  } catch (er) {
228
228
  }
229
229
  } else {
230
- fs13.closeSync(fd);
230
+ fs14.closeSync(fd);
231
231
  }
232
232
  }
233
233
  return ret;
234
234
  };
235
- } else if (fs13.futimes) {
236
- fs13.lutimes = function(_a, _b, _c, cb) {
235
+ } else if (fs14.futimes) {
236
+ fs14.lutimes = function(_a, _b, _c, cb) {
237
237
  if (cb) process.nextTick(cb);
238
238
  };
239
- fs13.lutimesSync = function() {
239
+ fs14.lutimesSync = function() {
240
240
  };
241
241
  }
242
242
  }
243
243
  function chmodFix(orig) {
244
244
  if (!orig) return orig;
245
245
  return function(target, mode, cb) {
246
- return orig.call(fs12, target, mode, function(er) {
246
+ return orig.call(fs13, target, mode, function(er) {
247
247
  if (chownErOk(er)) er = null;
248
248
  if (cb) cb.apply(this, arguments);
249
249
  });
@@ -253,7 +253,7 @@ var require_polyfills = __commonJS({
253
253
  if (!orig) return orig;
254
254
  return function(target, mode) {
255
255
  try {
256
- return orig.call(fs12, target, mode);
256
+ return orig.call(fs13, target, mode);
257
257
  } catch (er) {
258
258
  if (!chownErOk(er)) throw er;
259
259
  }
@@ -262,7 +262,7 @@ var require_polyfills = __commonJS({
262
262
  function chownFix(orig) {
263
263
  if (!orig) return orig;
264
264
  return function(target, uid, gid, cb) {
265
- return orig.call(fs12, target, uid, gid, function(er) {
265
+ return orig.call(fs13, target, uid, gid, function(er) {
266
266
  if (chownErOk(er)) er = null;
267
267
  if (cb) cb.apply(this, arguments);
268
268
  });
@@ -272,7 +272,7 @@ var require_polyfills = __commonJS({
272
272
  if (!orig) return orig;
273
273
  return function(target, uid, gid) {
274
274
  try {
275
- return orig.call(fs12, target, uid, gid);
275
+ return orig.call(fs13, target, uid, gid);
276
276
  } catch (er) {
277
277
  if (!chownErOk(er)) throw er;
278
278
  }
@@ -292,13 +292,13 @@ var require_polyfills = __commonJS({
292
292
  }
293
293
  if (cb) cb.apply(this, arguments);
294
294
  }
295
- return options ? orig.call(fs12, target, options, callback) : orig.call(fs12, target, callback);
295
+ return options ? orig.call(fs13, target, options, callback) : orig.call(fs13, target, callback);
296
296
  };
297
297
  }
298
298
  function statFixSync(orig) {
299
299
  if (!orig) return orig;
300
300
  return function(target, options) {
301
- var stats = options ? orig.call(fs12, target, options) : orig.call(fs12, target);
301
+ var stats = options ? orig.call(fs13, target, options) : orig.call(fs13, target);
302
302
  if (stats) {
303
303
  if (stats.uid < 0) stats.uid += 4294967296;
304
304
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -327,16 +327,16 @@ var require_legacy_streams = __commonJS({
327
327
  "node_modules/graceful-fs/legacy-streams.js"(exports, module) {
328
328
  var Stream = __require("stream").Stream;
329
329
  module.exports = legacy;
330
- function legacy(fs12) {
330
+ function legacy(fs13) {
331
331
  return {
332
332
  ReadStream,
333
333
  WriteStream
334
334
  };
335
- function ReadStream(path13, options) {
336
- if (!(this instanceof ReadStream)) return new ReadStream(path13, options);
335
+ function ReadStream(path14, options) {
336
+ if (!(this instanceof ReadStream)) return new ReadStream(path14, options);
337
337
  Stream.call(this);
338
338
  var self = this;
339
- this.path = path13;
339
+ this.path = path14;
340
340
  this.fd = null;
341
341
  this.readable = true;
342
342
  this.paused = false;
@@ -370,7 +370,7 @@ var require_legacy_streams = __commonJS({
370
370
  });
371
371
  return;
372
372
  }
373
- fs12.open(this.path, this.flags, this.mode, function(err, fd) {
373
+ fs13.open(this.path, this.flags, this.mode, function(err, fd) {
374
374
  if (err) {
375
375
  self.emit("error", err);
376
376
  self.readable = false;
@@ -381,10 +381,10 @@ var require_legacy_streams = __commonJS({
381
381
  self._read();
382
382
  });
383
383
  }
384
- function WriteStream(path13, options) {
385
- if (!(this instanceof WriteStream)) return new WriteStream(path13, options);
384
+ function WriteStream(path14, options) {
385
+ if (!(this instanceof WriteStream)) return new WriteStream(path14, options);
386
386
  Stream.call(this);
387
- this.path = path13;
387
+ this.path = path14;
388
388
  this.fd = null;
389
389
  this.writable = true;
390
390
  this.flags = "w";
@@ -409,7 +409,7 @@ var require_legacy_streams = __commonJS({
409
409
  this.busy = false;
410
410
  this._queue = [];
411
411
  if (this.fd === null) {
412
- this._open = fs12.open;
412
+ this._open = fs13.open;
413
413
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
414
414
  this.flush();
415
415
  }
@@ -444,7 +444,7 @@ var require_clone = __commonJS({
444
444
  // node_modules/graceful-fs/graceful-fs.js
445
445
  var require_graceful_fs = __commonJS({
446
446
  "node_modules/graceful-fs/graceful-fs.js"(exports, module) {
447
- var fs12 = __require("fs");
447
+ var fs13 = __require("fs");
448
448
  var polyfills = require_polyfills();
449
449
  var legacy = require_legacy_streams();
450
450
  var clone = require_clone();
@@ -476,12 +476,12 @@ var require_graceful_fs = __commonJS({
476
476
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
477
477
  console.error(m);
478
478
  };
479
- if (!fs12[gracefulQueue]) {
479
+ if (!fs13[gracefulQueue]) {
480
480
  queue = global[gracefulQueue] || [];
481
- publishQueue(fs12, queue);
482
- fs12.close = (function(fs$close) {
481
+ publishQueue(fs13, queue);
482
+ fs13.close = (function(fs$close) {
483
483
  function close(fd, cb) {
484
- return fs$close.call(fs12, fd, function(err) {
484
+ return fs$close.call(fs13, fd, function(err) {
485
485
  if (!err) {
486
486
  resetQueue();
487
487
  }
@@ -493,48 +493,48 @@ var require_graceful_fs = __commonJS({
493
493
  value: fs$close
494
494
  });
495
495
  return close;
496
- })(fs12.close);
497
- fs12.closeSync = (function(fs$closeSync) {
496
+ })(fs13.close);
497
+ fs13.closeSync = (function(fs$closeSync) {
498
498
  function closeSync2(fd) {
499
- fs$closeSync.apply(fs12, arguments);
499
+ fs$closeSync.apply(fs13, arguments);
500
500
  resetQueue();
501
501
  }
502
502
  Object.defineProperty(closeSync2, previousSymbol, {
503
503
  value: fs$closeSync
504
504
  });
505
505
  return closeSync2;
506
- })(fs12.closeSync);
506
+ })(fs13.closeSync);
507
507
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
508
508
  process.on("exit", function() {
509
- debug(fs12[gracefulQueue]);
510
- __require("assert").equal(fs12[gracefulQueue].length, 0);
509
+ debug(fs13[gracefulQueue]);
510
+ __require("assert").equal(fs13[gracefulQueue].length, 0);
511
511
  });
512
512
  }
513
513
  }
514
514
  var queue;
515
515
  if (!global[gracefulQueue]) {
516
- publishQueue(global, fs12[gracefulQueue]);
517
- }
518
- module.exports = patch(clone(fs12));
519
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs12.__patched) {
520
- module.exports = patch(fs12);
521
- fs12.__patched = true;
522
- }
523
- function patch(fs13) {
524
- polyfills(fs13);
525
- fs13.gracefulify = patch;
526
- fs13.createReadStream = createReadStream;
527
- fs13.createWriteStream = createWriteStream;
528
- var fs$readFile = fs13.readFile;
529
- fs13.readFile = readFile;
530
- function readFile(path13, options, cb) {
516
+ publishQueue(global, fs13[gracefulQueue]);
517
+ }
518
+ module.exports = patch(clone(fs13));
519
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs13.__patched) {
520
+ module.exports = patch(fs13);
521
+ fs13.__patched = true;
522
+ }
523
+ function patch(fs14) {
524
+ polyfills(fs14);
525
+ fs14.gracefulify = patch;
526
+ fs14.createReadStream = createReadStream;
527
+ fs14.createWriteStream = createWriteStream;
528
+ var fs$readFile = fs14.readFile;
529
+ fs14.readFile = readFile;
530
+ function readFile(path14, options, cb) {
531
531
  if (typeof options === "function")
532
532
  cb = options, options = null;
533
- return go$readFile(path13, options, cb);
534
- function go$readFile(path14, options2, cb2, startTime) {
535
- return fs$readFile(path14, options2, function(err) {
533
+ return go$readFile(path14, options, cb);
534
+ function go$readFile(path15, options2, cb2, startTime) {
535
+ return fs$readFile(path15, options2, function(err) {
536
536
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
537
- enqueue([go$readFile, [path14, options2, cb2], err, startTime || Date.now(), Date.now()]);
537
+ enqueue([go$readFile, [path15, options2, cb2], err, startTime || Date.now(), Date.now()]);
538
538
  else {
539
539
  if (typeof cb2 === "function")
540
540
  cb2.apply(this, arguments);
@@ -542,16 +542,16 @@ var require_graceful_fs = __commonJS({
542
542
  });
543
543
  }
544
544
  }
545
- var fs$writeFile = fs13.writeFile;
546
- fs13.writeFile = writeFile;
547
- function writeFile(path13, data, options, cb) {
545
+ var fs$writeFile = fs14.writeFile;
546
+ fs14.writeFile = writeFile;
547
+ function writeFile(path14, data, options, cb) {
548
548
  if (typeof options === "function")
549
549
  cb = options, options = null;
550
- return go$writeFile(path13, data, options, cb);
551
- function go$writeFile(path14, data2, options2, cb2, startTime) {
552
- return fs$writeFile(path14, data2, options2, function(err) {
550
+ return go$writeFile(path14, data, options, cb);
551
+ function go$writeFile(path15, data2, options2, cb2, startTime) {
552
+ return fs$writeFile(path15, data2, options2, function(err) {
553
553
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
554
- enqueue([go$writeFile, [path14, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
554
+ enqueue([go$writeFile, [path15, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
555
555
  else {
556
556
  if (typeof cb2 === "function")
557
557
  cb2.apply(this, arguments);
@@ -559,17 +559,17 @@ var require_graceful_fs = __commonJS({
559
559
  });
560
560
  }
561
561
  }
562
- var fs$appendFile = fs13.appendFile;
562
+ var fs$appendFile = fs14.appendFile;
563
563
  if (fs$appendFile)
564
- fs13.appendFile = appendFile;
565
- function appendFile(path13, data, options, cb) {
564
+ fs14.appendFile = appendFile;
565
+ function appendFile(path14, data, options, cb) {
566
566
  if (typeof options === "function")
567
567
  cb = options, options = null;
568
- return go$appendFile(path13, data, options, cb);
569
- function go$appendFile(path14, data2, options2, cb2, startTime) {
570
- return fs$appendFile(path14, data2, options2, function(err) {
568
+ return go$appendFile(path14, data, options, cb);
569
+ function go$appendFile(path15, data2, options2, cb2, startTime) {
570
+ return fs$appendFile(path15, data2, options2, function(err) {
571
571
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
572
- enqueue([go$appendFile, [path14, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
572
+ enqueue([go$appendFile, [path15, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
573
573
  else {
574
574
  if (typeof cb2 === "function")
575
575
  cb2.apply(this, arguments);
@@ -577,9 +577,9 @@ var require_graceful_fs = __commonJS({
577
577
  });
578
578
  }
579
579
  }
580
- var fs$copyFile = fs13.copyFile;
580
+ var fs$copyFile = fs14.copyFile;
581
581
  if (fs$copyFile)
582
- fs13.copyFile = copyFile;
582
+ fs14.copyFile = copyFile;
583
583
  function copyFile(src, dest, flags, cb) {
584
584
  if (typeof flags === "function") {
585
585
  cb = flags;
@@ -597,34 +597,34 @@ var require_graceful_fs = __commonJS({
597
597
  });
598
598
  }
599
599
  }
600
- var fs$readdir = fs13.readdir;
601
- fs13.readdir = readdir;
600
+ var fs$readdir = fs14.readdir;
601
+ fs14.readdir = readdir;
602
602
  var noReaddirOptionVersions = /^v[0-5]\./;
603
- function readdir(path13, options, cb) {
603
+ function readdir(path14, options, cb) {
604
604
  if (typeof options === "function")
605
605
  cb = options, options = null;
606
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path14, options2, cb2, startTime) {
607
- return fs$readdir(path14, fs$readdirCallback(
608
- path14,
606
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path15, options2, cb2, startTime) {
607
+ return fs$readdir(path15, fs$readdirCallback(
608
+ path15,
609
609
  options2,
610
610
  cb2,
611
611
  startTime
612
612
  ));
613
- } : function go$readdir2(path14, options2, cb2, startTime) {
614
- return fs$readdir(path14, options2, fs$readdirCallback(
615
- path14,
613
+ } : function go$readdir2(path15, options2, cb2, startTime) {
614
+ return fs$readdir(path15, options2, fs$readdirCallback(
615
+ path15,
616
616
  options2,
617
617
  cb2,
618
618
  startTime
619
619
  ));
620
620
  };
621
- return go$readdir(path13, options, cb);
622
- function fs$readdirCallback(path14, options2, cb2, startTime) {
621
+ return go$readdir(path14, options, cb);
622
+ function fs$readdirCallback(path15, options2, cb2, startTime) {
623
623
  return function(err, files) {
624
624
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
625
625
  enqueue([
626
626
  go$readdir,
627
- [path14, options2, cb2],
627
+ [path15, options2, cb2],
628
628
  err,
629
629
  startTime || Date.now(),
630
630
  Date.now()
@@ -639,21 +639,21 @@ var require_graceful_fs = __commonJS({
639
639
  }
640
640
  }
641
641
  if (process.version.substr(0, 4) === "v0.8") {
642
- var legStreams = legacy(fs13);
642
+ var legStreams = legacy(fs14);
643
643
  ReadStream = legStreams.ReadStream;
644
644
  WriteStream = legStreams.WriteStream;
645
645
  }
646
- var fs$ReadStream = fs13.ReadStream;
646
+ var fs$ReadStream = fs14.ReadStream;
647
647
  if (fs$ReadStream) {
648
648
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
649
649
  ReadStream.prototype.open = ReadStream$open;
650
650
  }
651
- var fs$WriteStream = fs13.WriteStream;
651
+ var fs$WriteStream = fs14.WriteStream;
652
652
  if (fs$WriteStream) {
653
653
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
654
654
  WriteStream.prototype.open = WriteStream$open;
655
655
  }
656
- Object.defineProperty(fs13, "ReadStream", {
656
+ Object.defineProperty(fs14, "ReadStream", {
657
657
  get: function() {
658
658
  return ReadStream;
659
659
  },
@@ -663,7 +663,7 @@ var require_graceful_fs = __commonJS({
663
663
  enumerable: true,
664
664
  configurable: true
665
665
  });
666
- Object.defineProperty(fs13, "WriteStream", {
666
+ Object.defineProperty(fs14, "WriteStream", {
667
667
  get: function() {
668
668
  return WriteStream;
669
669
  },
@@ -674,7 +674,7 @@ var require_graceful_fs = __commonJS({
674
674
  configurable: true
675
675
  });
676
676
  var FileReadStream = ReadStream;
677
- Object.defineProperty(fs13, "FileReadStream", {
677
+ Object.defineProperty(fs14, "FileReadStream", {
678
678
  get: function() {
679
679
  return FileReadStream;
680
680
  },
@@ -685,7 +685,7 @@ var require_graceful_fs = __commonJS({
685
685
  configurable: true
686
686
  });
687
687
  var FileWriteStream = WriteStream;
688
- Object.defineProperty(fs13, "FileWriteStream", {
688
+ Object.defineProperty(fs14, "FileWriteStream", {
689
689
  get: function() {
690
690
  return FileWriteStream;
691
691
  },
@@ -695,7 +695,7 @@ var require_graceful_fs = __commonJS({
695
695
  enumerable: true,
696
696
  configurable: true
697
697
  });
698
- function ReadStream(path13, options) {
698
+ function ReadStream(path14, options) {
699
699
  if (this instanceof ReadStream)
700
700
  return fs$ReadStream.apply(this, arguments), this;
701
701
  else
@@ -715,7 +715,7 @@ var require_graceful_fs = __commonJS({
715
715
  }
716
716
  });
717
717
  }
718
- function WriteStream(path13, options) {
718
+ function WriteStream(path14, options) {
719
719
  if (this instanceof WriteStream)
720
720
  return fs$WriteStream.apply(this, arguments), this;
721
721
  else
@@ -733,22 +733,22 @@ var require_graceful_fs = __commonJS({
733
733
  }
734
734
  });
735
735
  }
736
- function createReadStream(path13, options) {
737
- return new fs13.ReadStream(path13, options);
736
+ function createReadStream(path14, options) {
737
+ return new fs14.ReadStream(path14, options);
738
738
  }
739
- function createWriteStream(path13, options) {
740
- return new fs13.WriteStream(path13, options);
739
+ function createWriteStream(path14, options) {
740
+ return new fs14.WriteStream(path14, options);
741
741
  }
742
- var fs$open = fs13.open;
743
- fs13.open = open;
744
- function open(path13, flags, mode, cb) {
742
+ var fs$open = fs14.open;
743
+ fs14.open = open;
744
+ function open(path14, flags, mode, cb) {
745
745
  if (typeof mode === "function")
746
746
  cb = mode, mode = null;
747
- return go$open(path13, flags, mode, cb);
748
- function go$open(path14, flags2, mode2, cb2, startTime) {
749
- return fs$open(path14, flags2, mode2, function(err, fd) {
747
+ return go$open(path14, flags, mode, cb);
748
+ function go$open(path15, flags2, mode2, cb2, startTime) {
749
+ return fs$open(path15, flags2, mode2, function(err, fd) {
750
750
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
751
- enqueue([go$open, [path14, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
751
+ enqueue([go$open, [path15, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
752
752
  else {
753
753
  if (typeof cb2 === "function")
754
754
  cb2.apply(this, arguments);
@@ -756,20 +756,20 @@ var require_graceful_fs = __commonJS({
756
756
  });
757
757
  }
758
758
  }
759
- return fs13;
759
+ return fs14;
760
760
  }
761
761
  function enqueue(elem) {
762
762
  debug("ENQUEUE", elem[0].name, elem[1]);
763
- fs12[gracefulQueue].push(elem);
763
+ fs13[gracefulQueue].push(elem);
764
764
  retry();
765
765
  }
766
766
  var retryTimer;
767
767
  function resetQueue() {
768
768
  var now = Date.now();
769
- for (var i = 0; i < fs12[gracefulQueue].length; ++i) {
770
- if (fs12[gracefulQueue][i].length > 2) {
771
- fs12[gracefulQueue][i][3] = now;
772
- fs12[gracefulQueue][i][4] = now;
769
+ for (var i = 0; i < fs13[gracefulQueue].length; ++i) {
770
+ if (fs13[gracefulQueue][i].length > 2) {
771
+ fs13[gracefulQueue][i][3] = now;
772
+ fs13[gracefulQueue][i][4] = now;
773
773
  }
774
774
  }
775
775
  retry();
@@ -777,9 +777,9 @@ var require_graceful_fs = __commonJS({
777
777
  function retry() {
778
778
  clearTimeout(retryTimer);
779
779
  retryTimer = void 0;
780
- if (fs12[gracefulQueue].length === 0)
780
+ if (fs13[gracefulQueue].length === 0)
781
781
  return;
782
- var elem = fs12[gracefulQueue].shift();
782
+ var elem = fs13[gracefulQueue].shift();
783
783
  var fn = elem[0];
784
784
  var args = elem[1];
785
785
  var err = elem[2];
@@ -801,7 +801,7 @@ var require_graceful_fs = __commonJS({
801
801
  debug("RETRY", fn.name, args);
802
802
  fn.apply(null, args.concat([startTime]));
803
803
  } else {
804
- fs12[gracefulQueue].push(elem);
804
+ fs13[gracefulQueue].push(elem);
805
805
  }
806
806
  }
807
807
  if (retryTimer === void 0) {
@@ -1236,10 +1236,10 @@ var require_mtime_precision = __commonJS({
1236
1236
  "node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
1237
1237
  "use strict";
1238
1238
  var cacheSymbol = Symbol();
1239
- function probe(file, fs12, callback) {
1240
- const cachedPrecision = fs12[cacheSymbol];
1239
+ function probe(file, fs13, callback) {
1240
+ const cachedPrecision = fs13[cacheSymbol];
1241
1241
  if (cachedPrecision) {
1242
- return fs12.stat(file, (err, stat) => {
1242
+ return fs13.stat(file, (err, stat) => {
1243
1243
  if (err) {
1244
1244
  return callback(err);
1245
1245
  }
@@ -1247,16 +1247,16 @@ var require_mtime_precision = __commonJS({
1247
1247
  });
1248
1248
  }
1249
1249
  const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1250
- fs12.utimes(file, mtime, mtime, (err) => {
1250
+ fs13.utimes(file, mtime, mtime, (err) => {
1251
1251
  if (err) {
1252
1252
  return callback(err);
1253
1253
  }
1254
- fs12.stat(file, (err2, stat) => {
1254
+ fs13.stat(file, (err2, stat) => {
1255
1255
  if (err2) {
1256
1256
  return callback(err2);
1257
1257
  }
1258
1258
  const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1259
- Object.defineProperty(fs12, cacheSymbol, { value: precision });
1259
+ Object.defineProperty(fs13, cacheSymbol, { value: precision });
1260
1260
  callback(null, stat.mtime, precision);
1261
1261
  });
1262
1262
  });
@@ -1277,8 +1277,8 @@ var require_mtime_precision = __commonJS({
1277
1277
  var require_lockfile = __commonJS({
1278
1278
  "node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
1279
1279
  "use strict";
1280
- var path13 = __require("path");
1281
- var fs12 = require_graceful_fs();
1280
+ var path14 = __require("path");
1281
+ var fs13 = require_graceful_fs();
1282
1282
  var retry = require_retry2();
1283
1283
  var onExit = require_signal_exit();
1284
1284
  var mtimePrecision = require_mtime_precision();
@@ -1288,7 +1288,7 @@ var require_lockfile = __commonJS({
1288
1288
  }
1289
1289
  function resolveCanonicalPath(file, options, callback) {
1290
1290
  if (!options.realpath) {
1291
- return callback(null, path13.resolve(file));
1291
+ return callback(null, path14.resolve(file));
1292
1292
  }
1293
1293
  options.fs.realpath(file, callback);
1294
1294
  }
@@ -1409,7 +1409,7 @@ var require_lockfile = __commonJS({
1409
1409
  update: null,
1410
1410
  realpath: true,
1411
1411
  retries: 0,
1412
- fs: fs12,
1412
+ fs: fs13,
1413
1413
  onCompromised: (err) => {
1414
1414
  throw err;
1415
1415
  },
@@ -1453,7 +1453,7 @@ var require_lockfile = __commonJS({
1453
1453
  }
1454
1454
  function unlock(file, options, callback) {
1455
1455
  options = {
1456
- fs: fs12,
1456
+ fs: fs13,
1457
1457
  realpath: true,
1458
1458
  ...options
1459
1459
  };
@@ -1475,7 +1475,7 @@ var require_lockfile = __commonJS({
1475
1475
  options = {
1476
1476
  stale: 1e4,
1477
1477
  realpath: true,
1478
- fs: fs12,
1478
+ fs: fs13,
1479
1479
  ...options
1480
1480
  };
1481
1481
  options.stale = Math.max(options.stale || 0, 2e3);
@@ -1514,16 +1514,16 @@ var require_lockfile = __commonJS({
1514
1514
  var require_adapter = __commonJS({
1515
1515
  "node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
1516
1516
  "use strict";
1517
- var fs12 = require_graceful_fs();
1518
- function createSyncFs(fs13) {
1517
+ var fs13 = require_graceful_fs();
1518
+ function createSyncFs(fs14) {
1519
1519
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
1520
- const newFs = { ...fs13 };
1520
+ const newFs = { ...fs14 };
1521
1521
  methods.forEach((method) => {
1522
1522
  newFs[method] = (...args) => {
1523
1523
  const callback = args.pop();
1524
1524
  let ret;
1525
1525
  try {
1526
- ret = fs13[`${method}Sync`](...args);
1526
+ ret = fs14[`${method}Sync`](...args);
1527
1527
  } catch (err) {
1528
1528
  return callback(err);
1529
1529
  }
@@ -1533,12 +1533,12 @@ var require_adapter = __commonJS({
1533
1533
  return newFs;
1534
1534
  }
1535
1535
  function toPromise(method) {
1536
- return (...args) => new Promise((resolve4, reject) => {
1536
+ return (...args) => new Promise((resolve5, reject) => {
1537
1537
  args.push((err, result) => {
1538
1538
  if (err) {
1539
1539
  reject(err);
1540
1540
  } else {
1541
- resolve4(result);
1541
+ resolve5(result);
1542
1542
  }
1543
1543
  });
1544
1544
  method(...args);
@@ -1561,7 +1561,7 @@ var require_adapter = __commonJS({
1561
1561
  }
1562
1562
  function toSyncOptions(options) {
1563
1563
  options = { ...options };
1564
- options.fs = createSyncFs(options.fs || fs12);
1564
+ options.fs = createSyncFs(options.fs || fs13);
1565
1565
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
1566
1566
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
1567
1567
  }
@@ -2715,17 +2715,17 @@ var require_lib = __commonJS({
2715
2715
  "node_modules/json5/lib/index.js"(exports, module) {
2716
2716
  var parse = require_parse();
2717
2717
  var stringify = require_stringify();
2718
- var JSON52 = {
2718
+ var JSON53 = {
2719
2719
  parse,
2720
2720
  stringify
2721
2721
  };
2722
- module.exports = JSON52;
2722
+ module.exports = JSON53;
2723
2723
  }
2724
2724
  });
2725
2725
 
2726
2726
  // src/index.ts
2727
- import * as fs11 from "node:fs";
2728
- import * as path12 from "node:path";
2727
+ import * as fs12 from "node:fs";
2728
+ import * as path13 from "node:path";
2729
2729
 
2730
2730
  // node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
2731
2731
  var value_exports = {};
@@ -6298,32 +6298,32 @@ var ValueErrorIterator = class {
6298
6298
  return next.done ? void 0 : next.value;
6299
6299
  }
6300
6300
  };
6301
- function Create(errorType, schema, path13, value, errors = []) {
6301
+ function Create(errorType, schema, path14, value, errors = []) {
6302
6302
  return {
6303
6303
  type: errorType,
6304
6304
  schema,
6305
- path: path13,
6305
+ path: path14,
6306
6306
  value,
6307
- message: GetErrorFunction()({ errorType, path: path13, schema, value, errors }),
6307
+ message: GetErrorFunction()({ errorType, path: path14, schema, value, errors }),
6308
6308
  errors
6309
6309
  };
6310
6310
  }
6311
- function* FromAny3(schema, references, path13, value) {
6311
+ function* FromAny3(schema, references, path14, value) {
6312
6312
  }
6313
- function* FromArgument3(schema, references, path13, value) {
6313
+ function* FromArgument3(schema, references, path14, value) {
6314
6314
  }
6315
- function* FromArray8(schema, references, path13, value) {
6315
+ function* FromArray8(schema, references, path14, value) {
6316
6316
  if (!IsArray2(value)) {
6317
- return yield Create(ValueErrorType.Array, schema, path13, value);
6317
+ return yield Create(ValueErrorType.Array, schema, path14, value);
6318
6318
  }
6319
6319
  if (IsDefined2(schema.minItems) && !(value.length >= schema.minItems)) {
6320
- yield Create(ValueErrorType.ArrayMinItems, schema, path13, value);
6320
+ yield Create(ValueErrorType.ArrayMinItems, schema, path14, value);
6321
6321
  }
6322
6322
  if (IsDefined2(schema.maxItems) && !(value.length <= schema.maxItems)) {
6323
- yield Create(ValueErrorType.ArrayMaxItems, schema, path13, value);
6323
+ yield Create(ValueErrorType.ArrayMaxItems, schema, path14, value);
6324
6324
  }
6325
6325
  for (let i = 0; i < value.length; i++) {
6326
- yield* Visit6(schema.items, references, `${path13}/${i}`, value[i]);
6326
+ yield* Visit6(schema.items, references, `${path14}/${i}`, value[i]);
6327
6327
  }
6328
6328
  if (schema.uniqueItems === true && !(function() {
6329
6329
  const set = /* @__PURE__ */ new Set();
@@ -6337,116 +6337,116 @@ function* FromArray8(schema, references, path13, value) {
6337
6337
  }
6338
6338
  return true;
6339
6339
  })()) {
6340
- yield Create(ValueErrorType.ArrayUniqueItems, schema, path13, value);
6340
+ yield Create(ValueErrorType.ArrayUniqueItems, schema, path14, value);
6341
6341
  }
6342
6342
  if (!(IsDefined2(schema.contains) || IsDefined2(schema.minContains) || IsDefined2(schema.maxContains))) {
6343
6343
  return;
6344
6344
  }
6345
6345
  const containsSchema = IsDefined2(schema.contains) ? schema.contains : Never();
6346
- const containsCount = value.reduce((acc, value2, index) => Visit6(containsSchema, references, `${path13}${index}`, value2).next().done === true ? acc + 1 : acc, 0);
6346
+ const containsCount = value.reduce((acc, value2, index) => Visit6(containsSchema, references, `${path14}${index}`, value2).next().done === true ? acc + 1 : acc, 0);
6347
6347
  if (containsCount === 0) {
6348
- yield Create(ValueErrorType.ArrayContains, schema, path13, value);
6348
+ yield Create(ValueErrorType.ArrayContains, schema, path14, value);
6349
6349
  }
6350
6350
  if (IsNumber2(schema.minContains) && containsCount < schema.minContains) {
6351
- yield Create(ValueErrorType.ArrayMinContains, schema, path13, value);
6351
+ yield Create(ValueErrorType.ArrayMinContains, schema, path14, value);
6352
6352
  }
6353
6353
  if (IsNumber2(schema.maxContains) && containsCount > schema.maxContains) {
6354
- yield Create(ValueErrorType.ArrayMaxContains, schema, path13, value);
6354
+ yield Create(ValueErrorType.ArrayMaxContains, schema, path14, value);
6355
6355
  }
6356
6356
  }
6357
- function* FromAsyncIterator5(schema, references, path13, value) {
6357
+ function* FromAsyncIterator5(schema, references, path14, value) {
6358
6358
  if (!IsAsyncIterator2(value))
6359
- yield Create(ValueErrorType.AsyncIterator, schema, path13, value);
6359
+ yield Create(ValueErrorType.AsyncIterator, schema, path14, value);
6360
6360
  }
6361
- function* FromBigInt3(schema, references, path13, value) {
6361
+ function* FromBigInt3(schema, references, path14, value) {
6362
6362
  if (!IsBigInt2(value))
6363
- return yield Create(ValueErrorType.BigInt, schema, path13, value);
6363
+ return yield Create(ValueErrorType.BigInt, schema, path14, value);
6364
6364
  if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
6365
- yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path13, value);
6365
+ yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path14, value);
6366
6366
  }
6367
6367
  if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
6368
- yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path13, value);
6368
+ yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path14, value);
6369
6369
  }
6370
6370
  if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
6371
- yield Create(ValueErrorType.BigIntMaximum, schema, path13, value);
6371
+ yield Create(ValueErrorType.BigIntMaximum, schema, path14, value);
6372
6372
  }
6373
6373
  if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
6374
- yield Create(ValueErrorType.BigIntMinimum, schema, path13, value);
6374
+ yield Create(ValueErrorType.BigIntMinimum, schema, path14, value);
6375
6375
  }
6376
6376
  if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
6377
- yield Create(ValueErrorType.BigIntMultipleOf, schema, path13, value);
6377
+ yield Create(ValueErrorType.BigIntMultipleOf, schema, path14, value);
6378
6378
  }
6379
6379
  }
6380
- function* FromBoolean3(schema, references, path13, value) {
6380
+ function* FromBoolean3(schema, references, path14, value) {
6381
6381
  if (!IsBoolean2(value))
6382
- yield Create(ValueErrorType.Boolean, schema, path13, value);
6382
+ yield Create(ValueErrorType.Boolean, schema, path14, value);
6383
6383
  }
6384
- function* FromConstructor5(schema, references, path13, value) {
6385
- yield* Visit6(schema.returns, references, path13, value.prototype);
6384
+ function* FromConstructor5(schema, references, path14, value) {
6385
+ yield* Visit6(schema.returns, references, path14, value.prototype);
6386
6386
  }
6387
- function* FromDate3(schema, references, path13, value) {
6387
+ function* FromDate3(schema, references, path14, value) {
6388
6388
  if (!IsDate2(value))
6389
- return yield Create(ValueErrorType.Date, schema, path13, value);
6389
+ return yield Create(ValueErrorType.Date, schema, path14, value);
6390
6390
  if (IsDefined2(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
6391
- yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path13, value);
6391
+ yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path14, value);
6392
6392
  }
6393
6393
  if (IsDefined2(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
6394
- yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path13, value);
6394
+ yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path14, value);
6395
6395
  }
6396
6396
  if (IsDefined2(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
6397
- yield Create(ValueErrorType.DateMaximumTimestamp, schema, path13, value);
6397
+ yield Create(ValueErrorType.DateMaximumTimestamp, schema, path14, value);
6398
6398
  }
6399
6399
  if (IsDefined2(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
6400
- yield Create(ValueErrorType.DateMinimumTimestamp, schema, path13, value);
6400
+ yield Create(ValueErrorType.DateMinimumTimestamp, schema, path14, value);
6401
6401
  }
6402
6402
  if (IsDefined2(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
6403
- yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path13, value);
6403
+ yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path14, value);
6404
6404
  }
6405
6405
  }
6406
- function* FromFunction5(schema, references, path13, value) {
6406
+ function* FromFunction5(schema, references, path14, value) {
6407
6407
  if (!IsFunction2(value))
6408
- yield Create(ValueErrorType.Function, schema, path13, value);
6408
+ yield Create(ValueErrorType.Function, schema, path14, value);
6409
6409
  }
6410
- function* FromImport2(schema, references, path13, value) {
6410
+ function* FromImport2(schema, references, path14, value) {
6411
6411
  const definitions = globalThis.Object.values(schema.$defs);
6412
6412
  const target = schema.$defs[schema.$ref];
6413
- yield* Visit6(target, [...references, ...definitions], path13, value);
6413
+ yield* Visit6(target, [...references, ...definitions], path14, value);
6414
6414
  }
6415
- function* FromInteger3(schema, references, path13, value) {
6415
+ function* FromInteger3(schema, references, path14, value) {
6416
6416
  if (!IsInteger(value))
6417
- return yield Create(ValueErrorType.Integer, schema, path13, value);
6417
+ return yield Create(ValueErrorType.Integer, schema, path14, value);
6418
6418
  if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
6419
- yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path13, value);
6419
+ yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path14, value);
6420
6420
  }
6421
6421
  if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
6422
- yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path13, value);
6422
+ yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path14, value);
6423
6423
  }
6424
6424
  if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
6425
- yield Create(ValueErrorType.IntegerMaximum, schema, path13, value);
6425
+ yield Create(ValueErrorType.IntegerMaximum, schema, path14, value);
6426
6426
  }
6427
6427
  if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
6428
- yield Create(ValueErrorType.IntegerMinimum, schema, path13, value);
6428
+ yield Create(ValueErrorType.IntegerMinimum, schema, path14, value);
6429
6429
  }
6430
6430
  if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
6431
- yield Create(ValueErrorType.IntegerMultipleOf, schema, path13, value);
6431
+ yield Create(ValueErrorType.IntegerMultipleOf, schema, path14, value);
6432
6432
  }
6433
6433
  }
6434
- function* FromIntersect10(schema, references, path13, value) {
6434
+ function* FromIntersect10(schema, references, path14, value) {
6435
6435
  let hasError = false;
6436
6436
  for (const inner of schema.allOf) {
6437
- for (const error of Visit6(inner, references, path13, value)) {
6437
+ for (const error of Visit6(inner, references, path14, value)) {
6438
6438
  hasError = true;
6439
6439
  yield error;
6440
6440
  }
6441
6441
  }
6442
6442
  if (hasError) {
6443
- return yield Create(ValueErrorType.Intersect, schema, path13, value);
6443
+ return yield Create(ValueErrorType.Intersect, schema, path14, value);
6444
6444
  }
6445
6445
  if (schema.unevaluatedProperties === false) {
6446
6446
  const keyCheck = new RegExp(KeyOfPattern(schema));
6447
6447
  for (const valueKey of Object.getOwnPropertyNames(value)) {
6448
6448
  if (!keyCheck.test(valueKey)) {
6449
- yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path13}/${valueKey}`, value);
6449
+ yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path14}/${valueKey}`, value);
6450
6450
  }
6451
6451
  }
6452
6452
  }
@@ -6454,59 +6454,59 @@ function* FromIntersect10(schema, references, path13, value) {
6454
6454
  const keyCheck = new RegExp(KeyOfPattern(schema));
6455
6455
  for (const valueKey of Object.getOwnPropertyNames(value)) {
6456
6456
  if (!keyCheck.test(valueKey)) {
6457
- const next = Visit6(schema.unevaluatedProperties, references, `${path13}/${valueKey}`, value[valueKey]).next();
6457
+ const next = Visit6(schema.unevaluatedProperties, references, `${path14}/${valueKey}`, value[valueKey]).next();
6458
6458
  if (!next.done)
6459
6459
  yield next.value;
6460
6460
  }
6461
6461
  }
6462
6462
  }
6463
6463
  }
6464
- function* FromIterator5(schema, references, path13, value) {
6464
+ function* FromIterator5(schema, references, path14, value) {
6465
6465
  if (!IsIterator2(value))
6466
- yield Create(ValueErrorType.Iterator, schema, path13, value);
6466
+ yield Create(ValueErrorType.Iterator, schema, path14, value);
6467
6467
  }
6468
- function* FromLiteral4(schema, references, path13, value) {
6468
+ function* FromLiteral4(schema, references, path14, value) {
6469
6469
  if (!(value === schema.const))
6470
- yield Create(ValueErrorType.Literal, schema, path13, value);
6470
+ yield Create(ValueErrorType.Literal, schema, path14, value);
6471
6471
  }
6472
- function* FromNever3(schema, references, path13, value) {
6473
- yield Create(ValueErrorType.Never, schema, path13, value);
6472
+ function* FromNever3(schema, references, path14, value) {
6473
+ yield Create(ValueErrorType.Never, schema, path14, value);
6474
6474
  }
6475
- function* FromNot3(schema, references, path13, value) {
6476
- if (Visit6(schema.not, references, path13, value).next().done === true)
6477
- yield Create(ValueErrorType.Not, schema, path13, value);
6475
+ function* FromNot3(schema, references, path14, value) {
6476
+ if (Visit6(schema.not, references, path14, value).next().done === true)
6477
+ yield Create(ValueErrorType.Not, schema, path14, value);
6478
6478
  }
6479
- function* FromNull3(schema, references, path13, value) {
6479
+ function* FromNull3(schema, references, path14, value) {
6480
6480
  if (!IsNull2(value))
6481
- yield Create(ValueErrorType.Null, schema, path13, value);
6481
+ yield Create(ValueErrorType.Null, schema, path14, value);
6482
6482
  }
6483
- function* FromNumber3(schema, references, path13, value) {
6483
+ function* FromNumber3(schema, references, path14, value) {
6484
6484
  if (!TypeSystemPolicy.IsNumberLike(value))
6485
- return yield Create(ValueErrorType.Number, schema, path13, value);
6485
+ return yield Create(ValueErrorType.Number, schema, path14, value);
6486
6486
  if (IsDefined2(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
6487
- yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path13, value);
6487
+ yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path14, value);
6488
6488
  }
6489
6489
  if (IsDefined2(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
6490
- yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path13, value);
6490
+ yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path14, value);
6491
6491
  }
6492
6492
  if (IsDefined2(schema.maximum) && !(value <= schema.maximum)) {
6493
- yield Create(ValueErrorType.NumberMaximum, schema, path13, value);
6493
+ yield Create(ValueErrorType.NumberMaximum, schema, path14, value);
6494
6494
  }
6495
6495
  if (IsDefined2(schema.minimum) && !(value >= schema.minimum)) {
6496
- yield Create(ValueErrorType.NumberMinimum, schema, path13, value);
6496
+ yield Create(ValueErrorType.NumberMinimum, schema, path14, value);
6497
6497
  }
6498
6498
  if (IsDefined2(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
6499
- yield Create(ValueErrorType.NumberMultipleOf, schema, path13, value);
6499
+ yield Create(ValueErrorType.NumberMultipleOf, schema, path14, value);
6500
6500
  }
6501
6501
  }
6502
- function* FromObject9(schema, references, path13, value) {
6502
+ function* FromObject9(schema, references, path14, value) {
6503
6503
  if (!TypeSystemPolicy.IsObjectLike(value))
6504
- return yield Create(ValueErrorType.Object, schema, path13, value);
6504
+ return yield Create(ValueErrorType.Object, schema, path14, value);
6505
6505
  if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
6506
- yield Create(ValueErrorType.ObjectMinProperties, schema, path13, value);
6506
+ yield Create(ValueErrorType.ObjectMinProperties, schema, path14, value);
6507
6507
  }
6508
6508
  if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
6509
- yield Create(ValueErrorType.ObjectMaxProperties, schema, path13, value);
6509
+ yield Create(ValueErrorType.ObjectMaxProperties, schema, path14, value);
6510
6510
  }
6511
6511
  const requiredKeys = Array.isArray(schema.required) ? schema.required : [];
6512
6512
  const knownKeys = Object.getOwnPropertyNames(schema.properties);
@@ -6514,12 +6514,12 @@ function* FromObject9(schema, references, path13, value) {
6514
6514
  for (const requiredKey of requiredKeys) {
6515
6515
  if (unknownKeys.includes(requiredKey))
6516
6516
  continue;
6517
- yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path13}/${EscapeKey(requiredKey)}`, void 0);
6517
+ yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path14}/${EscapeKey(requiredKey)}`, void 0);
6518
6518
  }
6519
6519
  if (schema.additionalProperties === false) {
6520
6520
  for (const valueKey of unknownKeys) {
6521
6521
  if (!knownKeys.includes(valueKey)) {
6522
- yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path13}/${EscapeKey(valueKey)}`, value[valueKey]);
6522
+ yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path14}/${EscapeKey(valueKey)}`, value[valueKey]);
6523
6523
  }
6524
6524
  }
6525
6525
  }
@@ -6527,235 +6527,235 @@ function* FromObject9(schema, references, path13, value) {
6527
6527
  for (const valueKey of unknownKeys) {
6528
6528
  if (knownKeys.includes(valueKey))
6529
6529
  continue;
6530
- yield* Visit6(schema.additionalProperties, references, `${path13}/${EscapeKey(valueKey)}`, value[valueKey]);
6530
+ yield* Visit6(schema.additionalProperties, references, `${path14}/${EscapeKey(valueKey)}`, value[valueKey]);
6531
6531
  }
6532
6532
  }
6533
6533
  for (const knownKey of knownKeys) {
6534
6534
  const property = schema.properties[knownKey];
6535
6535
  if (schema.required && schema.required.includes(knownKey)) {
6536
- yield* Visit6(property, references, `${path13}/${EscapeKey(knownKey)}`, value[knownKey]);
6536
+ yield* Visit6(property, references, `${path14}/${EscapeKey(knownKey)}`, value[knownKey]);
6537
6537
  if (ExtendsUndefinedCheck(schema) && !(knownKey in value)) {
6538
- yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path13}/${EscapeKey(knownKey)}`, void 0);
6538
+ yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path14}/${EscapeKey(knownKey)}`, void 0);
6539
6539
  }
6540
6540
  } else {
6541
6541
  if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey)) {
6542
- yield* Visit6(property, references, `${path13}/${EscapeKey(knownKey)}`, value[knownKey]);
6542
+ yield* Visit6(property, references, `${path14}/${EscapeKey(knownKey)}`, value[knownKey]);
6543
6543
  }
6544
6544
  }
6545
6545
  }
6546
6546
  }
6547
- function* FromPromise5(schema, references, path13, value) {
6547
+ function* FromPromise5(schema, references, path14, value) {
6548
6548
  if (!IsPromise(value))
6549
- yield Create(ValueErrorType.Promise, schema, path13, value);
6549
+ yield Create(ValueErrorType.Promise, schema, path14, value);
6550
6550
  }
6551
- function* FromRecord5(schema, references, path13, value) {
6551
+ function* FromRecord5(schema, references, path14, value) {
6552
6552
  if (!TypeSystemPolicy.IsRecordLike(value))
6553
- return yield Create(ValueErrorType.Object, schema, path13, value);
6553
+ return yield Create(ValueErrorType.Object, schema, path14, value);
6554
6554
  if (IsDefined2(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
6555
- yield Create(ValueErrorType.ObjectMinProperties, schema, path13, value);
6555
+ yield Create(ValueErrorType.ObjectMinProperties, schema, path14, value);
6556
6556
  }
6557
6557
  if (IsDefined2(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
6558
- yield Create(ValueErrorType.ObjectMaxProperties, schema, path13, value);
6558
+ yield Create(ValueErrorType.ObjectMaxProperties, schema, path14, value);
6559
6559
  }
6560
6560
  const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
6561
6561
  const regex = new RegExp(patternKey);
6562
6562
  for (const [propertyKey, propertyValue] of Object.entries(value)) {
6563
6563
  if (regex.test(propertyKey))
6564
- yield* Visit6(patternSchema, references, `${path13}/${EscapeKey(propertyKey)}`, propertyValue);
6564
+ yield* Visit6(patternSchema, references, `${path14}/${EscapeKey(propertyKey)}`, propertyValue);
6565
6565
  }
6566
6566
  if (typeof schema.additionalProperties === "object") {
6567
6567
  for (const [propertyKey, propertyValue] of Object.entries(value)) {
6568
6568
  if (!regex.test(propertyKey))
6569
- yield* Visit6(schema.additionalProperties, references, `${path13}/${EscapeKey(propertyKey)}`, propertyValue);
6569
+ yield* Visit6(schema.additionalProperties, references, `${path14}/${EscapeKey(propertyKey)}`, propertyValue);
6570
6570
  }
6571
6571
  }
6572
6572
  if (schema.additionalProperties === false) {
6573
6573
  for (const [propertyKey, propertyValue] of Object.entries(value)) {
6574
6574
  if (regex.test(propertyKey))
6575
6575
  continue;
6576
- return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path13}/${EscapeKey(propertyKey)}`, propertyValue);
6576
+ return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path14}/${EscapeKey(propertyKey)}`, propertyValue);
6577
6577
  }
6578
6578
  }
6579
6579
  }
6580
- function* FromRef6(schema, references, path13, value) {
6581
- yield* Visit6(Deref(schema, references), references, path13, value);
6580
+ function* FromRef6(schema, references, path14, value) {
6581
+ yield* Visit6(Deref(schema, references), references, path14, value);
6582
6582
  }
6583
- function* FromRegExp3(schema, references, path13, value) {
6583
+ function* FromRegExp3(schema, references, path14, value) {
6584
6584
  if (!IsString2(value))
6585
- return yield Create(ValueErrorType.String, schema, path13, value);
6585
+ return yield Create(ValueErrorType.String, schema, path14, value);
6586
6586
  if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
6587
- yield Create(ValueErrorType.StringMinLength, schema, path13, value);
6587
+ yield Create(ValueErrorType.StringMinLength, schema, path14, value);
6588
6588
  }
6589
6589
  if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
6590
- yield Create(ValueErrorType.StringMaxLength, schema, path13, value);
6590
+ yield Create(ValueErrorType.StringMaxLength, schema, path14, value);
6591
6591
  }
6592
6592
  const regex = new RegExp(schema.source, schema.flags);
6593
6593
  if (!regex.test(value)) {
6594
- return yield Create(ValueErrorType.RegExp, schema, path13, value);
6594
+ return yield Create(ValueErrorType.RegExp, schema, path14, value);
6595
6595
  }
6596
6596
  }
6597
- function* FromString3(schema, references, path13, value) {
6597
+ function* FromString3(schema, references, path14, value) {
6598
6598
  if (!IsString2(value))
6599
- return yield Create(ValueErrorType.String, schema, path13, value);
6599
+ return yield Create(ValueErrorType.String, schema, path14, value);
6600
6600
  if (IsDefined2(schema.minLength) && !(value.length >= schema.minLength)) {
6601
- yield Create(ValueErrorType.StringMinLength, schema, path13, value);
6601
+ yield Create(ValueErrorType.StringMinLength, schema, path14, value);
6602
6602
  }
6603
6603
  if (IsDefined2(schema.maxLength) && !(value.length <= schema.maxLength)) {
6604
- yield Create(ValueErrorType.StringMaxLength, schema, path13, value);
6604
+ yield Create(ValueErrorType.StringMaxLength, schema, path14, value);
6605
6605
  }
6606
6606
  if (IsString2(schema.pattern)) {
6607
6607
  const regex = new RegExp(schema.pattern);
6608
6608
  if (!regex.test(value)) {
6609
- yield Create(ValueErrorType.StringPattern, schema, path13, value);
6609
+ yield Create(ValueErrorType.StringPattern, schema, path14, value);
6610
6610
  }
6611
6611
  }
6612
6612
  if (IsString2(schema.format)) {
6613
6613
  if (!format_exports.Has(schema.format)) {
6614
- yield Create(ValueErrorType.StringFormatUnknown, schema, path13, value);
6614
+ yield Create(ValueErrorType.StringFormatUnknown, schema, path14, value);
6615
6615
  } else {
6616
6616
  const format = format_exports.Get(schema.format);
6617
6617
  if (!format(value)) {
6618
- yield Create(ValueErrorType.StringFormat, schema, path13, value);
6618
+ yield Create(ValueErrorType.StringFormat, schema, path14, value);
6619
6619
  }
6620
6620
  }
6621
6621
  }
6622
6622
  }
6623
- function* FromSymbol3(schema, references, path13, value) {
6623
+ function* FromSymbol3(schema, references, path14, value) {
6624
6624
  if (!IsSymbol2(value))
6625
- yield Create(ValueErrorType.Symbol, schema, path13, value);
6625
+ yield Create(ValueErrorType.Symbol, schema, path14, value);
6626
6626
  }
6627
- function* FromTemplateLiteral5(schema, references, path13, value) {
6627
+ function* FromTemplateLiteral5(schema, references, path14, value) {
6628
6628
  if (!IsString2(value))
6629
- return yield Create(ValueErrorType.String, schema, path13, value);
6629
+ return yield Create(ValueErrorType.String, schema, path14, value);
6630
6630
  const regex = new RegExp(schema.pattern);
6631
6631
  if (!regex.test(value)) {
6632
- yield Create(ValueErrorType.StringPattern, schema, path13, value);
6632
+ yield Create(ValueErrorType.StringPattern, schema, path14, value);
6633
6633
  }
6634
6634
  }
6635
- function* FromThis2(schema, references, path13, value) {
6636
- yield* Visit6(Deref(schema, references), references, path13, value);
6635
+ function* FromThis2(schema, references, path14, value) {
6636
+ yield* Visit6(Deref(schema, references), references, path14, value);
6637
6637
  }
6638
- function* FromTuple7(schema, references, path13, value) {
6638
+ function* FromTuple7(schema, references, path14, value) {
6639
6639
  if (!IsArray2(value))
6640
- return yield Create(ValueErrorType.Tuple, schema, path13, value);
6640
+ return yield Create(ValueErrorType.Tuple, schema, path14, value);
6641
6641
  if (schema.items === void 0 && !(value.length === 0)) {
6642
- return yield Create(ValueErrorType.TupleLength, schema, path13, value);
6642
+ return yield Create(ValueErrorType.TupleLength, schema, path14, value);
6643
6643
  }
6644
6644
  if (!(value.length === schema.maxItems)) {
6645
- return yield Create(ValueErrorType.TupleLength, schema, path13, value);
6645
+ return yield Create(ValueErrorType.TupleLength, schema, path14, value);
6646
6646
  }
6647
6647
  if (!schema.items) {
6648
6648
  return;
6649
6649
  }
6650
6650
  for (let i = 0; i < schema.items.length; i++) {
6651
- yield* Visit6(schema.items[i], references, `${path13}/${i}`, value[i]);
6651
+ yield* Visit6(schema.items[i], references, `${path14}/${i}`, value[i]);
6652
6652
  }
6653
6653
  }
6654
- function* FromUndefined3(schema, references, path13, value) {
6654
+ function* FromUndefined3(schema, references, path14, value) {
6655
6655
  if (!IsUndefined2(value))
6656
- yield Create(ValueErrorType.Undefined, schema, path13, value);
6656
+ yield Create(ValueErrorType.Undefined, schema, path14, value);
6657
6657
  }
6658
- function* FromUnion12(schema, references, path13, value) {
6658
+ function* FromUnion12(schema, references, path14, value) {
6659
6659
  if (Check(schema, references, value))
6660
6660
  return;
6661
- const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit6(variant, references, path13, value)));
6662
- yield Create(ValueErrorType.Union, schema, path13, value, errors);
6661
+ const errors = schema.anyOf.map((variant) => new ValueErrorIterator(Visit6(variant, references, path14, value)));
6662
+ yield Create(ValueErrorType.Union, schema, path14, value, errors);
6663
6663
  }
6664
- function* FromUint8Array3(schema, references, path13, value) {
6664
+ function* FromUint8Array3(schema, references, path14, value) {
6665
6665
  if (!IsUint8Array2(value))
6666
- return yield Create(ValueErrorType.Uint8Array, schema, path13, value);
6666
+ return yield Create(ValueErrorType.Uint8Array, schema, path14, value);
6667
6667
  if (IsDefined2(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
6668
- yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path13, value);
6668
+ yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path14, value);
6669
6669
  }
6670
6670
  if (IsDefined2(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
6671
- yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path13, value);
6671
+ yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path14, value);
6672
6672
  }
6673
6673
  }
6674
- function* FromUnknown3(schema, references, path13, value) {
6674
+ function* FromUnknown3(schema, references, path14, value) {
6675
6675
  }
6676
- function* FromVoid3(schema, references, path13, value) {
6676
+ function* FromVoid3(schema, references, path14, value) {
6677
6677
  if (!TypeSystemPolicy.IsVoidLike(value))
6678
- yield Create(ValueErrorType.Void, schema, path13, value);
6678
+ yield Create(ValueErrorType.Void, schema, path14, value);
6679
6679
  }
6680
- function* FromKind2(schema, references, path13, value) {
6680
+ function* FromKind2(schema, references, path14, value) {
6681
6681
  const check2 = type_exports2.Get(schema[Kind]);
6682
6682
  if (!check2(schema, value))
6683
- yield Create(ValueErrorType.Kind, schema, path13, value);
6683
+ yield Create(ValueErrorType.Kind, schema, path14, value);
6684
6684
  }
6685
- function* Visit6(schema, references, path13, value) {
6685
+ function* Visit6(schema, references, path14, value) {
6686
6686
  const references_ = IsDefined2(schema.$id) ? [...references, schema] : references;
6687
6687
  const schema_ = schema;
6688
6688
  switch (schema_[Kind]) {
6689
6689
  case "Any":
6690
- return yield* FromAny3(schema_, references_, path13, value);
6690
+ return yield* FromAny3(schema_, references_, path14, value);
6691
6691
  case "Argument":
6692
- return yield* FromArgument3(schema_, references_, path13, value);
6692
+ return yield* FromArgument3(schema_, references_, path14, value);
6693
6693
  case "Array":
6694
- return yield* FromArray8(schema_, references_, path13, value);
6694
+ return yield* FromArray8(schema_, references_, path14, value);
6695
6695
  case "AsyncIterator":
6696
- return yield* FromAsyncIterator5(schema_, references_, path13, value);
6696
+ return yield* FromAsyncIterator5(schema_, references_, path14, value);
6697
6697
  case "BigInt":
6698
- return yield* FromBigInt3(schema_, references_, path13, value);
6698
+ return yield* FromBigInt3(schema_, references_, path14, value);
6699
6699
  case "Boolean":
6700
- return yield* FromBoolean3(schema_, references_, path13, value);
6700
+ return yield* FromBoolean3(schema_, references_, path14, value);
6701
6701
  case "Constructor":
6702
- return yield* FromConstructor5(schema_, references_, path13, value);
6702
+ return yield* FromConstructor5(schema_, references_, path14, value);
6703
6703
  case "Date":
6704
- return yield* FromDate3(schema_, references_, path13, value);
6704
+ return yield* FromDate3(schema_, references_, path14, value);
6705
6705
  case "Function":
6706
- return yield* FromFunction5(schema_, references_, path13, value);
6706
+ return yield* FromFunction5(schema_, references_, path14, value);
6707
6707
  case "Import":
6708
- return yield* FromImport2(schema_, references_, path13, value);
6708
+ return yield* FromImport2(schema_, references_, path14, value);
6709
6709
  case "Integer":
6710
- return yield* FromInteger3(schema_, references_, path13, value);
6710
+ return yield* FromInteger3(schema_, references_, path14, value);
6711
6711
  case "Intersect":
6712
- return yield* FromIntersect10(schema_, references_, path13, value);
6712
+ return yield* FromIntersect10(schema_, references_, path14, value);
6713
6713
  case "Iterator":
6714
- return yield* FromIterator5(schema_, references_, path13, value);
6714
+ return yield* FromIterator5(schema_, references_, path14, value);
6715
6715
  case "Literal":
6716
- return yield* FromLiteral4(schema_, references_, path13, value);
6716
+ return yield* FromLiteral4(schema_, references_, path14, value);
6717
6717
  case "Never":
6718
- return yield* FromNever3(schema_, references_, path13, value);
6718
+ return yield* FromNever3(schema_, references_, path14, value);
6719
6719
  case "Not":
6720
- return yield* FromNot3(schema_, references_, path13, value);
6720
+ return yield* FromNot3(schema_, references_, path14, value);
6721
6721
  case "Null":
6722
- return yield* FromNull3(schema_, references_, path13, value);
6722
+ return yield* FromNull3(schema_, references_, path14, value);
6723
6723
  case "Number":
6724
- return yield* FromNumber3(schema_, references_, path13, value);
6724
+ return yield* FromNumber3(schema_, references_, path14, value);
6725
6725
  case "Object":
6726
- return yield* FromObject9(schema_, references_, path13, value);
6726
+ return yield* FromObject9(schema_, references_, path14, value);
6727
6727
  case "Promise":
6728
- return yield* FromPromise5(schema_, references_, path13, value);
6728
+ return yield* FromPromise5(schema_, references_, path14, value);
6729
6729
  case "Record":
6730
- return yield* FromRecord5(schema_, references_, path13, value);
6730
+ return yield* FromRecord5(schema_, references_, path14, value);
6731
6731
  case "Ref":
6732
- return yield* FromRef6(schema_, references_, path13, value);
6732
+ return yield* FromRef6(schema_, references_, path14, value);
6733
6733
  case "RegExp":
6734
- return yield* FromRegExp3(schema_, references_, path13, value);
6734
+ return yield* FromRegExp3(schema_, references_, path14, value);
6735
6735
  case "String":
6736
- return yield* FromString3(schema_, references_, path13, value);
6736
+ return yield* FromString3(schema_, references_, path14, value);
6737
6737
  case "Symbol":
6738
- return yield* FromSymbol3(schema_, references_, path13, value);
6738
+ return yield* FromSymbol3(schema_, references_, path14, value);
6739
6739
  case "TemplateLiteral":
6740
- return yield* FromTemplateLiteral5(schema_, references_, path13, value);
6740
+ return yield* FromTemplateLiteral5(schema_, references_, path14, value);
6741
6741
  case "This":
6742
- return yield* FromThis2(schema_, references_, path13, value);
6742
+ return yield* FromThis2(schema_, references_, path14, value);
6743
6743
  case "Tuple":
6744
- return yield* FromTuple7(schema_, references_, path13, value);
6744
+ return yield* FromTuple7(schema_, references_, path14, value);
6745
6745
  case "Undefined":
6746
- return yield* FromUndefined3(schema_, references_, path13, value);
6746
+ return yield* FromUndefined3(schema_, references_, path14, value);
6747
6747
  case "Union":
6748
- return yield* FromUnion12(schema_, references_, path13, value);
6748
+ return yield* FromUnion12(schema_, references_, path14, value);
6749
6749
  case "Uint8Array":
6750
- return yield* FromUint8Array3(schema_, references_, path13, value);
6750
+ return yield* FromUint8Array3(schema_, references_, path14, value);
6751
6751
  case "Unknown":
6752
- return yield* FromUnknown3(schema_, references_, path13, value);
6752
+ return yield* FromUnknown3(schema_, references_, path14, value);
6753
6753
  case "Void":
6754
- return yield* FromVoid3(schema_, references_, path13, value);
6754
+ return yield* FromVoid3(schema_, references_, path14, value);
6755
6755
  default:
6756
6756
  if (!type_exports2.Has(schema_[Kind]))
6757
6757
  throw new ValueErrorsUnknownTypeError(schema);
6758
- return yield* FromKind2(schema_, references_, path13, value);
6758
+ return yield* FromKind2(schema_, references_, path14, value);
6759
6759
  }
6760
6760
  }
6761
6761
  function Errors(...args) {
@@ -7797,58 +7797,58 @@ var TransformDecodeCheckError = class extends TypeBoxError {
7797
7797
  }
7798
7798
  };
7799
7799
  var TransformDecodeError = class extends TypeBoxError {
7800
- constructor(schema, path13, value, error) {
7800
+ constructor(schema, path14, value, error) {
7801
7801
  super(error instanceof Error ? error.message : "Unknown error");
7802
7802
  this.schema = schema;
7803
- this.path = path13;
7803
+ this.path = path14;
7804
7804
  this.value = value;
7805
7805
  this.error = error;
7806
7806
  }
7807
7807
  };
7808
- function Default3(schema, path13, value) {
7808
+ function Default3(schema, path14, value) {
7809
7809
  try {
7810
7810
  return IsTransform(schema) ? schema[TransformKind].Decode(value) : value;
7811
7811
  } catch (error) {
7812
- throw new TransformDecodeError(schema, path13, value, error);
7812
+ throw new TransformDecodeError(schema, path14, value, error);
7813
7813
  }
7814
7814
  }
7815
- function FromArray14(schema, references, path13, value) {
7816
- return IsArray2(value) ? Default3(schema, path13, value.map((value2, index) => Visit11(schema.items, references, `${path13}/${index}`, value2))) : Default3(schema, path13, value);
7815
+ function FromArray14(schema, references, path14, value) {
7816
+ return IsArray2(value) ? Default3(schema, path14, value.map((value2, index) => Visit11(schema.items, references, `${path14}/${index}`, value2))) : Default3(schema, path14, value);
7817
7817
  }
7818
- function FromIntersect15(schema, references, path13, value) {
7818
+ function FromIntersect15(schema, references, path14, value) {
7819
7819
  if (!IsObject2(value) || IsValueType(value))
7820
- return Default3(schema, path13, value);
7820
+ return Default3(schema, path14, value);
7821
7821
  const knownEntries = KeyOfPropertyEntries(schema);
7822
7822
  const knownKeys = knownEntries.map((entry) => entry[0]);
7823
7823
  const knownProperties = { ...value };
7824
7824
  for (const [knownKey, knownSchema] of knownEntries)
7825
7825
  if (knownKey in knownProperties) {
7826
- knownProperties[knownKey] = Visit11(knownSchema, references, `${path13}/${knownKey}`, knownProperties[knownKey]);
7826
+ knownProperties[knownKey] = Visit11(knownSchema, references, `${path14}/${knownKey}`, knownProperties[knownKey]);
7827
7827
  }
7828
7828
  if (!IsTransform(schema.unevaluatedProperties)) {
7829
- return Default3(schema, path13, knownProperties);
7829
+ return Default3(schema, path14, knownProperties);
7830
7830
  }
7831
7831
  const unknownKeys = Object.getOwnPropertyNames(knownProperties);
7832
7832
  const unevaluatedProperties = schema.unevaluatedProperties;
7833
7833
  const unknownProperties = { ...knownProperties };
7834
7834
  for (const key of unknownKeys)
7835
7835
  if (!knownKeys.includes(key)) {
7836
- unknownProperties[key] = Default3(unevaluatedProperties, `${path13}/${key}`, unknownProperties[key]);
7836
+ unknownProperties[key] = Default3(unevaluatedProperties, `${path14}/${key}`, unknownProperties[key]);
7837
7837
  }
7838
- return Default3(schema, path13, unknownProperties);
7838
+ return Default3(schema, path14, unknownProperties);
7839
7839
  }
7840
- function FromImport7(schema, references, path13, value) {
7840
+ function FromImport7(schema, references, path14, value) {
7841
7841
  const additional = globalThis.Object.values(schema.$defs);
7842
7842
  const target = schema.$defs[schema.$ref];
7843
- const result = Visit11(target, [...references, ...additional], path13, value);
7844
- return Default3(schema, path13, result);
7843
+ const result = Visit11(target, [...references, ...additional], path14, value);
7844
+ return Default3(schema, path14, result);
7845
7845
  }
7846
- function FromNot5(schema, references, path13, value) {
7847
- return Default3(schema, path13, Visit11(schema.not, references, path13, value));
7846
+ function FromNot5(schema, references, path14, value) {
7847
+ return Default3(schema, path14, Visit11(schema.not, references, path14, value));
7848
7848
  }
7849
- function FromObject15(schema, references, path13, value) {
7849
+ function FromObject15(schema, references, path14, value) {
7850
7850
  if (!IsObject2(value))
7851
- return Default3(schema, path13, value);
7851
+ return Default3(schema, path14, value);
7852
7852
  const knownKeys = KeyOfPropertyKeys(schema);
7853
7853
  const knownProperties = { ...value };
7854
7854
  for (const key of knownKeys) {
@@ -7856,90 +7856,90 @@ function FromObject15(schema, references, path13, value) {
7856
7856
  continue;
7857
7857
  if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
7858
7858
  continue;
7859
- knownProperties[key] = Visit11(schema.properties[key], references, `${path13}/${key}`, knownProperties[key]);
7859
+ knownProperties[key] = Visit11(schema.properties[key], references, `${path14}/${key}`, knownProperties[key]);
7860
7860
  }
7861
7861
  if (!IsSchema(schema.additionalProperties)) {
7862
- return Default3(schema, path13, knownProperties);
7862
+ return Default3(schema, path14, knownProperties);
7863
7863
  }
7864
7864
  const unknownKeys = Object.getOwnPropertyNames(knownProperties);
7865
7865
  const additionalProperties = schema.additionalProperties;
7866
7866
  const unknownProperties = { ...knownProperties };
7867
7867
  for (const key of unknownKeys)
7868
7868
  if (!knownKeys.includes(key)) {
7869
- unknownProperties[key] = Default3(additionalProperties, `${path13}/${key}`, unknownProperties[key]);
7869
+ unknownProperties[key] = Default3(additionalProperties, `${path14}/${key}`, unknownProperties[key]);
7870
7870
  }
7871
- return Default3(schema, path13, unknownProperties);
7871
+ return Default3(schema, path14, unknownProperties);
7872
7872
  }
7873
- function FromRecord10(schema, references, path13, value) {
7873
+ function FromRecord10(schema, references, path14, value) {
7874
7874
  if (!IsObject2(value))
7875
- return Default3(schema, path13, value);
7875
+ return Default3(schema, path14, value);
7876
7876
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
7877
7877
  const knownKeys = new RegExp(pattern);
7878
7878
  const knownProperties = { ...value };
7879
7879
  for (const key of Object.getOwnPropertyNames(value))
7880
7880
  if (knownKeys.test(key)) {
7881
- knownProperties[key] = Visit11(schema.patternProperties[pattern], references, `${path13}/${key}`, knownProperties[key]);
7881
+ knownProperties[key] = Visit11(schema.patternProperties[pattern], references, `${path14}/${key}`, knownProperties[key]);
7882
7882
  }
7883
7883
  if (!IsSchema(schema.additionalProperties)) {
7884
- return Default3(schema, path13, knownProperties);
7884
+ return Default3(schema, path14, knownProperties);
7885
7885
  }
7886
7886
  const unknownKeys = Object.getOwnPropertyNames(knownProperties);
7887
7887
  const additionalProperties = schema.additionalProperties;
7888
7888
  const unknownProperties = { ...knownProperties };
7889
7889
  for (const key of unknownKeys)
7890
7890
  if (!knownKeys.test(key)) {
7891
- unknownProperties[key] = Default3(additionalProperties, `${path13}/${key}`, unknownProperties[key]);
7891
+ unknownProperties[key] = Default3(additionalProperties, `${path14}/${key}`, unknownProperties[key]);
7892
7892
  }
7893
- return Default3(schema, path13, unknownProperties);
7893
+ return Default3(schema, path14, unknownProperties);
7894
7894
  }
7895
- function FromRef11(schema, references, path13, value) {
7895
+ function FromRef11(schema, references, path14, value) {
7896
7896
  const target = Deref(schema, references);
7897
- return Default3(schema, path13, Visit11(target, references, path13, value));
7897
+ return Default3(schema, path14, Visit11(target, references, path14, value));
7898
7898
  }
7899
- function FromThis7(schema, references, path13, value) {
7899
+ function FromThis7(schema, references, path14, value) {
7900
7900
  const target = Deref(schema, references);
7901
- return Default3(schema, path13, Visit11(target, references, path13, value));
7901
+ return Default3(schema, path14, Visit11(target, references, path14, value));
7902
7902
  }
7903
- function FromTuple12(schema, references, path13, value) {
7904
- return IsArray2(value) && IsArray2(schema.items) ? Default3(schema, path13, schema.items.map((schema2, index) => Visit11(schema2, references, `${path13}/${index}`, value[index]))) : Default3(schema, path13, value);
7903
+ function FromTuple12(schema, references, path14, value) {
7904
+ return IsArray2(value) && IsArray2(schema.items) ? Default3(schema, path14, schema.items.map((schema2, index) => Visit11(schema2, references, `${path14}/${index}`, value[index]))) : Default3(schema, path14, value);
7905
7905
  }
7906
- function FromUnion17(schema, references, path13, value) {
7906
+ function FromUnion17(schema, references, path14, value) {
7907
7907
  for (const subschema of schema.anyOf) {
7908
7908
  if (!Check(subschema, references, value))
7909
7909
  continue;
7910
- const decoded = Visit11(subschema, references, path13, value);
7911
- return Default3(schema, path13, decoded);
7910
+ const decoded = Visit11(subschema, references, path14, value);
7911
+ return Default3(schema, path14, decoded);
7912
7912
  }
7913
- return Default3(schema, path13, value);
7913
+ return Default3(schema, path14, value);
7914
7914
  }
7915
- function Visit11(schema, references, path13, value) {
7915
+ function Visit11(schema, references, path14, value) {
7916
7916
  const references_ = Pushref(schema, references);
7917
7917
  const schema_ = schema;
7918
7918
  switch (schema[Kind]) {
7919
7919
  case "Array":
7920
- return FromArray14(schema_, references_, path13, value);
7920
+ return FromArray14(schema_, references_, path14, value);
7921
7921
  case "Import":
7922
- return FromImport7(schema_, references_, path13, value);
7922
+ return FromImport7(schema_, references_, path14, value);
7923
7923
  case "Intersect":
7924
- return FromIntersect15(schema_, references_, path13, value);
7924
+ return FromIntersect15(schema_, references_, path14, value);
7925
7925
  case "Not":
7926
- return FromNot5(schema_, references_, path13, value);
7926
+ return FromNot5(schema_, references_, path14, value);
7927
7927
  case "Object":
7928
- return FromObject15(schema_, references_, path13, value);
7928
+ return FromObject15(schema_, references_, path14, value);
7929
7929
  case "Record":
7930
- return FromRecord10(schema_, references_, path13, value);
7930
+ return FromRecord10(schema_, references_, path14, value);
7931
7931
  case "Ref":
7932
- return FromRef11(schema_, references_, path13, value);
7932
+ return FromRef11(schema_, references_, path14, value);
7933
7933
  case "Symbol":
7934
- return Default3(schema_, path13, value);
7934
+ return Default3(schema_, path14, value);
7935
7935
  case "This":
7936
- return FromThis7(schema_, references_, path13, value);
7936
+ return FromThis7(schema_, references_, path14, value);
7937
7937
  case "Tuple":
7938
- return FromTuple12(schema_, references_, path13, value);
7938
+ return FromTuple12(schema_, references_, path14, value);
7939
7939
  case "Union":
7940
- return FromUnion17(schema_, references_, path13, value);
7940
+ return FromUnion17(schema_, references_, path14, value);
7941
7941
  default:
7942
- return Default3(schema_, path13, value);
7942
+ return Default3(schema_, path14, value);
7943
7943
  }
7944
7944
  }
7945
7945
  function TransformDecode(schema, references, value) {
@@ -7956,33 +7956,33 @@ var TransformEncodeCheckError = class extends TypeBoxError {
7956
7956
  }
7957
7957
  };
7958
7958
  var TransformEncodeError = class extends TypeBoxError {
7959
- constructor(schema, path13, value, error) {
7959
+ constructor(schema, path14, value, error) {
7960
7960
  super(`${error instanceof Error ? error.message : "Unknown error"}`);
7961
7961
  this.schema = schema;
7962
- this.path = path13;
7962
+ this.path = path14;
7963
7963
  this.value = value;
7964
7964
  this.error = error;
7965
7965
  }
7966
7966
  };
7967
- function Default4(schema, path13, value) {
7967
+ function Default4(schema, path14, value) {
7968
7968
  try {
7969
7969
  return IsTransform(schema) ? schema[TransformKind].Encode(value) : value;
7970
7970
  } catch (error) {
7971
- throw new TransformEncodeError(schema, path13, value, error);
7971
+ throw new TransformEncodeError(schema, path14, value, error);
7972
7972
  }
7973
7973
  }
7974
- function FromArray15(schema, references, path13, value) {
7975
- const defaulted = Default4(schema, path13, value);
7976
- return IsArray2(defaulted) ? defaulted.map((value2, index) => Visit12(schema.items, references, `${path13}/${index}`, value2)) : defaulted;
7974
+ function FromArray15(schema, references, path14, value) {
7975
+ const defaulted = Default4(schema, path14, value);
7976
+ return IsArray2(defaulted) ? defaulted.map((value2, index) => Visit12(schema.items, references, `${path14}/${index}`, value2)) : defaulted;
7977
7977
  }
7978
- function FromImport8(schema, references, path13, value) {
7978
+ function FromImport8(schema, references, path14, value) {
7979
7979
  const additional = globalThis.Object.values(schema.$defs);
7980
7980
  const target = schema.$defs[schema.$ref];
7981
- const result = Default4(schema, path13, value);
7982
- return Visit12(target, [...references, ...additional], path13, result);
7981
+ const result = Default4(schema, path14, value);
7982
+ return Visit12(target, [...references, ...additional], path14, result);
7983
7983
  }
7984
- function FromIntersect16(schema, references, path13, value) {
7985
- const defaulted = Default4(schema, path13, value);
7984
+ function FromIntersect16(schema, references, path14, value) {
7985
+ const defaulted = Default4(schema, path14, value);
7986
7986
  if (!IsObject2(value) || IsValueType(value))
7987
7987
  return defaulted;
7988
7988
  const knownEntries = KeyOfPropertyEntries(schema);
@@ -7990,7 +7990,7 @@ function FromIntersect16(schema, references, path13, value) {
7990
7990
  const knownProperties = { ...defaulted };
7991
7991
  for (const [knownKey, knownSchema] of knownEntries)
7992
7992
  if (knownKey in knownProperties) {
7993
- knownProperties[knownKey] = Visit12(knownSchema, references, `${path13}/${knownKey}`, knownProperties[knownKey]);
7993
+ knownProperties[knownKey] = Visit12(knownSchema, references, `${path14}/${knownKey}`, knownProperties[knownKey]);
7994
7994
  }
7995
7995
  if (!IsTransform(schema.unevaluatedProperties)) {
7996
7996
  return knownProperties;
@@ -8000,15 +8000,15 @@ function FromIntersect16(schema, references, path13, value) {
8000
8000
  const properties = { ...knownProperties };
8001
8001
  for (const key of unknownKeys)
8002
8002
  if (!knownKeys.includes(key)) {
8003
- properties[key] = Default4(unevaluatedProperties, `${path13}/${key}`, properties[key]);
8003
+ properties[key] = Default4(unevaluatedProperties, `${path14}/${key}`, properties[key]);
8004
8004
  }
8005
8005
  return properties;
8006
8006
  }
8007
- function FromNot6(schema, references, path13, value) {
8008
- return Default4(schema.not, path13, Default4(schema, path13, value));
8007
+ function FromNot6(schema, references, path14, value) {
8008
+ return Default4(schema.not, path14, Default4(schema, path14, value));
8009
8009
  }
8010
- function FromObject16(schema, references, path13, value) {
8011
- const defaulted = Default4(schema, path13, value);
8010
+ function FromObject16(schema, references, path14, value) {
8011
+ const defaulted = Default4(schema, path14, value);
8012
8012
  if (!IsObject2(defaulted))
8013
8013
  return defaulted;
8014
8014
  const knownKeys = KeyOfPropertyKeys(schema);
@@ -8018,7 +8018,7 @@ function FromObject16(schema, references, path13, value) {
8018
8018
  continue;
8019
8019
  if (IsUndefined2(knownProperties[key]) && (!IsUndefined3(schema.properties[key]) || TypeSystemPolicy.IsExactOptionalProperty(knownProperties, key)))
8020
8020
  continue;
8021
- knownProperties[key] = Visit12(schema.properties[key], references, `${path13}/${key}`, knownProperties[key]);
8021
+ knownProperties[key] = Visit12(schema.properties[key], references, `${path14}/${key}`, knownProperties[key]);
8022
8022
  }
8023
8023
  if (!IsSchema(schema.additionalProperties)) {
8024
8024
  return knownProperties;
@@ -8028,12 +8028,12 @@ function FromObject16(schema, references, path13, value) {
8028
8028
  const properties = { ...knownProperties };
8029
8029
  for (const key of unknownKeys)
8030
8030
  if (!knownKeys.includes(key)) {
8031
- properties[key] = Default4(additionalProperties, `${path13}/${key}`, properties[key]);
8031
+ properties[key] = Default4(additionalProperties, `${path14}/${key}`, properties[key]);
8032
8032
  }
8033
8033
  return properties;
8034
8034
  }
8035
- function FromRecord11(schema, references, path13, value) {
8036
- const defaulted = Default4(schema, path13, value);
8035
+ function FromRecord11(schema, references, path14, value) {
8036
+ const defaulted = Default4(schema, path14, value);
8037
8037
  if (!IsObject2(value))
8038
8038
  return defaulted;
8039
8039
  const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
@@ -8041,7 +8041,7 @@ function FromRecord11(schema, references, path13, value) {
8041
8041
  const knownProperties = { ...defaulted };
8042
8042
  for (const key of Object.getOwnPropertyNames(value))
8043
8043
  if (knownKeys.test(key)) {
8044
- knownProperties[key] = Visit12(schema.patternProperties[pattern], references, `${path13}/${key}`, knownProperties[key]);
8044
+ knownProperties[key] = Visit12(schema.patternProperties[pattern], references, `${path14}/${key}`, knownProperties[key]);
8045
8045
  }
8046
8046
  if (!IsSchema(schema.additionalProperties)) {
8047
8047
  return knownProperties;
@@ -8051,65 +8051,65 @@ function FromRecord11(schema, references, path13, value) {
8051
8051
  const properties = { ...knownProperties };
8052
8052
  for (const key of unknownKeys)
8053
8053
  if (!knownKeys.test(key)) {
8054
- properties[key] = Default4(additionalProperties, `${path13}/${key}`, properties[key]);
8054
+ properties[key] = Default4(additionalProperties, `${path14}/${key}`, properties[key]);
8055
8055
  }
8056
8056
  return properties;
8057
8057
  }
8058
- function FromRef12(schema, references, path13, value) {
8058
+ function FromRef12(schema, references, path14, value) {
8059
8059
  const target = Deref(schema, references);
8060
- const resolved = Visit12(target, references, path13, value);
8061
- return Default4(schema, path13, resolved);
8060
+ const resolved = Visit12(target, references, path14, value);
8061
+ return Default4(schema, path14, resolved);
8062
8062
  }
8063
- function FromThis8(schema, references, path13, value) {
8063
+ function FromThis8(schema, references, path14, value) {
8064
8064
  const target = Deref(schema, references);
8065
- const resolved = Visit12(target, references, path13, value);
8066
- return Default4(schema, path13, resolved);
8065
+ const resolved = Visit12(target, references, path14, value);
8066
+ return Default4(schema, path14, resolved);
8067
8067
  }
8068
- function FromTuple13(schema, references, path13, value) {
8069
- const value1 = Default4(schema, path13, value);
8070
- return IsArray2(schema.items) ? schema.items.map((schema2, index) => Visit12(schema2, references, `${path13}/${index}`, value1[index])) : [];
8068
+ function FromTuple13(schema, references, path14, value) {
8069
+ const value1 = Default4(schema, path14, value);
8070
+ return IsArray2(schema.items) ? schema.items.map((schema2, index) => Visit12(schema2, references, `${path14}/${index}`, value1[index])) : [];
8071
8071
  }
8072
- function FromUnion18(schema, references, path13, value) {
8072
+ function FromUnion18(schema, references, path14, value) {
8073
8073
  for (const subschema of schema.anyOf) {
8074
8074
  if (!Check(subschema, references, value))
8075
8075
  continue;
8076
- const value1 = Visit12(subschema, references, path13, value);
8077
- return Default4(schema, path13, value1);
8076
+ const value1 = Visit12(subschema, references, path14, value);
8077
+ return Default4(schema, path14, value1);
8078
8078
  }
8079
8079
  for (const subschema of schema.anyOf) {
8080
- const value1 = Visit12(subschema, references, path13, value);
8080
+ const value1 = Visit12(subschema, references, path14, value);
8081
8081
  if (!Check(schema, references, value1))
8082
8082
  continue;
8083
- return Default4(schema, path13, value1);
8083
+ return Default4(schema, path14, value1);
8084
8084
  }
8085
- return Default4(schema, path13, value);
8085
+ return Default4(schema, path14, value);
8086
8086
  }
8087
- function Visit12(schema, references, path13, value) {
8087
+ function Visit12(schema, references, path14, value) {
8088
8088
  const references_ = Pushref(schema, references);
8089
8089
  const schema_ = schema;
8090
8090
  switch (schema[Kind]) {
8091
8091
  case "Array":
8092
- return FromArray15(schema_, references_, path13, value);
8092
+ return FromArray15(schema_, references_, path14, value);
8093
8093
  case "Import":
8094
- return FromImport8(schema_, references_, path13, value);
8094
+ return FromImport8(schema_, references_, path14, value);
8095
8095
  case "Intersect":
8096
- return FromIntersect16(schema_, references_, path13, value);
8096
+ return FromIntersect16(schema_, references_, path14, value);
8097
8097
  case "Not":
8098
- return FromNot6(schema_, references_, path13, value);
8098
+ return FromNot6(schema_, references_, path14, value);
8099
8099
  case "Object":
8100
- return FromObject16(schema_, references_, path13, value);
8100
+ return FromObject16(schema_, references_, path14, value);
8101
8101
  case "Record":
8102
- return FromRecord11(schema_, references_, path13, value);
8102
+ return FromRecord11(schema_, references_, path14, value);
8103
8103
  case "Ref":
8104
- return FromRef12(schema_, references_, path13, value);
8104
+ return FromRef12(schema_, references_, path14, value);
8105
8105
  case "This":
8106
- return FromThis8(schema_, references_, path13, value);
8106
+ return FromThis8(schema_, references_, path14, value);
8107
8107
  case "Tuple":
8108
- return FromTuple13(schema_, references_, path13, value);
8108
+ return FromTuple13(schema_, references_, path14, value);
8109
8109
  case "Union":
8110
- return FromUnion18(schema_, references_, path13, value);
8110
+ return FromUnion18(schema_, references_, path14, value);
8111
8111
  default:
8112
- return Default4(schema_, path13, value);
8112
+ return Default4(schema_, path14, value);
8113
8113
  }
8114
8114
  }
8115
8115
  function TransformEncode(schema, references, value) {
@@ -8377,18 +8377,18 @@ __export(pointer_exports, {
8377
8377
  ValuePointerRootSetError: () => ValuePointerRootSetError
8378
8378
  });
8379
8379
  var ValuePointerRootSetError = class extends TypeBoxError {
8380
- constructor(value, path13, update) {
8380
+ constructor(value, path14, update) {
8381
8381
  super("Cannot set root value");
8382
8382
  this.value = value;
8383
- this.path = path13;
8383
+ this.path = path14;
8384
8384
  this.update = update;
8385
8385
  }
8386
8386
  };
8387
8387
  var ValuePointerRootDeleteError = class extends TypeBoxError {
8388
- constructor(value, path13) {
8388
+ constructor(value, path14) {
8389
8389
  super("Cannot delete root value");
8390
8390
  this.value = value;
8391
- this.path = path13;
8391
+ this.path = path14;
8392
8392
  }
8393
8393
  };
8394
8394
  function Escape2(component) {
@@ -8532,82 +8532,82 @@ var ValueDiffError = class extends TypeBoxError {
8532
8532
  this.value = value;
8533
8533
  }
8534
8534
  };
8535
- function CreateUpdate(path13, value) {
8536
- return { type: "update", path: path13, value };
8535
+ function CreateUpdate(path14, value) {
8536
+ return { type: "update", path: path14, value };
8537
8537
  }
8538
- function CreateInsert(path13, value) {
8539
- return { type: "insert", path: path13, value };
8538
+ function CreateInsert(path14, value) {
8539
+ return { type: "insert", path: path14, value };
8540
8540
  }
8541
- function CreateDelete(path13) {
8542
- return { type: "delete", path: path13 };
8541
+ function CreateDelete(path14) {
8542
+ return { type: "delete", path: path14 };
8543
8543
  }
8544
8544
  function AssertDiffable(value) {
8545
8545
  if (globalThis.Object.getOwnPropertySymbols(value).length > 0)
8546
8546
  throw new ValueDiffError(value, "Cannot diff objects with symbols");
8547
8547
  }
8548
- function* ObjectType4(path13, current, next) {
8548
+ function* ObjectType4(path14, current, next) {
8549
8549
  AssertDiffable(current);
8550
8550
  AssertDiffable(next);
8551
8551
  if (!IsStandardObject(next))
8552
- return yield CreateUpdate(path13, next);
8552
+ return yield CreateUpdate(path14, next);
8553
8553
  const currentKeys = globalThis.Object.getOwnPropertyNames(current);
8554
8554
  const nextKeys = globalThis.Object.getOwnPropertyNames(next);
8555
8555
  for (const key of nextKeys) {
8556
8556
  if (HasPropertyKey2(current, key))
8557
8557
  continue;
8558
- yield CreateInsert(`${path13}/${key}`, next[key]);
8558
+ yield CreateInsert(`${path14}/${key}`, next[key]);
8559
8559
  }
8560
8560
  for (const key of currentKeys) {
8561
8561
  if (!HasPropertyKey2(next, key))
8562
8562
  continue;
8563
8563
  if (Equal(current, next))
8564
8564
  continue;
8565
- yield* Visit15(`${path13}/${key}`, current[key], next[key]);
8565
+ yield* Visit15(`${path14}/${key}`, current[key], next[key]);
8566
8566
  }
8567
8567
  for (const key of currentKeys) {
8568
8568
  if (HasPropertyKey2(next, key))
8569
8569
  continue;
8570
- yield CreateDelete(`${path13}/${key}`);
8570
+ yield CreateDelete(`${path14}/${key}`);
8571
8571
  }
8572
8572
  }
8573
- function* ArrayType4(path13, current, next) {
8573
+ function* ArrayType4(path14, current, next) {
8574
8574
  if (!IsArray2(next))
8575
- return yield CreateUpdate(path13, next);
8575
+ return yield CreateUpdate(path14, next);
8576
8576
  for (let i = 0; i < Math.min(current.length, next.length); i++) {
8577
- yield* Visit15(`${path13}/${i}`, current[i], next[i]);
8577
+ yield* Visit15(`${path14}/${i}`, current[i], next[i]);
8578
8578
  }
8579
8579
  for (let i = 0; i < next.length; i++) {
8580
8580
  if (i < current.length)
8581
8581
  continue;
8582
- yield CreateInsert(`${path13}/${i}`, next[i]);
8582
+ yield CreateInsert(`${path14}/${i}`, next[i]);
8583
8583
  }
8584
8584
  for (let i = current.length - 1; i >= 0; i--) {
8585
8585
  if (i < next.length)
8586
8586
  continue;
8587
- yield CreateDelete(`${path13}/${i}`);
8587
+ yield CreateDelete(`${path14}/${i}`);
8588
8588
  }
8589
8589
  }
8590
- function* TypedArrayType2(path13, current, next) {
8590
+ function* TypedArrayType2(path14, current, next) {
8591
8591
  if (!IsTypedArray(next) || current.length !== next.length || globalThis.Object.getPrototypeOf(current).constructor.name !== globalThis.Object.getPrototypeOf(next).constructor.name)
8592
- return yield CreateUpdate(path13, next);
8592
+ return yield CreateUpdate(path14, next);
8593
8593
  for (let i = 0; i < Math.min(current.length, next.length); i++) {
8594
- yield* Visit15(`${path13}/${i}`, current[i], next[i]);
8594
+ yield* Visit15(`${path14}/${i}`, current[i], next[i]);
8595
8595
  }
8596
8596
  }
8597
- function* ValueType2(path13, current, next) {
8597
+ function* ValueType2(path14, current, next) {
8598
8598
  if (current === next)
8599
8599
  return;
8600
- yield CreateUpdate(path13, next);
8600
+ yield CreateUpdate(path14, next);
8601
8601
  }
8602
- function* Visit15(path13, current, next) {
8602
+ function* Visit15(path14, current, next) {
8603
8603
  if (IsStandardObject(current))
8604
- return yield* ObjectType4(path13, current, next);
8604
+ return yield* ObjectType4(path14, current, next);
8605
8605
  if (IsArray2(current))
8606
- return yield* ArrayType4(path13, current, next);
8606
+ return yield* ArrayType4(path14, current, next);
8607
8607
  if (IsTypedArray(current))
8608
- return yield* TypedArrayType2(path13, current, next);
8608
+ return yield* TypedArrayType2(path14, current, next);
8609
8609
  if (IsValueType(current))
8610
- return yield* ValueType2(path13, current, next);
8610
+ return yield* ValueType2(path14, current, next);
8611
8611
  throw new ValueDiffError(current, "Unable to diff value");
8612
8612
  }
8613
8613
  function Diff(current, next) {
@@ -8664,9 +8664,9 @@ var ValueMutateError = class extends TypeBoxError {
8664
8664
  super(message);
8665
8665
  }
8666
8666
  };
8667
- function ObjectType5(root, path13, current, next) {
8667
+ function ObjectType5(root, path14, current, next) {
8668
8668
  if (!IsStandardObject2(current)) {
8669
- pointer_exports.Set(root, path13, Clone2(next));
8669
+ pointer_exports.Set(root, path14, Clone2(next));
8670
8670
  } else {
8671
8671
  const currentKeys = Object.getOwnPropertyNames(current);
8672
8672
  const nextKeys = Object.getOwnPropertyNames(next);
@@ -8681,43 +8681,43 @@ function ObjectType5(root, path13, current, next) {
8681
8681
  }
8682
8682
  }
8683
8683
  for (const nextKey of nextKeys) {
8684
- Visit16(root, `${path13}/${nextKey}`, current[nextKey], next[nextKey]);
8684
+ Visit16(root, `${path14}/${nextKey}`, current[nextKey], next[nextKey]);
8685
8685
  }
8686
8686
  }
8687
8687
  }
8688
- function ArrayType5(root, path13, current, next) {
8688
+ function ArrayType5(root, path14, current, next) {
8689
8689
  if (!IsArray2(current)) {
8690
- pointer_exports.Set(root, path13, Clone2(next));
8690
+ pointer_exports.Set(root, path14, Clone2(next));
8691
8691
  } else {
8692
8692
  for (let index = 0; index < next.length; index++) {
8693
- Visit16(root, `${path13}/${index}`, current[index], next[index]);
8693
+ Visit16(root, `${path14}/${index}`, current[index], next[index]);
8694
8694
  }
8695
8695
  current.splice(next.length);
8696
8696
  }
8697
8697
  }
8698
- function TypedArrayType3(root, path13, current, next) {
8698
+ function TypedArrayType3(root, path14, current, next) {
8699
8699
  if (IsTypedArray(current) && current.length === next.length) {
8700
8700
  for (let i = 0; i < current.length; i++) {
8701
8701
  current[i] = next[i];
8702
8702
  }
8703
8703
  } else {
8704
- pointer_exports.Set(root, path13, Clone2(next));
8704
+ pointer_exports.Set(root, path14, Clone2(next));
8705
8705
  }
8706
8706
  }
8707
- function ValueType3(root, path13, current, next) {
8707
+ function ValueType3(root, path14, current, next) {
8708
8708
  if (current === next)
8709
8709
  return;
8710
- pointer_exports.Set(root, path13, next);
8710
+ pointer_exports.Set(root, path14, next);
8711
8711
  }
8712
- function Visit16(root, path13, current, next) {
8712
+ function Visit16(root, path14, current, next) {
8713
8713
  if (IsArray2(next))
8714
- return ArrayType5(root, path13, current, next);
8714
+ return ArrayType5(root, path14, current, next);
8715
8715
  if (IsTypedArray(next))
8716
- return TypedArrayType3(root, path13, current, next);
8716
+ return TypedArrayType3(root, path14, current, next);
8717
8717
  if (IsStandardObject2(next))
8718
- return ObjectType5(root, path13, current, next);
8718
+ return ObjectType5(root, path14, current, next);
8719
8719
  if (IsValueType(next))
8720
- return ValueType3(root, path13, current, next);
8720
+ return ValueType3(root, path14, current, next);
8721
8721
  }
8722
8722
  function IsNonMutableValue(value) {
8723
8723
  return IsTypedArray(value) || IsValueType(value);
@@ -8815,8 +8815,8 @@ __export(value_exports2, {
8815
8815
  });
8816
8816
 
8817
8817
  // src/lib/types.ts
8818
- var CURRENT_REGISTRY_VERSION = 2;
8819
- var CAPSULE_VERSION = 1;
8818
+ var CURRENT_REGISTRY_VERSION = 3;
8819
+ var CAPSULE_VERSION = 2;
8820
8820
  var MAX_POST_ERROR_LENGTH = 500;
8821
8821
  var MAX_NAME_LENGTH = 100;
8822
8822
  var DOCTOR_ALL_COOLDOWN_MS = 60 * 60 * 1e3;
@@ -8861,6 +8861,7 @@ var RegistrySchema = Type.Object({
8861
8861
  topicManagerAdmins: Type.Array(Type.String()),
8862
8862
  callbackSecret: Type.String(),
8863
8863
  lastDoctorAllRunAt: Type.Union([Type.String(), Type.Null()]),
8864
+ autopilotEnabled: Type.Boolean(),
8864
8865
  maxTopics: Type.Integer({ minimum: 1 }),
8865
8866
  topics: Type.Record(Type.String(), TopicEntrySchema)
8866
8867
  });
@@ -8877,7 +8878,8 @@ var BASE_FILES = [
8877
8878
  "COMMANDS.md",
8878
8879
  "LINKS.md",
8879
8880
  "CRON.md",
8880
- "NOTES.md"
8881
+ "NOTES.md",
8882
+ "LEARNINGS.md"
8881
8883
  ];
8882
8884
  function topicKey(groupId, threadId) {
8883
8885
  return `${groupId}:${threadId}`;
@@ -8908,6 +8910,12 @@ var migrations = {
8908
8910
  }
8909
8911
  }
8910
8912
  return data;
8913
+ },
8914
+ "2_to_3": (data) => {
8915
+ if (data["autopilotEnabled"] === void 0) {
8916
+ data["autopilotEnabled"] = false;
8917
+ }
8918
+ return data;
8911
8919
  }
8912
8920
  };
8913
8921
  function migrateRegistry(data) {
@@ -9055,21 +9063,21 @@ function validateGroupId(id) {
9055
9063
  function validateThreadId(id) {
9056
9064
  return THREAD_ID_RE.test(id);
9057
9065
  }
9058
- var CALLBACK_RE = /^tm:[a-z0-9]+:-?\d+:\d+:[a-f0-9]+$/;
9059
- function buildCallbackData(action, groupId, threadId, secret) {
9060
- const payload = `tm:${action}:${groupId}:${threadId}`;
9066
+ var CALLBACK_RE = /^tm:[a-z0-9]+:-?\d+:\d+:\d+:[a-f0-9]+$/;
9067
+ function buildCallbackData(action, groupId, threadId, secret, userId) {
9068
+ const payload = `tm:${action}:${groupId}:${threadId}:${userId}`;
9061
9069
  const sig = hmacSign(secret, payload);
9062
9070
  return `${payload}:${sig}`;
9063
9071
  }
9064
9072
  function parseAndVerifyCallback(data, secret, contextGroupId, contextThreadId) {
9065
9073
  if (!CALLBACK_RE.test(data)) return null;
9066
9074
  const parts = data.split(":");
9067
- if (parts.length !== 5) return null;
9068
- const [, action, groupId, threadId, signature] = parts;
9075
+ if (parts.length !== 6) return null;
9076
+ const [, action, groupId, threadId, userId, signature] = parts;
9069
9077
  if (groupId !== contextGroupId || threadId !== contextThreadId) return null;
9070
- const payload = `tm:${action}:${groupId}:${threadId}`;
9078
+ const payload = `tm:${action}:${groupId}:${threadId}:${userId}`;
9071
9079
  if (!hmacVerify(secret, payload, signature)) return null;
9072
- return { action, groupId, threadId };
9080
+ return { action, groupId, threadId, userId };
9073
9081
  }
9074
9082
 
9075
9083
  // src/lib/audit.ts
@@ -9098,62 +9106,6 @@ function buildAuditEntry(userId, cmd, slug, detail) {
9098
9106
  };
9099
9107
  }
9100
9108
 
9101
- // src/commands/init.ts
9102
- import * as fs6 from "node:fs";
9103
- import * as path6 from "node:path";
9104
-
9105
- // src/lib/auth.ts
9106
- var AuthTier = {
9107
- User: "User",
9108
- Admin: "Admin"
9109
- };
9110
- var ADMIN_COMMANDS = /* @__PURE__ */ new Set([
9111
- "doctor --all",
9112
- "doctor-all",
9113
- "list",
9114
- "sync",
9115
- "rename",
9116
- "archive",
9117
- "unarchive"
9118
- ]);
9119
- var USER_COMMANDS = /* @__PURE__ */ new Set([
9120
- "init",
9121
- "doctor",
9122
- "status",
9123
- "help",
9124
- "upgrade",
9125
- "snooze"
9126
- ]);
9127
- function getCommandTier(command) {
9128
- const normalized = command.toLowerCase().trim();
9129
- if (USER_COMMANDS.has(normalized)) return AuthTier.User;
9130
- if (ADMIN_COMMANDS.has(normalized)) return AuthTier.Admin;
9131
- return AuthTier.Admin;
9132
- }
9133
- function checkAuthorization(userId, command, registry, topicAllowFrom) {
9134
- const tier = getCommandTier(command);
9135
- const admins = registry.topicManagerAdmins;
9136
- if (admins.length === 0 && tier === AuthTier.User) {
9137
- return { authorized: true };
9138
- }
9139
- const isAdmin = admins.includes(userId);
9140
- if (tier === AuthTier.Admin) {
9141
- if (isAdmin) return { authorized: true };
9142
- return {
9143
- authorized: false,
9144
- message: "Not authorized. Ask a telegram-manager admin to run this command."
9145
- };
9146
- }
9147
- if (isAdmin) return { authorized: true };
9148
- if (topicAllowFrom && topicAllowFrom.includes(userId)) {
9149
- return { authorized: true };
9150
- }
9151
- return {
9152
- authorized: false,
9153
- message: "Not authorized. Ask a telegram-manager admin to run this command."
9154
- };
9155
- }
9156
-
9157
9109
  // src/lib/capsule.ts
9158
9110
  import * as fs4 from "node:fs";
9159
9111
  import * as path4 from "node:path";
@@ -9164,25 +9116,27 @@ _Describe what this topic is about._
9164
9116
  `,
9165
9117
  "STATUS.md": (name) => `# Status: ${name}
9166
9118
 
9119
+ > This file is maintained by the agent \u2014 just send messages in the chat.
9120
+
9167
9121
  ## Last done (UTC)
9168
9122
 
9169
9123
  ${(/* @__PURE__ */ new Date()).toISOString()}
9170
9124
 
9171
- _No work recorded yet._
9125
+ _Waiting for first instructions._
9172
9126
 
9173
9127
  ## Next 3 actions
9174
9128
 
9175
- 1. [T-1] _Define first task in TODO.md_
9176
- 2. [T-2] _Define second task in TODO.md_
9177
- 3. [T-3] _Define third task in TODO.md_
9129
+ 1. [T-1] _e.g. Set up project scaffolding_
9130
+ 2. [T-2] _Waiting for next task_
9131
+ 3. [T-3] _Waiting for next task_
9178
9132
  `,
9179
9133
  "TODO.md": (name) => `# TODO: ${name}
9180
9134
 
9181
9135
  ## Backlog
9182
9136
 
9183
- - [T-1] _First task placeholder \u2014 replace with actual task_
9184
- - [T-2] _Second task placeholder \u2014 replace with actual task_
9185
- - [T-3] _Third task placeholder \u2014 replace with actual task_
9137
+ - [T-1] _e.g. Set up project scaffolding_
9138
+ - [T-2] _Waiting for next task_
9139
+ - [T-3] _Waiting for next task_
9186
9140
 
9187
9141
  ## Completed
9188
9142
 
@@ -9203,6 +9157,11 @@ _Cron job IDs and schedules for this topic._
9203
9157
  "NOTES.md": (name) => `# Notes: ${name}
9204
9158
 
9205
9159
  _Anything worth remembering about this topic._
9160
+ `,
9161
+ "LEARNINGS.md": (name) => `# Learnings: ${name}
9162
+
9163
+ _Hard-won insights, mistakes, and workarounds._
9164
+ _Agent prepends here automatically. Most recent entries first._
9206
9165
  `
9207
9166
  };
9208
9167
  var OVERLAY_TEMPLATES = {
@@ -9297,13 +9256,74 @@ function upgradeCapsule(projectsBase, slug, name, type, currentVersion) {
9297
9256
  };
9298
9257
  }
9299
9258
 
9259
+ // src/commands/init.ts
9260
+ import * as fs6 from "node:fs";
9261
+ import * as path6 from "node:path";
9262
+
9263
+ // src/lib/auth.ts
9264
+ var AuthTier = {
9265
+ User: "User",
9266
+ Admin: "Admin"
9267
+ };
9268
+ var ADMIN_COMMANDS = /* @__PURE__ */ new Set([
9269
+ "doctor --all",
9270
+ "doctor-all",
9271
+ "list",
9272
+ "sync",
9273
+ "rename",
9274
+ "archive",
9275
+ "unarchive",
9276
+ "autopilot"
9277
+ ]);
9278
+ var USER_COMMANDS = /* @__PURE__ */ new Set([
9279
+ "init",
9280
+ "doctor",
9281
+ "status",
9282
+ "help",
9283
+ "upgrade",
9284
+ "snooze"
9285
+ ]);
9286
+ function getCommandTier(command) {
9287
+ const normalized = command.toLowerCase().trim();
9288
+ if (USER_COMMANDS.has(normalized)) return AuthTier.User;
9289
+ if (ADMIN_COMMANDS.has(normalized)) return AuthTier.Admin;
9290
+ return AuthTier.Admin;
9291
+ }
9292
+ function checkAuthorization(userId, command, registry, topicAllowFrom) {
9293
+ const tier = getCommandTier(command);
9294
+ const admins = registry.topicManagerAdmins;
9295
+ if (admins.length === 0 && tier === AuthTier.User) {
9296
+ return { authorized: true };
9297
+ }
9298
+ const isAdmin = admins.includes(userId);
9299
+ if (tier === AuthTier.Admin) {
9300
+ if (isAdmin) return { authorized: true };
9301
+ return {
9302
+ authorized: false,
9303
+ message: "Not authorized. Ask a telegram-manager admin to run this command."
9304
+ };
9305
+ }
9306
+ if (isAdmin) return { authorized: true };
9307
+ if (topicAllowFrom && topicAllowFrom.includes(userId)) {
9308
+ return { authorized: true };
9309
+ }
9310
+ return {
9311
+ authorized: false,
9312
+ message: "Not authorized. Ask a telegram-manager admin to run this command."
9313
+ };
9314
+ }
9315
+
9300
9316
  // src/lib/telegram.ts
9301
9317
  var TELEGRAM_MSG_LIMIT = 4096;
9318
+ var DEFAULT_RATE_LIMIT = {
9319
+ sameGroupDelayMs: 4e3,
9320
+ crossGroupDelayMs: 1e3
9321
+ };
9302
9322
  function buildInlineKeyboard(rows) {
9303
9323
  return { inline_keyboard: rows };
9304
9324
  }
9305
- function buildDoctorButtons(groupId, threadId, secret) {
9306
- const cb = (action) => buildCallbackData(action, groupId, threadId, secret);
9325
+ function buildDoctorButtons(groupId, threadId, secret, userId) {
9326
+ const cb = (action) => buildCallbackData(action, groupId, threadId, secret, userId);
9307
9327
  return buildInlineKeyboard([
9308
9328
  [
9309
9329
  { text: "Fix", callback_data: cb("fix") },
@@ -9316,8 +9336,8 @@ function buildDoctorButtons(groupId, threadId, secret) {
9316
9336
  ]
9317
9337
  ]);
9318
9338
  }
9319
- function buildInitTypeButtons(groupId, threadId, secret) {
9320
- const cb = (action) => buildCallbackData(action, groupId, threadId, secret);
9339
+ function buildInitTypeButtons(groupId, threadId, secret, userId) {
9340
+ const cb = (action) => buildCallbackData(action, groupId, threadId, secret, userId);
9321
9341
  return buildInlineKeyboard([
9322
9342
  [
9323
9343
  { text: "Coding", callback_data: cb("ic") },
@@ -9329,6 +9349,16 @@ function buildInitTypeButtons(groupId, threadId, secret) {
9329
9349
  ]
9330
9350
  ]);
9331
9351
  }
9352
+ function buildInitConfirmButton(groupId, threadId, secret, userId, type) {
9353
+ const actionMap = {
9354
+ coding: "yc",
9355
+ research: "yr",
9356
+ marketing: "ym",
9357
+ custom: "yx"
9358
+ };
9359
+ const cb = buildCallbackData(actionMap[type], groupId, threadId, secret, userId);
9360
+ return buildInlineKeyboard([[{ text: "Confirm", callback_data: cb }]]);
9361
+ }
9332
9362
  function buildTopicCard(name, slug, type, capsuleVersion) {
9333
9363
  const n = htmlEscape(name);
9334
9364
  const s = htmlEscape(slug);
@@ -9339,13 +9369,20 @@ function buildTopicCard(name, slug, type, capsuleVersion) {
9339
9369
  `Type: ${t} | Version: ${v}`,
9340
9370
  `Capsule: projects/${s}/`,
9341
9371
  "",
9372
+ "<b>How it works</b>",
9373
+ "Just send your instructions in this topic. The agent",
9374
+ "maintains STATUS.md and TODO.md automatically as it",
9375
+ "works \u2014 nothing is lost on reset or context compaction.",
9376
+ "Doctor checks run periodically and alert you if anything",
9377
+ "needs attention.",
9378
+ "",
9342
9379
  "<b>Commands:</b>",
9343
- "/tm doctor \u2014 health checks",
9344
- "/tm status \u2014 quick view",
9345
- "/tm sync \u2014 re-apply config",
9380
+ "/tm status \u2014 quick STATUS.md view",
9381
+ "/tm doctor \u2014 run health checks",
9382
+ "/tm rename &lt;name&gt; \u2014 rename this topic",
9346
9383
  "/tm list \u2014 all topics",
9347
9384
  "/tm archive \u2014 archive this topic",
9348
- "/tm help \u2014 command reference"
9385
+ "/tm help \u2014 full command reference"
9349
9386
  ].join("\n");
9350
9387
  }
9351
9388
  function buildDoctorReport(name, results) {
@@ -9385,16 +9422,17 @@ function buildHelpCard() {
9385
9422
  "<b>Topic Manager Commands</b>",
9386
9423
  "",
9387
9424
  "/tm init \u2014 register this topic",
9425
+ "/tm status \u2014 quick STATUS.md view",
9388
9426
  "/tm doctor \u2014 run health checks",
9389
9427
  "/tm doctor --all \u2014 check all topics",
9390
- "/tm status \u2014 quick STATUS.md view",
9391
- "/tm list \u2014 show all topics",
9428
+ "/tm rename &lt;name&gt; \u2014 rename this topic",
9429
+ "/tm list \u2014 all topics",
9392
9430
  "/tm sync \u2014 re-apply config",
9393
- "/tm rename &lt;name&gt; \u2014 rename topic",
9394
9431
  "/tm upgrade \u2014 update capsule template",
9395
9432
  "/tm snooze &lt;Nd&gt; \u2014 snooze doctor (7d, 30d, etc.)",
9396
9433
  "/tm archive \u2014 archive topic",
9397
9434
  "/tm unarchive \u2014 reactivate topic",
9435
+ "/tm autopilot [enable|disable|status] \u2014 daily sweeps",
9398
9436
  "/tm help \u2014 this message"
9399
9437
  ].join("\n");
9400
9438
  }
@@ -9436,6 +9474,48 @@ function relativeTime(iso) {
9436
9474
  const days = Math.floor(hours / 24);
9437
9475
  return `${days}d ago`;
9438
9476
  }
9477
+ function createRateLimitedPoster(postFn, config = DEFAULT_RATE_LIMIT) {
9478
+ let lastPostTime = 0;
9479
+ let lastGroupId = "";
9480
+ return async (groupId, threadId, text, keyboard) => {
9481
+ const now = Date.now();
9482
+ const delay = groupId === lastGroupId ? config.sameGroupDelayMs : config.crossGroupDelayMs;
9483
+ const elapsed = now - lastPostTime;
9484
+ if (elapsed < delay) {
9485
+ await sleep(delay - elapsed);
9486
+ }
9487
+ try {
9488
+ await postFn(groupId, threadId, text, keyboard);
9489
+ } catch (err) {
9490
+ if (isTooManyRequestsError(err)) {
9491
+ const retryAfter = getRetryAfter(err);
9492
+ await sleep(retryAfter * 1e3);
9493
+ await postFn(groupId, threadId, text, keyboard);
9494
+ } else {
9495
+ throw err;
9496
+ }
9497
+ }
9498
+ lastPostTime = Date.now();
9499
+ lastGroupId = groupId;
9500
+ };
9501
+ }
9502
+ function sleep(ms) {
9503
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
9504
+ }
9505
+ function isTooManyRequestsError(err) {
9506
+ if (err && typeof err === "object" && "status" in err) {
9507
+ const status = err["status"];
9508
+ return typeof status === "number" && status === 429;
9509
+ }
9510
+ return false;
9511
+ }
9512
+ function getRetryAfter(err) {
9513
+ if (err && typeof err === "object" && "retryAfter" in err) {
9514
+ const val = err.retryAfter;
9515
+ if (typeof val === "number" && val > 0) return val;
9516
+ }
9517
+ return 5;
9518
+ }
9439
9519
  function truncateMessage(msg, limit = TELEGRAM_MSG_LIMIT) {
9440
9520
  if (msg.length <= limit) return msg;
9441
9521
  const suffix = "\n\n... (truncated)";
@@ -9460,8 +9540,9 @@ function getSystemPromptTemplate(name, slug, absoluteWorkspacePath) {
9460
9540
  Determinism rules:
9461
9541
  - Source of truth is the project capsule at: ${absoluteWorkspacePath}/projects/${slug}/
9462
9542
  - After /reset, /new, or context compaction: ALWAYS re-read STATUS.md,
9463
- then TODO.md, then COMMANDS.md before continuing work. Do not rely on
9464
- summarized memory for paths, commands, or task state.
9543
+ then TODO.md, then LEARNINGS.md (last 20 entries), then COMMANDS.md
9544
+ before continuing work. Do not rely on summarized memory for paths,
9545
+ commands, or task state.
9465
9546
  - Before context compaction or when the conversation is long: proactively
9466
9547
  flush current progress to STATUS.md (update "Last done (UTC)" and
9467
9548
  "Next 3 actions") so compaction cannot erase critical state.
@@ -9472,6 +9553,14 @@ Determinism rules:
9472
9553
  - If automation/cron is involved, record job IDs + schedules in CRON.md.
9473
9554
  - Task IDs (e.g., [T-1]) must stay consistent between STATUS.md and TODO.md.
9474
9555
 
9556
+ Learning capture:
9557
+ - When you discover something unexpected, a mistake, a workaround, or a
9558
+ constraint \u2014 prepend a dated entry to LEARNINGS.md.
9559
+ - Format: ## YYYY-MM-DD\\n- source: (chat/debug/research)\\n- insight text
9560
+ - Most recent first (prepend after the header, before existing entries).
9561
+ - Only write when a genuinely new insight exists \u2014 avoid restating known facts.
9562
+ - If LEARNINGS.md exceeds ~200 lines, archive older entries to LEARNINGS-archive.md.
9563
+
9475
9564
  Separation:
9476
9565
  - Do not mix in other topics' work unless explicitly requested.
9477
9566
  - Ask one clarifying question if the next action is ambiguous.`;
@@ -9627,7 +9716,7 @@ async function triggerRestart(rpc, logger) {
9627
9716
  logger.warn(
9628
9717
  `config.patch baseHash mismatch (attempt ${attempt + 1}/${MAX_RETRIES + 1}). Retrying in ${delay}ms...`
9629
9718
  );
9630
- await sleep(delay);
9719
+ await sleep2(delay);
9631
9720
  continue;
9632
9721
  }
9633
9722
  const errMsg = err instanceof Error ? err.message : String(err);
@@ -9655,8 +9744,8 @@ function isHashMismatchError(err) {
9655
9744
  }
9656
9745
  return false;
9657
9746
  }
9658
- function sleep(ms) {
9659
- return new Promise((resolve4) => setTimeout(resolve4, ms));
9747
+ function sleep2(ms) {
9748
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
9660
9749
  }
9661
9750
  async function getConfigWrites(rpc) {
9662
9751
  if (!rpc) return false;
@@ -9673,6 +9762,21 @@ async function getConfigWrites(rpc) {
9673
9762
 
9674
9763
  // src/commands/init.ts
9675
9764
  var VALID_TYPES = /* @__PURE__ */ new Set(["coding", "research", "marketing", "custom"]);
9765
+ function deriveTopicName(nameArg, messageContext, threadId) {
9766
+ const topicTitle = messageContext?.["topicTitle"] ?? "";
9767
+ let name;
9768
+ if (nameArg) {
9769
+ name = nameArg;
9770
+ } else if (topicTitle) {
9771
+ name = topicTitle;
9772
+ } else {
9773
+ name = `Topic ${threadId}`;
9774
+ }
9775
+ if (name.length > MAX_NAME_LENGTH) {
9776
+ name = name.slice(0, MAX_NAME_LENGTH);
9777
+ }
9778
+ return name;
9779
+ }
9676
9780
  async function handleInit(ctx, args) {
9677
9781
  const { workspaceDir, configDir, userId, groupId, threadId, rpc, logger, messageContext } = ctx;
9678
9782
  if (!userId || !groupId || !threadId) {
@@ -9711,18 +9815,7 @@ async function handleInit(ctx, args) {
9711
9815
  } else {
9712
9816
  nameArg = parts.join(" ");
9713
9817
  }
9714
- const topicTitle = messageContext?.["topicTitle"] ?? "";
9715
- let name;
9716
- if (nameArg) {
9717
- name = nameArg;
9718
- } else if (topicTitle) {
9719
- name = topicTitle;
9720
- } else {
9721
- name = `Topic ${threadId}`;
9722
- }
9723
- if (name.length > MAX_NAME_LENGTH) {
9724
- name = name.slice(0, MAX_NAME_LENGTH);
9725
- }
9818
+ const name = deriveTopicName(nameArg, messageContext, threadId);
9726
9819
  const existingSlugs = new Set(Object.values(registry.topics).map((t) => t.slug));
9727
9820
  const finalSlug = generateSlug(threadId, groupId, existingSlugs);
9728
9821
  const projectsBase = path6.join(workspaceDir, "projects");
@@ -9794,8 +9887,9 @@ Warning: include generation failed: ${htmlEscape(msg)}`;
9794
9887
  if (isFirstUser) {
9795
9888
  adminNote = "\n\nYou are the first user and have been added as a telegram-manager admin.";
9796
9889
  }
9890
+ const autopilotTip = "\n\nTip: Enable daily health sweeps with /tm autopilot enable";
9797
9891
  return {
9798
- text: `${topicCard}${adminNote}${restartMsg}`,
9892
+ text: `${topicCard}${adminNote}${restartMsg}${autopilotTip}`,
9799
9893
  parseMode: "HTML",
9800
9894
  pin: true
9801
9895
  };
@@ -9833,7 +9927,7 @@ async function buildTypePicker(ctx) {
9833
9927
  parseMode: "HTML"
9834
9928
  };
9835
9929
  }
9836
- const keyboard = buildInitTypeButtons(groupId, threadId, registry.callbackSecret);
9930
+ const keyboard = buildInitTypeButtons(groupId, threadId, registry.callbackSecret, userId);
9837
9931
  return {
9838
9932
  text: "Pick a topic type:",
9839
9933
  parseMode: "HTML",
@@ -9841,14 +9935,57 @@ async function buildTypePicker(ctx) {
9841
9935
  };
9842
9936
  }
9843
9937
  async function handleInitTypeSelect(ctx, type) {
9938
+ const { workspaceDir, userId, groupId, threadId, messageContext } = ctx;
9939
+ if (!userId || !groupId || !threadId) {
9940
+ return { text: "Missing context: groupId, threadId, or userId not available. Run this command inside a Telegram forum topic." };
9941
+ }
9942
+ if (!validateGroupId(groupId)) {
9943
+ return { text: "Invalid groupId format." };
9944
+ }
9945
+ if (!validateThreadId(threadId)) {
9946
+ return { text: "Invalid threadId format." };
9947
+ }
9948
+ const registry = readRegistry(workspaceDir);
9949
+ const auth = checkAuthorization(userId, "init", registry);
9950
+ if (!auth.authorized) {
9951
+ return { text: auth.message ?? "Not authorized." };
9952
+ }
9953
+ const topicCount = Object.keys(registry.topics).length;
9954
+ if (topicCount >= registry.maxTopics) {
9955
+ return { text: `Maximum number of topics (${registry.maxTopics}) reached. Archive or remove existing topics first.` };
9956
+ }
9957
+ const key = topicKey(groupId, threadId);
9958
+ if (registry.topics[key]) {
9959
+ return {
9960
+ text: `This topic is already registered as <b>${htmlEscape(registry.topics[key].name)}</b>.`,
9961
+ parseMode: "HTML"
9962
+ };
9963
+ }
9964
+ const name = deriveTopicName("", messageContext, threadId);
9965
+ const keyboard = buildInitConfirmButton(groupId, threadId, registry.callbackSecret, userId, type);
9966
+ return {
9967
+ text: buildInitConfirmMessage(name, type),
9968
+ parseMode: "HTML",
9969
+ inlineKeyboard: keyboard
9970
+ };
9971
+ }
9972
+ async function handleInitNameConfirm(ctx, type) {
9844
9973
  return handleInit(ctx, type);
9845
9974
  }
9975
+ function buildInitConfirmMessage(name, type) {
9976
+ return [
9977
+ `Name: <b>${htmlEscape(name)}</b> | Type: ${htmlEscape(type)}`,
9978
+ "",
9979
+ `To use a different name: /tm init &lt;name&gt; ${htmlEscape(type)}`
9980
+ ].join("\n");
9981
+ }
9846
9982
 
9847
9983
  // src/commands/doctor.ts
9848
9984
  import * as fs8 from "node:fs";
9849
9985
  import * as path8 from "node:path";
9850
9986
 
9851
9987
  // src/lib/doctor-checks.ts
9988
+ var import_json52 = __toESM(require_lib(), 1);
9852
9989
  import * as fs7 from "node:fs";
9853
9990
  import * as path7 from "node:path";
9854
9991
  function isIgnored(entry, checkId) {
@@ -9913,7 +10050,7 @@ function runCapsuleChecks(entry, projectsBase) {
9913
10050
  check(
9914
10051
  Severity.INFO,
9915
10052
  "capsuleVersionBehind",
9916
- `Capsule version ${entry.capsuleVersion} is behind current ${CAPSULE_VERSION}. Run /tm upgrade.`,
10053
+ `Capsule version ${entry.capsuleVersion} is behind current ${CAPSULE_VERSION}. Will auto-upgrade on next command.`,
9917
10054
  false
9918
10055
  )
9919
10056
  );
@@ -10083,8 +10220,7 @@ function runConfigChecks(entry, includeContent, registry) {
10083
10220
  const results = [];
10084
10221
  let includeObj;
10085
10222
  try {
10086
- const stripped = includeContent.split("\n").filter((l) => !l.startsWith("//")).join("\n");
10087
- includeObj = JSON.parse(stripped);
10223
+ includeObj = import_json52.default.parse(includeContent);
10088
10224
  } catch {
10089
10225
  return results;
10090
10226
  }
@@ -10203,6 +10339,7 @@ function readCapsuleFiles(capsuleDir) {
10203
10339
  "CRON.md",
10204
10340
  "NOTES.md",
10205
10341
  "README.md",
10342
+ "LEARNINGS.md",
10206
10343
  "ARCHITECTURE.md",
10207
10344
  "DEPLOY.md",
10208
10345
  "SOURCES.md",
@@ -10266,7 +10403,8 @@ async function handleDoctor(ctx) {
10266
10403
  const keyboard = buildDoctorButtons(
10267
10404
  groupId,
10268
10405
  threadId,
10269
- registry.callbackSecret
10406
+ registry.callbackSecret,
10407
+ userId
10270
10408
  );
10271
10409
  const textCommands = [
10272
10410
  "",
@@ -10349,7 +10487,8 @@ async function handleDoctorAll(ctx) {
10349
10487
  const keyboard = buildDoctorButtons(
10350
10488
  entry.groupId,
10351
10489
  entry.threadId,
10352
- registry.callbackSecret
10490
+ registry.callbackSecret,
10491
+ userId
10353
10492
  );
10354
10493
  reports.push({
10355
10494
  slug: entry.slug,
@@ -10384,6 +10523,36 @@ async function handleDoctorAll(ctx) {
10384
10523
  migrationGroups.push(gid);
10385
10524
  }
10386
10525
  }
10526
+ let postErrors = 0;
10527
+ let postSuccesses = 0;
10528
+ if (ctx.postFn && reports.length > 0) {
10529
+ const rateLimitedPost = createRateLimitedPoster(ctx.postFn);
10530
+ for (const report of reports) {
10531
+ try {
10532
+ await rateLimitedPost(report.groupId, report.threadId, report.text, report.keyboard);
10533
+ postSuccesses++;
10534
+ await withRegistry(workspaceDir, (data) => {
10535
+ const key = `${report.groupId}:${report.threadId}`;
10536
+ const entry = data.topics[key];
10537
+ if (entry) {
10538
+ entry.lastDoctorReportAt = now.toISOString();
10539
+ entry.lastPostError = null;
10540
+ }
10541
+ });
10542
+ } catch (err) {
10543
+ postErrors++;
10544
+ const msg = err instanceof Error ? err.message : String(err);
10545
+ logger.error(`[doctor-all] Post failed for ${report.slug}: ${msg}`);
10546
+ await withRegistry(workspaceDir, (data) => {
10547
+ const key = `${report.groupId}:${report.threadId}`;
10548
+ const entry = data.topics[key];
10549
+ if (entry) {
10550
+ entry.lastPostError = msg.slice(0, MAX_POST_ERROR_LENGTH);
10551
+ }
10552
+ });
10553
+ }
10554
+ }
10555
+ }
10387
10556
  await withRegistry(workspaceDir, (data) => {
10388
10557
  data.lastDoctorAllRunAt = now.toISOString();
10389
10558
  for (const [_key, entry] of Object.entries(data.topics)) {
@@ -10400,6 +10569,9 @@ async function handleDoctorAll(ctx) {
10400
10569
  entry.consecutiveSilentDoctors++;
10401
10570
  }
10402
10571
  entry.lastDoctorRunAt = now.toISOString();
10572
+ if (!ctx.postFn) {
10573
+ entry.lastDoctorReportAt = now.toISOString();
10574
+ }
10403
10575
  if (entry.consecutiveSilentDoctors >= SPAM_THRESHOLD) {
10404
10576
  entry.snoozeUntil = new Date(Date.now() + 30 * 24 * 60 * 60 * 1e3).toISOString();
10405
10577
  entry.status = "snoozed";
@@ -10414,6 +10586,9 @@ async function handleDoctorAll(ctx) {
10414
10586
  `Skipped (ineligible): ${skipped}`,
10415
10587
  `Total: ${allEntries.length}`
10416
10588
  ];
10589
+ if (ctx.postFn) {
10590
+ lines.push(`Posted: ${postSuccesses}, Post failures: ${postErrors}`);
10591
+ }
10417
10592
  if (errors.length > 0) {
10418
10593
  lines.push("");
10419
10594
  lines.push(`<b>Errors (${errors.length}):</b>`);
@@ -10764,6 +10939,118 @@ Warning: include generation failed: ${htmlEscape(msg)}`;
10764
10939
  };
10765
10940
  }
10766
10941
 
10942
+ // src/commands/autopilot.ts
10943
+ import * as fs11 from "node:fs";
10944
+ import * as path12 from "node:path";
10945
+ var MARKER_START = "<!-- TM_AUTOPILOT_START -->";
10946
+ var MARKER_END = "<!-- TM_AUTOPILOT_END -->";
10947
+ var HEARTBEAT_BLOCK = `${MARKER_START}
10948
+ ## Topic Manager Daily Sweep
10949
+ - [ ] If 24+ hours since the last topic sweep (check \`lastDoctorAllRunAt\` in
10950
+ {workspace}/projects/topics.json), call \`topic_manager\` with command
10951
+ "doctor --all" to health-check all active topics.
10952
+ ${MARKER_END}`;
10953
+ var HEARTBEAT_FILENAME = "HEARTBEAT.md";
10954
+ async function handleAutopilot(ctx, args) {
10955
+ const { workspaceDir, userId } = ctx;
10956
+ if (!userId) {
10957
+ return { text: "Missing context: userId not available." };
10958
+ }
10959
+ const registry = readRegistry(workspaceDir);
10960
+ const auth = checkAuthorization(userId, "autopilot", registry);
10961
+ if (!auth.authorized) {
10962
+ return { text: auth.message ?? "Not authorized." };
10963
+ }
10964
+ const subCommand = args.trim().toLowerCase() || "enable";
10965
+ switch (subCommand) {
10966
+ case "enable":
10967
+ return handleEnable(ctx);
10968
+ case "disable":
10969
+ return handleDisable(ctx);
10970
+ case "status":
10971
+ return handleStatus2(ctx);
10972
+ default:
10973
+ return { text: `Unknown autopilot sub-command: "${htmlEscape(subCommand)}". Use enable, disable, or status.` };
10974
+ }
10975
+ }
10976
+ async function handleEnable(ctx) {
10977
+ const { workspaceDir } = ctx;
10978
+ const heartbeatPath = path12.join(workspaceDir, HEARTBEAT_FILENAME);
10979
+ const block = HEARTBEAT_BLOCK.replace("{workspace}", path12.resolve(workspaceDir));
10980
+ let content = "";
10981
+ try {
10982
+ if (fs11.existsSync(heartbeatPath)) {
10983
+ content = fs11.readFileSync(heartbeatPath, "utf-8");
10984
+ }
10985
+ } catch {
10986
+ }
10987
+ if (content.includes(MARKER_START)) {
10988
+ await withRegistry(workspaceDir, (data) => {
10989
+ data.autopilotEnabled = true;
10990
+ });
10991
+ return { text: "Autopilot is already enabled." };
10992
+ }
10993
+ const newContent = content ? content.trimEnd() + "\n\n" + block + "\n" : block + "\n";
10994
+ fs11.writeFileSync(heartbeatPath, newContent, { mode: 416 });
10995
+ await withRegistry(workspaceDir, (data) => {
10996
+ data.autopilotEnabled = true;
10997
+ });
10998
+ return {
10999
+ text: "<b>Autopilot enabled.</b>\nDaily health sweeps will run via the OpenClaw heartbeat.",
11000
+ parseMode: "HTML"
11001
+ };
11002
+ }
11003
+ async function handleDisable(ctx) {
11004
+ const { workspaceDir } = ctx;
11005
+ const heartbeatPath = path12.join(workspaceDir, HEARTBEAT_FILENAME);
11006
+ if (!fs11.existsSync(heartbeatPath)) {
11007
+ await withRegistry(workspaceDir, (data) => {
11008
+ data.autopilotEnabled = false;
11009
+ });
11010
+ return { text: "Autopilot is not enabled (no HEARTBEAT.md found)." };
11011
+ }
11012
+ let content = fs11.readFileSync(heartbeatPath, "utf-8");
11013
+ if (!content.includes(MARKER_START)) {
11014
+ await withRegistry(workspaceDir, (data) => {
11015
+ data.autopilotEnabled = false;
11016
+ });
11017
+ return { text: "Autopilot is not enabled (no marker found in HEARTBEAT.md)." };
11018
+ }
11019
+ const startIdx = content.indexOf(MARKER_START);
11020
+ const endIdx = content.indexOf(MARKER_END);
11021
+ if (startIdx >= 0 && endIdx >= 0) {
11022
+ const before = content.slice(0, startIdx);
11023
+ const after = content.slice(endIdx + MARKER_END.length);
11024
+ content = (before + after).replace(/\n{3,}/g, "\n\n").trim();
11025
+ if (content) {
11026
+ fs11.writeFileSync(heartbeatPath, content + "\n", { mode: 416 });
11027
+ } else {
11028
+ fs11.unlinkSync(heartbeatPath);
11029
+ }
11030
+ }
11031
+ await withRegistry(workspaceDir, (data) => {
11032
+ data.autopilotEnabled = false;
11033
+ });
11034
+ return {
11035
+ text: "<b>Autopilot disabled.</b>\nDaily sweeps will no longer run automatically.",
11036
+ parseMode: "HTML"
11037
+ };
11038
+ }
11039
+ async function handleStatus2(ctx) {
11040
+ const { workspaceDir } = ctx;
11041
+ const registry = readRegistry(workspaceDir);
11042
+ const enabled = registry.autopilotEnabled;
11043
+ const lastRun = registry.lastDoctorAllRunAt ?? "never";
11044
+ const lines = [
11045
+ `<b>Autopilot:</b> ${enabled ? "enabled" : "disabled"}`,
11046
+ `<b>Last doctor-all run:</b> ${htmlEscape(lastRun)}`
11047
+ ];
11048
+ return {
11049
+ text: lines.join("\n"),
11050
+ parseMode: "HTML"
11051
+ };
11052
+ }
11053
+
10767
11054
  // src/commands/help.ts
10768
11055
  function handleHelp(_ctx) {
10769
11056
  return {
@@ -10786,6 +11073,29 @@ function createTopicManagerTool(deps) {
10786
11073
  return handleCallback(commandStr, ctx);
10787
11074
  }
10788
11075
  const { subCommand, args, flags } = parseCommand(commandStr);
11076
+ if (ctx.groupId && ctx.threadId) {
11077
+ const key = topicKey(ctx.groupId, ctx.threadId);
11078
+ const projectsBase = `${workspaceDir}/projects`;
11079
+ void withRegistry(workspaceDir, (data) => {
11080
+ const entry = data.topics[key];
11081
+ if (!entry) return;
11082
+ entry.lastMessageAt = (/* @__PURE__ */ new Date()).toISOString();
11083
+ if (entry.capsuleVersion < CAPSULE_VERSION) {
11084
+ const oldVersion = entry.capsuleVersion;
11085
+ try {
11086
+ upgradeCapsule(projectsBase, entry.slug, entry.name, entry.type, entry.capsuleVersion);
11087
+ entry.capsuleVersion = CAPSULE_VERSION;
11088
+ logger.info(`[auto-upgrade] ${entry.slug} v${oldVersion} \u2192 v${CAPSULE_VERSION}`);
11089
+ } catch (err) {
11090
+ const msg = err instanceof Error ? err.message : String(err);
11091
+ logger.error(`[auto-upgrade] ${entry.slug} failed: ${msg}`);
11092
+ }
11093
+ }
11094
+ }).catch((err) => {
11095
+ const msg = err instanceof Error ? err.message : String(err);
11096
+ logger.error(`[activity-tracking] Failed: ${msg}`);
11097
+ });
11098
+ }
10789
11099
  try {
10790
11100
  switch (subCommand) {
10791
11101
  case "init":
@@ -10813,6 +11123,8 @@ function createTopicManagerTool(deps) {
10813
11123
  return await handleArchive(ctx);
10814
11124
  case "unarchive":
10815
11125
  return await handleUnarchive(ctx);
11126
+ case "autopilot":
11127
+ return await handleAutopilot(ctx, args);
10816
11128
  case "help":
10817
11129
  return await handleHelp(ctx);
10818
11130
  default:
@@ -10861,7 +11173,8 @@ function buildContext(deps, execContext) {
10861
11173
  groupId: groupId ?? void 0,
10862
11174
  threadId: threadId ?? void 0,
10863
11175
  userId: userId ?? void 0,
10864
- messageContext: execContext
11176
+ messageContext: execContext,
11177
+ postFn: deps.postFn
10865
11178
  };
10866
11179
  }
10867
11180
  function extractString(obj, key) {
@@ -10881,11 +11194,11 @@ function extractNestedString(obj, ...keys) {
10881
11194
  return String(current);
10882
11195
  }
10883
11196
  async function handleCallback(data, ctx) {
10884
- const { workspaceDir, userId } = ctx;
11197
+ const { workspaceDir } = ctx;
10885
11198
  const cbParts = data.split(":");
10886
11199
  const cbGroupId = cbParts[2];
10887
11200
  const cbThreadId = cbParts[3];
10888
- if (!cbGroupId || !cbThreadId || !userId) {
11201
+ if (!cbGroupId || !cbThreadId) {
10889
11202
  return { text: "Cannot verify callback: missing context." };
10890
11203
  }
10891
11204
  const registry = readRegistry(workspaceDir);
@@ -10893,17 +11206,26 @@ async function handleCallback(data, ctx) {
10893
11206
  if (!parsed) {
10894
11207
  return { text: "Invalid or expired callback." };
10895
11208
  }
10896
- const { action } = parsed;
11209
+ const { action, userId: cbUserId } = parsed;
10897
11210
  const initTypeMap = {
10898
11211
  ic: "coding",
10899
11212
  ir: "research",
10900
11213
  im: "marketing",
10901
11214
  ix: "custom"
10902
11215
  };
10903
- const cbCtx = { ...ctx, groupId: cbGroupId, threadId: cbThreadId };
11216
+ const initConfirmMap = {
11217
+ yc: "coding",
11218
+ yr: "research",
11219
+ ym: "marketing",
11220
+ yx: "custom"
11221
+ };
11222
+ const cbCtx = { ...ctx, groupId: cbGroupId, threadId: cbThreadId, userId: cbUserId };
10904
11223
  if (action in initTypeMap) {
10905
11224
  return handleInitTypeSelect(cbCtx, initTypeMap[action]);
10906
11225
  }
11226
+ if (action in initConfirmMap) {
11227
+ return handleInitNameConfirm(cbCtx, initConfirmMap[action]);
11228
+ }
10907
11229
  const key = topicKey(cbGroupId, cbThreadId);
10908
11230
  const entry = registry.topics[key];
10909
11231
  if (!entry) {
@@ -10941,40 +11263,71 @@ async function handleCallbackFix(ctx) {
10941
11263
  // src/index.ts
10942
11264
  function resolveConfigDir() {
10943
11265
  const thisFile = new URL(import.meta.url).pathname;
10944
- const parts = thisFile.split(path12.sep);
11266
+ const parts = thisFile.split(path13.sep);
10945
11267
  const extIndex = parts.lastIndexOf("extensions");
10946
11268
  if (extIndex > 0) {
10947
- const candidate = parts.slice(0, extIndex).join(path12.sep);
10948
- if (fs11.existsSync(path12.join(candidate, "openclaw.json")) || fs11.existsSync(path12.join(candidate, "extensions"))) {
11269
+ const candidate = parts.slice(0, extIndex).join(path13.sep);
11270
+ if (fs12.existsSync(path13.join(candidate, "openclaw.json")) || fs12.existsSync(path13.join(candidate, "extensions"))) {
10949
11271
  return candidate;
10950
11272
  }
10951
11273
  }
10952
11274
  const envDir = process.env["OPENCLAW_CONFIG_DIR"];
10953
- if (envDir && fs11.existsSync(envDir)) return path12.resolve(envDir);
11275
+ if (envDir && fs12.existsSync(envDir)) return path13.resolve(envDir);
10954
11276
  const homeDir = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
10955
- const defaultDir = path12.join(homeDir, ".openclaw");
10956
- if (fs11.existsSync(defaultDir)) return defaultDir;
11277
+ const defaultDir = path13.join(homeDir, ".openclaw");
11278
+ if (fs12.existsSync(defaultDir)) return defaultDir;
10957
11279
  return void 0;
10958
11280
  }
10959
11281
  function register(api) {
10960
11282
  const resolvedConfigDir = resolveConfigDir();
10961
11283
  const configDir = api.configDir ?? api.pluginConfig?.configDir ?? resolvedConfigDir;
10962
- const workspaceDir = api.workspaceDir ?? api.pluginConfig?.workspaceDir ?? (resolvedConfigDir ? path12.join(resolvedConfigDir, "workspace") : void 0);
11284
+ const workspaceDir = api.workspaceDir ?? api.pluginConfig?.workspaceDir ?? (resolvedConfigDir ? path13.join(resolvedConfigDir, "workspace") : void 0);
10963
11285
  if (!configDir || !workspaceDir) {
10964
11286
  api.logger.error(
10965
11287
  "telegram-manager: configDir or workspaceDir not available. Plugin cannot initialize."
10966
11288
  );
10967
11289
  return;
10968
11290
  }
11291
+ let resolvedPostFn;
11292
+ const lazyPostFn = async (groupId, threadId, text, keyboard) => {
11293
+ if (resolvedPostFn === null) return;
11294
+ if (resolvedPostFn === void 0) {
11295
+ try {
11296
+ const sdkPath = ["openclaw", "dist", "plugin-sdk", "index.js"].join("/");
11297
+ const sdk = await import(
11298
+ /* @vite-ignore */
11299
+ sdkPath
11300
+ );
11301
+ if (typeof sdk["sendMessageTelegram"] === "function") {
11302
+ const sendMsg = sdk["sendMessageTelegram"];
11303
+ resolvedPostFn = async (gId, tId, txt, kb) => {
11304
+ const opts = {
11305
+ messageThreadId: Number(tId),
11306
+ textMode: "html"
11307
+ };
11308
+ if (kb) opts.buttons = kb.inline_keyboard;
11309
+ await sendMsg(gId, txt, opts);
11310
+ };
11311
+ api.logger.info("telegram-manager: postFn wired via plugin-sdk");
11312
+ } else {
11313
+ resolvedPostFn = null;
11314
+ }
11315
+ } catch {
11316
+ resolvedPostFn = null;
11317
+ }
11318
+ }
11319
+ if (resolvedPostFn) await resolvedPostFn(groupId, threadId, text, keyboard);
11320
+ };
10969
11321
  const tool = createTopicManagerTool({
10970
11322
  logger: api.logger,
10971
11323
  configDir,
10972
11324
  workspaceDir,
10973
- rpc: api.rpc
11325
+ rpc: api.rpc,
11326
+ postFn: lazyPostFn
10974
11327
  });
10975
11328
  api.registerTool({
10976
11329
  name: "topic_manager",
10977
- description: "Manage Telegram forum topics as deterministic workcells. Sub-commands: init, doctor, list, status, sync, rename, upgrade, snooze, archive, unarchive, help.",
11330
+ description: "Manage Telegram forum topics as deterministic workcells. Sub-commands: init, doctor, list, status, sync, rename, upgrade, snooze, archive, unarchive, autopilot, help.",
10978
11331
  parameters: Type.Object({
10979
11332
  command: Type.String({
10980
11333
  description: "Sub-command and arguments (e.g., 'init', 'doctor --all', 'rename new-name')"
@@ -10990,17 +11343,19 @@ function register(api) {
10990
11343
  if (api.registerCommand) {
10991
11344
  api.registerCommand({
10992
11345
  name: "tm",
10993
- description: "Manage Telegram forum topics as deterministic workcells. Sub-commands: init, doctor, list, status, sync, rename, upgrade, snooze, archive, unarchive, help.",
11346
+ description: "Manage Telegram forum topics as deterministic workcells. Sub-commands: init, doctor, list, status, sync, rename, upgrade, snooze, archive, unarchive, autopilot, help.",
10994
11347
  acceptsArgs: true,
10995
11348
  requireAuth: false,
10996
11349
  async handler(ctx) {
10997
11350
  const userId = ctx.senderId;
10998
11351
  const groupId = ctx.from?.replace(/^telegram:(?:group:)?/, "").split(":topic:")[0] || void 0;
10999
11352
  const threadId = ctx.messageThreadId != null ? String(ctx.messageThreadId) : void 0;
11353
+ const topicTitle = ctx["topicTitle"] ?? ctx["topicName"];
11000
11354
  const execContext = {};
11001
11355
  if (userId) execContext.userId = userId;
11002
11356
  if (groupId) execContext.groupId = groupId;
11003
11357
  if (threadId) execContext.threadId = threadId;
11358
+ if (topicTitle != null) execContext.topicTitle = String(topicTitle);
11004
11359
  const result = await tool.execute("cmd", { command: ctx.args }, execContext);
11005
11360
  const reply = {
11006
11361
  text: result.text