agentschat-mcp 0.36.13 → 0.36.14

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 home = join(stateDir, "codex-home-isolated");
44
- mkdirSync(home, { recursive: true, mode: 448 });
45
- assertIndependentTree(home, undefined, executablePath(codexBin));
46
- return { home: realpathSync(home) };
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) };
47
47
  }
48
48
  if (mode === "auth-only") {
49
- const legacyHome = realpathSync(source);
50
- const origin = join(legacyHome, "auth.json");
49
+ const legacyHome2 = realpathSync(source);
50
+ const origin = join(legacyHome2, "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 home = join(stateDir, "codex-home-auth-only");
54
- mkdirSync(home, { recursive: true, mode: 448 });
55
- if (lstatSync(home).isSymbolicLink() || realpathSync(home) === legacyHome)
53
+ const home2 = join(stateDir, "codex-home-auth-only");
54
+ mkdirSync(home2, { recursive: true, mode: 448 });
55
+ if (lstatSync(home2).isSymbolicLink() || realpathSync(home2) === legacyHome2)
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(home, name));
59
+ lstatSync(join(home2, 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(home, "skills");
67
+ const skills = join(home2, "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(home, origin, executablePath(codexBin));
71
- const target = join(home, "auth.json");
70
+ assertIndependentTree(home2, origin, executablePath(codexBin));
71
+ const target = join(home2, "auth.json");
72
72
  try {
73
- if (!lstatSync(target).isSymbolicLink() || resolve(home, readlinkSync(target)) !== origin)
73
+ if (!lstatSync(target).isSymbolicLink() || resolve(home2, 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(home, origin, executablePath(codexBin));
81
- return { home: realpathSync(home) };
80
+ assertIndependentTree(home2, origin, executablePath(codexBin));
81
+ return { home: realpathSync(home2) };
82
82
  }
83
83
  const legacyHome = existsSync(source) ? realpathSync(source) : resolve(source);
84
84
  const home = join(stateDir, "codex-home");
@@ -171,7 +171,7 @@ async function getOnboardingStatus(base, agentId, token, request = fetch) {
171
171
  return result;
172
172
  result.authentication = "ok";
173
173
  result.claimed = data.claimed;
174
- result.next_step = data.claimed ? "verify_reply" : "claim_agent";
174
+ result.next_step = data.claimed ? "verify_reply" : "join_public_chat";
175
175
  } catch {}
176
176
  return result;
177
177
  }
@@ -292,9 +292,9 @@ ${text}`,
292
292
  }
293
293
 
294
294
  // codex/run.ts
295
- import { readFileSync as readFileSync8 } from "node:fs";
295
+ import { readFileSync as readFileSync9 } from "node:fs";
296
296
  import { homedir as homedir4 } from "node:os";
297
- import { join as join9 } from "node:path";
297
+ import { join as join10 } from "node:path";
298
298
 
299
299
  // codex/bots-config.ts
300
300
  import { readFileSync as readFileSync3, realpathSync as realpathSync3, mkdirSync as mkdirSync3 } from "node:fs";
@@ -315,6 +315,126 @@ 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
+
318
438
  // node_modules/smol-toml/dist/error.js
319
439
  /*!
320
440
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -344,11 +464,11 @@ function validateIdentityProfile(profile, file, allowDevToken = false) {
344
464
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
345
465
  */
346
466
  function getLineColFromPtr(string, ptr) {
347
- let lines = string.slice(0, ptr).split(/\r?\n/);
467
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
348
468
  return [lines.length, lines.pop().length + 1];
349
469
  }
350
470
  function makeCodeBlock(string, line, column) {
351
- let lines = string.split(/\r?\n/);
471
+ let lines = string.split(/\r\n|\n|\r/g);
352
472
  let codeblock = "";
353
473
  let numberLen = (Math.log10(line + 1) | 0) + 1;
354
474
  for (let i = line - 1;i <= line + 1; i++) {
@@ -383,9 +503,89 @@ ${codeblock}`, options);
383
503
  this.column = column;
384
504
  this.codeblock = codeblock;
385
505
  }
386
- static x(message, ctx, ptr) {
387
- throw new TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
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
+ }
388
584
  }
585
+ throw new TomlError("cannot find end of structure", {
586
+ toml: ctx.s,
587
+ ptr
588
+ });
389
589
  }
390
590
 
391
591
  // node_modules/smol-toml/dist/primitive.js
@@ -416,8 +616,11 @@ ${codeblock}`, options);
416
616
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
417
617
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
418
618
  */
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_]/;
419
622
  function parseString(ctx) {
420
- let startPtr = ctx.p;
623
+ let start = ctx.p;
421
624
  let c = ctx.s.charCodeAt(ctx.p++);
422
625
  let first = c;
423
626
  let isLiteral = c === 39;
@@ -436,7 +639,10 @@ function parseString(ctx) {
436
639
  if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
437
640
  state = state && 3;
438
641
  } else if (c < 32 && c !== 9 || c === 127) {
439
- TomlError.x("control characters are not allowed in strings", ctx);
642
+ throw new TomlError("control characters are not allowed in strings", {
643
+ toml: ctx.s,
644
+ ptr: ctx.p
645
+ });
440
646
  } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
441
647
  if (isMultiline) {
442
648
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
@@ -444,10 +650,8 @@ function parseString(ctx) {
444
650
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
445
651
  ctx.p++;
446
652
  }
447
- if (!state) {
448
- let s = ctx.s.slice(sliceStart, ctx.p);
449
- parsed = parsed ? parsed + s : s;
450
- }
653
+ if (!state)
654
+ parsed += ctx.s.slice(sliceStart, ctx.p);
451
655
  ctx.p += isMultiline ? 3 : 1;
452
656
  return parsed;
453
657
  } else if (!state) {
@@ -457,23 +661,22 @@ function parseString(ctx) {
457
661
  }
458
662
  } else if (state === 1) {
459
663
  if (c === 120 || c === 117 || c === 85) {
460
- let errPtr = ctx.p++ - 1;
461
664
  let value = 0;
462
665
  let len = c === 120 ? 2 : c === 117 ? 4 : 8;
463
666
  for (let j = 0;j < len; j++, ctx.p++) {
464
- let hex = ctx.s.charCodeAt(ctx.p);
667
+ let hex = ctx.s.charCodeAt(ctx.p + 1);
465
668
  let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
466
669
  if (digit < 0)
467
- TomlError.x("invalid non-hex character in unicode escape", ctx);
670
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
468
671
  value = value << 4 | digit;
469
672
  }
470
673
  if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
471
- TomlError.x("invalid unicode escape", ctx, errPtr);
674
+ throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
472
675
  }
473
676
  parsed += String.fromCodePoint(value);
474
- sliceStart = ctx.p--;
677
+ sliceStart = ctx.p + 1;
475
678
  state = 0;
476
- } else if (isMultiline && (c === 32 || c === 9)) {
679
+ } else if (c === 32 || c === 9) {
477
680
  state = 2;
478
681
  } else {
479
682
  if (c === 98)
@@ -494,161 +697,70 @@ function parseString(ctx) {
494
697
  else if (c === 92)
495
698
  parsed += "\\";
496
699
  else
497
- TomlError.x("unrecognised escape sequence", ctx);
700
+ throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
498
701
  sliceStart = ctx.p + 1;
499
702
  state = 0;
500
703
  }
501
704
  } else if (c !== 32 && c !== 9) {
502
- if (state === 2)
503
- TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
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
+ }
504
711
  state = !isLiteral && c === 92 ? 1 : 0;
505
712
  sliceStart = ctx.p;
506
713
  }
507
714
  }
508
- TomlError.x("unfinished string", ctx, startPtr);
715
+ throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
509
716
  }
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
- }
591
- }
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();
725
+ }
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);
592
745
  }
593
- super(date);
594
- if (!isNaN(this.getTime())) {
595
- this.#hasDate = hasDate;
596
- this.#hasTime = hasTime;
597
- this.#offset = offset;
746
+ value = value.replace(/_/g, "");
747
+ let numeric = +value;
748
+ if (isNaN(numeric)) {
749
+ throw new TomlError("invalid number", err);
598
750
  }
751
+ if (isInt) {
752
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
753
+ throw new TomlError("integer value cannot be represented losslessly", err);
754
+ }
755
+ if (isInt || integersAsBigInt === true)
756
+ numeric = BigInt(value);
757
+ }
758
+ return numeric;
599
759
  }
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;
651
- }
760
+ const date = new TomlDate(value);
761
+ if (!date.isValid())
762
+ throw new TomlError("invalid value", err);
763
+ return date;
652
764
  }
653
765
 
654
766
  // node_modules/smol-toml/dist/extract.js
@@ -679,18 +791,17 @@ class TomlDate extends Date {
679
791
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
680
792
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
681
793
  */
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);
794
+ function extractValue(ctx, end, integersAsBigInt) {
795
+ let ptr = ctx.p;
796
+ let c = ctx.s.charCodeAt(ptr);
691
797
  if (c === 91 || c === 123) {
692
- ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
693
- let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
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);
694
805
  ctx.d++;
695
806
  return value;
696
807
  }
@@ -699,243 +810,17 @@ function extractValue(ctx, end) {
699
810
  }
700
811
  if (c === 116) {
701
812
  if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
702
- TomlError.x("invalid value", ctx, errPtr);
703
- return ctx.p++, true;
813
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
814
+ ctx.p++;
815
+ return true;
704
816
  }
705
817
  if (c === 102) {
706
818
  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)
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);
819
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
820
+ ctx.p++;
821
+ return false;
938
822
  }
823
+ return parseValue(ctx, integersAsBigInt, end);
939
824
  }
940
825
 
941
826
  // node_modules/smol-toml/dist/struct.js
@@ -966,50 +851,76 @@ function skipVoid(ctx, banNewLines, banComments) {
966
851
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
967
852
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
968
853
  */
969
- function parseKey(ctx, end = 61) {
970
- let startPtr;
971
- let state = 0;
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;
972
858
  let parsed = [];
973
- let sliceStart;
974
- let c = ctx.s.charCodeAt(startPtr = ctx.p);
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
+ }
975
866
  do {
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;
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());
998
912
  }
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;
1004
913
  }
1005
- } while (c = ctx.s.charCodeAt(++ctx.p));
1006
- TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
914
+ } while (dot + 1 && dot < endPtr);
915
+ ctx.p = endPtr + 1;
916
+ skipVoid(ctx, true, true);
917
+ return parsed;
1007
918
  }
1008
- function parseInlineTable(ctx) {
1009
- let startPtr = ctx.p++;
1010
- let res = Object.create(null);
919
+ function parseInlineTable(ctx, integersAsBigInt) {
920
+ let res = {};
1011
921
  let seen = new Set;
1012
922
  let c;
923
+ ctx.p++;
1013
924
  while (ctx.p < ctx.s.length) {
1014
925
  skipVoid(ctx);
1015
926
  if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
@@ -1019,59 +930,66 @@ function parseInlineTable(ctx) {
1019
930
  let k;
1020
931
  let t = res;
1021
932
  let hasOwn = false;
1022
- let errPtr = ctx.p;
933
+ let p = ctx.p;
1023
934
  let key = parseKey(ctx);
1024
935
  for (let i = 0;i < key.length; i++) {
1025
936
  if (i)
1026
- t = hasOwn ? t[k] : t[k] = Object.create(null);
937
+ t = hasOwn ? t[k] : t[k] = {};
1027
938
  k = key[i];
1028
939
  if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
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;
940
+ throw new TomlError("trying to redefine an already defined value", {
941
+ toml: ctx.s,
942
+ ptr: p
943
+ });
1035
944
  }
1036
- if (!hasOwn && unsafe) {
945
+ if (!hasOwn && k === "__proto__") {
1037
946
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1038
947
  }
1039
948
  }
1040
949
  if (hasOwn) {
1041
- TomlError.x("trying to redefine an already defined value", ctx, errPtr);
950
+ throw new TomlError("trying to redefine an already defined value", {
951
+ toml: ctx.s,
952
+ ptr: ctx.p
953
+ });
1042
954
  }
1043
- skipVoid(ctx, true, true);
1044
- let value = extractValue(ctx, 125);
1045
- if (t && typeof (t[k] = value) === "object")
1046
- seen.add(value);
955
+ let value = extractValue(ctx, 125, integersAsBigInt);
956
+ seen.add(t[k] = value);
1047
957
  skipVoid(ctx);
1048
958
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
1049
959
  return res;
1050
960
  }
1051
- if (c !== 44)
1052
- TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
961
+ if (c !== 44) {
962
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
963
+ }
1053
964
  }
1054
- TomlError.x("unfinished table", ctx, startPtr);
965
+ throw new TomlError("unfinished table encountered", {
966
+ toml: ctx.s,
967
+ ptr: ctx.p
968
+ });
1055
969
  }
1056
- function parseArray(ctx) {
1057
- let startPtr = ctx.p++;
970
+ function parseArray(ctx, integersAsBigInt) {
1058
971
  let res = [];
1059
972
  let c;
973
+ ctx.p++;
1060
974
  while (ctx.p < ctx.s.length) {
1061
975
  skipVoid(ctx);
1062
976
  if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
1063
977
  ctx.p++;
1064
978
  return res;
1065
979
  }
1066
- res.push(extractValue(ctx, 93));
980
+ res.push(extractValue(ctx, 93, integersAsBigInt));
1067
981
  skipVoid(ctx);
1068
982
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
1069
983
  return res;
1070
984
  }
1071
- if (c !== 44)
1072
- TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
985
+ if (c !== 44) {
986
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
987
+ }
1073
988
  }
1074
- TomlError.x("unfinished array", ctx, startPtr);
989
+ throw new TomlError("unfinished array encountered", {
990
+ toml: ctx.s,
991
+ ptr: ctx.p
992
+ });
1075
993
  }
1076
994
 
1077
995
  // node_modules/smol-toml/dist/parse.js
@@ -1102,7 +1020,7 @@ function parseArray(ctx) {
1102
1020
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1103
1021
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1104
1022
  */
1105
- function peekTable(ctx, key, table, meta, type) {
1023
+ function peekTable(key, table, meta, type) {
1106
1024
  let t = table;
1107
1025
  let m = meta;
1108
1026
  let k;
@@ -1110,7 +1028,7 @@ function peekTable(ctx, key, table, meta, type) {
1110
1028
  let state;
1111
1029
  for (let i = 0;i < key.length; i++) {
1112
1030
  if (i) {
1113
- t = hasOwn ? t[k] : t[k] = Object.create(null);
1031
+ t = hasOwn ? t[k] : t[k] = {};
1114
1032
  m = (state = m[k]).c;
1115
1033
  if (type === 0 && (state.t === 1 || state.t === 2)) {
1116
1034
  return null;
@@ -1126,10 +1044,7 @@ function peekTable(ctx, key, table, meta, type) {
1126
1044
  return null;
1127
1045
  }
1128
1046
  if (!hasOwn) {
1129
- let unsafe = k === "__proto__";
1130
- if (ctx.uk && (unsafe || k === "constructor"))
1131
- return false;
1132
- if (unsafe) {
1047
+ if (k === "__proto__") {
1133
1048
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1134
1049
  Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
1135
1050
  }
@@ -1137,7 +1052,7 @@ function peekTable(ctx, key, table, meta, type) {
1137
1052
  t: i < key.length - 1 && type === 2 ? 3 : type,
1138
1053
  d: false,
1139
1054
  i: 0,
1140
- c: Object.create(null)
1055
+ c: {}
1141
1056
  };
1142
1057
  }
1143
1058
  }
@@ -1150,76 +1065,69 @@ function peekTable(ctx, key, table, meta, type) {
1150
1065
  state.d = true;
1151
1066
  t[k] = [];
1152
1067
  }
1153
- t[k].push(t = Object.create(null));
1154
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: Object.create(null) };
1068
+ t[k].push(t = {});
1069
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
1155
1070
  }
1156
1071
  if (state.d) {
1157
1072
  return null;
1158
1073
  }
1159
1074
  state.d = true;
1160
1075
  if (type === 1) {
1161
- t = hasOwn ? t[k] : t[k] = Object.create(null);
1076
+ t = hasOwn ? t[k] : t[k] = {};
1162
1077
  } else if (type === 0 && hasOwn) {
1163
1078
  return null;
1164
1079
  }
1165
1080
  return [k, t, state.c];
1166
1081
  }
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);
1082
+ function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
1083
+ let ctx = { s: toml, p: 0, d: maxDepth };
1084
+ let res = {};
1085
+ let meta = {};
1182
1086
  let tmp;
1183
- let skipping = false;
1184
1087
  let tbl = res;
1185
1088
  let m = meta;
1186
- if (toml.charCodeAt(0) === 65279)
1187
- ctx.p++;
1188
1089
  skipVoid(ctx);
1189
1090
  while (ctx.p < toml.length) {
1190
1091
  if (toml.charCodeAt(ctx.p) === 91) {
1191
1092
  let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1192
1093
  tmp = ctx.p += +isTableArray;
1193
- skipping = false;
1194
- let k = parseKey(ctx, 93);
1094
+ let k = parseKey(ctx, "]");
1195
1095
  if (isTableArray) {
1196
- if (toml.charCodeAt(ctx.p) !== 93) {
1197
- TomlError.x("expected end of table array declaration", ctx);
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
+ });
1198
1101
  }
1199
1102
  ctx.p++;
1200
1103
  }
1201
- let p = peekTable(ctx, k, res, meta, isTableArray ? 2 : 1);
1104
+ let p = peekTable(k, res, meta, isTableArray ? 2 : 1);
1202
1105
  if (!p) {
1203
- validateTablePeek(ctx, p, tmp);
1204
- skipping = true;
1205
- } else {
1206
- m = p[2];
1207
- tbl = p[1];
1106
+ throw new TomlError("trying to redefine an already defined table or value", {
1107
+ toml,
1108
+ ptr: tmp
1109
+ });
1208
1110
  }
1111
+ m = p[2];
1112
+ tbl = p[1];
1209
1113
  } else {
1210
1114
  tmp = ctx.p;
1211
1115
  let k = parseKey(ctx);
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;
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);
1219
1124
  }
1220
1125
  skipVoid(ctx, true);
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);
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
+ });
1223
1131
  }
1224
1132
  skipVoid(ctx);
1225
1133
  }
@@ -1254,7 +1162,6 @@ function parse(toml, options = {}) {
1254
1162
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1255
1163
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1256
1164
  */
1257
- var HAS_WELLFORMED = !!"".isWellFormed;
1258
1165
 
1259
1166
  // node_modules/smol-toml/dist/index.js
1260
1167
  /*!
@@ -1530,6 +1437,8 @@ class AppServer {
1530
1437
  }
1531
1438
  async start() {
1532
1439
  const env = Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^AGENTS?CHAT_|^RELAY_/.test(k)));
1440
+ env.AGENTSCHAT_LOCK_OWNER_PID = String(process.pid);
1441
+ env.AGENTSCHAT_TOOL_ONLY = "1";
1533
1442
  if (this.runtime) {
1534
1443
  env.CODEX_HOME = this.runtime.home;
1535
1444
  env.CODEX_SQLITE_HOME = this.runtime.home;
@@ -1577,9 +1486,9 @@ class AppServer {
1577
1486
  `);
