agentschat-mcp 0.36.10 → 0.36.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,23 +40,23 @@ function prepareRuntimeHome(stateDir, source = process.env.CODEX_HOME || join(ho
40
40
  if (mode !== "linked" && mode !== "isolated" && mode !== "auth-only")
41
41
  throw new Error("Invalid Codex home mode");
42
42
  if (mode === "isolated") {
43
- const home2 = join(stateDir, "codex-home-isolated");
44
- mkdirSync(home2, { recursive: true, mode: 448 });
45
- assertIndependentTree(home2, undefined, executablePath(codexBin));
46
- return { home: realpathSync(home2) };
43
+ const home = join(stateDir, "codex-home-isolated");
44
+ mkdirSync(home, { recursive: true, mode: 448 });
45
+ assertIndependentTree(home, undefined, executablePath(codexBin));
46
+ return { home: realpathSync(home) };
47
47
  }
48
48
  if (mode === "auth-only") {
49
- const legacyHome2 = realpathSync(source);
50
- const origin = join(legacyHome2, "auth.json");
49
+ const legacyHome = realpathSync(source);
50
+ const origin = join(legacyHome, "auth.json");
51
51
  if (!lstatSync(origin).isFile())
52
52
  throw new Error("auth-only requires an existing regular auth.json; authorize its use explicitly");
53
- const home2 = join(stateDir, "codex-home-auth-only");
54
- mkdirSync(home2, { recursive: true, mode: 448 });
55
- if (lstatSync(home2).isSymbolicLink() || realpathSync(home2) === legacyHome2)
53
+ const home = join(stateDir, "codex-home-auth-only");
54
+ mkdirSync(home, { recursive: true, mode: 448 });
55
+ if (lstatSync(home).isSymbolicLink() || realpathSync(home) === legacyHome)
56
56
  throw new Error("auth-only home must be independent");
57
57
  for (const name of ["config.toml", "AGENTS.md", "rules", "plugins", "hooks.json"]) {
58
58
  try {
59
- lstatSync(join(home2, name));
59
+ lstatSync(join(home, name));
60
60
  } catch (e) {
61
61
  if (e.code === "ENOENT")
62
62
  continue;
@@ -64,21 +64,21 @@ function prepareRuntimeHome(stateDir, source = process.env.CODEX_HOME || join(ho
64
64
  }
65
65
  throw new Error("auth-only home contains unexpected configuration; use a fresh state root");
66
66
  }
67
- const skills = join(home2, "skills");
67
+ const skills = join(home, "skills");
68
68
  if (existsSync(skills) && (!lstatSync(skills).isDirectory() || readdirSync(skills).some((name) => name !== ".system")))
69
69
  throw new Error("auth-only home contains unexpected custom skills");
70
- assertIndependentTree(home2, origin, executablePath(codexBin));
71
- const target = join(home2, "auth.json");
70
+ assertIndependentTree(home, origin, executablePath(codexBin));
71
+ const target = join(home, "auth.json");
72
72
  try {
73
- if (!lstatSync(target).isSymbolicLink() || resolve(home2, readlinkSync(target)) !== origin)
73
+ if (!lstatSync(target).isSymbolicLink() || resolve(home, readlinkSync(target)) !== origin)
74
74
  throw new Error("Unexpected auth-only login binding");
75
75
  } catch (e) {
76
76
  if (e.code !== "ENOENT")
77
77
  throw e;
78
78
  symlinkSync(origin, target);
79
79
  }
80
- assertIndependentTree(home2, origin, executablePath(codexBin));
81
- return { home: realpathSync(home2) };
80
+ assertIndependentTree(home, origin, executablePath(codexBin));
81
+ return { home: realpathSync(home) };
82
82
  }
83
83
  const legacyHome = existsSync(source) ? realpathSync(source) : resolve(source);
84
84
  const home = join(stateDir, "codex-home");
@@ -315,126 +315,6 @@ function validateIdentityProfile(profile, file, allowDevToken = false) {
315
315
  }
316
316
  }
317
317
 
318
- // node_modules/smol-toml/dist/date.js
319
- /*!
320
- * Copyright (c) Squirrel Chat et al., All rights reserved.
321
- * SPDX-License-Identifier: BSD-3-Clause
322
- *
323
- * Redistribution and use in source and binary forms, with or without
324
- * modification, are permitted provided that the following conditions are met:
325
- *
326
- * 1. Redistributions of source code must retain the above copyright notice, this
327
- * list of conditions and the following disclaimer.
328
- * 2. Redistributions in binary form must reproduce the above copyright notice,
329
- * this list of conditions and the following disclaimer in the
330
- * documentation and/or other materials provided with the distribution.
331
- * 3. Neither the name of the copyright holder nor the names of its contributors
332
- * may be used to endorse or promote products derived from this software without
333
- * specific prior written permission.
334
- *
335
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
336
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
337
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
338
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
339
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
340
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
341
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
342
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
343
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
344
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
345
- */
346
- var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
347
-
348
- class TomlDate extends Date {
349
- #hasDate = false;
350
- #hasTime = false;
351
- #offset = null;
352
- constructor(date) {
353
- let hasDate = true;
354
- let hasTime = true;
355
- let offset = "Z";
356
- if (typeof date === "string") {
357
- let match = date.match(DATE_TIME_RE);
358
- if (match) {
359
- if (!match[1]) {
360
- hasDate = false;
361
- date = `0000-01-01T${date}`;
362
- }
363
- hasTime = !!match[2];
364
- hasTime && date[10] === " " && (date = date.replace(" ", "T"));
365
- if (match[2] && +match[2] > 23) {
366
- date = "";
367
- } else {
368
- offset = match[3] || null;
369
- date = date.toUpperCase();
370
- if (!offset && hasTime)
371
- date += "Z";
372
- }
373
- } else {
374
- date = "";
375
- }
376
- }
377
- super(date);
378
- if (!isNaN(this.getTime())) {
379
- this.#hasDate = hasDate;
380
- this.#hasTime = hasTime;
381
- this.#offset = offset;
382
- }
383
- }
384
- isDateTime() {
385
- return this.#hasDate && this.#hasTime;
386
- }
387
- isLocal() {
388
- return !this.#hasDate || !this.#hasTime || !this.#offset;
389
- }
390
- isDate() {
391
- return this.#hasDate && !this.#hasTime;
392
- }
393
- isTime() {
394
- return this.#hasTime && !this.#hasDate;
395
- }
396
- isValid() {
397
- return this.#hasDate || this.#hasTime;
398
- }
399
- toISOString() {
400
- let iso = super.toISOString();
401
- if (this.isDate())
402
- return iso.slice(0, 10);
403
- if (this.isTime())
404
- return iso.slice(11, 23);
405
- if (this.#offset === null)
406
- return iso.slice(0, -1);
407
- if (this.#offset === "Z")
408
- return iso;
409
- let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
410
- offset = this.#offset[0] === "-" ? offset : -offset;
411
- let offsetDate = new Date(this.getTime() - offset * 60000);
412
- return offsetDate.toISOString().slice(0, -1) + this.#offset;
413
- }
414
- static wrapAsOffsetDateTime(jsDate, offset = "Z") {
415
- let date = new TomlDate(jsDate);
416
- date.#offset = offset;
417
- return date;
418
- }
419
- static wrapAsLocalDateTime(jsDate) {
420
- let date = new TomlDate(jsDate);
421
- date.#offset = null;
422
- return date;
423
- }
424
- static wrapAsLocalDate(jsDate) {
425
- let date = new TomlDate(jsDate);
426
- date.#hasTime = false;
427
- date.#offset = null;
428
- return date;
429
- }
430
- static wrapAsLocalTime(jsDate) {
431
- let date = new TomlDate(jsDate);
432
- date.#hasDate = false;
433
- date.#offset = null;
434
- return date;
435
- }
436
- }
437
-
438
318
  // node_modules/smol-toml/dist/error.js
439
319
  /*!
440
320
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -464,11 +344,11 @@ class TomlDate extends Date {
464
344
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
465
345
  */
466
346
  function getLineColFromPtr(string, ptr) {
467
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
347
+ let lines = string.slice(0, ptr).split(/\r?\n/);
468
348
  return [lines.length, lines.pop().length + 1];
469
349
  }
470
350
  function makeCodeBlock(string, line, column) {
471
- let lines = string.split(/\r\n|\n|\r/g);
351
+ let lines = string.split(/\r?\n/);
472
352
  let codeblock = "";
473
353
  let numberLen = (Math.log10(line + 1) | 0) + 1;
474
354
  for (let i = line - 1;i <= line + 1; i++) {
@@ -503,89 +383,9 @@ ${codeblock}`, options);
503
383
  this.column = column;
504
384
  this.codeblock = codeblock;
505
385
  }
506
- }
507
-
508
- // node_modules/smol-toml/dist/util.js
509
- /*!
510
- * Copyright (c) Squirrel Chat et al., All rights reserved.
511
- * SPDX-License-Identifier: BSD-3-Clause
512
- *
513
- * Redistribution and use in source and binary forms, with or without
514
- * modification, are permitted provided that the following conditions are met:
515
- *
516
- * 1. Redistributions of source code must retain the above copyright notice, this
517
- * list of conditions and the following disclaimer.
518
- * 2. Redistributions in binary form must reproduce the above copyright notice,
519
- * this list of conditions and the following disclaimer in the
520
- * documentation and/or other materials provided with the distribution.
521
- * 3. Neither the name of the copyright holder nor the names of its contributors
522
- * may be used to endorse or promote products derived from this software without
523
- * specific prior written permission.
524
- *
525
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
526
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
527
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
528
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
529
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
530
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
531
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
532
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
533
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
534
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
535
- */
536
- function indexOfNewline(str, start = 0) {
537
- let idx = str.indexOf(`
538
- `, start);
539
- if (str.charCodeAt(idx - 1) === 13)
540
- idx--;
541
- return idx;
542
- }
543
- function skipComment(ctx) {
544
- for (;ctx.p < ctx.s.length; ctx.p++) {
545
- let c = ctx.s.charCodeAt(ctx.p);
546
- if (c === 10)
547
- break;
548
- if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
549
- ctx.p++;
550
- break;
551
- }
552
- if (c < 32 && c !== 9 || c === 127) {
553
- throw new TomlError("control characters are not allowed in comments", {
554
- toml: ctx.s,
555
- ptr: ctx.p
556
- });
557
- }
558
- }
559
- }
560
- function skipVoid(ctx, banNewLines, banComments) {
561
- let c;
562
- while (true) {
563
- while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
564
- ctx.p++;
565
- if (banComments || c !== 35)
566
- break;
567
- skipComment(ctx);
568
- }
569
- }
570
- function skipUntil(ctx, sep2, end) {
571
- let ptr = ctx.p;
572
- if (!end) {
573
- ptr = indexOfNewline(ctx.s, ptr);
574
- ctx.p = ptr < 0 ? ctx.s.length : ptr;
575
- return;
576
- }
577
- for (;ctx.p < ctx.s.length; ctx.p++) {
578
- let c = ctx.s.charCodeAt(ctx.p);
579
- if (c === 35) {
580
- skipComment(ctx);
581
- } else if (c === end || c === sep2) {
582
- return;
583
- }
386
+ static x(message, ctx, ptr) {
387
+ throw new TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
584
388
  }
585
- throw new TomlError("cannot find end of structure", {
586
- toml: ctx.s,
587
- ptr
588
- });
589
389
  }
590
390
 
591
391
  // node_modules/smol-toml/dist/primitive.js
@@ -616,11 +416,8 @@ function skipUntil(ctx, sep2, end) {
616
416
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
617
417
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
618
418
  */
619
- var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
620
- var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
621
- var LEADING_ZERO = /^[+-]?0[0-9_]/;
622
419
  function parseString(ctx) {
623
- let start = ctx.p;
420
+ let startPtr = ctx.p;
624
421
  let c = ctx.s.charCodeAt(ctx.p++);
625
422
  let first = c;
626
423
  let isLiteral = c === 39;
@@ -639,10 +436,7 @@ function parseString(ctx) {
639
436
  if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
640
437
  state = state && 3;
641
438
  } else if (c < 32 && c !== 9 || c === 127) {
642
- throw new TomlError("control characters are not allowed in strings", {
643
- toml: ctx.s,
644
- ptr: ctx.p
645
- });
439
+ TomlError.x("control characters are not allowed in strings", ctx);
646
440
  } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
647
441
  if (isMultiline) {
648
442
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
@@ -650,8 +444,10 @@ function parseString(ctx) {
650
444
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
651
445
  ctx.p++;
652
446
  }
653
- if (!state)
654
- parsed += ctx.s.slice(sliceStart, ctx.p);
447
+ if (!state) {
448
+ let s = ctx.s.slice(sliceStart, ctx.p);
449
+ parsed = parsed ? parsed + s : s;
450
+ }
655
451
  ctx.p += isMultiline ? 3 : 1;
656
452
  return parsed;
657
453
  } else if (!state) {
@@ -661,22 +457,23 @@ function parseString(ctx) {
661
457
  }
662
458
  } else if (state === 1) {
663
459
  if (c === 120 || c === 117 || c === 85) {
460
+ let errPtr = ctx.p++ - 1;
664
461
  let value = 0;
665
462
  let len = c === 120 ? 2 : c === 117 ? 4 : 8;
666
463
  for (let j = 0;j < len; j++, ctx.p++) {
667
- let hex = ctx.s.charCodeAt(ctx.p + 1);
464
+ let hex = ctx.s.charCodeAt(ctx.p);
668
465
  let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
669
466
  if (digit < 0)
670
- throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
467
+ TomlError.x("invalid non-hex character in unicode escape", ctx);
671
468
  value = value << 4 | digit;
672
469
  }
673
470
  if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
674
- throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
471
+ TomlError.x("invalid unicode escape", ctx, errPtr);
675
472
  }
676
473
  parsed += String.fromCodePoint(value);
677
- sliceStart = ctx.p + 1;
474
+ sliceStart = ctx.p--;
678
475
  state = 0;
679
- } else if (c === 32 || c === 9) {
476
+ } else if (isMultiline && (c === 32 || c === 9)) {
680
477
  state = 2;
681
478
  } else {
682
479
  if (c === 98)
@@ -697,70 +494,161 @@ function parseString(ctx) {
697
494
  else if (c === 92)
698
495
  parsed += "\\";
699
496
  else
700
- throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
497
+ TomlError.x("unrecognised escape sequence", ctx);
701
498
  sliceStart = ctx.p + 1;
702
499
  state = 0;
703
500
  }
704
501
  } else if (c !== 32 && c !== 9) {
705
- if (state === 2) {
706
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
707
- toml: ctx.s,
708
- ptr: sliceStart
709
- });
710
- }
502
+ if (state === 2)
503
+ TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
711
504
  state = !isLiteral && c === 92 ? 1 : 0;
712
505
  sliceStart = ctx.p;
713
506
  }
714
507
  }
715
- throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
716
- }
717
- function sliceAndTrimEndOf(ctx, start, end) {
718
- let value = ctx.s.slice(start, end);
719
- let commentIdx = value.indexOf("#");
720
- if (commentIdx > 0) {
721
- skipComment({ s: value, p: commentIdx, d: 0 });
722
- value = value.slice(0, commentIdx);
723
- }
724
- return value.trimEnd();
508
+ TomlError.x("unfinished string", ctx, startPtr);
725
509
  }
726
- function parseValue(ctx, integersAsBigInt, end) {
727
- let ptr = ctx.p;
728
- let err = { toml: ctx.s, ptr };
729
- skipUntil(ctx, 44, end);
730
- let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
731
- if (!value)
732
- throw new TomlError("incomplete declaration: value expected", err);
733
- if (value === "-inf")
734
- return -Infinity;
735
- if (value === "inf" || value === "+inf")
736
- return Infinity;
737
- if (value === "nan" || value === "+nan" || value === "-nan")
738
- return NaN;
739
- if (value === "-0")
740
- return integersAsBigInt ? 0n : 0;
741
- let isInt = INT_REGEX.test(value);
742
- if (isInt || FLOAT_REGEX.test(value)) {
743
- if (LEADING_ZERO.test(value)) {
744
- throw new TomlError("leading zeroes are not allowed", err);
745
- }
746
- value = value.replace(/_/g, "");
747
- let numeric = +value;
748
- if (isNaN(numeric)) {
749
- throw new TomlError("invalid number", err);
750
- }
751
- if (isInt) {
752
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
753
- throw new TomlError("integer value cannot be represented losslessly", err);
510
+
511
+ // node_modules/smol-toml/dist/date.js
512
+ /*!
513
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
514
+ * SPDX-License-Identifier: BSD-3-Clause
515
+ *
516
+ * Redistribution and use in source and binary forms, with or without
517
+ * modification, are permitted provided that the following conditions are met:
518
+ *
519
+ * 1. Redistributions of source code must retain the above copyright notice, this
520
+ * list of conditions and the following disclaimer.
521
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
522
+ * this list of conditions and the following disclaimer in the
523
+ * documentation and/or other materials provided with the distribution.
524
+ * 3. Neither the name of the copyright holder nor the names of its contributors
525
+ * may be used to endorse or promote products derived from this software without
526
+ * specific prior written permission.
527
+ *
528
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
529
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
530
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
531
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
532
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
533
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
534
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
535
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
536
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
537
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
538
+ */
539
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
540
+
541
+ class TomlDate extends Date {
542
+ #hasDate = false;
543
+ #hasTime = false;
544
+ #offset = null;
545
+ constructor(date, fasttype, unsafeDelim) {
546
+ let hasDate = true;
547
+ let hasTime = true;
548
+ let offset = "Z";
549
+ let c;
550
+ if (typeof date === "string") {
551
+ if (fasttype)
552
+ prep: {
553
+ if (fasttype < 3) {
554
+ if (+date.slice(11, 13) > 23) {
555
+ date = "";
556
+ break prep;
557
+ }
558
+ if (fasttype === 2) {
559
+ offset = null;
560
+ date += "Z";
561
+ } else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) {
562
+ offset = date.slice(date.length - 6);
563
+ }
564
+ if (unsafeDelim)
565
+ date = date.slice(0, 10) + "T" + date.slice(11);
566
+ } else if (fasttype === 4) {
567
+ date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
568
+ }
569
+ hasDate = fasttype !== 4;
570
+ hasTime = fasttype !== 3;
571
+ }
572
+ else {
573
+ let match = date.match(DATE_TIME_RE);
574
+ if (match) {
575
+ if (!match[1]) {
576
+ hasDate = false;
577
+ date = `0000-01-01T${date}`;
578
+ }
579
+ hasTime = !!match[2];
580
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
581
+ if (match[2] && +match[2] > 23) {
582
+ date = "";
583
+ } else {
584
+ offset = match[3] || null;
585
+ if (!offset && hasTime)
586
+ date += "Z";
587
+ }
588
+ } else {
589
+ date = "";
590
+ }
754
591
  }
755
- if (isInt || integersAsBigInt === true)
756
- numeric = BigInt(value);
757
592
  }
758
- return numeric;
593
+ super(date);
594
+ if (!isNaN(this.getTime())) {
595
+ this.#hasDate = hasDate;
596
+ this.#hasTime = hasTime;
597
+ this.#offset = offset;
598
+ }
599
+ }
600
+ isDateTime() {
601
+ return this.#hasDate && this.#hasTime;
602
+ }
603
+ isLocal() {
604
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
605
+ }
606
+ isDate() {
607
+ return this.#hasDate && !this.#hasTime;
608
+ }
609
+ isTime() {
610
+ return this.#hasTime && !this.#hasDate;
611
+ }
612
+ isValid() {
613
+ return this.#hasDate || this.#hasTime;
614
+ }
615
+ toISOString() {
616
+ let iso = super.toISOString();
617
+ if (this.isDate())
618
+ return iso.slice(0, 10);
619
+ if (this.isTime())
620
+ return iso.slice(11, 23);
621
+ if (this.#offset === null)
622
+ return iso.slice(0, -1);
623
+ if (this.#offset === "Z" || this.#offset === "z")
624
+ return iso;
625
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
626
+ offset = this.#offset[0] === "-" ? offset : -offset;
627
+ let offsetDate = new Date(this.getTime() - offset * 60000);
628
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
629
+ }
630
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
631
+ let date = new TomlDate(jsDate);
632
+ date.#offset = offset;
633
+ return date;
634
+ }
635
+ static wrapAsLocalDateTime(jsDate) {
636
+ let date = new TomlDate(jsDate);
637
+ date.#offset = null;
638
+ return date;
639
+ }
640
+ static wrapAsLocalDate(jsDate) {
641
+ let date = new TomlDate(jsDate);
642
+ date.#hasTime = false;
643
+ date.#offset = null;
644
+ return date;
645
+ }
646
+ static wrapAsLocalTime(jsDate) {
647
+ let date = new TomlDate(jsDate);
648
+ date.#hasDate = false;
649
+ date.#offset = null;
650
+ return date;
759
651
  }
760
- const date = new TomlDate(value);
761
- if (!date.isValid())
762
- throw new TomlError("invalid value", err);
763
- return date;
764
652
  }
765
653
 
766
654
  // node_modules/smol-toml/dist/extract.js
@@ -791,17 +679,18 @@ function parseValue(ctx, integersAsBigInt, end) {
791
679
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
792
680
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
793
681
  */
794
- function extractValue(ctx, end, integersAsBigInt) {
795
- let ptr = ctx.p;
796
- let c = ctx.s.charCodeAt(ptr);
682
+ function isDigit(char, base = 10) {
683
+ return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
684
+ }
685
+ function isEndOfValue(char, delim) {
686
+ return char === 32 || char === 9 || char === 10 || char === 13 || delim && (char === delim || char === 44) || char === 35;
687
+ }
688
+ function extractValue(ctx, end) {
689
+ let errPtr = ctx.p;
690
+ let c = ctx.s.charCodeAt(ctx.p);
797
691
  if (c === 91 || c === 123) {
798
- if (!ctx.d--) {
799
- throw new TomlError("document contains excessively nested structures. aborting.", {
800
- toml: ctx.s,
801
- ptr
802
- });
803
- }
804
- let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
692
+ ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
693
+ let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
805
694
  ctx.d++;
806
695
  return value;
807
696
  }
@@ -810,17 +699,243 @@ function extractValue(ctx, end, integersAsBigInt) {
810
699
  }
811
700
  if (c === 116) {
812
701
  if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
813
- throw new TomlError("invalid value", { toml: ctx.s, ptr });
814
- ctx.p++;
815
- return true;
702
+ TomlError.x("invalid value", ctx, errPtr);
703
+ return ctx.p++, true;
816
704
  }
817
705
  if (c === 102) {
818
706
  if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
819
- throw new TomlError("invalid value", { toml: ctx.s, ptr });
820
- ctx.p++;
821
- return false;
707
+ TomlError.x("invalid value", ctx, errPtr);
708
+ return ctx.p++, false;
709
+ }
710
+ if (c === 43 || c === 45) {
711
+ return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
712
+ }
713
+ if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) {
714
+ return parseDate(ctx, c, end);
715
+ }
716
+ if (ctx.s.charCodeAt(ctx.p + 2) === 58) {
717
+ return parseTime(ctx, c, end);
718
+ }
719
+ return parseNumber(ctx, ctx.p, c, 0, end);
720
+ }
721
+ function parseNumber(ctx, startPtr, startChr, sign, endChr) {
722
+ let c = startChr;
723
+ let state = 0;
724
+ let hasUnderscores = false;
725
+ if (c === 105) {
726
+ if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102)
727
+ TomlError.x("invalid value", ctx, startPtr);
728
+ return ctx.p++, (sign || 1) / 0;
729
+ }
730
+ if (c === 110) {
731
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110)
732
+ TomlError.x("invalid value", ctx, startPtr);
733
+ return ctx.p++, NaN;
734
+ }
735
+ if (c === 48) {
736
+ if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
737
+ return ctx.bi === true ? 0n : 0;
738
+ if (!sign) {
739
+ if (c === 120)
740
+ return parseIntegerBaseN(ctx, startPtr, 16, endChr);
741
+ else if (c === 98)
742
+ return parseIntegerBaseN(ctx, startPtr, 2, endChr);
743
+ else if (c === 111)
744
+ return parseIntegerBaseN(ctx, startPtr, 8, endChr);
745
+ }
746
+ if (c === 46)
747
+ state = 2;
748
+ else if (c === 101 || c === 69)
749
+ state = 4;
750
+ else
751
+ TomlError.x("illegal leading zero", ctx, startPtr);
752
+ } else if (!isDigit(c))
753
+ TomlError.x("invalid value", ctx, startPtr);
754
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
755
+ if (!state)
756
+ state = 1;
757
+ if (c === 95) {
758
+ if (!(state & 1))
759
+ TomlError.x("illegal underscore", ctx);
760
+ state += 11;
761
+ hasUnderscores = true;
762
+ } else if (state === 1 && c === 46)
763
+ state = 2;
764
+ else if ((state === 1 || state === 3) && (c === 101 || c === 69))
765
+ state = 4;
766
+ else if (state === 4 && (c === 43 || c === 45)) {
767
+ state = 6;
768
+ } else if (!isDigit(c))
769
+ TomlError.x(`illegal character in numeric literal`, ctx);
770
+ else if (state > 9)
771
+ state -= 11;
772
+ else if (!(state & 1))
773
+ state++;
774
+ }
775
+ if (!state) {
776
+ let val = (startChr - 48) * (sign || 1);
777
+ return ctx.bi === true ? BigInt(val) : val;
778
+ }
779
+ if (!(state & 1))
780
+ TomlError.x("unfinished numeric value", ctx, startPtr);
781
+ let str = ctx.s.slice(startPtr, ctx.p);
782
+ if (hasUnderscores)
783
+ str = str.replaceAll("_", "");
784
+ return state > 1 ? parseFloat(str) : parseInteger(ctx, str, 10, startPtr);
785
+ }
786
+ function parseIntegerBaseN(ctx, startPtr, base, endChr) {
787
+ let c, underscore = 1;
788
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
789
+ if (c === 95) {
790
+ if (underscore & 1)
791
+ TomlError.x("illegal underscore", ctx);
792
+ underscore = 3;
793
+ } else if (!isDigit(c, base))
794
+ TomlError.x(`illegal character in numeric literal`, ctx);
795
+ else if (underscore & 1)
796
+ underscore--;
797
+ }
798
+ if (underscore & 1)
799
+ TomlError.x("unfinished numeric value", ctx);
800
+ let str = ctx.s.slice(startPtr + 2, ctx.p);
801
+ if (underscore)
802
+ str = str.replaceAll("_", "");
803
+ return parseInteger(ctx, str, base, startPtr);
804
+ }
805
+ function parseInteger(ctx, str, base, startPtr) {
806
+ if (ctx.bi !== true)
807
+ int: {
808
+ let val = parseInt(str, base);
809
+ if (!Number.isSafeInteger(val)) {
810
+ if (ctx.bi)
811
+ break int;
812
+ TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
813
+ }
814
+ return val;
815
+ }
816
+ return base === 10 ? BigInt(str) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str);
817
+ }
818
+ function parseDate(ctx, c, endChr) {
819
+ let startPtr = ctx.p++, unsafeSeparator;
820
+ if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++))) {
821
+ return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
822
+ }
823
+ ctx.p += 5;
824
+ if (!isDigit(ctx.s.charCodeAt(ctx.p++)))
825
+ TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
826
+ if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
827
+ let t = ctx.s.slice(startPtr, ctx.p);
828
+ return readDate(ctx, t, 3, false, startPtr);
829
+ }
830
+ if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
831
+ TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
832
+ if (ctx.s.charCodeAt(ctx.p += 3) === 58)
833
+ ctx.p += 3;
834
+ if (ctx.s.charCodeAt(ctx.p) === 46)
835
+ while (isDigit(ctx.s.charCodeAt(++ctx.p)))
836
+ ;
837
+ if (c = ctx.s.charCodeAt(ctx.p)) {
838
+ if (c === 90 || c === 122) {
839
+ let t = ctx.s.slice(startPtr, ++ctx.p);
840
+ return readDate(ctx, t, 1, unsafeSeparator, startPtr, "[+00:00]");
841
+ }
842
+ if (c === 43 || c === 45) {
843
+ let t = ctx.s.slice(startPtr, ctx.p += 6);
844
+ return readDate(ctx, t, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
845
+ }
846
+ }
847
+ let t = ctx.s.slice(startPtr, ctx.p);
848
+ return readDate(ctx, t, 2, unsafeSeparator, startPtr);
849
+ }
850
+ function parseTime(ctx, c, endChr) {
851
+ let start = ctx.p;
852
+ if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) {
853
+ return parseNumber(ctx, --ctx.p, c, 0, endChr);
854
+ }
855
+ if (ctx.s.charCodeAt(ctx.p += 4) === 58)
856
+ ctx.p += 3;
857
+ if (ctx.s.charCodeAt(ctx.p) === 46)
858
+ while (isDigit(ctx.s.charCodeAt(++ctx.p)))
859
+ ;
860
+ let t = ctx.s.slice(start, ctx.p);
861
+ return readDate(ctx, t, 4, false, start);
862
+ }
863
+ function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
864
+ if (ctx.ld) {
865
+ let date = new TomlDate(str, type, unsafeDelim);
866
+ if (!date.isValid())
867
+ TomlError.x("invalid date", ctx, errPtr);
868
+ return date;
869
+ }
870
+ try {
871
+ if (temporalSuffix)
872
+ str += temporalSuffix;
873
+ switch (type) {
874
+ case 1:
875
+ return Temporal.ZonedDateTime.from(str);
876
+ case 2:
877
+ return Temporal.PlainDateTime.from(str);
878
+ case 3:
879
+ return Temporal.PlainDate.from(str);
880
+ case 4:
881
+ return Temporal.PlainTime.from(str);
882
+ }
883
+ } catch (e) {
884
+ TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
885
+ }
886
+ }
887
+
888
+ // node_modules/smol-toml/dist/util.js
889
+ /*!
890
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
891
+ * SPDX-License-Identifier: BSD-3-Clause
892
+ *
893
+ * Redistribution and use in source and binary forms, with or without
894
+ * modification, are permitted provided that the following conditions are met:
895
+ *
896
+ * 1. Redistributions of source code must retain the above copyright notice, this
897
+ * list of conditions and the following disclaimer.
898
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
899
+ * this list of conditions and the following disclaimer in the
900
+ * documentation and/or other materials provided with the distribution.
901
+ * 3. Neither the name of the copyright holder nor the names of its contributors
902
+ * may be used to endorse or promote products derived from this software without
903
+ * specific prior written permission.
904
+ *
905
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
906
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
907
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
908
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
909
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
910
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
911
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
912
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
913
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
914
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
915
+ */
916
+ function skipComment(ctx) {
917
+ for (;ctx.p < ctx.s.length; ctx.p++) {
918
+ let c = ctx.s.charCodeAt(ctx.p);
919
+ if (c === 10)
920
+ break;
921
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
922
+ ctx.p++;
923
+ break;
924
+ }
925
+ if (c < 32 && c !== 9 || c === 127) {
926
+ TomlError.x("control characters are not allowed in comments", ctx);
927
+ }
928
+ }
929
+ }
930
+ function skipVoid(ctx, banNewLines, banComments) {
931
+ let c;
932
+ while (ctx.p < ctx.s.length) {
933
+ while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)))
934
+ ctx.p++;
935
+ if (banComments || c !== 35)
936
+ break;
937
+ skipComment(ctx);
822
938
  }
823
- return parseValue(ctx, integersAsBigInt, end);
824
939
  }
825
940
 
826
941
  // node_modules/smol-toml/dist/struct.js
@@ -851,76 +966,50 @@ function extractValue(ctx, end, integersAsBigInt) {
851
966
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
852
967
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
853
968
  */
854
- var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
855
- function parseKey(ctx, end = "=") {
856
- let start = ctx.p;
857
- let dot = start - 1;
969
+ function parseKey(ctx, end = 61) {
970
+ let startPtr;
971
+ let state = 0;
858
972
  let parsed = [];
859
- let endPtr = ctx.s.indexOf(end, start);
860
- if (endPtr < 0) {
861
- throw new TomlError("incomplete key-value: cannot find end of key", {
862
- toml: ctx.s,
863
- ptr: start
864
- });
865
- }
973
+ let sliceStart;
974
+ let c = ctx.s.charCodeAt(startPtr = ctx.p);
866
975
  do {
867
- let c = ctx.s.charCodeAt(ctx.p = ++dot);
868
- if (c !== 32 && c !== 9) {
869
- if (c === 34 || c === 39) {
870
- if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
871
- throw new TomlError("multiline strings are not allowed in keys", {
872
- toml: ctx.s,
873
- ptr: ctx.p
874
- });
875
- }
876
- let part = parseString(ctx);
877
- dot = ctx.s.indexOf(".", ctx.p);
878
- let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
879
- let newLine = indexOfNewline(strEnd);
880
- if (newLine > -1) {
881
- throw new TomlError("newlines are not allowed in keys", {
882
- toml: ctx.s,
883
- ptr: newLine
884
- });
885
- }
886
- if (strEnd.trimStart()) {
887
- throw new TomlError("found extra tokens after the string part", {
888
- toml: ctx.s,
889
- ptr: ctx.p
890
- });
891
- }
892
- if (endPtr < ctx.p) {
893
- endPtr = ctx.s.indexOf(end, ctx.p);
894
- if (endPtr < 0) {
895
- throw new TomlError("incomplete key-value: cannot find end of key", {
896
- toml: ctx.s,
897
- ptr: start
898
- });
899
- }
900
- }
901
- parsed.push(part);
902
- } else {
903
- dot = ctx.s.indexOf(".", ctx.p);
904
- let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
905
- if (!KEY_PART_RE.test(part)) {
906
- throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
907
- toml: ctx.s,
908
- ptr: ctx.p
909
- });
910
- }
911
- parsed.push(part.trimEnd());
976
+ if (c === end) {
977
+ if (!state)
978
+ TomlError.x("unexpected end of key", ctx);
979
+ if (state === 1)
980
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
981
+ return ctx.p++, parsed;
982
+ } else if (c === 46) {
983
+ if (!state)
984
+ TomlError.x("illegal empty bare key", ctx);
985
+ if (state === 1)
986
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
987
+ state = 0;
988
+ } else if (!state && (c === 34 || c === 39)) {
989
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2))
990
+ TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
991
+ parsed.push(parseString(ctx));
992
+ state = 2;
993
+ ctx.p--;
994
+ } else if (c === 32 || c === 9) {
995
+ if (state === 1) {
996
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
997
+ state = 2;
912
998
  }
999
+ } else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) {
1000
+ TomlError.x("illegal character in key", ctx);
1001
+ } else if (!state) {
1002
+ state = 1;
1003
+ sliceStart = ctx.p;
913
1004
  }
914
- } while (dot + 1 && dot < endPtr);
915
- ctx.p = endPtr + 1;
916
- skipVoid(ctx, true, true);
917
- return parsed;
1005
+ } while (c = ctx.s.charCodeAt(++ctx.p));
1006
+ TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
918
1007
  }
919
- function parseInlineTable(ctx, integersAsBigInt) {
920
- let res = {};
1008
+ function parseInlineTable(ctx) {
1009
+ let startPtr = ctx.p++;
1010
+ let res = Object.create(null);
921
1011
  let seen = new Set;
922
1012
  let c;
923
- ctx.p++;
924
1013
  while (ctx.p < ctx.s.length) {
925
1014
  skipVoid(ctx);
926
1015
  if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
@@ -930,66 +1019,59 @@ function parseInlineTable(ctx, integersAsBigInt) {
930
1019
  let k;
931
1020
  let t = res;
932
1021
  let hasOwn = false;
933
- let p = ctx.p;
1022
+ let errPtr = ctx.p;
934
1023
  let key = parseKey(ctx);
935
1024
  for (let i = 0;i < key.length; i++) {
936
1025
  if (i)
937
- t = hasOwn ? t[k] : t[k] = {};
1026
+ t = hasOwn ? t[k] : t[k] = Object.create(null);
938
1027
  k = key[i];
939
1028
  if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
940
- throw new TomlError("trying to redefine an already defined value", {
941
- toml: ctx.s,
942
- ptr: p
943
- });
1029
+ TomlError.x("trying to redefine an already defined value", ctx, errPtr);
1030
+ }
1031
+ let unsafe = k === "__proto__";
1032
+ if (ctx.uk && (unsafe || k === "constructor")) {
1033
+ t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
1034
+ break;
944
1035
  }
945
- if (!hasOwn && k === "__proto__") {
1036
+ if (!hasOwn && unsafe) {
946
1037
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
947
1038
  }
948
1039
  }
949
1040
  if (hasOwn) {
950
- throw new TomlError("trying to redefine an already defined value", {
951
- toml: ctx.s,
952
- ptr: ctx.p
953
- });
1041
+ TomlError.x("trying to redefine an already defined value", ctx, errPtr);
954
1042
  }
955
- let value = extractValue(ctx, 125, integersAsBigInt);
956
- seen.add(t[k] = value);
1043
+ skipVoid(ctx, true, true);
1044
+ let value = extractValue(ctx, 125);
1045
+ if (t && typeof (t[k] = value) === "object")
1046
+ seen.add(value);
957
1047
  skipVoid(ctx);
958
1048
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
959
1049
  return res;
960
1050
  }
961
- if (c !== 44) {
962
- throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
963
- }
1051
+ if (c !== 44)
1052
+ TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
964
1053
  }
965
- throw new TomlError("unfinished table encountered", {
966
- toml: ctx.s,
967
- ptr: ctx.p
968
- });
1054
+ TomlError.x("unfinished table", ctx, startPtr);
969
1055
  }
970
- function parseArray(ctx, integersAsBigInt) {
1056
+ function parseArray(ctx) {
1057
+ let startPtr = ctx.p++;
971
1058
  let res = [];
972
1059
  let c;
973
- ctx.p++;
974
1060
  while (ctx.p < ctx.s.length) {
975
1061
  skipVoid(ctx);
976
1062
  if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
977
1063
  ctx.p++;
978
1064
  return res;
979
1065
  }
980
- res.push(extractValue(ctx, 93, integersAsBigInt));
1066
+ res.push(extractValue(ctx, 93));
981
1067
  skipVoid(ctx);
982
1068
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
983
1069
  return res;
984
1070
  }
985
- if (c !== 44) {
986
- throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
987
- }
1071
+ if (c !== 44)
1072
+ TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
988
1073
  }
989
- throw new TomlError("unfinished array encountered", {
990
- toml: ctx.s,
991
- ptr: ctx.p
992
- });
1074
+ TomlError.x("unfinished array", ctx, startPtr);
993
1075
  }
994
1076
 
995
1077
  // node_modules/smol-toml/dist/parse.js
@@ -1020,7 +1102,7 @@ function parseArray(ctx, integersAsBigInt) {
1020
1102
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1021
1103
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1022
1104
  */
1023
- function peekTable(key, table, meta, type) {
1105
+ function peekTable(ctx, key, table, meta, type) {
1024
1106
  let t = table;
1025
1107
  let m = meta;
1026
1108
  let k;
@@ -1028,7 +1110,7 @@ function peekTable(key, table, meta, type) {
1028
1110
  let state;
1029
1111
  for (let i = 0;i < key.length; i++) {
1030
1112
  if (i) {
1031
- t = hasOwn ? t[k] : t[k] = {};
1113
+ t = hasOwn ? t[k] : t[k] = Object.create(null);
1032
1114
  m = (state = m[k]).c;
1033
1115
  if (type === 0 && (state.t === 1 || state.t === 2)) {
1034
1116
  return null;
@@ -1044,7 +1126,10 @@ function peekTable(key, table, meta, type) {
1044
1126
  return null;
1045
1127
  }
1046
1128
  if (!hasOwn) {
1047
- if (k === "__proto__") {
1129
+ let unsafe = k === "__proto__";
1130
+ if (ctx.uk && (unsafe || k === "constructor"))
1131
+ return false;
1132
+ if (unsafe) {
1048
1133
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1049
1134
  Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
1050
1135
  }
@@ -1052,7 +1137,7 @@ function peekTable(key, table, meta, type) {
1052
1137
  t: i < key.length - 1 && type === 2 ? 3 : type,
1053
1138
  d: false,
1054
1139
  i: 0,
1055
- c: {}
1140
+ c: Object.create(null)
1056
1141
  };
1057
1142
  }
1058
1143
  }
@@ -1065,69 +1150,76 @@ function peekTable(key, table, meta, type) {
1065
1150
  state.d = true;
1066
1151
  t[k] = [];
1067
1152
  }
1068
- t[k].push(t = {});
1069
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
1153
+ t[k].push(t = Object.create(null));
1154
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: Object.create(null) };
1070
1155
  }
1071
1156
  if (state.d) {
1072
1157
  return null;
1073
1158
  }
1074
1159
  state.d = true;
1075
1160
  if (type === 1) {
1076
- t = hasOwn ? t[k] : t[k] = {};
1161
+ t = hasOwn ? t[k] : t[k] = Object.create(null);
1077
1162
  } else if (type === 0 && hasOwn) {
1078
1163
  return null;
1079
1164
  }
1080
1165
  return [k, t, state.c];
1081
1166
  }
1082
- function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
1083
- let ctx = { s: toml, p: 0, d: maxDepth };
1084
- let res = {};
1085
- let meta = {};
1167
+ function validateTablePeek(ctx, peek, ptr) {
1168
+ if (peek === null || ctx.uk === 2)
1169
+ TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
1170
+ }
1171
+ function parse(toml, options = {}) {
1172
+ let ctx = {
1173
+ s: toml,
1174
+ p: 0,
1175
+ d: options.maxDepth ?? 1000,
1176
+ bi: options.integersAsBigInt ?? false,
1177
+ ld: options.useLegacyDate ?? true,
1178
+ uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
1179
+ };
1180
+ let res = Object.create(null);
1181
+ let meta = Object.create(null);
1086
1182
  let tmp;
1183
+ let skipping = false;
1087
1184
  let tbl = res;
1088
1185
  let m = meta;
1186
+ if (toml.charCodeAt(0) === 65279)
1187
+ ctx.p++;
1089
1188
  skipVoid(ctx);
1090
1189
  while (ctx.p < toml.length) {
1091
1190
  if (toml.charCodeAt(ctx.p) === 91) {
1092
1191
  let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1093
1192
  tmp = ctx.p += +isTableArray;
1094
- let k = parseKey(ctx, "]");
1193
+ skipping = false;
1194
+ let k = parseKey(ctx, 93);
1095
1195
  if (isTableArray) {
1096
- if (toml.charCodeAt(ctx.p - 1) !== 93) {
1097
- throw new TomlError("expected end of table declaration", {
1098
- toml,
1099
- ptr: ctx.p - 1
1100
- });
1196
+ if (toml.charCodeAt(ctx.p) !== 93) {
1197
+ TomlError.x("expected end of table array declaration", ctx);
1101
1198
  }
1102
1199
  ctx.p++;
1103
1200
  }
1104
- let p = peekTable(k, res, meta, isTableArray ? 2 : 1);
1201
+ let p = peekTable(ctx, k, res, meta, isTableArray ? 2 : 1);
1105
1202
  if (!p) {
1106
- throw new TomlError("trying to redefine an already defined table or value", {
1107
- toml,
1108
- ptr: tmp
1109
- });
1203
+ validateTablePeek(ctx, p, tmp);
1204
+ skipping = true;
1205
+ } else {
1206
+ m = p[2];
1207
+ tbl = p[1];
1110
1208
  }
1111
- m = p[2];
1112
- tbl = p[1];
1113
1209
  } else {
1114
1210
  tmp = ctx.p;
1115
1211
  let k = parseKey(ctx);
1116
- let p = peekTable(k, tbl, m, 0);
1117
- if (!p) {
1118
- throw new TomlError("trying to redefine an already defined table or value", {
1119
- toml,
1120
- ptr: tmp
1121
- });
1122
- }
1123
- p[1][p[0]] = extractValue(ctx, undefined, integersAsBigInt);
1212
+ let p = peekTable(ctx, k, tbl, m, 0);
1213
+ if (!p && !skipping)
1214
+ validateTablePeek(ctx, p, tmp);
1215
+ skipVoid(ctx, true, true);
1216
+ let v = extractValue(ctx, undefined);
1217
+ if (p && !skipping)
1218
+ p[1][p[0]] = v;
1124
1219
  }
1125
1220
  skipVoid(ctx, true);
1126
- if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
1127
- throw new TomlError("each key-value declaration must be followed by an end-of-line", {
1128
- toml,
1129
- ptr: ctx.p
1130
- });
1221
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) {
1222
+ TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
1131
1223
  }
1132
1224
  skipVoid(ctx);
1133
1225
  }
@@ -1162,6 +1254,7 @@ function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
1162
1254
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1163
1255
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1164
1256
  */
1257
+ var HAS_WELLFORMED = !!"".isWellFormed;
1165
1258
 
1166
1259
  // node_modules/smol-toml/dist/index.js
1167
1260
  /*!
@@ -1484,9 +1577,9 @@ class AppServer {
1484
1577
  `);
1485
1578
  }
1486
1579
  request(method, params) {
1487
- return new Promise((resolve4, reject) => {
1580
+ return new Promise((resolve, reject) => {
1488
1581
  const id = ++this.nextId;
1489
- this.pending.set(id, { method, resolve: resolve4, reject });
1582
+ this.pending.set(id, { method, resolve, reject });
1490
1583
  try {
1491
1584
  this.write({ id, method, params });
1492
1585
  } catch (e) {
@@ -1589,8 +1682,8 @@ class AppServer {
1589
1682
  const permissions = this.threadPermissions.get(thread);
1590
1683
  if (!permissions)
1591
1684
  throw new Error("Thread permissions have not been configured");
1592
- const completed = new Promise((resolve4, reject) => {
1593
- this.active = { thread, items: new Map, early: [], resolve: resolve4, reject };
1685
+ const completed = new Promise((resolve, reject) => {
1686
+ this.active = { thread, items: new Map, early: [], resolve, reject };
1594
1687
  });
1595
1688
  completed.catch(() => {});
1596
1689
  try {
@@ -1943,7 +2036,7 @@ class Bridge {
1943
2036
  }
1944
2037
  async run() {
1945
2038
  while (!this.stopped) {
1946
- const e = this.state.entries.find((e2) => e2.status === "pending" || e2.status === "ready");
2039
+ const e = this.state.entries.find((e) => e.status === "pending" || e.status === "ready");
1947
2040
  if (!e)
1948
2041
  return;
1949
2042
  if (!permitted(e.message, this.config)) {
@@ -2310,12 +2403,12 @@ class AgentsChatTransport {
2310
2403
  async send(channel, text) {
2311
2404
  if (this.authenticated && this.socket?.readyState === WebSocket.OPEN) {
2312
2405
  const id = randomUUID2();
2313
- await new Promise((resolve4, reject) => {
2406
+ await new Promise((resolve, reject) => {
2314
2407
  const timer = setTimeout(() => {
2315
2408
  this.pending.delete(id);
2316
2409
  reject(new Error("AgentsChat acknowledgement timed out"));
2317
2410
  }, 15000);
2318
- this.pending.set(id, { resolve: resolve4, reject, timer });
2411
+ this.pending.set(id, { resolve, reject, timer });
2319
2412
  this.socket.send(JSON.stringify({
2320
2413
  type: "message",
2321
2414
  id,
@@ -2350,7 +2443,7 @@ class AgentsChatTransport {
2350
2443
  if (current() && socket.readyState === WebSocket.OPEN)
2351
2444
  socket.send(JSON.stringify(value));
2352
2445
  };
2353
- const join9 = (channel) => {
2446
+ const join = (channel) => {
2354
2447
  if (!this.config.channels.length || this.config.channels.includes(channel)) {
2355
2448
  this.inboxSync?.watch(channel);
2356
2449
  send({ type: "join_channel", channel_id: channel, agent_id: this.config.agentId });
@@ -2390,7 +2483,7 @@ class AgentsChatTransport {
2390
2483
  const ids = channels.map((c) => c.id ?? c.channel_id).filter((id) => typeof id === "string" && (!this.config.channels.length || this.config.channels.includes(id)));
2391
2484
  this.inboxSync?.memberships(ids);
2392
2485
  for (const id of ids)
2393
- join9(id);
2486
+ join(id);
2394
2487
  this.inboxSync?.sync();
2395
2488
  }).catch(() => {
2396
2489
  if (current()) {
@@ -2406,7 +2499,7 @@ class AgentsChatTransport {
2406
2499
  pending.resolve();
2407
2500
  }
2408
2501
  } else if (data.type === "channel_created" && typeof data.channel_id === "string")
2409
- join9(data.channel_id);
2502
+ join(data.channel_id);
2410
2503
  else if (["message", "thread_reply"].includes(data.type))
2411
2504
  this.receive(data);
2412
2505
  else if (data.type === "shard_moved" || data.type === "please_reconnect")
@@ -2497,7 +2590,7 @@ async function main() {
2497
2590
  if (values["gui-thread"] || values["gui-message-file"] || values["gui-status"]) {
2498
2591
  const channel = new GuiChannel(join9(homedir4(), ".agentschat/codex-gui-outbox"), values["gui-thread"] ? [values["gui-thread"]] : []);
2499
2592
  if (values["gui-status"]) {
2500
- console.log(JSON.stringify(channel.list().map(({ prompt: prompt2, ...receipt2 }) => receipt2)));
2593
+ console.log(JSON.stringify(channel.list().map(({ prompt, ...receipt }) => receipt)));
2501
2594
  return;
2502
2595
  }
2503
2596
  if (!values["gui-thread"] || !values["gui-message-file"])
@@ -2508,7 +2601,7 @@ async function main() {
2508
2601
  }
2509
2602
  if ((values.bot || values["managed-worker"]) && (values["state-root"] || values["codex-home-mode"]))
2510
2603
  throw new Error("For managed bots, configure state_root/codex_home_mode in the bot registry");
2511
- const snapshot = values["managed-worker"] ? await new Promise((resolve4, reject) => {
2604
+ const snapshot = values["managed-worker"] ? await new Promise((resolve, reject) => {
2512
2605
  if (!process.connected) {
2513
2606
  reject(new Error("Managed worker needs parent IPC"));
2514
2607
  return;
@@ -2516,7 +2609,7 @@ async function main() {
2516
2609
  const timer = setTimeout(() => reject(new Error("Parent configuration missing")), 1e4);
2517
2610
  process.once("message", (config) => {
2518
2611
  clearTimeout(timer);
2519
- resolve4(config);
2612
+ resolve(config);
2520
2613
  });
2521
2614
  }) : undefined;
2522
2615
  const c = snapshot ?? (values.bot ? loadBots(values.registry).find((b) => b.name === values.bot) : resolveConfig({ cwd: values.cwd, profile: values.profile, codexBin: values["codex-bin"], stateRoot: values["state-root"], codexHomeMode: values["codex-home-mode"] }));
@@ -2541,7 +2634,7 @@ async function main() {
2541
2634
  const state = JSON.parse(readFileSync8(join9(c.stateDir, "state.json"), "utf8"));
2542
2635
  const channels = state.channels ?? {};
2543
2636
  if (values.conversations) {
2544
- console.log(JSON.stringify(Object.entries(channels).map(([channel2, data]) => ({ channel: channel2, thread: data.thread, isolated: data.namespace === runtime.home }))));
2637
+ console.log(JSON.stringify(Object.entries(channels).map(([channel, data]) => ({ channel, thread: data.thread, isolated: data.namespace === runtime.home }))));
2545
2638
  return;
2546
2639
  }
2547
2640
  const channel = channels[values["read-conversation"]];