claude-threads 1.32.1 → 1.33.1

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.
@@ -3035,10 +3035,12 @@ var require_data = __commonJS((exports, module) => {
3035
3035
  var require_utils = __commonJS((exports, module) => {
3036
3036
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3037
3037
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3038
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3038
3039
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3039
3040
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3040
- var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3041
- var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/?]$/iu);
3041
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3042
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3043
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3042
3044
  function stringArrayToHexStripped(input) {
3043
3045
  let acc = "";
3044
3046
  let code = 0;
@@ -3063,91 +3065,127 @@ var require_utils = __commonJS((exports, module) => {
3063
3065
  }
3064
3066
  return acc;
3065
3067
  }
3068
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3069
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3070
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3066
3071
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3067
- function consumeIsZone(buffer) {
3068
- buffer.length = 0;
3069
- return true;
3072
+ var nonSimpleDomainChars = RegExp.prototype.test.bind(/[^\d!"$&'()*+,\-.;=_`a-z{}~]/u);
3073
+ var numericLastLabel = RegExp.prototype.test.bind(/(?:^|\.)\d+$/u);
3074
+ function nonSimpleMailtoDomain(domain) {
3075
+ return nonSimpleDomainChars(domain) || numericLastLabel(domain);
3070
3076
  }
3071
- function consumeHextets(buffer, address, output) {
3072
- if (buffer.length) {
3073
- const hex = stringArrayToHexStripped(buffer);
3074
- if (hex !== "") {
3075
- address.push(hex);
3076
- } else {
3077
- output.error = true;
3078
- return false;
3077
+ function isZoneIdentifier(zone) {
3078
+ if (zone.length === 0)
3079
+ return false;
3080
+ for (let i = 0;i < zone.length; i++) {
3081
+ if (isZoneCharacter(zone[i]))
3082
+ continue;
3083
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3084
+ i += 2;
3085
+ continue;
3079
3086
  }
3080
- buffer.length = 0;
3087
+ return false;
3081
3088
  }
3082
3089
  return true;
3083
3090
  }
3084
- function getIPV6(input) {
3085
- let tokenCount = 0;
3086
- const output = { error: false, address: "", zone: "" };
3087
- const address = [];
3088
- const buffer = [];
3089
- let endipv6Encountered = false;
3090
- let endIpv6 = false;
3091
- let consume = consumeHextets;
3092
- for (let i = 0;i < input.length; i++) {
3093
- const cursor = input[i];
3094
- if (cursor === "[" || cursor === "]") {
3095
- continue;
3096
- }
3097
- if (cursor === ":") {
3098
- if (endipv6Encountered === true) {
3099
- endIpv6 = true;
3100
- }
3101
- if (!consume(buffer, address, output)) {
3102
- break;
3103
- }
3104
- if (++tokenCount > 7) {
3105
- output.error = true;
3106
- break;
3107
- }
3108
- if (i > 0 && input[i - 1] === ":") {
3109
- endipv6Encountered = true;
3110
- }
3111
- address.push(":");
3112
- continue;
3113
- } else if (cursor === "%") {
3114
- if (!consume(buffer, address, output)) {
3115
- break;
3091
+ function compressIPv6ZeroRun(hextets) {
3092
+ let bestStart = -1;
3093
+ let bestLength = 0;
3094
+ let runStart = -1;
3095
+ let runLength = 0;
3096
+ for (let i = 0;i < hextets.length; i++) {
3097
+ if (hextets[i] === "0") {
3098
+ if (runStart === -1)
3099
+ runStart = i;
3100
+ runLength++;
3101
+ if (runLength > bestLength) {
3102
+ bestLength = runLength;
3103
+ bestStart = runStart;
3116
3104
  }
3117
- consume = consumeIsZone;
3118
3105
  } else {
3119
- buffer.push(cursor);
3120
- continue;
3106
+ runStart = -1;
3107
+ runLength = 0;
3121
3108
  }
3122
3109
  }
3123
- if (buffer.length) {
3124
- if (consume === consumeIsZone) {
3125
- output.zone = buffer.join("");
3126
- } else if (endIpv6) {
3127
- address.push(buffer.join(""));
3128
- } else {
3129
- address.push(stringArrayToHexStripped(buffer));
3110
+ if (bestLength < 2)
3111
+ return hextets.join(":");
3112
+ const head = hextets.slice(0, bestStart).join(":");
3113
+ const tail = hextets.slice(bestStart + bestLength).join(":");
3114
+ return head + "::" + tail;
3115
+ }
3116
+ function normalizeIPv6Address(input) {
3117
+ const compression = input.indexOf("::");
3118
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1)
3119
+ return;
3120
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3121
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3122
+ if (compression !== -1) {
3123
+ if (left.length === 1 && left[0] === "")
3124
+ left.length = 0;
3125
+ if (right.length === 1 && right[0] === "")
3126
+ right.length = 0;
3127
+ }
3128
+ const parts = left.concat(right);
3129
+ let hextetCount = 0;
3130
+ for (let i = 0;i < parts.length; i++) {
3131
+ const part = parts[i];
3132
+ if (part === "")
3133
+ return;
3134
+ if (part.indexOf(".") !== -1) {
3135
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part))
3136
+ return;
3137
+ hextetCount += 2;
3138
+ continue;
3130
3139
  }
3140
+ if (!isHextet(part))
3141
+ return;
3142
+ parts[i] = parseInt(part, 16).toString(16);
3143
+ hextetCount++;
3131
3144
  }
3132
- output.address = address.join("");
3133
- return output;
3145
+ if (compression === -1) {
3146
+ if (hextetCount !== 8)
3147
+ return;
3148
+ return compressIPv6ZeroRun(parts);
3149
+ }
3150
+ if (hextetCount >= 8)
3151
+ return;
3152
+ const expanded = parts.slice(0, left.length);
3153
+ for (let i = hextetCount;i < 8; i++)
3154
+ expanded.push("0");
3155
+ for (let i = left.length;i < parts.length; i++)
3156
+ expanded.push(parts[i]);
3157
+ return compressIPv6ZeroRun(expanded);
3134
3158
  }
3135
3159
  function normalizeIPv6(host) {
3136
- if (findToken(host, ":") < 2) {
3137
- return { host, isIPV6: false };
3138
- }
3139
- const ipv62 = getIPV6(host);
3140
- if (!ipv62.error) {
3141
- let newHost = ipv62.address;
3142
- let escapedHost = ipv62.address;
3143
- if (ipv62.zone) {
3144
- newHost += "%" + ipv62.zone;
3145
- escapedHost += "%25" + ipv62.zone;
3146
- }
3147
- return { host: newHost, isIPV6: true, escapedHost };
3148
- } else {
3149
- return { host, isIPV6: false };
3150
- }
3160
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3161
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3162
+ if (hasBracket && !bracketed)
3163
+ return { host, isIPV6: false, error: true };
3164
+ let input = bracketed ? host.slice(1, -1) : host;
3165
+ if (bracketed && isIPvFuture(input)) {
3166
+ input = input.toLowerCase();
3167
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3168
+ }
3169
+ if (findToken(input, ":") < 2) {
3170
+ return { host, isIPV6: false, error: bracketed };
3171
+ }
3172
+ let zoneIdentifier = "";
3173
+ const zoneSeparator = input.indexOf("%");
3174
+ if (zoneSeparator !== -1) {
3175
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3176
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3177
+ if (!isZoneIdentifier(zoneIdentifier))
3178
+ return { host, isIPV6: false, error: true };
3179
+ input = input.slice(0, zoneSeparator);
3180
+ }
3181
+ const address = normalizeIPv6Address(input);
3182
+ if (address === undefined)
3183
+ return { host, isIPV6: false, error: true };
3184
+ return {
3185
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3186
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3187
+ isIPV6: true
3188
+ };
3151
3189
  }
3152
3190
  function findToken(str, token) {
3153
3191
  let ind = 0;
@@ -3324,6 +3362,45 @@ var require_utils = __commonJS((exports, module) => {
3324
3362
  }
3325
3363
  return output;
3326
3364
  }
3365
+ function serializePathEncoding(input, pathNoScheme = false) {
3366
+ let output = "";
3367
+ let firstSegment = pathNoScheme && input[0] !== "/";
3368
+ for (let i = 0;i < input.length; i++) {
3369
+ const ch = input[i];
3370
+ if (ch === "%" && i + 2 < input.length) {
3371
+ const hex = input.slice(i + 1, i + 3);
3372
+ if (isHexPair(hex)) {
3373
+ output += "%" + hex.toUpperCase();
3374
+ i += 2;
3375
+ continue;
3376
+ }
3377
+ }
3378
+ if (ch === "/") {
3379
+ firstSegment = false;
3380
+ }
3381
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3382
+ output += ch;
3383
+ } else {
3384
+ const code = input.charCodeAt(i);
3385
+ if (code < 128) {
3386
+ output += BYTE_HEX[code];
3387
+ } else if (code < 55296 || code > 57343) {
3388
+ output += percentEncodeNonAscii(code);
3389
+ } else if (code <= 56319 && i + 1 < input.length) {
3390
+ const low = input.charCodeAt(i + 1);
3391
+ if (low >= 56320 && low <= 57343) {
3392
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3393
+ i++;
3394
+ } else {
3395
+ output += percentEncodeNonAscii(65533);
3396
+ }
3397
+ } else {
3398
+ output += percentEncodeNonAscii(65533);
3399
+ }
3400
+ }
3401
+ }
3402
+ return output;
3403
+ }
3327
3404
  function normalizeQueryFragmentEncoding(input) {
3328
3405
  let output = "";
3329
3406
  for (let i = 0;i < input.length; i++) {
@@ -3365,6 +3442,50 @@ var require_utils = __commonJS((exports, module) => {
3365
3442
  }
3366
3443
  return output;
3367
3444
  }
3445
+ function encodeComponent(input, isAllowed) {
3446
+ let output = "";
3447
+ for (let i = 0;i < input.length; i++) {
3448
+ const ch = input[i];
3449
+ if (ch === "%" && i + 2 < input.length) {
3450
+ const hex = input.slice(i + 1, i + 3);
3451
+ if (isHexPair(hex)) {
3452
+ output += "%" + hex.toUpperCase();
3453
+ i += 2;
3454
+ continue;
3455
+ }
3456
+ }
3457
+ if (isAllowed(ch)) {
3458
+ output += ch;
3459
+ } else {
3460
+ const code = input.charCodeAt(i);
3461
+ if (code < 128) {
3462
+ output += BYTE_HEX[code];
3463
+ } else if (code < 55296 || code > 57343) {
3464
+ output += percentEncodeNonAscii(code);
3465
+ } else if (code <= 56319 && i + 1 < input.length) {
3466
+ const low = input.charCodeAt(i + 1);
3467
+ if (low >= 56320 && low <= 57343) {
3468
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3469
+ i++;
3470
+ } else {
3471
+ output += percentEncodeNonAscii(65533);
3472
+ }
3473
+ } else {
3474
+ output += percentEncodeNonAscii(65533);
3475
+ }
3476
+ }
3477
+ }
3478
+ return output;
3479
+ }
3480
+ function encodeUserinfo(input) {
3481
+ return encodeComponent(input, isUserinfoCharacter);
3482
+ }
3483
+ function encodeQuery(input) {
3484
+ return encodeComponent(input, isQueryFragmentCharacter);
3485
+ }
3486
+ function encodeFragment(input) {
3487
+ return encodeComponent(input, isQueryFragmentCharacter);
3488
+ }
3368
3489
  function escapePreservingEscapes(input) {
3369
3490
  let output = "";
3370
3491
  for (let i = 0;i < input.length; i++) {
@@ -3399,14 +3520,18 @@ var require_utils = __commonJS((exports, module) => {
3399
3520
  function recomposeAuthority(component) {
3400
3521
  const uriTokens = [];
3401
3522
  if (component.userinfo !== undefined) {
3402
- uriTokens.push(component.userinfo);
3523
+ uriTokens.push(encodeUserinfo(component.userinfo));
3403
3524
  uriTokens.push("@");
3404
3525
  }
3405
3526
  if (component.host !== undefined) {
3406
- let host = unescape(component.host);
3527
+ let host = component.host;
3407
3528
  if (!isIPv4(host)) {
3408
- const ipV6res = normalizeIPv6(host);
3409
- if (ipV6res.isIPV6 === true) {
3529
+ let ipV6res = normalizeIPv6(host);
3530
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3531
+ host = normalizePercentEncoding(host, true);
3532
+ ipV6res = normalizeIPv6(host);
3533
+ }
3534
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3410
3535
  host = `[${ipV6res.escapedHost}]`;
3411
3536
  } else {
3412
3537
  host = reescapeHostDelimiters(host, false);
@@ -3415,18 +3540,29 @@ var require_utils = __commonJS((exports, module) => {
3415
3540
  uriTokens.push(host);
3416
3541
  }
3417
3542
  if (typeof component.port === "number" || typeof component.port === "string") {
3543
+ const port = String(component.port);
3544
+ if (!isPort(port)) {
3545
+ throw new TypeError("URI port is malformed.");
3546
+ }
3418
3547
  uriTokens.push(":");
3419
- uriTokens.push(String(component.port));
3548
+ uriTokens.push(port);
3420
3549
  }
3421
3550
  return uriTokens.length ? uriTokens.join("") : undefined;
3422
3551
  }
3423
3552
  module.exports = {
3553
+ BYTE_HEX,
3554
+ percentEncodeNonAscii,
3424
3555
  nonSimpleDomain,
3556
+ nonSimpleMailtoDomain,
3425
3557
  recomposeAuthority,
3426
3558
  reescapeHostDelimiters,
3427
3559
  normalizePercentEncoding,
3428
3560
  normalizePathEncoding,
3561
+ serializePathEncoding,
3429
3562
  normalizeQueryFragmentEncoding,
3563
+ encodeUserinfo,
3564
+ encodeQuery,
3565
+ encodeFragment,
3430
3566
  escapePreservingEscapes,
3431
3567
  removeDotSegments,
3432
3568
  isIPv4,
@@ -3438,15 +3574,16 @@ var require_utils = __commonJS((exports, module) => {
3438
3574
 
3439
3575
  // node_modules/fast-uri/lib/schemes.js
3440
3576
  var require_schemes = __commonJS((exports, module) => {
3441
- var { isUUID } = require_utils();
3442
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3577
+ var { isUUID, BYTE_HEX, percentEncodeNonAscii, nonSimpleMailtoDomain } = require_utils();
3578
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3443
3579
  var supportedSchemeNames = [
3444
3580
  "http",
3445
3581
  "https",
3446
3582
  "ws",
3447
3583
  "wss",
3448
3584
  "urn",
3449
- "urn:uuid"
3585
+ "urn:uuid",
3586
+ "mailto"
3450
3587
  ];
3451
3588
  function isValidSchemeName(name) {
3452
3589
  return supportedSchemeNames.indexOf(name) !== -1;
@@ -3494,9 +3631,10 @@ var require_schemes = __commonJS((exports, module) => {
3494
3631
  wsComponent.secure = undefined;
3495
3632
  }
3496
3633
  if (wsComponent.resourceName) {
3497
- const [path, query] = wsComponent.resourceName.split("?");
3634
+ const queryIndex = wsComponent.resourceName.indexOf("?");
3635
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3498
3636
  wsComponent.path = path && path !== "/" ? path : undefined;
3499
- wsComponent.query = query;
3637
+ wsComponent.query = queryIndex === -1 ? undefined : wsComponent.resourceName.slice(queryIndex + 1);
3500
3638
  wsComponent.resourceName = undefined;
3501
3639
  }
3502
3640
  wsComponent.fragment = undefined;
@@ -3508,7 +3646,7 @@ var require_schemes = __commonJS((exports, module) => {
3508
3646
  return urnComponent;
3509
3647
  }
3510
3648
  const matches = urnComponent.path.match(URN_REG);
3511
- if (matches) {
3649
+ if (matches && matches[0] === urnComponent.path) {
3512
3650
  const scheme = options.scheme || urnComponent.scheme || "urn";
3513
3651
  urnComponent.nid = matches[1].toLowerCase();
3514
3652
  urnComponent.nss = matches[2];
@@ -3590,13 +3728,235 @@ var require_schemes = __commonJS((exports, module) => {
3590
3728
  serialize: urnuuidSerialize,
3591
3729
  skipNormalize: true
3592
3730
  };
3731
+ var LOCAL_PART_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+=";
3732
+ var HFNAME_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+,;:@";
3733
+ var DTEXT_ALLOWED = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$'()*+;:";
3734
+ function allowSet(chars, allowNonAscii = false) {
3735
+ const table = new Uint8Array(128);
3736
+ for (let i = 0;i < chars.length; i++) {
3737
+ table[chars.charCodeAt(i)] = 1;
3738
+ }
3739
+ const escaped = chars.replace(/[\\\]^-]/gu, "\\$&");
3740
+ const cls = allowNonAscii ? `[${escaped}]|[^\\0-\\x7F\\uD800-\\uDFFF]` : `[${escaped}]`;
3741
+ return { all: new RegExp(`^(?:${cls})*$`, "u"), table, allowNonAscii };
3742
+ }
3743
+ var LOCAL_PART = allowSet(LOCAL_PART_ALLOWED);
3744
+ var HFNAME = allowSet(HFNAME_ALLOWED);
3745
+ var DTEXT = allowSet(DTEXT_ALLOWED);
3746
+ var DTEXT_IRI = allowSet(DTEXT_ALLOWED, true);
3747
+ var HEX_PAIR = /^[\da-f]{2}$/iu;
3748
+ var MAILTO_DOMAIN_LITERAL = /^\[[\x21-\x5A\x5E-\x7E]*\]$/u;
3749
+ var MAILTO_DOMAIN_ERROR = "URI mailto has an invalid recipient domain.";
3750
+ var HAS_SURROGATE = /[\uD800-\uDFFF]/u;
3751
+ function decodeHex(str) {
3752
+ if (typeof str !== "string" || str.indexOf("%") === -1) {
3753
+ return str;
3754
+ }
3755
+ try {
3756
+ return decodeURIComponent(str);
3757
+ } catch {
3758
+ return str;
3759
+ }
3760
+ }
3761
+ function replaceLoneSurrogates(input) {
3762
+ let result = "";
3763
+ for (let i = 0;i < input.length; i++) {
3764
+ const code = input.charCodeAt(i);
3765
+ if (code >= 55296 && code <= 56319 && i + 1 < input.length) {
3766
+ const low = input.charCodeAt(i + 1);
3767
+ if (low >= 56320 && low <= 57343) {
3768
+ result += input[i] + input[i + 1];
3769
+ i++;
3770
+ continue;
3771
+ }
3772
+ }
3773
+ result += code >= 55296 && code <= 57343 ? "�" : input[i];
3774
+ }
3775
+ return result;
3776
+ }
3777
+ function encodeWithAllow(input, set2) {
3778
+ if (set2.all.test(input)) {
3779
+ return input;
3780
+ }
3781
+ const table = set2.table;
3782
+ let result = "";
3783
+ for (let i = 0;i < input.length; i++) {
3784
+ const code = input.charCodeAt(i);
3785
+ if (code < 128) {
3786
+ if (table[code] === 1) {
3787
+ result += input[i];
3788
+ } else if (code === 37 && i + 2 < input.length && HEX_PAIR.test(input.slice(i + 1, i + 3))) {
3789
+ result += "%" + input.slice(i + 1, i + 3).toUpperCase();
3790
+ i += 2;
3791
+ } else {
3792
+ result += BYTE_HEX[code];
3793
+ }
3794
+ continue;
3795
+ }
3796
+ if (code < 55296 || code > 57343) {
3797
+ result += set2.allowNonAscii ? input[i] : percentEncodeNonAscii(code);
3798
+ continue;
3799
+ }
3800
+ if (code <= 56319 && i + 1 < input.length) {
3801
+ const low = input.charCodeAt(i + 1);
3802
+ if (low >= 56320 && low <= 57343) {
3803
+ result += set2.allowNonAscii ? input[i] + input[i + 1] : percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3804
+ i++;
3805
+ continue;
3806
+ }
3807
+ }
3808
+ result += set2.allowNonAscii ? "�" : percentEncodeNonAscii(65533);
3809
+ }
3810
+ return result;
3811
+ }
3812
+ function mailtoNormalizeDomain(domain, options, component) {
3813
+ const normalizedDomain = String(domain).toLowerCase();
3814
+ if (MAILTO_DOMAIN_LITERAL.test(normalizedDomain)) {
3815
+ return normalizedDomain;
3816
+ }
3817
+ if (normalizedDomain !== "" && !nonSimpleMailtoDomain(normalizedDomain)) {
3818
+ return normalizedDomain;
3819
+ }
3820
+ try {
3821
+ const parsedDomain = new URL("http://" + normalizedDomain);
3822
+ if (parsedDomain.username || parsedDomain.password || parsedDomain.port || parsedDomain.pathname !== "/" || parsedDomain.search || parsedDomain.hash || !parsedDomain.hostname) {
3823
+ throw new Error(MAILTO_DOMAIN_ERROR);
3824
+ }
3825
+ return options && options.unicodeSupport ? normalizedDomain : parsedDomain.hostname;
3826
+ } catch {
3827
+ if (component) {
3828
+ component.error = component.error || MAILTO_DOMAIN_ERROR;
3829
+ }
3830
+ return normalizedDomain;
3831
+ }
3832
+ }
3833
+ function mailtoEncodeDomain(domain, options) {
3834
+ const set2 = options && options.unicodeSupport ? DTEXT_IRI : DTEXT;
3835
+ if (domain.length > 1 && domain[0] === "[" && domain[domain.length - 1] === "]") {
3836
+ return "[" + encodeWithAllow(domain.slice(1, -1), set2) + "]";
3837
+ }
3838
+ return encodeWithAllow(domain, set2);
3839
+ }
3840
+ function mailtoParse(component, options) {
3841
+ const mailtoComponent = component;
3842
+ let rawPath = mailtoComponent.path;
3843
+ let rawQuery = mailtoComponent.query;
3844
+ if (rawPath && HAS_SURROGATE.test(rawPath))
3845
+ rawPath = replaceLoneSurrogates(rawPath);
3846
+ if (rawQuery && HAS_SURROGATE.test(rawQuery))
3847
+ rawQuery = replaceLoneSurrogates(rawQuery);
3848
+ const to = rawPath ? rawPath.indexOf(",") === -1 ? [rawPath] : rawPath.split(",") : [];
3849
+ mailtoComponent.path = undefined;
3850
+ if (rawQuery) {
3851
+ let headers = null;
3852
+ let start = 0;
3853
+ while (start <= rawQuery.length) {
3854
+ let end = rawQuery.indexOf("&", start);
3855
+ if (end === -1)
3856
+ end = rawQuery.length;
3857
+ const token = rawQuery.slice(start, end);
3858
+ start = end + 1;
3859
+ const eqIdx = token.indexOf("=");
3860
+ if (eqIdx !== token.lastIndexOf("=")) {
3861
+ mailtoComponent.error = mailtoComponent.error || "URI mailto has malformed header fields.";
3862
+ continue;
3863
+ }
3864
+ const name = eqIdx === -1 ? token : token.slice(0, eqIdx);
3865
+ const value = eqIdx === -1 ? "" : token.slice(eqIdx + 1);
3866
+ if (name === "to") {
3867
+ const addrs = value.split(",");
3868
+ for (let j = 0;j < addrs.length; j++)
3869
+ to.push(addrs[j]);
3870
+ continue;
3871
+ }
3872
+ if (name === "subject") {
3873
+ mailtoComponent.subject = decodeHex(value);
3874
+ continue;
3875
+ }
3876
+ if (name === "body") {
3877
+ mailtoComponent.body = decodeHex(value);
3878
+ continue;
3879
+ }
3880
+ if (headers === null)
3881
+ headers = Object.create(null);
3882
+ headers[decodeHex(name)] = decodeHex(value);
3883
+ }
3884
+ if (headers !== null)
3885
+ mailtoComponent.headers = headers;
3886
+ }
3887
+ mailtoComponent.query = undefined;
3888
+ for (let i = 0;i < to.length; i++) {
3889
+ const rawAddr = to[i];
3890
+ const atIdx = rawAddr.lastIndexOf("@");
3891
+ if (atIdx < 0) {
3892
+ mailtoComponent.error = mailtoComponent.error || MAILTO_DOMAIN_ERROR;
3893
+ to[i] = decodeHex(rawAddr);
3894
+ continue;
3895
+ }
3896
+ const local = decodeHex(rawAddr.slice(0, atIdx));
3897
+ const domain = mailtoNormalizeDomain(decodeHex(rawAddr.slice(atIdx + 1)), options, mailtoComponent);
3898
+ to[i] = local + "@" + domain;
3899
+ }
3900
+ if (to.length)
3901
+ mailtoComponent.to = to;
3902
+ return mailtoComponent;
3903
+ }
3904
+ function mailtoSerialize(component, options) {
3905
+ const mailtoComponent = component;
3906
+ const to = Array.isArray(mailtoComponent.to) ? mailtoComponent.to.slice() : [];
3907
+ if (to.length) {
3908
+ for (let i = 0;i < to.length; i++) {
3909
+ const addr = String(to[i]);
3910
+ const atIdx = addr.lastIndexOf("@");
3911
+ const rawLocal = atIdx >= 0 ? addr.slice(0, atIdx) : addr;
3912
+ const rawDomain = atIdx >= 0 ? addr.slice(atIdx + 1) : "";
3913
+ const local = encodeWithAllow(rawLocal, LOCAL_PART);
3914
+ const decodedDomain = decodeHex(rawDomain);
3915
+ const normalizedDomain = mailtoNormalizeDomain(decodedDomain, options);
3916
+ to[i] = local + "@" + mailtoEncodeDomain(normalizedDomain, options);
3917
+ }
3918
+ mailtoComponent.path = to.join(",");
3919
+ options.skipEscape = true;
3920
+ } else {
3921
+ mailtoComponent.path = undefined;
3922
+ }
3923
+ const headers = mailtoComponent.headers && typeof mailtoComponent.headers === "object" ? Object.assign(Object.create(null), mailtoComponent.headers) : Object.create(null);
3924
+ if (mailtoComponent.subject)
3925
+ headers.subject = mailtoComponent.subject;
3926
+ if (mailtoComponent.body)
3927
+ headers.body = mailtoComponent.body;
3928
+ mailtoComponent.headers = headers;
3929
+ let query = "";
3930
+ let count = 0;
3931
+ for (const name in headers) {
3932
+ if (count++ !== 0)
3933
+ query += "&";
3934
+ query += encodeWithAllow(name, HFNAME) + "=" + encodeWithAllow(String(headers[name]), HFNAME);
3935
+ }
3936
+ if (count !== 0) {
3937
+ mailtoComponent.query = query;
3938
+ } else {
3939
+ mailtoComponent.headers = undefined;
3940
+ }
3941
+ return mailtoComponent;
3942
+ }
3943
+ var mailto = {
3944
+ scheme: "mailto",
3945
+ parse: mailtoParse,
3946
+ serialize: mailtoSerialize,
3947
+ domainHost: false,
3948
+ unicodeSupport: true,
3949
+ skipNormalize: true,
3950
+ absolutePath: true
3951
+ };
3593
3952
  var SCHEMES = {
3594
3953
  http,
3595
3954
  https,
3596
3955
  ws,
3597
3956
  wss,
3598
3957
  urn,
3599
- "urn:uuid": urnuuid
3958
+ "urn:uuid": urnuuid,
3959
+ mailto
3600
3960
  };
3601
3961
  Object.setPrototypeOf(SCHEMES, null);
3602
3962
  function getSchemeHandler(scheme) {
@@ -3612,8 +3972,17 @@ var require_schemes = __commonJS((exports, module) => {
3612
3972
 
3613
3973
  // node_modules/fast-uri/index.js
3614
3974
  var require_fast_uri = __commonJS((exports, module) => {
3615
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, normalizeQueryFragmentEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3975
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3616
3976
  var { SCHEMES, getSchemeHandler } = require_schemes();
3977
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3978
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3979
+ function decodeValidScheme(scheme) {
3980
+ const decodedScheme = unescape(String(scheme));
3981
+ if (!VALID_SCHEME.test(decodedScheme)) {
3982
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
3983
+ }
3984
+ return decodedScheme;
3985
+ }
3617
3986
  function normalize(uri, options) {
3618
3987
  if (typeof uri === "string") {
3619
3988
  uri = normalizeString(uri, options);
@@ -3624,12 +3993,34 @@ var require_fast_uri = __commonJS((exports, module) => {
3624
3993
  }
3625
3994
  function resolve(baseURI, relativeURI, options) {
3626
3995
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3627
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3628
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3629
- if (baseMalformed || relativeMalformed) {
3996
+ const {
3997
+ parsed: baseParsed,
3998
+ malformedAuthorityOrPort: baseMalformed,
3999
+ malformedPercentEncoding: baseMalformedPercentEncoding,
4000
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
4001
+ malformedHost: baseMalformedHost,
4002
+ malformedScheme: baseMalformedScheme
4003
+ } = parseWithStatus(baseURI, schemelessOptions);
4004
+ const {
4005
+ parsed: relativeParsed,
4006
+ malformedAuthorityOrPort: relativeMalformed,
4007
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
4008
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
4009
+ malformedHost: relativeMalformedHost,
4010
+ malformedScheme: relativeMalformedScheme
4011
+ } = parseWithStatus(relativeURI, schemelessOptions);
4012
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3630
4013
  throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3631
4014
  }
3632
4015
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
4016
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
4017
+ const resolvedHost = resolved.host;
4018
+ const resolvedHostIsIP = resolvedHost !== undefined && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
4019
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
4020
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
4021
+ if (resolved.error && !encodedASCIIHost) {
4022
+ throw new Error(resolved.error);
4023
+ }
3633
4024
  schemelessOptions.skipEscape = true;
3634
4025
  return serialize(resolved, schemelessOptions);
3635
4026
  }
@@ -3689,7 +4080,7 @@ var require_fast_uri = __commonJS((exports, module) => {
3689
4080
  function equal(uriA, uriB, options) {
3690
4081
  const normalizedA = normalizeComparableURI(uriA, options);
3691
4082
  const normalizedB = normalizeComparableURI(uriB, options);
3692
- return normalizedA !== undefined && normalizedB !== undefined && normalizedA.toLowerCase() === normalizedB.toLowerCase();
4083
+ return normalizedA !== undefined && normalizedB !== undefined && normalizedA === normalizedB;
3693
4084
  }
3694
4085
  function serialize(cmpts, opts) {
3695
4086
  const component = {
@@ -3706,24 +4097,31 @@ var require_fast_uri = __commonJS((exports, module) => {
3706
4097
  reference: cmpts.reference,
3707
4098
  resourceName: cmpts.resourceName,
3708
4099
  secure: cmpts.secure,
4100
+ to: cmpts.to,
4101
+ subject: cmpts.subject,
4102
+ body: cmpts.body,
4103
+ headers: cmpts.headers,
3709
4104
  error: ""
3710
4105
  };
3711
4106
  const options = Object.assign({}, opts);
3712
4107
  const uriTokens = [];
4108
+ if (component.scheme) {
4109
+ component.scheme = decodeValidScheme(component.scheme);
4110
+ }
3713
4111
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3714
4112
  if (schemeHandler && schemeHandler.serialize)
3715
4113
  schemeHandler.serialize(component, options);
4114
+ const hasAuthority = component.userinfo !== undefined || component.host !== undefined || component.port !== undefined;
4115
+ const pathNoScheme = !options.skipEscape && component.scheme === undefined && !hasAuthority;
3716
4116
  if (component.path !== undefined) {
3717
4117
  if (!options.skipEscape) {
3718
- component.path = escapePreservingEscapes(component.path);
3719
- if (component.scheme !== undefined) {
3720
- component.path = component.path.split("%3A").join(":");
3721
- }
4118
+ component.path = serializePathEncoding(component.path, pathNoScheme);
3722
4119
  } else {
3723
4120
  component.path = normalizePercentEncoding(component.path);
3724
4121
  }
3725
4122
  }
3726
4123
  if (options.reference !== "suffix" && component.scheme) {
4124
+ component.scheme = decodeValidScheme(component.scheme);
3727
4125
  uriTokens.push(component.scheme, ":");
3728
4126
  }
3729
4127
  const authority = recomposeAuthority(component);
@@ -3741,16 +4139,19 @@ var require_fast_uri = __commonJS((exports, module) => {
3741
4139
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3742
4140
  s = removeDotSegments(s);
3743
4141
  }
4142
+ if (pathNoScheme) {
4143
+ s = serializePathEncoding(s, true);
4144
+ }
3744
4145
  if (authority === undefined && s[0] === "/" && s[1] === "/") {
3745
4146
  s = "/%2F" + s.slice(2);
3746
4147
  }
3747
4148
  uriTokens.push(s);
3748
4149
  }
3749
4150
  if (component.query !== undefined) {
3750
- uriTokens.push("?", component.query);
4151
+ uriTokens.push("?", encodeQuery(component.query));
3751
4152
  }
3752
4153
  if (component.fragment !== undefined) {
3753
- uriTokens.push("#", component.fragment);
4154
+ uriTokens.push("#", encodeFragment(component.fragment));
3754
4155
  }
3755
4156
  return uriTokens.join("");
3756
4157
  }
@@ -3766,6 +4167,37 @@ var require_fast_uri = __commonJS((exports, module) => {
3766
4167
  }
3767
4168
  return;
3768
4169
  }
4170
+ function hasMalformedPercentEncoding(component) {
4171
+ if (component === undefined)
4172
+ return false;
4173
+ let percent = component.indexOf("%");
4174
+ while (percent !== -1) {
4175
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4176
+ return true;
4177
+ }
4178
+ percent = component.indexOf("%", percent + 3);
4179
+ }
4180
+ return false;
4181
+ }
4182
+ function isIPLiteral(host) {
4183
+ return host[0] === "[" && host[host.length - 1] === "]";
4184
+ }
4185
+ function hasMalformedComponentPercentEncoding(matches) {
4186
+ const host = matches[4];
4187
+ return hasMalformedPercentEncoding(matches[3]) || host !== undefined && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4188
+ }
4189
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4190
+ const bracketedIPLiteral = parsed.host && parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
4191
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && !bracketedIPLiteral && nonSimpleDomain(parsed.host)) {
4192
+ try {
4193
+ parsed.host = new URL("http://" + parsed.host).hostname;
4194
+ } catch (e) {
4195
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4196
+ return true;
4197
+ }
4198
+ }
4199
+ return false;
4200
+ }
3769
4201
  function parseWithStatus(uri, opts) {
3770
4202
  const options = Object.assign({}, opts);
3771
4203
  const parsed = {
@@ -3778,6 +4210,11 @@ var require_fast_uri = __commonJS((exports, module) => {
3778
4210
  fragment: undefined
3779
4211
  };
3780
4212
  let malformedAuthorityOrPort = false;
4213
+ let malformedPercentEncoding = false;
4214
+ let malformedSchemeSpecific = false;
4215
+ let malformedHost = false;
4216
+ let malformedIPLiteral = false;
4217
+ let malformedScheme = false;
3781
4218
  let isIP = false;
3782
4219
  if (options.reference === "suffix") {
3783
4220
  if (options.scheme) {
@@ -3807,13 +4244,26 @@ var require_fast_uri = __commonJS((exports, module) => {
3807
4244
  }
3808
4245
  const matches = uri.match(URI_PARSE);
3809
4246
  if (matches) {
3810
- parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase();
4247
+ parsed.scheme = matches[1];
3811
4248
  parsed.userinfo = matches[3];
3812
4249
  parsed.host = matches[4];
3813
4250
  parsed.port = parseInt(matches[5], 10);
3814
4251
  parsed.path = matches[6] || "";
3815
4252
  parsed.query = matches[7];
3816
4253
  parsed.fragment = matches[8];
4254
+ if (parsed.scheme !== undefined) {
4255
+ const decodedScheme = unescape(parsed.scheme);
4256
+ if (VALID_SCHEME.test(decodedScheme)) {
4257
+ parsed.scheme = decodedScheme.toLowerCase();
4258
+ } else {
4259
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4260
+ malformedScheme = true;
4261
+ }
4262
+ }
4263
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4264
+ if (malformedPercentEncoding) {
4265
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4266
+ }
3817
4267
  if (isNaN(parsed.port)) {
3818
4268
  parsed.port = matches[5];
3819
4269
  }
@@ -3825,9 +4275,16 @@ var require_fast_uri = __commonJS((exports, module) => {
3825
4275
  if (parsed.host) {
3826
4276
  const ipv4result = isIPv4(parsed.host);
3827
4277
  if (ipv4result === false) {
4278
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4279
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3828
4280
  const ipv6result = normalizeIPv6(parsed.host);
3829
- parsed.host = ipv6result.host.toLowerCase();
3830
- isIP = ipv6result.isIPV6;
4281
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4282
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4283
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4284
+ if (malformedIPLiteral) {
4285
+ parsed.error = parsed.error || "URI host is malformed.";
4286
+ malformedAuthorityOrPort = true;
4287
+ }
3831
4288
  } else {
3832
4289
  isIP = true;
3833
4290
  }
@@ -3845,22 +4302,14 @@ var require_fast_uri = __commonJS((exports, module) => {
3845
4302
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3846
4303
  }
3847
4304
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3848
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3849
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3850
- try {
3851
- parsed.host = new URL("http://" + parsed.host).hostname;
3852
- } catch (e) {
3853
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3854
- }
3855
- }
4305
+ if (!malformedIPLiteral) {
4306
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3856
4307
  }
3857
4308
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3858
4309
  if (uri.indexOf("%") !== -1) {
3859
- if (parsed.scheme !== undefined) {
3860
- parsed.scheme = unescape(parsed.scheme);
3861
- }
3862
- if (parsed.host !== undefined) {
3863
- parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
4310
+ if (parsed.host !== undefined && !malformedIPLiteral) {
4311
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4312
+ parsed.host = reescapeHostDelimiters(host, isIP);
3864
4313
  }
3865
4314
  }
3866
4315
  if (parsed.path) {
@@ -3875,11 +4324,14 @@ var require_fast_uri = __commonJS((exports, module) => {
3875
4324
  }
3876
4325
  if (schemeHandler && schemeHandler.parse) {
3877
4326
  schemeHandler.parse(parsed, options);
4327
+ if (schemeHandler === SCHEMES.urn && parsed.nid === undefined) {
4328
+ malformedSchemeSpecific = true;
4329
+ }
3878
4330
  }
3879
4331
  } else {
3880
4332
  parsed.error = parsed.error || "URI can not be parsed.";
3881
4333
  }
3882
- return { parsed, malformedAuthorityOrPort };
4334
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3883
4335
  }
3884
4336
  function parse6(uri, opts) {
3885
4337
  return parseWithStatus(uri, opts).parsed;
@@ -3888,20 +4340,28 @@ var require_fast_uri = __commonJS((exports, module) => {
3888
4340
  return normalizeStringWithStatus(uri, opts).normalized;
3889
4341
  }
3890
4342
  function normalizeStringWithStatus(uri, opts) {
3891
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4343
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3892
4344
  return {
3893
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3894
- malformedAuthorityOrPort
4345
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4346
+ malformedAuthorityOrPort,
4347
+ malformedPercentEncoding,
4348
+ malformedSchemeSpecific,
4349
+ malformedHost,
4350
+ malformedScheme
3895
4351
  };
3896
4352
  }
3897
4353
  function normalizeComparableURI(uri, opts) {
3898
- if (typeof uri === "string") {
3899
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3900
- return malformedAuthorityOrPort ? undefined : normalized;
4354
+ if (typeof uri !== "string" && typeof uri !== "object") {
4355
+ return;
3901
4356
  }
3902
- if (typeof uri === "object") {
3903
- return serialize(uri, opts);
4357
+ let value;
4358
+ try {
4359
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
4360
+ } catch {
4361
+ return;
3904
4362
  }
4363
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4364
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? undefined : normalized;
3905
4365
  }
3906
4366
  var fastUri = {
3907
4367
  SCHEMES,
@@ -14239,12 +14699,12 @@ var init_spawn = __esm(() => {
14239
14699
  });
14240
14700
 
14241
14701
  // src/claude/quick-query.ts
14242
- var log14;
14702
+ var log15;
14243
14703
  var init_quick_query = __esm(() => {
14244
14704
  init_spawn();
14245
14705
  init_version_check();
14246
14706
  init_logger();
14247
- log14 = createLogger("query");
14707
+ log15 = createLogger("query");
14248
14708
  });
14249
14709
 
14250
14710
  // node_modules/ws/lib/constants.js
@@ -52442,9 +52902,54 @@ var ALLOWED_TRANSITIONS = {
52442
52902
  cancelling: new Set(["ending"]),
52443
52903
  ending: new Set
52444
52904
  };
52905
+ // src/persistence/atomic-file.ts
52906
+ import { chmodSync as chmodSync2, renameSync, writeFileSync } from "fs";
52907
+
52908
+ class SerialQueue {
52909
+ tail = Promise.resolve();
52910
+ run(fn) {
52911
+ const next = this.tail.then(fn, fn);
52912
+ this.tail = next.catch(() => {
52913
+ return;
52914
+ });
52915
+ return next;
52916
+ }
52917
+ }
52918
+ function writeFileAtomic(file2, content) {
52919
+ const tempFile = `${file2}.tmp`;
52920
+ writeFileSync(tempFile, content, { encoding: "utf-8", mode: 384 });
52921
+ renameSync(tempFile, file2);
52922
+ chmodSync2(file2, 384);
52923
+ }
52924
+
52925
+ // src/persistence/session-store.ts
52926
+ init_logger();
52927
+ import { homedir as homedir2 } from "os";
52928
+ import { join as join3 } from "path";
52929
+
52930
+ // src/sponsor.ts
52931
+ var SPONSOR_URL = "https://github.com/sponsors/axolotl-systems";
52932
+ var MILESTONE_VISIBLE_MS = 24 * 60 * 60 * 1000;
52933
+ function formatSponsorFooter(formatter) {
52934
+ return formatter.formatItalic(`♥ Support claude-threads: ${formatter.formatLink("github.com/sponsors/axolotl-systems", SPONSOR_URL)}`);
52935
+ }
52936
+
52937
+ // src/persistence/session-store.ts
52938
+ var log6 = createLogger("persist");
52939
+ function resolveEndReason(session) {
52940
+ if (!session.cleanedAt)
52941
+ return;
52942
+ return session.endReason ?? "stopped";
52943
+ }
52944
+ function isRevivable(session) {
52945
+ return resolveEndReason(session) !== "stopped";
52946
+ }
52947
+ var DEFAULT_CONFIG_DIR = join3(homedir2(), ".config", "claude-threads");
52948
+ var DEFAULT_SESSIONS_FILE = join3(DEFAULT_CONFIG_DIR, "sessions.json");
52949
+
52445
52950
  // src/config/index.ts
52446
52951
  import { resolve as resolve2, dirname as dirname2 } from "path";
52447
- import { homedir as homedir2 } from "os";
52952
+ import { homedir as homedir3 } from "os";
52448
52953
 
52449
52954
  // node_modules/js-yaml/dist/js-yaml.mjs
52450
52955
  function getDefaultExportFromCjs(x) {
@@ -55556,7 +56061,7 @@ var jsYamlExports = requireJsYaml();
55556
56061
  var yaml = /* @__PURE__ */ getDefaultExportFromCjs(jsYamlExports);
55557
56062
 
55558
56063
  // src/config/index.ts
55559
- var CONFIG_PATH = resolve2(homedir2(), ".config", "claude-threads", "config.yaml");
56064
+ var CONFIG_PATH = resolve2(homedir3(), ".config", "claude-threads", "config.yaml");
55560
56065
 
55561
56066
  // src/utils/battery.ts
55562
56067
  import { exec } from "child_process";
@@ -55665,7 +56170,7 @@ init_logger();
55665
56170
  // src/utils/keep-alive.ts
55666
56171
  init_logger();
55667
56172
  import { spawn } from "child_process";
55668
- var log6 = createLogger("keepalive");
56173
+ var log7 = createLogger("keepalive");
55669
56174
  function keepAliveSpawnSpec(platform, parentPid) {
55670
56175
  switch (platform) {
55671
56176
  case "darwin":
@@ -55721,7 +56226,7 @@ class KeepAliveManager {
55721
56226
  if (!enabled && this.keepAliveProcess) {
55722
56227
  this.stopKeepAlive();
55723
56228
  }
55724
- log6.debug(`Keep-alive ${enabled ? "enabled" : "disabled"}`);
56229
+ log7.debug(`Keep-alive ${enabled ? "enabled" : "disabled"}`);
55725
56230
  }
55726
56231
  isEnabled() {
55727
56232
  return this.enabled;
@@ -55731,7 +56236,7 @@ class KeepAliveManager {
55731
56236
  }
55732
56237
  sessionStarted() {
55733
56238
  this.activeSessionCount++;
55734
- log6.debug(`Session started (${this.activeSessionCount} active)`);
56239
+ log7.debug(`Session started (${this.activeSessionCount} active)`);
55735
56240
  if (this.activeSessionCount === 1) {
55736
56241
  this.startKeepAlive();
55737
56242
  }
@@ -55740,7 +56245,7 @@ class KeepAliveManager {
55740
56245
  if (this.activeSessionCount > 0) {
55741
56246
  this.activeSessionCount--;
55742
56247
  }
55743
- log6.debug(`Session ended (${this.activeSessionCount} active)`);
56248
+ log7.debug(`Session ended (${this.activeSessionCount} active)`);
55744
56249
  if (this.activeSessionCount === 0) {
55745
56250
  this.stopKeepAlive();
55746
56251
  }
@@ -55754,11 +56259,11 @@ class KeepAliveManager {
55754
56259
  }
55755
56260
  startKeepAlive() {
55756
56261
  if (!this.enabled) {
55757
- log6.debug("Keep-alive disabled, skipping");
56262
+ log7.debug("Keep-alive disabled, skipping");
55758
56263
  return;
55759
56264
  }
55760
56265
  if (this.keepAliveProcess) {
55761
- log6.debug("Keep-alive already running");
56266
+ log7.debug("Keep-alive already running");
55762
56267
  return;
55763
56268
  }
55764
56269
  switch (this.platform) {
@@ -55772,12 +56277,12 @@ class KeepAliveManager {
55772
56277
  this.startWindowsKeepAlive();
55773
56278
  break;
55774
56279
  default:
55775
- log6.warn(`Keep-alive not supported on ${this.platform}`);
56280
+ log7.warn(`Keep-alive not supported on ${this.platform}`);
55776
56281
  }
55777
56282
  }
55778
56283
  stopKeepAlive() {
55779
56284
  if (this.keepAliveProcess) {
55780
- log6.debug("Stopping keep-alive");
56285
+ log7.debug("Stopping keep-alive");
55781
56286
  this.keepAliveProcess.kill();
55782
56287
  this.keepAliveProcess = null;
55783
56288
  }
@@ -55792,18 +56297,18 @@ class KeepAliveManager {
55792
56297
  detached: false
55793
56298
  });
55794
56299
  this.keepAliveProcess.on("error", (err) => {
55795
- log6.error(`Failed to start caffeinate: ${err.message}`);
56300
+ log7.error(`Failed to start caffeinate: ${err.message}`);
55796
56301
  this.keepAliveProcess = null;
55797
56302
  });
55798
56303
  this.keepAliveProcess.on("exit", (code) => {
55799
56304
  if (code !== null && code !== 0 && this.activeSessionCount > 0) {
55800
- log6.debug(`caffeinate exited with code ${code}`);
56305
+ log7.debug(`caffeinate exited with code ${code}`);
55801
56306
  }
55802
56307
  this.keepAliveProcess = null;
55803
56308
  });
55804
- log6.info("Sleep prevention active (caffeinate)");
56309
+ log7.info("Sleep prevention active (caffeinate)");
55805
56310
  } catch (err) {
55806
- log6.error(`Failed to start caffeinate: ${err}`);
56311
+ log7.error(`Failed to start caffeinate: ${err}`);
55807
56312
  }
55808
56313
  }
55809
56314
  startLinuxKeepAlive() {
@@ -55816,19 +56321,19 @@ class KeepAliveManager {
55816
56321
  detached: false
55817
56322
  });
55818
56323
  this.keepAliveProcess.on("error", (err) => {
55819
- log6.debug(`systemd-inhibit not available: ${err.message}`);
56324
+ log7.debug(`systemd-inhibit not available: ${err.message}`);
55820
56325
  this.keepAliveProcess = null;
55821
56326
  this.startLinuxKeepAliveFallback();
55822
56327
  });
55823
56328
  this.keepAliveProcess.on("exit", (code) => {
55824
56329
  if (code !== null && code !== 0 && this.activeSessionCount > 0) {
55825
- log6.debug(`systemd-inhibit exited with code ${code}`);
56330
+ log7.debug(`systemd-inhibit exited with code ${code}`);
55826
56331
  }
55827
56332
  this.keepAliveProcess = null;
55828
56333
  });
55829
- log6.info("Sleep prevention active (systemd-inhibit)");
56334
+ log7.info("Sleep prevention active (systemd-inhibit)");
55830
56335
  } catch (err) {
55831
- log6.debug(`Failed to start systemd-inhibit: ${err}`);
56336
+ log7.debug(`Failed to start systemd-inhibit: ${err}`);
55832
56337
  this.startLinuxKeepAliveFallback();
55833
56338
  }
55834
56339
  }
@@ -55839,15 +56344,15 @@ class KeepAliveManager {
55839
56344
  detached: false
55840
56345
  });
55841
56346
  this.keepAliveProcess.on("error", (err) => {
55842
- log6.warn(`Linux keep-alive fallback not available: ${err.message}`);
56347
+ log7.warn(`Linux keep-alive fallback not available: ${err.message}`);
55843
56348
  this.keepAliveProcess = null;
55844
56349
  });
55845
56350
  this.keepAliveProcess.on("exit", () => {
55846
56351
  this.keepAliveProcess = null;
55847
56352
  });
55848
- log6.info("Sleep prevention active (xdg-screensaver)");
56353
+ log7.info("Sleep prevention active (xdg-screensaver)");
55849
56354
  } catch (err) {
55850
- log6.warn(`Linux keep-alive not available: ${err}`);
56355
+ log7.warn(`Linux keep-alive not available: ${err}`);
55851
56356
  }
55852
56357
  }
55853
56358
  startWindowsKeepAlive() {
@@ -55859,32 +56364,25 @@ class KeepAliveManager {
55859
56364
  windowsHide: true
55860
56365
  });
55861
56366
  this.keepAliveProcess.on("error", (err) => {
55862
- log6.warn(`Windows keep-alive not available: ${err.message}`);
56367
+ log7.warn(`Windows keep-alive not available: ${err.message}`);
55863
56368
  this.keepAliveProcess = null;
55864
56369
  });
55865
56370
  this.keepAliveProcess.on("exit", (code) => {
55866
56371
  if (code !== null && code !== 0 && this.activeSessionCount > 0) {
55867
- log6.debug(`PowerShell keep-alive exited with code ${code}`);
56372
+ log7.debug(`PowerShell keep-alive exited with code ${code}`);
55868
56373
  }
55869
56374
  this.keepAliveProcess = null;
55870
56375
  });
55871
- log6.info("Sleep prevention active (SetThreadExecutionState)");
56376
+ log7.info("Sleep prevention active (SetThreadExecutionState)");
55872
56377
  } catch (err) {
55873
- log6.warn(`Windows keep-alive not available: ${err}`);
56378
+ log7.warn(`Windows keep-alive not available: ${err}`);
55874
56379
  }
55875
56380
  }
55876
56381
  }
55877
56382
  var keepAlive = new KeepAliveManager;
55878
56383
 
55879
- // src/sponsor.ts
55880
- var SPONSOR_URL = "https://github.com/sponsors/axolotl-systems";
55881
- var MILESTONE_VISIBLE_MS = 24 * 60 * 60 * 1000;
55882
- function formatSponsorFooter(formatter) {
55883
- return formatter.formatItalic(`♥ Support claude-threads: ${formatter.formatLink("github.com/sponsors/axolotl-systems", SPONSOR_URL)}`);
55884
- }
55885
-
55886
56384
  // src/operations/sticky-message/handler.ts
55887
- var log7 = createLogger("sticky");
56385
+ var log8 = createLogger("sticky");
55888
56386
  var botStartedAt = new Date;
55889
56387
  var stickyPostIds = new Map;
55890
56388
  var needsBump = new Map;
@@ -56127,10 +56625,10 @@ init_version_check();
56127
56625
 
56128
56626
  // src/persistence/thread-logger.ts
56129
56627
  init_logger();
56130
- import { homedir as homedir3 } from "os";
56131
- import { join as join3, dirname as dirname4 } from "path";
56132
- var log8 = createLogger("thread-log");
56133
- var LOGS_BASE_DIR = join3(homedir3(), ".claude-threads", "logs");
56628
+ import { homedir as homedir4 } from "os";
56629
+ import { join as join4, dirname as dirname4 } from "path";
56630
+ var log9 = createLogger("thread-log");
56631
+ var LOGS_BASE_DIR = join4(homedir4(), ".claude-threads", "logs");
56134
56632
 
56135
56633
  // src/operations/bug-report/handler.ts
56136
56634
  var piiRedactor = new Redactor({ aggressive: true });
@@ -56153,7 +56651,7 @@ class UsernameAnonymizer {
56153
56651
  // src/mcp/decision-bridge.ts
56154
56652
  import { createServer, createConnection } from "node:net";
56155
56653
  import { tmpdir } from "node:os";
56156
- import { join as join4 } from "node:path";
56654
+ import { join as join5 } from "node:path";
56157
56655
  import { randomUUID } from "node:crypto";
56158
56656
  import { mkdtempSync } from "node:fs";
56159
56657
  import { rm } from "node:fs/promises";
@@ -56164,8 +56662,8 @@ function bridgeSocketPath() {
56164
56662
  if (process.platform === "win32") {
56165
56663
  return `\\\\.\\pipe\\ctb-${randomUUID()}`;
56166
56664
  }
56167
- const dir = mkdtempSync(join4(tmpdir(), "ctb-"));
56168
- return join4(dir, "b.sock");
56665
+ const dir = mkdtempSync(join5(tmpdir(), "ctb-"));
56666
+ return join5(dir, "b.sock");
56169
56667
  }
56170
56668
  var MAX_BRIDGE_REQUEST_BYTES = 1024 * 1024;
56171
56669
 
@@ -56242,7 +56740,7 @@ class DecisionBridgeServer {
56242
56740
  });
56243
56741
  } catch (err) {
56244
56742
  if (process.platform !== "win32") {
56245
- await rm(join4(path, ".."), { recursive: true, force: true }).catch(() => {});
56743
+ await rm(join5(path, ".."), { recursive: true, force: true }).catch(() => {});
56246
56744
  }
56247
56745
  throw err;
56248
56746
  }
@@ -56255,7 +56753,7 @@ class DecisionBridgeServer {
56255
56753
  socket.destroy();
56256
56754
  await new Promise((resolve4) => this.server.close(() => resolve4()));
56257
56755
  if (process.platform !== "win32") {
56258
- await rm(join4(this.path, ".."), { recursive: true, force: true }).catch(() => {});
56756
+ await rm(join5(this.path, ".."), { recursive: true, force: true }).catch(() => {});
56259
56757
  }
56260
56758
  }
56261
56759
  }
@@ -56313,9 +56811,9 @@ init_version_check();
56313
56811
  import { EventEmitter as EventEmitter2 } from "events";
56314
56812
  import { resolve as resolve4, dirname as dirname5 } from "path";
56315
56813
  import { fileURLToPath as fileURLToPath3 } from "url";
56316
- import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync } from "fs";
56814
+ import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync as writeFileSync2 } from "fs";
56317
56815
  import { tmpdir as tmpdir2 } from "os";
56318
- import { join as join5 } from "path";
56816
+ import { join as join6 } from "path";
56319
56817
 
56320
56818
  // src/mcp/outbound-env.ts
56321
56819
  var OUTBOUND_ENV = {
@@ -56415,25 +56913,25 @@ function parseRateLimitEvent(event, now = Date.now()) {
56415
56913
  }
56416
56914
 
56417
56915
  // src/claude/cli.ts
56418
- var log9 = createLogger("claude");
56916
+ var log10 = createLogger("claude");
56419
56917
  function cleanupBrowserBridgeSockets() {
56420
56918
  try {
56421
56919
  const tempDir = tmpdir2();
56422
56920
  const files = readdirSync(tempDir);
56423
56921
  for (const file2 of files) {
56424
56922
  if (file2.startsWith("claude-mcp-browser-bridge-")) {
56425
- const filePath = join5(tempDir, file2);
56923
+ const filePath = join6(tempDir, file2);
56426
56924
  try {
56427
56925
  const stats = statSync(filePath);
56428
56926
  if (stats.isSocket()) {
56429
56927
  unlinkSync(filePath);
56430
- log9.debug(`Removed stale browser bridge socket: ${file2}`);
56928
+ log10.debug(`Removed stale browser bridge socket: ${file2}`);
56431
56929
  }
56432
56930
  } catch {}
56433
56931
  }
56434
56932
  }
56435
56933
  } catch (err) {
56436
- log9.debug(`Browser bridge cleanup failed: ${err}`);
56934
+ log10.debug(`Browser bridge cleanup failed: ${err}`);
56437
56935
  }
56438
56936
  }
56439
56937
  function buildClaudeChildEnv(parentEnv, account, opts) {
@@ -56455,9 +56953,13 @@ function buildClaudeChildEnv(parentEnv, account, opts) {
56455
56953
  env.USERPROFILE = account.home;
56456
56954
  delete env.ANTHROPIC_API_KEY;
56457
56955
  delete env.CLAUDE_CODE_OAUTH_TOKEN;
56956
+ delete env.ANTHROPIC_AUTH_TOKEN;
56957
+ delete env.CLAUDE_CONFIG_DIR;
56958
+ delete env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
56458
56959
  } else if (account?.apiKey) {
56459
56960
  env.ANTHROPIC_API_KEY = account.apiKey;
56460
56961
  delete env.CLAUDE_CODE_OAUTH_TOKEN;
56962
+ delete env.ANTHROPIC_AUTH_TOKEN;
56461
56963
  }
56462
56964
  return env;
56463
56965
  }
@@ -56492,8 +56994,8 @@ function materializeMcpConfig(config3, sessionId, opts = {}) {
56492
56994
  return { mode: "inline", value: JSON.stringify(config3) };
56493
56995
  }
56494
56996
  const dir = opts.tmpDirOverride ?? tmpdir2();
56495
- const path = join5(dir, `claude-threads-mcp-${sessionId ?? process.pid}-${Date.now()}.json`);
56496
- writeFileSync(path, JSON.stringify(config3), { mode: 384 });
56997
+ const path = join6(dir, `claude-threads-mcp-${sessionId ?? process.pid}-${Date.now()}.json`);
56998
+ writeFileSync2(path, JSON.stringify(config3), { mode: 384 });
56497
56999
  return { mode: "file", path };
56498
57000
  }
56499
57001
  function buildPermissionArgs(opts) {
@@ -56689,7 +57191,7 @@ class ClaudeCli extends EventEmitter2 {
56689
57191
  }
56690
57192
  let statusLineCommand;
56691
57193
  if (this.options.sessionId) {
56692
- this.statusFilePath = join5(tmpdir2(), `claude-threads-status-${this.options.sessionId}.json`);
57194
+ this.statusFilePath = join6(tmpdir2(), `claude-threads-status-${this.options.sessionId}.json`);
56693
57195
  const statusLineWriterPath = this.getStatusLineWriterPath();
56694
57196
  const runtime = runtimeForScriptPath(statusLineWriterPath);
56695
57197
  statusLineCommand = `${runtime} ${statusLineWriterPath} ${this.options.sessionId}`;
@@ -57659,7 +58161,7 @@ handlers.set("model", createPassthroughHandler("model"));
57659
58161
  handlers.set("effort", createPassthroughHandler("effort"));
57660
58162
  // src/commands/system-prompt-generator.ts
57661
58163
  init_logger();
57662
- var log10 = createLogger("system-prompt");
58164
+ var log11 = createLogger("system-prompt");
57663
58165
  function formatUserCommand(cmd) {
57664
58166
  const cmdStr = cmd.args ? `\`!${cmd.command} ${cmd.args}\`` : `\`!${cmd.command}\``;
57665
58167
  const description = cmd.description;
@@ -57751,7 +58253,7 @@ ${avoidCommands.map((c) => `- \`!${c.command}\` - ${c.reason}`).join(`
57751
58253
  }
57752
58254
  // src/utils/error-handler/index.ts
57753
58255
  init_logger();
57754
- var log11 = createLogger("error");
58256
+ var log12 = createLogger("error");
57755
58257
 
57756
58258
  // src/session/lifecycle.ts
57757
58259
  init_logger();
@@ -57774,35 +58276,35 @@ init_emoji();
57774
58276
  init_spawn();
57775
58277
  import * as path from "path";
57776
58278
  init_logger();
57777
- import { homedir as homedir4 } from "os";
57778
- var log12 = createLogger("git-wt");
57779
- var WORKTREES_DIR = path.join(homedir4(), ".claude-threads", "worktrees");
57780
- var METADATA_STORE_PATH = path.join(homedir4(), ".claude-threads", "worktree-metadata.json");
58279
+ import { homedir as homedir5 } from "os";
58280
+ var log13 = createLogger("git-wt");
58281
+ var WORKTREES_DIR = path.join(homedir5(), ".claude-threads", "worktrees");
58282
+ var METADATA_STORE_PATH = path.join(homedir5(), ".claude-threads", "worktree-metadata.json");
57781
58283
 
57782
58284
  // src/operations/post-helpers/index.ts
57783
- var log13 = createLogger("helpers");
57784
- var sessionLog = createSessionLog(log13);
58285
+ var log14 = createLogger("helpers");
58286
+ var sessionLog = createSessionLog(log14);
57785
58287
 
57786
58288
  // src/operations/suggestions/title.ts
57787
58289
  init_quick_query();
57788
58290
  init_logger();
57789
- var log15 = createLogger("title");
58291
+ var log16 = createLogger("title");
57790
58292
 
57791
58293
  // src/operations/suggestions/tag.ts
57792
58294
  init_quick_query();
57793
58295
  init_logger();
57794
- var log16 = createLogger("tags");
58296
+ var log17 = createLogger("tags");
57795
58297
 
57796
58298
  // src/session/metadata-suggestions.ts
57797
58299
  init_logger();
57798
- var log17 = createLogger("session");
57799
- var sessionLog2 = createSessionLog(log17);
58300
+ var log18 = createLogger("session");
58301
+ var sessionLog2 = createSessionLog(log18);
57800
58302
 
57801
58303
  // src/operations/context-prompt/handler.ts
57802
58304
  init_emoji();
57803
58305
  init_logger();
57804
- var log18 = createLogger("context");
57805
- var sessionLog3 = createSessionLog(log18);
58306
+ var log19 = createLogger("context");
58307
+ var sessionLog3 = createSessionLog(log19);
57806
58308
  var contextPromptTimeouts = new Map;
57807
58309
  var contextPromptFiles = new Map;
57808
58310
  // src/memory/store.ts
@@ -57813,33 +58315,11 @@ import {
57813
58315
  readFileSync as readFileSync4,
57814
58316
  realpathSync
57815
58317
  } from "fs";
57816
- import { homedir as homedir5 } from "os";
57817
- import { basename as basename3, dirname as dirname7, join as join7, sep as sep2 } from "path";
57818
-
57819
- // src/persistence/atomic-file.ts
57820
- import { chmodSync as chmodSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
57821
-
57822
- class SerialQueue {
57823
- tail = Promise.resolve();
57824
- run(fn) {
57825
- const next = this.tail.then(fn, fn);
57826
- this.tail = next.catch(() => {
57827
- return;
57828
- });
57829
- return next;
57830
- }
57831
- }
57832
- function writeFileAtomic(file2, content) {
57833
- const tempFile = `${file2}.tmp`;
57834
- writeFileSync2(tempFile, content, { encoding: "utf-8", mode: 384 });
57835
- renameSync(tempFile, file2);
57836
- chmodSync2(file2, 384);
57837
- }
57838
-
57839
- // src/memory/store.ts
58318
+ import { homedir as homedir6 } from "os";
58319
+ import { basename as basename3, dirname as dirname7, join as join8, sep as sep2 } from "path";
57840
58320
  init_logger();
57841
- var log19 = createLogger("memory");
57842
- var DEFAULT_ROOT = join7(homedir5(), ".config", "claude-threads", "memory");
58321
+ var log20 = createLogger("memory");
58322
+ var DEFAULT_ROOT = join8(homedir6(), ".config", "claude-threads", "memory");
57843
58323
  var CHANNEL_BLOCK_MAX_LINES = 200;
57844
58324
  var CHANNEL_BLOCK_MAX_BYTES = 25 * 1024;
57845
58325
  var CHANNEL_FILE_MAX_ENTRIES = 400;
@@ -57884,10 +58364,10 @@ class MemoryStore {
57884
58364
  return this.root;
57885
58365
  }
57886
58366
  channelMemoryPath(platformId) {
57887
- return join7(this.root, platformSegment(platformId), "channel", "MEMORY.md");
58367
+ return join8(this.root, platformSegment(platformId), "channel", "MEMORY.md");
57888
58368
  }
57889
58369
  repoMemoryDir(platformId, repoKey) {
57890
- const dir = join7(this.root, platformSegment(platformId), "repos", repoKey);
58370
+ const dir = join8(this.root, platformSegment(platformId), "repos", repoKey);
57891
58371
  this.ensureDir(dir);
57892
58372
  return dir;
57893
58373
  }
@@ -57934,7 +58414,7 @@ class MemoryStore {
57934
58414
  if (result.added.length > 0) {
57935
58415
  this.enforceFileCap(lines);
57936
58416
  this.writeLines(platformId, lines);
57937
- log19.debug(`Channel memory for ${platformId}: +${result.added.length} entries` + (result.duplicates.length ? ` (${result.duplicates.length} duplicates skipped)` : ""));
58417
+ log20.debug(`Channel memory for ${platformId}: +${result.added.length} entries` + (result.duplicates.length ? ` (${result.duplicates.length} duplicates skipped)` : ""));
57938
58418
  }
57939
58419
  return result;
57940
58420
  });
@@ -57973,14 +58453,14 @@ class MemoryStore {
57973
58453
  }
57974
58454
  lines.splice(target.lineIndex, 1);
57975
58455
  this.writeLines(platformId, lines);
57976
- log19.debug(`Channel memory for ${platformId}: removed one entry`);
58456
+ log20.debug(`Channel memory for ${platformId}: removed one entry`);
57977
58457
  return { ok: true, removed: target.entry };
57978
58458
  });
57979
58459
  }
57980
58460
  clearChannel(platformId) {
57981
58461
  return this.runExclusive(platformId, () => {
57982
58462
  this.writeLines(platformId, []);
57983
- log19.debug(`Channel memory for ${platformId}: cleared`);
58463
+ log20.debug(`Channel memory for ${platformId}: cleared`);
57984
58464
  });
57985
58465
  }
57986
58466
  buildChannelMemoryBlock(platformId) {
@@ -57988,7 +58468,7 @@ class MemoryStore {
57988
58468
  try {
57989
58469
  lines = this.loadLines(platformId);
57990
58470
  } catch (err) {
57991
- log19.warn(`Failed to read channel memory for ${platformId}: ${err.message}`);
58471
+ log20.warn(`Failed to read channel memory for ${platformId}: ${err.message}`);
57992
58472
  return null;
57993
58473
  }
57994
58474
  if (lines.length === 0)
@@ -58072,7 +58552,7 @@ _(older entries omitted — \`!memory\` shows all)_` : rendered;
58072
58552
  // src/memory/distiller.ts
58073
58553
  init_quick_query();
58074
58554
  init_logger();
58075
- var log20 = createLogger("memory");
58555
+ var log21 = createLogger("memory");
58076
58556
 
58077
58557
  // src/session/registry.ts
58078
58558
  function compositeSessionId(platformId, threadId) {
@@ -58165,7 +58645,8 @@ class SessionRegistry {
58165
58645
  return this.sessionStore.findByThread(platformId, threadId);
58166
58646
  }
58167
58647
  getPersistedByThreadId(threadId, platformId) {
58168
- return this.sessionStore.findByThreadIdAnyState(threadId, platformId);
58648
+ const persisted = this.sessionStore.findByThreadIdAnyState(threadId, platformId);
58649
+ return persisted && isRevivable(persisted) ? persisted : undefined;
58169
58650
  }
58170
58651
  getSessionStore() {
58171
58652
  return this.sessionStore;
@@ -58191,14 +58672,14 @@ class SessionRegistry {
58191
58672
  init_emoji();
58192
58673
 
58193
58674
  // src/persistence/routines-store.ts
58194
- import { join as join9 } from "path";
58675
+ import { join as join10 } from "path";
58195
58676
  init_logger();
58196
58677
 
58197
58678
  // src/persistence/platform-list-store.ts
58198
58679
  import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
58199
- import { homedir as homedir6 } from "os";
58200
- import { join as join8 } from "path";
58201
- var STORES_CONFIG_DIR = join8(homedir6(), ".config", "claude-threads");
58680
+ import { homedir as homedir7 } from "os";
58681
+ import { join as join9 } from "path";
58682
+ var STORES_CONFIG_DIR = join9(homedir7(), ".config", "claude-threads");
58202
58683
  var STORE_VERSION = 1;
58203
58684
 
58204
58685
  class PlatformListStore {
@@ -58211,7 +58692,7 @@ class PlatformListStore {
58211
58692
  this.collectionKey = collectionKey;
58212
58693
  if (filePath) {
58213
58694
  this.file = filePath;
58214
- this.configDir = join8(filePath, "..");
58695
+ this.configDir = join9(filePath, "..");
58215
58696
  } else {
58216
58697
  this.file = defaultFile;
58217
58698
  this.configDir = STORES_CONFIG_DIR;
@@ -58335,41 +58816,41 @@ class PlatformListStore {
58335
58816
  }
58336
58817
 
58337
58818
  // src/persistence/routines-store.ts
58338
- var log21 = createLogger("routines");
58339
- var DEFAULT_FILE = join9(STORES_CONFIG_DIR, "routines.yaml");
58819
+ var log22 = createLogger("routines");
58820
+ var DEFAULT_FILE = join10(STORES_CONFIG_DIR, "routines.yaml");
58340
58821
 
58341
58822
  // src/routines/parser.ts
58342
58823
  init_logger();
58343
- var log22 = createLogger("routines");
58824
+ var log23 = createLogger("routines");
58344
58825
 
58345
58826
  // src/persistence/watches-store.ts
58346
- import { join as join10 } from "path";
58827
+ import { join as join11 } from "path";
58347
58828
  init_logger();
58348
- var log23 = createLogger("watches");
58349
- var DEFAULT_FILE2 = join10(STORES_CONFIG_DIR, "watches.yaml");
58829
+ var log24 = createLogger("watches");
58830
+ var DEFAULT_FILE2 = join11(STORES_CONFIG_DIR, "watches.yaml");
58350
58831
 
58351
58832
  // src/watches/parser.ts
58352
58833
  init_logger();
58353
- var log24 = createLogger("watches");
58834
+ var log25 = createLogger("watches");
58354
58835
 
58355
58836
  // src/operations/commands/guards.ts
58356
58837
  init_logger();
58357
- var log25 = createLogger("commands");
58358
- var sessionLog4 = createSessionLog(log25);
58838
+ var log26 = createLogger("commands");
58839
+ var sessionLog4 = createSessionLog(log26);
58359
58840
 
58360
58841
  // src/operations/commands/automation.ts
58361
58842
  init_logger();
58362
- var log26 = createLogger("commands");
58363
- var sessionLog5 = createSessionLog(log26);
58843
+ var log27 = createLogger("commands");
58844
+ var sessionLog5 = createSessionLog(log27);
58364
58845
 
58365
58846
  // src/operations/agent-actions/handler.ts
58366
58847
  init_logger();
58367
- var log27 = createLogger("agent-actions");
58368
- var sessionLog6 = createSessionLog(log27);
58848
+ var log28 = createLogger("agent-actions");
58849
+ var sessionLog6 = createSessionLog(log28);
58369
58850
 
58370
58851
  // src/session/lifecycle.ts
58371
- var log28 = createLogger("lifecycle");
58372
- var sessionLog7 = createSessionLog(log28);
58852
+ var log29 = createLogger("lifecycle");
58853
+ var sessionLog7 = createSessionLog(log29);
58373
58854
  var _inFlightSessionStarts = new Map;
58374
58855
  var CHAT_PLATFORM_PROMPT = generateChatPlatformPrompt();
58375
58856
 
@@ -58382,39 +58863,39 @@ init_logger();
58382
58863
  init_quick_query();
58383
58864
 
58384
58865
  // src/persistence/github-emails-store.ts
58385
- import { homedir as homedir7 } from "os";
58386
- import { join as join11 } from "path";
58866
+ import { homedir as homedir8 } from "os";
58867
+ import { join as join12 } from "path";
58387
58868
  init_logger();
58388
- var log29 = createLogger("gh-emails");
58389
- var DEFAULT_CONFIG_DIR = join11(homedir7(), ".config", "claude-threads");
58390
- var DEFAULT_FILE3 = join11(DEFAULT_CONFIG_DIR, "github-emails.yaml");
58869
+ var log30 = createLogger("gh-emails");
58870
+ var DEFAULT_CONFIG_DIR2 = join12(homedir8(), ".config", "claude-threads");
58871
+ var DEFAULT_FILE3 = join12(DEFAULT_CONFIG_DIR2, "github-emails.yaml");
58391
58872
 
58392
58873
  // src/operations/commands/handler.ts
58393
- var log30 = createLogger("commands");
58394
- var sessionLog8 = createSessionLog(log30);
58874
+ var log31 = createLogger("commands");
58875
+ var sessionLog8 = createSessionLog(log31);
58395
58876
  // src/operations/commands/memory.ts
58396
58877
  init_logger();
58397
- var log31 = createLogger("commands");
58398
- var sessionLog9 = createSessionLog(log31);
58878
+ var log32 = createLogger("commands");
58879
+ var sessionLog9 = createSessionLog(log32);
58399
58880
  // src/operations/suggestions/branch.ts
58400
58881
  init_quick_query();
58401
58882
  init_logger();
58402
58883
  import { exec as exec2 } from "child_process";
58403
58884
  import { promisify as promisify2 } from "util";
58404
58885
  var execAsync2 = promisify2(exec2);
58405
- var log32 = createLogger("branch");
58886
+ var log33 = createLogger("branch");
58406
58887
 
58407
58888
  // src/operations/worktree/handler.ts
58408
58889
  init_logger();
58409
- var log33 = createLogger("worktree");
58410
- var sessionLog10 = createSessionLog(log33);
58890
+ var log34 = createLogger("worktree");
58891
+ var sessionLog10 = createSessionLog(log34);
58411
58892
  // src/operations/events/handler.ts
58412
58893
  init_logger();
58413
- var log34 = createLogger("events");
58414
- var sessionLog11 = createSessionLog(log34);
58894
+ var log35 = createLogger("events");
58895
+ var sessionLog11 = createSessionLog(log35);
58415
58896
  // src/operations/monitor/handler.ts
58416
58897
  init_logger();
58417
- var log35 = createLogger("monitor");
58898
+ var log36 = createLogger("monitor");
58418
58899
  var DEFAULT_INTERVAL_MS = 60 * 1000;
58419
58900
  // src/mcp/mcp-server.ts
58420
58901
  init_logger();
@@ -58503,7 +58984,7 @@ init_logger();
58503
58984
  // src/platform/mattermost/upload.ts
58504
58985
  init_logger();
58505
58986
  import { readFile } from "fs/promises";
58506
- var log36 = createLogger("mm-upload");
58987
+ var log37 = createLogger("mm-upload");
58507
58988
  async function uploadFileMattermost(args) {
58508
58989
  const { url: url2, token, channelId, threadId, filePath, filename, caption } = args;
58509
58990
  const buffer = await readFile(filePath);
@@ -58511,7 +58992,7 @@ async function uploadFileMattermost(args) {
58511
58992
  const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
58512
58993
  const formData = new FormData;
58513
58994
  formData.append("files", new Blob([arrayBuffer]), filename);
58514
- log36.debug(`POST /files (${buffer.length} bytes, ${filename})`);
58995
+ log37.debug(`POST /files (${buffer.length} bytes, ${filename})`);
58515
58996
  const uploadResponse = await fetch(uploadUrl, {
58516
58997
  method: "POST",
58517
58998
  headers: {
@@ -58535,7 +59016,7 @@ async function uploadFileMattermost(args) {
58535
59016
  root_id: resolvePostThreadId(threadId),
58536
59017
  file_ids: [fileInfo.id]
58537
59018
  };
58538
- log36.debug(`POST /posts (file_ids=[${fileInfo.id}])`);
59019
+ log37.debug(`POST /posts (file_ids=[${fileInfo.id}])`);
58539
59020
  const postResponse = await fetch(postUrl, {
58540
59021
  method: "POST",
58541
59022
  headers: {
@@ -59033,7 +59514,7 @@ ${code}
59033
59514
  // src/platform/slack/upload.ts
59034
59515
  init_logger();
59035
59516
  import { readFile as readFile2 } from "fs/promises";
59036
- var log37 = createLogger("slack-upload");
59517
+ var log38 = createLogger("slack-upload");
59037
59518
  var DEFAULT_API_URL = "https://slack.com/api";
59038
59519
  async function uploadFileSlack(args) {
59039
59520
  const { botToken, channelId, threadTs, filePath, filename, caption } = args;
@@ -59041,7 +59522,7 @@ async function uploadFileSlack(args) {
59041
59522
  const buffer = await readFile2(filePath);
59042
59523
  const params = new URLSearchParams({ filename, length: String(buffer.length) });
59043
59524
  const step1Url = `${apiUrl}/files.getUploadURLExternal?${params.toString()}`;
59044
- log37.debug(`GET files.getUploadURLExternal (${buffer.length} bytes, ${filename})`);
59525
+ log38.debug(`GET files.getUploadURLExternal (${buffer.length} bytes, ${filename})`);
59045
59526
  const step1Response = await fetch(step1Url, {
59046
59527
  method: "GET",
59047
59528
  headers: {
@@ -59059,7 +59540,7 @@ async function uploadFileSlack(args) {
59059
59540
  const uploadUrl = step1Data.upload_url;
59060
59541
  const fileId = step1Data.file_id;
59061
59542
  const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
59062
- log37.debug(`POST <upload_url>`);
59543
+ log38.debug(`POST <upload_url>`);
59063
59544
  const step2Response = await fetch(uploadUrl, {
59064
59545
  method: "POST",
59065
59546
  headers: {
@@ -59079,7 +59560,7 @@ async function uploadFileSlack(args) {
59079
59560
  if (caption !== undefined) {
59080
59561
  step3Body.initial_comment = caption;
59081
59562
  }
59082
- log37.debug(`POST files.completeUploadExternal (file_id=${fileId}, thread_ts=${threadTs})`);
59563
+ log38.debug(`POST files.completeUploadExternal (file_id=${fileId}, thread_ts=${threadTs})`);
59083
59564
  const step3Response = await fetch(`${apiUrl}/files.completeUploadExternal`, {
59084
59565
  method: "POST",
59085
59566
  headers: {
@@ -59097,7 +59578,7 @@ async function uploadFileSlack(args) {
59097
59578
  throw new Error(`Slack completeUploadExternal error: ${step3Data.error || "unknown"}`);
59098
59579
  }
59099
59580
  if (!step3Data.ts) {
59100
- log37.warn(`Slack completeUploadExternal returned no ts; using fileId ${fileId} as postId. ` + `Do not use this id for updatePost/addReaction.`);
59581
+ log38.warn(`Slack completeUploadExternal returned no ts; using fileId ${fileId} as postId. ` + `Do not use this id for updatePost/addReaction.`);
59101
59582
  }
59102
59583
  return { fileId, postId: step3Data.ts ?? fileId };
59103
59584
  }