1578
1487
  }
1579
1488
  request(method, params) {
1580
- return new Promise((resolve, reject) => {
1489
+ return new Promise((resolve4, reject) => {
1581
1490
  const id = ++this.nextId;
1582
- this.pending.set(id, { method, resolve, reject });
1491
+ this.pending.set(id, { method, resolve: resolve4, reject });
1583
1492
  try {
1584
1493
  this.write({ id, method, params });
1585
1494
  } catch (e) {
@@ -1682,8 +1591,8 @@ class AppServer {
1682
1591
  const permissions = this.threadPermissions.get(thread);
1683
1592
  if (!permissions)
1684
1593
  throw new Error("Thread permissions have not been configured");
1685
- const completed = new Promise((resolve, reject) => {
1686
- this.active = { thread, items: new Map, early: [], resolve, reject };
1594
+ const completed = new Promise((resolve4, reject) => {
1595
+ this.active = { thread, items: new Map, early: [], resolve: resolve4, reject };
1687
1596
  });
1688
1597
  completed.catch(() => {});
1689
1598
  try {
@@ -1737,8 +1646,8 @@ function isTeamLeadSkillInvocation(prompt) {
1737
1646
  }
1738
1647
 
1739
1648
  // codex/bridge.ts
1740
- import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync3, openSync, closeSync, unlinkSync } from "node:fs";
1741
- import { join as join7 } from "node:path";
1649
+ import { existsSync as existsSync5, mkdirSync as mkdirSync6, readFileSync as readFileSync7, renameSync as renameSync4, writeFileSync as writeFileSync4, openSync, closeSync, unlinkSync as unlinkSync3 } from "node:fs";
1650
+ import { join as join8 } from "node:path";
1742
1651
 
1743
1652
  // codex/thread-history.ts
1744
1653
  import { createHash as createHash2 } from "node:crypto";
@@ -1873,6 +1782,124 @@ async function verifyLoopTick(raw, config, owner, list) {
1873
1782
  return current && current.owner_id === owner ? current : null;
1874
1783
  }
1875
1784
 
1785
+ // src/session-bind.ts
1786
+ import { createHash as createHash3 } from "node:crypto";
1787
+ import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, unlinkSync as unlinkSync2 } from "node:fs";
1788
+ import { tmpdir } from "node:os";
1789
+ import { join as join7 } from "node:path";
1790
+
1791
+ // src/profile-store.ts
1792
+ import { existsSync as existsSync3, writeFileSync as writeFileSync3, renameSync as renameSync3, chmodSync, unlinkSync, statSync as statSync2 } from "fs";
1793
+ var defaultWarn = (m) => process.stderr.write(m);
1794
+ function safeWriteProfile(path, data, warn = defaultWarn) {
1795
+ const tmp = path + ".tmp";
1796
+ try {
1797
+ if (existsSync3(tmp))
1798
+ unlinkSync(tmp);
1799
+ } catch (e) {
1800
+ warn(`[agentchat] WARNING: stale ${tmp} could not be removed: ${e}
1801
+ `);
1802
+ }
1803
+ writeFileSync3(tmp, JSON.stringify(data, null, 2), { mode: 384 });
1804
+ renameSync3(tmp, path);
1805
+ try {
1806
+ chmodSync(path, 384);
1807
+ } catch (e) {
1808
+ warn(`[agentchat] WARNING: could not chmod ${path} to 0600: ${e}
1809
+ `);
1810
+ }
1811
+ try {
1812
+ const mode = statSync2(path).mode & 511;
1813
+ if (mode !== 384) {
1814
+ warn(`[agentchat] WARNING: ${path} is mode ${mode.toString(8)}, expected 600 — it holds your agent key. Fix: chmod 600 ${path}
1815
+ `);
1816
+ }
1817
+ } catch (e) {
1818
+ warn(`[agentchat] WARNING: could not verify permissions of ${path}: ${e}
1819
+ `);
1820
+ }
1821
+ }
1822
+
1823
+ // src/session-bind.ts
1824
+ function isPidAlive(pid) {
1825
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0)
1826
+ return false;
1827
+ try {
1828
+ process.kill(pid, 0);
1829
+ return true;
1830
+ } catch (e) {
1831
+ if (e && typeof e === "object" && e.code === "EPERM")
1832
+ return true;
1833
+ return false;
1834
+ }
1835
+ }
1836
+ function resolveLockDir(homeDir, env = process.env) {
1837
+ const explicit = env.AGENTSCHAT_LOCK_DIR?.trim();
1838
+ if (explicit)
1839
+ return explicit;
1840
+ const hash = createHash3("sha256").update(homeDir || ".").digest("hex").slice(0, 12);
1841
+ const baseTmp = process.platform === "win32" ? tmpdir() : "/tmp";
1842
+ return join7(baseTmp, `agentschat-locks-${hash}`);
1843
+ }
1844
+ function lockFilePath(lockDir, agentId) {
1845
+ const safe = String(agentId || "").trim().replace(/[^a-zA-Z0-9_-]/g, "_");
1846
+ return join7(lockDir, `${safe}.lock`);
1847
+ }
1848
+ function readAgentLock(lockDir, agentId) {
1849
+ if (!agentId)
1850
+ return null;
1851
+ const file = lockFilePath(lockDir, agentId);
1852
+ if (!existsSync4(file))
1853
+ return null;
1854
+ try {
1855
+ const raw = JSON.parse(readFileSync6(file, "utf8"));
1856
+ if (!raw || typeof raw !== "object" || typeof raw.pid !== "number" || typeof raw.agentId !== "string") {
1857
+ return null;
1858
+ }
1859
+ return raw;
1860
+ } catch {
1861
+ return null;
1862
+ }
1863
+ }
1864
+ function acquireAgentLock(opts) {
1865
+ if (!opts.agentId)
1866
+ return null;
1867
+ const record = {
1868
+ pid: opts.currentPid ?? process.pid,
1869
+ agentId: opts.agentId,
1870
+ profileName: opts.profileName ?? null,
1871
+ sessionId: opts.sessionId ?? null,
1872
+ runtime: opts.runtime ?? "mcp",
1873
+ updatedAt: new Date().toISOString()
1874
+ };
1875
+ try {
1876
+ mkdirSync5(opts.lockDir, { recursive: true, mode: 448 });
1877
+ safeWriteProfile(lockFilePath(opts.lockDir, opts.agentId), record);
1878
+ return record;
1879
+ } catch {
1880
+ return null;
1881
+ }
1882
+ }
1883
+ function releaseAgentLock(opts) {
1884
+ if (!opts.agentId)
1885
+ return false;
1886
+ const currentPid = opts.currentPid ?? process.pid;
1887
+ const existing = readAgentLock(opts.lockDir, opts.agentId);
1888
+ if (!existing)
1889
+ return false;
1890
+ const samePid = existing.pid === currentPid;
1891
+ const sameSession = Boolean(opts.currentSessionId && existing.sessionId && opts.currentSessionId === existing.sessionId);
1892
+ const dead = !isPidAlive(existing.pid);
1893
+ if (!samePid && !sameSession && !dead)
1894
+ return false;
1895
+ try {
1896
+ unlinkSync2(lockFilePath(opts.lockDir, opts.agentId));
1897
+ return true;
1898
+ } catch {
1899
+ return false;
1900
+ }
1901
+ }
1902
+
1876
1903
  // codex/bridge.ts
1877
1904
  function permitted(m, c) {
1878
1905
  if (m.meta?.kind === "loop_tick")
@@ -1919,18 +1946,31 @@ class Bridge {
1919
1946
  this.activity = activity;
1920
1947
  this.owner = owner;
1921
1948
  this.loops = loops;
1922
- mkdirSync5(config.stateDir, { recursive: true, mode: 448 });
1923
- this.file = join7(config.stateDir, "state.json");
1924
- this.lock = join7(config.stateDir, "bridge.lock");
1949
+ mkdirSync6(config.stateDir, { recursive: true, mode: 448 });
1950
+ this.file = join8(config.stateDir, "state.json");
1951
+ this.lock = join8(config.stateDir, "bridge.lock");
1952
+ if (existsSync5(this.lock)) {
1953
+ try {
1954
+ const holderPid = Number(readFileSync7(this.lock, "utf8").trim());
1955
+ if (holderPid > 0 && !isPidAlive(holderPid))
1956
+ unlinkSync3(this.lock);
1957
+ } catch {}
1958
+ }
1925
1959
  try {
1926
1960
  const fd = openSync(this.lock, "wx", 384);
1927
- writeFileSync3(fd, String(process.pid));
1961
+ writeFileSync4(fd, String(process.pid));
1928
1962
  closeSync(fd);
1929
1963
  } catch {
1930
1964
  throw new Error(`Bridge already locked: ${this.lock}. If its process has exited, remove that lock manually.`);
1931
1965
  }
1966
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
1967
+ acquireAgentLock({
1968
+ lockDir: resolveLockDir(homeDir, process.env),
1969
+ agentId: config.agentId,
1970
+ runtime: "codex-bridge"
1971
+ });
1932
1972
  try {
1933
- this.state = existsSync3(this.file) ? JSON.parse(readFileSync6(this.file, "utf8")) : { version: 1, threads: {}, entries: [] };
1973
+ this.state = existsSync5(this.file) ? JSON.parse(readFileSync7(this.file, "utf8")) : { version: 1, threads: {}, entries: [] };
1934
1974
  if (this.state.version !== 1 || !this.state.threads || !Array.isArray(this.state.entries))
1935
1975
  throw new Error("Invalid bridge state");
1936
1976
  for (const e of this.state.entries) {
@@ -1941,14 +1981,14 @@ class Bridge {
1941
1981
  }
1942
1982
  this.save();
1943
1983
  } catch {
1944
- unlinkSync(this.lock);
1984
+ unlinkSync3(this.lock);
1945
1985
  throw new Error("Cannot load bridge state; refusing to discard history");
1946
1986
  }
1947
1987
  }
1948
1988
  save() {
1949
1989
  const tmp = this.file + ".tmp";
1950
- writeFileSync3(tmp, JSON.stringify(this.state), { mode: 384 });
1951
- renameSync3(tmp, this.file);
1990
+ writeFileSync4(tmp, JSON.stringify(this.state), { mode: 384 });
1991
+ renameSync4(tmp, this.file);
1952
1992
  }
1953
1993
  accept(raw) {
1954
1994
  if (this.stopped || !addressed(raw, this.config))
@@ -2036,7 +2076,7 @@ class Bridge {
2036
2076
  }
2037
2077
  async run() {
2038
2078
  while (!this.stopped) {
2039
- const e = this.state.entries.find((e) => e.status === "pending" || e.status === "ready");
2079
+ const e = this.state.entries.find((e2) => e2.status === "pending" || e2.status === "ready");
2040
2080
  if (!e)
2041
2081
  return;
2042
2082
  if (!permitted(e.message, this.config)) {
@@ -2067,7 +2107,7 @@ This scheduled skill run supports ${TEAM_LEAD_NO_UPDATE}; return it alone only w
2067
2107
  Authorized task:
2068
2108
  ${authorizedTask}` : `You are the online AgentsChat bot ${this.config.agentId}, running through Codex App Server in ${this.config.cwd}. This message was delivered to you live. If asked whether you are online, confirm your own availability.
2069
2109
  Use this channel's shared conversation and configured tools to carry out the request.
2070
- Recurring-task setup, only when requested: create the server loop as this bot in this same channel. Then verify its record with list_loops and confirm this bot is claimed with whoami and obtain its owner_account_id with my_entitlements. Maintain the private file ${join7(this.config.stateDir, "loop-grants.json")} (mode 0600): {"version":1,"grants":[{"loop_id":"server loop ID","channel_id":"this channel ID","agent_id":"this bot ID","owner_id":"verified owner ID","interval_ms":60000,"prompt":"exact server prompt"}]}. Use the actual server interval, preserve other grants, and confirm setup only after both server registration and the matching local grant exist. Stopping a loop also removes its grant. Do not change unrelated loops.
2110
+ Recurring-task setup, only when requested: create the server loop as this bot in this same channel. Then verify its record with list_loops and confirm this bot is claimed with whoami and obtain its owner_account_id with my_entitlements. Maintain the private file ${join8(this.config.stateDir, "loop-grants.json")} (mode 0600): {"version":1,"grants":[{"loop_id":"server loop ID","channel_id":"this channel ID","agent_id":"this bot ID","owner_id":"verified owner ID","interval_ms":60000,"prompt":"exact server prompt"}]}. Use the actual server interval, preserve other grants, and confirm setup only after both server registration and the matching local grant exist. Stopping a loop also removes its grant. Do not change unrelated loops.
2071
2111
  AgentsChat message:
2072
2112
  ` + JSON.stringify(e.message);
2073
2113
  e.answer = this.redact(await this.codex.generate(channel.thread, (channel.bootstrap ?? "") + prompt));
@@ -2125,8 +2165,10 @@ AgentsChat message:
2125
2165
  async stop() {
2126
2166
  this.pause();
2127
2167
  await this.draining;
2128
- if (existsSync3(this.lock))
2129
- unlinkSync(this.lock);
2168
+ if (existsSync5(this.lock))
2169
+ unlinkSync3(this.lock);
2170
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
2171
+ releaseAgentLock({ lockDir: resolveLockDir(homeDir, process.env), agentId: this.config.agentId });
2130
2172
  }
2131
2173
  }
2132
2174
 
@@ -2207,8 +2249,8 @@ class HeartbeatMonitor {
2207
2249
  }
2208
2250
 
2209
2251
  // codex/inbox-sync.ts
2210
- import { existsSync as existsSync4, mkdirSync as mkdirSync6, readFileSync as readFileSync7, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "node:fs";
2211
- import { join as join8 } from "node:path";
2252
+ import { existsSync as existsSync6, mkdirSync as mkdirSync7, readFileSync as readFileSync8, renameSync as renameSync5, writeFileSync as writeFileSync5 } from "node:fs";
2253
+ import { join as join9 } from "node:path";
2212
2254
 
2213
2255
  // src/timestamps.ts
2214
2256
  function normalizeTimestampForCursor(ts, mode) {
@@ -2250,9 +2292,9 @@ class InboxSync {
2250
2292
  this.receive = receive;
2251
2293
  this.active = active;
2252
2294
  this.log = log;
2253
- mkdirSync6(stateDir, { recursive: true, mode: 448 });
2254
- this.file = join8(stateDir, "inbound-cursors.json");
2255
- this.state = existsSync4(this.file) ? JSON.parse(readFileSync7(this.file, "utf8")) : { version: 1, channels: {} };
2295
+ mkdirSync7(stateDir, { recursive: true, mode: 448 });
2296
+ this.file = join9(stateDir, "inbound-cursors.json");
2297
+ this.state = existsSync6(this.file) ? JSON.parse(readFileSync8(this.file, "utf8")) : { version: 1, channels: {} };
2256
2298
  if (this.state.version !== 1 || !this.state.channels || typeof this.state.channels !== "object" || Array.isArray(this.state.channels))
2257
2299
  throw new Error("Invalid inbound cursors; refusing to discard checkpoint");
2258
2300
  for (const value of Object.values(this.state.channels))
@@ -2260,8 +2302,8 @@ class InboxSync {
2260
2302
  this.state.channels = Object.assign(Object.create(null), this.state.channels);
2261
2303
  }
2262
2304
  save() {
2263
- writeFileSync4(this.file + ".tmp", JSON.stringify(this.state), { mode: 384 });
2264
- renameSync4(this.file + ".tmp", this.file);
2305
+ writeFileSync5(this.file + ".tmp", JSON.stringify(this.state), { mode: 384 });
2306
+ renameSync5(this.file + ".tmp", this.file);
2265
2307
  }
2266
2308
  watch(channel) {
2267
2309
  this.channels.add(channel);
@@ -2403,12 +2445,12 @@ class AgentsChatTransport {
2403
2445
  async send(channel, text) {
2404
2446
  if (this.authenticated && this.socket?.readyState === WebSocket.OPEN) {
2405
2447
  const id = randomUUID2();
2406
- await new Promise((resolve, reject) => {
2448
+ await new Promise((resolve4, reject) => {
2407
2449
  const timer = setTimeout(() => {
2408
2450
  this.pending.delete(id);
2409
2451
  reject(new Error("AgentsChat acknowledgement timed out"));
2410
2452
  }, 15000);
2411
- this.pending.set(id, { resolve, reject, timer });
2453
+ this.pending.set(id, { resolve: resolve4, reject, timer });
2412
2454
  this.socket.send(JSON.stringify({
2413
2455
  type: "message",
2414
2456
  id,
@@ -2443,7 +2485,7 @@ class AgentsChatTransport {
2443
2485
  if (current() && socket.readyState === WebSocket.OPEN)
2444
2486
  socket.send(JSON.stringify(value));
2445
2487
  };
2446
- const join = (channel) => {
2488
+ const join10 = (channel) => {
2447
2489
  if (!this.config.channels.length || this.config.channels.includes(channel)) {
2448
2490
  this.inboxSync?.watch(channel);
2449
2491
  send({ type: "join_channel", channel_id: channel, agent_id: this.config.agentId });
@@ -2483,7 +2525,7 @@ class AgentsChatTransport {
2483
2525
  const ids = channels.map((c) => c.id ?? c.channel_id).filter((id) => typeof id === "string" && (!this.config.channels.length || this.config.channels.includes(id)));
2484
2526
  this.inboxSync?.memberships(ids);
2485
2527
  for (const id of ids)
2486
- join(id);
2528
+ join10(id);
2487
2529
  this.inboxSync?.sync();
2488
2530
  }).catch(() => {
2489
2531
  if (current()) {
@@ -2499,7 +2541,7 @@ class AgentsChatTransport {
2499
2541
  pending.resolve();
2500
2542
  }
2501
2543
  } else if (data.type === "channel_created" && typeof data.channel_id === "string")
2502
- join(data.channel_id);
2544
+ join10(data.channel_id);
2503
2545
  else if (["message", "thread_reply"].includes(data.type))
2504
2546
  this.receive(data);
2505
2547
  else if (data.type === "shard_moved" || data.type === "please_reconnect")
@@ -2588,20 +2630,20 @@ async function main() {
2588
2630
  return;
2589
2631
  }
2590
2632
  if (values["gui-thread"] || values["gui-message-file"] || values["gui-status"]) {
2591
- const channel = new GuiChannel(join9(homedir4(), ".agentschat/codex-gui-outbox"), values["gui-thread"] ? [values["gui-thread"]] : []);
2633
+ const channel = new GuiChannel(join10(homedir4(), ".agentschat/codex-gui-outbox"), values["gui-thread"] ? [values["gui-thread"]] : []);
2592
2634
  if (values["gui-status"]) {
2593
- console.log(JSON.stringify(channel.list().map(({ prompt, ...receipt }) => receipt)));
2635
+ console.log(JSON.stringify(channel.list().map(({ prompt: prompt2, ...receipt2 }) => receipt2)));
2594
2636
  return;
2595
2637
  }
2596
2638
  if (!values["gui-thread"] || !values["gui-message-file"])
2597
2639
  throw new Error("GUI submission requires --gui-thread and --gui-message-file");
2598
- const { prompt, ...receipt } = channel.enqueue(values["gui-thread"], readFileSync8(values["gui-message-file"], "utf8"));
2640
+ const { prompt, ...receipt } = channel.enqueue(values["gui-thread"], readFileSync9(values["gui-message-file"], "utf8"));
2599
2641
  console.log(JSON.stringify(receipt));
2600
2642
  return;
2601
2643
  }
2602
2644
  if ((values.bot || values["managed-worker"]) && (values["state-root"] || values["codex-home-mode"]))
2603
2645
  throw new Error("For managed bots, configure state_root/codex_home_mode in the bot registry");
2604
- const snapshot = values["managed-worker"] ? await new Promise((resolve, reject) => {
2646
+ const snapshot = values["managed-worker"] ? await new Promise((resolve4, reject) => {
2605
2647
  if (!process.connected) {
2606
2648
  reject(new Error("Managed worker needs parent IPC"));
2607
2649
  return;
@@ -2609,7 +2651,7 @@ async function main() {
2609
2651
  const timer = setTimeout(() => reject(new Error("Parent configuration missing")), 1e4);
2610
2652
  process.once("message", (config) => {
2611
2653
  clearTimeout(timer);
2612
- resolve(config);
2654
+ resolve4(config);
2613
2655
  });
2614
2656
  }) : undefined;
2615
2657
  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"] }));
@@ -2631,10 +2673,10 @@ async function main() {
2631
2673
  const runtime = prepareRuntimeHome(c.stateDir, undefined, c.codexHomeMode, c.codexBin);
2632
2674
  codex = new AppServer(c.codexBin, undefined, undefined, c.permissions, runtime, c.effort, c.model);
2633
2675
  if (values.conversations || values["read-conversation"]) {
2634
- const state = JSON.parse(readFileSync8(join9(c.stateDir, "state.json"), "utf8"));
2676
+ const state = JSON.parse(readFileSync9(join10(c.stateDir, "state.json"), "utf8"));
2635
2677
  const channels = state.channels ?? {};
2636
2678
  if (values.conversations) {
2637
- console.log(JSON.stringify(Object.entries(channels).map(([channel, data]) => ({ channel, thread: data.thread, isolated: data.namespace === runtime.home }))));
2679
+ console.log(JSON.stringify(Object.entries(channels).map(([channel2, data]) => ({ channel: channel2, thread: data.thread, isolated: data.namespace === runtime.home }))));
2638
2680
  return;
2639
2681
  }
2640
2682
  const channel = channels[values["read-conversation"]];