gogcli-mcp 2.27.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -3108,9 +3108,28 @@ var require_utils = __commonJS({
3108
3108
  "use strict";
3109
3109
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3110
3110
  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);
3111
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3111
3112
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3112
3113
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3113
- var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3114
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3115
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3116
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3117
+ var BYTE_HEX = new Array(256);
3118
+ {
3119
+ const HEX_DIGITS = "0123456789ABCDEF";
3120
+ for (let i = 0; i < 256; i++) {
3121
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
3122
+ }
3123
+ }
3124
+ function percentEncodeNonAscii(cp) {
3125
+ if (cp < 2048) {
3126
+ return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
3127
+ }
3128
+ if (cp < 65536) {
3129
+ return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3130
+ }
3131
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3132
+ }
3114
3133
  function stringArrayToHexStripped(input) {
3115
3134
  let acc = "";
3116
3135
  let code = 0;
@@ -3135,91 +3154,105 @@ var require_utils = __commonJS({
3135
3154
  }
3136
3155
  return acc;
3137
3156
  }
3157
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3158
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3159
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3138
3160
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3139
- function consumeIsZone(buffer) {
3140
- buffer.length = 0;
3141
- return true;
3142
- }
3143
- function consumeHextets(buffer, address, output) {
3144
- if (buffer.length) {
3145
- const hex3 = stringArrayToHexStripped(buffer);
3146
- if (hex3 !== "") {
3147
- address.push(hex3);
3148
- } else {
3149
- output.error = true;
3150
- return false;
3161
+ function isZoneIdentifier(zone) {
3162
+ if (zone.length === 0) return false;
3163
+ for (let i = 0; i < zone.length; i++) {
3164
+ if (isZoneCharacter(zone[i])) continue;
3165
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3166
+ i += 2;
3167
+ continue;
3151
3168
  }
3152
- buffer.length = 0;
3169
+ return false;
3153
3170
  }
3154
3171
  return true;
3155
3172
  }
3156
- function getIPV6(input) {
3157
- let tokenCount = 0;
3158
- const output = { error: false, address: "", zone: "" };
3159
- const address = [];
3160
- const buffer = [];
3161
- let endipv6Encountered = false;
3162
- let endIpv6 = false;
3163
- let consume = consumeHextets;
3164
- for (let i = 0; i < input.length; i++) {
3165
- const cursor = input[i];
3166
- if (cursor === "[" || cursor === "]") {
3167
- continue;
3168
- }
3169
- if (cursor === ":") {
3170
- if (endipv6Encountered === true) {
3171
- endIpv6 = true;
3172
- }
3173
- if (!consume(buffer, address, output)) {
3174
- break;
3175
- }
3176
- if (++tokenCount > 7) {
3177
- output.error = true;
3178
- break;
3179
- }
3180
- if (i > 0 && input[i - 1] === ":") {
3181
- endipv6Encountered = true;
3173
+ function compressIPv6ZeroRun(hextets) {
3174
+ let bestStart = -1;
3175
+ let bestLength = 0;
3176
+ let runStart = -1;
3177
+ let runLength = 0;
3178
+ for (let i = 0; i < hextets.length; i++) {
3179
+ if (hextets[i] === "0") {
3180
+ if (runStart === -1) runStart = i;
3181
+ runLength++;
3182
+ if (runLength > bestLength) {
3183
+ bestLength = runLength;
3184
+ bestStart = runStart;
3182
3185
  }
3183
- address.push(":");
3184
- continue;
3185
- } else if (cursor === "%") {
3186
- if (!consume(buffer, address, output)) {
3187
- break;
3188
- }
3189
- consume = consumeIsZone;
3190
3186
  } else {
3191
- buffer.push(cursor);
3187
+ runStart = -1;
3188
+ runLength = 0;
3189
+ }
3190
+ }
3191
+ if (bestLength < 2) return hextets.join(":");
3192
+ const head = hextets.slice(0, bestStart).join(":");
3193
+ const tail = hextets.slice(bestStart + bestLength).join(":");
3194
+ return head + "::" + tail;
3195
+ }
3196
+ function normalizeIPv6Address(input) {
3197
+ const compression = input.indexOf("::");
3198
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
3199
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3200
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3201
+ if (compression !== -1) {
3202
+ if (left.length === 1 && left[0] === "") left.length = 0;
3203
+ if (right.length === 1 && right[0] === "") right.length = 0;
3204
+ }
3205
+ const parts = left.concat(right);
3206
+ let hextetCount = 0;
3207
+ for (let i = 0; i < parts.length; i++) {
3208
+ const part = parts[i];
3209
+ if (part === "") return void 0;
3210
+ if (part.indexOf(".") !== -1) {
3211
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
3212
+ hextetCount += 2;
3192
3213
  continue;
3193
3214
  }
3215
+ if (!isHextet(part)) return void 0;
3216
+ parts[i] = parseInt(part, 16).toString(16);
3217
+ hextetCount++;
3194
3218
  }
3195
- if (buffer.length) {
3196
- if (consume === consumeIsZone) {
3197
- output.zone = buffer.join("");
3198
- } else if (endIpv6) {
3199
- address.push(buffer.join(""));
3200
- } else {
3201
- address.push(stringArrayToHexStripped(buffer));
3202
- }
3219
+ if (compression === -1) {
3220
+ if (hextetCount !== 8) return void 0;
3221
+ return compressIPv6ZeroRun(parts);
3203
3222
  }
3204
- output.address = address.join("");
3205
- return output;
3223
+ if (hextetCount >= 8) return void 0;
3224
+ const expanded = parts.slice(0, left.length);
3225
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
3226
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
3227
+ return compressIPv6ZeroRun(expanded);
3206
3228
  }
3207
3229
  function normalizeIPv6(host) {
3208
- if (findToken(host, ":") < 2) {
3209
- return { host, isIPV6: false };
3210
- }
3211
- const ipv63 = getIPV6(host);
3212
- if (!ipv63.error) {
3213
- let newHost = ipv63.address;
3214
- let escapedHost = ipv63.address;
3215
- if (ipv63.zone) {
3216
- newHost += "%" + ipv63.zone;
3217
- escapedHost += "%25" + ipv63.zone;
3218
- }
3219
- return { host: newHost, isIPV6: true, escapedHost };
3220
- } else {
3221
- return { host, isIPV6: false };
3222
- }
3230
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3231
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3232
+ if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
3233
+ let input = bracketed ? host.slice(1, -1) : host;
3234
+ if (bracketed && isIPvFuture(input)) {
3235
+ input = input.toLowerCase();
3236
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3237
+ }
3238
+ if (findToken(input, ":") < 2) {
3239
+ return { host, isIPV6: false, error: bracketed };
3240
+ }
3241
+ let zoneIdentifier = "";
3242
+ const zoneSeparator = input.indexOf("%");
3243
+ if (zoneSeparator !== -1) {
3244
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3245
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3246
+ if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
3247
+ input = input.slice(0, zoneSeparator);
3248
+ }
3249
+ const address = normalizeIPv6Address(input);
3250
+ if (address === void 0) return { host, isIPV6: false, error: true };
3251
+ return {
3252
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3253
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3254
+ isIPV6: true
3255
+ };
3223
3256
  }
3224
3257
  function findToken(str, token) {
3225
3258
  let ind = 0;
@@ -3338,7 +3371,8 @@ var require_utils = __commonJS({
3338
3371
  function normalizePathEncoding(input) {
3339
3372
  let output = "";
3340
3373
  for (let i = 0; i < input.length; i++) {
3341
- if (input[i] === "%" && i + 2 < input.length) {
3374
+ const ch = input[i];
3375
+ if (ch === "%" && i + 2 < input.length) {
3342
3376
  const hex3 = input.slice(i + 1, i + 3);
3343
3377
  if (isHexPair(hex3)) {
3344
3378
  const normalizedHex = hex3.toUpperCase();
@@ -3352,10 +3386,152 @@ var require_utils = __commonJS({
3352
3386
  continue;
3353
3387
  }
3354
3388
  }
3355
- if (isPathCharacter(input[i])) {
3356
- output += input[i];
3389
+ if (isPathCharacter(ch)) {
3390
+ output += ch;
3391
+ } else {
3392
+ const code = input.charCodeAt(i);
3393
+ if (code < 128) {
3394
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3395
+ } else if (code < 55296 || code > 57343) {
3396
+ output += percentEncodeNonAscii(code);
3397
+ } else if (code <= 56319 && i + 1 < input.length) {
3398
+ const low = input.charCodeAt(i + 1);
3399
+ if (low >= 56320 && low <= 57343) {
3400
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3401
+ i++;
3402
+ } else {
3403
+ output += percentEncodeNonAscii(65533);
3404
+ }
3405
+ } else {
3406
+ output += percentEncodeNonAscii(65533);
3407
+ }
3408
+ }
3409
+ }
3410
+ return output;
3411
+ }
3412
+ function serializePathEncoding(input, pathNoScheme = false) {
3413
+ let output = "";
3414
+ let firstSegment = pathNoScheme && input[0] !== "/";
3415
+ for (let i = 0; i < input.length; i++) {
3416
+ const ch = input[i];
3417
+ if (ch === "%" && i + 2 < input.length) {
3418
+ const hex3 = input.slice(i + 1, i + 3);
3419
+ if (isHexPair(hex3)) {
3420
+ output += "%" + hex3.toUpperCase();
3421
+ i += 2;
3422
+ continue;
3423
+ }
3424
+ }
3425
+ if (ch === "/") {
3426
+ firstSegment = false;
3427
+ }
3428
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3429
+ output += ch;
3430
+ } else {
3431
+ const code = input.charCodeAt(i);
3432
+ if (code < 128) {
3433
+ output += BYTE_HEX[code];
3434
+ } else if (code < 55296 || code > 57343) {
3435
+ output += percentEncodeNonAscii(code);
3436
+ } else if (code <= 56319 && i + 1 < input.length) {
3437
+ const low = input.charCodeAt(i + 1);
3438
+ if (low >= 56320 && low <= 57343) {
3439
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3440
+ i++;
3441
+ } else {
3442
+ output += percentEncodeNonAscii(65533);
3443
+ }
3444
+ } else {
3445
+ output += percentEncodeNonAscii(65533);
3446
+ }
3447
+ }
3448
+ }
3449
+ return output;
3450
+ }
3451
+ function encodeComponent(input, isAllowed) {
3452
+ let output = "";
3453
+ for (let i = 0; i < input.length; i++) {
3454
+ const ch = input[i];
3455
+ if (ch === "%" && i + 2 < input.length) {
3456
+ const hex3 = input.slice(i + 1, i + 3);
3457
+ if (isHexPair(hex3)) {
3458
+ output += "%" + hex3.toUpperCase();
3459
+ i += 2;
3460
+ continue;
3461
+ }
3462
+ }
3463
+ if (isAllowed(ch)) {
3464
+ output += ch;
3465
+ } else {
3466
+ const code = input.charCodeAt(i);
3467
+ if (code < 128) {
3468
+ output += BYTE_HEX[code];
3469
+ } else if (code < 55296 || code > 57343) {
3470
+ output += percentEncodeNonAscii(code);
3471
+ } else if (code <= 56319 && i + 1 < input.length) {
3472
+ const low = input.charCodeAt(i + 1);
3473
+ if (low >= 56320 && low <= 57343) {
3474
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3475
+ i++;
3476
+ } else {
3477
+ output += percentEncodeNonAscii(65533);
3478
+ }
3479
+ } else {
3480
+ output += percentEncodeNonAscii(65533);
3481
+ }
3482
+ }
3483
+ }
3484
+ return output;
3485
+ }
3486
+ function encodeUserinfo(input) {
3487
+ return encodeComponent(input, isUserinfoCharacter);
3488
+ }
3489
+ function encodeQuery(input) {
3490
+ return encodeComponent(input, isQueryFragmentCharacter);
3491
+ }
3492
+ function encodeFragment(input) {
3493
+ return encodeComponent(input, isQueryFragmentCharacter);
3494
+ }
3495
+ function isEscapeSafe(cp) {
3496
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
3497
+ }
3498
+ function normalizeQueryFragmentEncoding(input) {
3499
+ let output = "";
3500
+ for (let i = 0; i < input.length; i++) {
3501
+ const ch = input[i];
3502
+ if (ch === "%" && i + 2 < input.length) {
3503
+ const hex3 = input.slice(i + 1, i + 3);
3504
+ if (isHexPair(hex3)) {
3505
+ const normalizedHex = hex3.toUpperCase();
3506
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3507
+ if (isUnreserved(decoded)) {
3508
+ output += decoded;
3509
+ } else {
3510
+ output += "%" + normalizedHex;
3511
+ }
3512
+ i += 2;
3513
+ continue;
3514
+ }
3515
+ }
3516
+ if (isQueryFragmentCharacter(ch)) {
3517
+ output += ch;
3357
3518
  } else {
3358
- output += escape(input[i]);
3519
+ const code = input.charCodeAt(i);
3520
+ if (code < 128) {
3521
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3522
+ } else if (code < 55296 || code > 57343) {
3523
+ output += percentEncodeNonAscii(code);
3524
+ } else if (code <= 56319 && i + 1 < input.length) {
3525
+ const low = input.charCodeAt(i + 1);
3526
+ if (low >= 56320 && low <= 57343) {
3527
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3528
+ i++;
3529
+ } else {
3530
+ output += percentEncodeNonAscii(65533);
3531
+ }
3532
+ } else {
3533
+ output += percentEncodeNonAscii(65533);
3534
+ }
3359
3535
  }
3360
3536
  }
3361
3537
  return output;
@@ -3378,14 +3554,18 @@ var require_utils = __commonJS({
3378
3554
  function recomposeAuthority(component) {
3379
3555
  const uriTokens = [];
3380
3556
  if (component.userinfo !== void 0) {
3381
- uriTokens.push(component.userinfo);
3557
+ uriTokens.push(encodeUserinfo(component.userinfo));
3382
3558
  uriTokens.push("@");
3383
3559
  }
3384
3560
  if (component.host !== void 0) {
3385
- let host = unescape(component.host);
3561
+ let host = component.host;
3386
3562
  if (!isIPv4(host)) {
3387
- const ipV6res = normalizeIPv6(host);
3388
- if (ipV6res.isIPV6 === true) {
3563
+ let ipV6res = normalizeIPv6(host);
3564
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3565
+ host = normalizePercentEncoding(host, true);
3566
+ ipV6res = normalizeIPv6(host);
3567
+ }
3568
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3389
3569
  host = `[${ipV6res.escapedHost}]`;
3390
3570
  } else {
3391
3571
  host = reescapeHostDelimiters(host, false);
@@ -3394,8 +3574,12 @@ var require_utils = __commonJS({
3394
3574
  uriTokens.push(host);
3395
3575
  }
3396
3576
  if (typeof component.port === "number" || typeof component.port === "string") {
3577
+ const port = String(component.port);
3578
+ if (!isPort(port)) {
3579
+ throw new TypeError("URI port is malformed.");
3580
+ }
3397
3581
  uriTokens.push(":");
3398
- uriTokens.push(String(component.port));
3582
+ uriTokens.push(port);
3399
3583
  }
3400
3584
  return uriTokens.length ? uriTokens.join("") : void 0;
3401
3585
  }
@@ -3405,6 +3589,11 @@ var require_utils = __commonJS({
3405
3589
  reescapeHostDelimiters,
3406
3590
  normalizePercentEncoding,
3407
3591
  normalizePathEncoding,
3592
+ serializePathEncoding,
3593
+ normalizeQueryFragmentEncoding,
3594
+ encodeUserinfo,
3595
+ encodeQuery,
3596
+ encodeFragment,
3408
3597
  escapePreservingEscapes,
3409
3598
  removeDotSegments,
3410
3599
  isIPv4,
@@ -3420,7 +3609,7 @@ var require_schemes = __commonJS({
3420
3609
  "../../node_modules/fast-uri/lib/schemes.js"(exports, module) {
3421
3610
  "use strict";
3422
3611
  var { isUUID } = require_utils();
3423
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3612
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3424
3613
  var supportedSchemeNames = (
3425
3614
  /** @type {const} */
3426
3615
  [
@@ -3481,9 +3670,10 @@ var require_schemes = __commonJS({
3481
3670
  wsComponent.secure = void 0;
3482
3671
  }
3483
3672
  if (wsComponent.resourceName) {
3484
- const [path, query] = wsComponent.resourceName.split("?");
3673
+ const queryIndex = wsComponent.resourceName.indexOf("?");
3674
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3485
3675
  wsComponent.path = path && path !== "/" ? path : void 0;
3486
- wsComponent.query = query;
3676
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3487
3677
  wsComponent.resourceName = void 0;
3488
3678
  }
3489
3679
  wsComponent.fragment = void 0;
@@ -3495,7 +3685,7 @@ var require_schemes = __commonJS({
3495
3685
  return urnComponent;
3496
3686
  }
3497
3687
  const matches = urnComponent.path.match(URN_REG);
3498
- if (matches) {
3688
+ if (matches && matches[0] === urnComponent.path) {
3499
3689
  const scheme = options.scheme || urnComponent.scheme || "urn";
3500
3690
  urnComponent.nid = matches[1].toLowerCase();
3501
3691
  urnComponent.nss = matches[2];
@@ -3629,8 +3819,17 @@ var require_schemes = __commonJS({
3629
3819
  var require_fast_uri = __commonJS({
3630
3820
  "../../node_modules/fast-uri/index.js"(exports, module) {
3631
3821
  "use strict";
3632
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3822
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3633
3823
  var { SCHEMES, getSchemeHandler } = require_schemes();
3824
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3825
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3826
+ function decodeValidScheme(scheme) {
3827
+ const decodedScheme = unescape(String(scheme));
3828
+ if (!VALID_SCHEME.test(decodedScheme)) {
3829
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
3830
+ }
3831
+ return decodedScheme;
3832
+ }
3634
3833
  function normalize(uri, options) {
3635
3834
  if (typeof uri === "string") {
3636
3835
  uri = /** @type {T} */
@@ -3643,12 +3842,34 @@ var require_fast_uri = __commonJS({
3643
3842
  }
3644
3843
  function resolve(baseURI, relativeURI, options) {
3645
3844
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3646
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3647
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3648
- if (baseMalformed || relativeMalformed) {
3845
+ const {
3846
+ parsed: baseParsed,
3847
+ malformedAuthorityOrPort: baseMalformed,
3848
+ malformedPercentEncoding: baseMalformedPercentEncoding,
3849
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
3850
+ malformedHost: baseMalformedHost,
3851
+ malformedScheme: baseMalformedScheme
3852
+ } = parseWithStatus(baseURI, schemelessOptions);
3853
+ const {
3854
+ parsed: relativeParsed,
3855
+ malformedAuthorityOrPort: relativeMalformed,
3856
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
3857
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
3858
+ malformedHost: relativeMalformedHost,
3859
+ malformedScheme: relativeMalformedScheme
3860
+ } = parseWithStatus(relativeURI, schemelessOptions);
3861
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3649
3862
  throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3650
3863
  }
3651
3864
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3865
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3866
+ const resolvedHost = resolved.host;
3867
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3868
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3869
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
3870
+ if (resolved.error && !encodedASCIIHost) {
3871
+ throw new Error(resolved.error);
3872
+ }
3652
3873
  schemelessOptions.skipEscape = true;
3653
3874
  return serialize(resolved, schemelessOptions);
3654
3875
  }
@@ -3708,7 +3929,7 @@ var require_fast_uri = __commonJS({
3708
3929
  function equal(uriA, uriB, options) {
3709
3930
  const normalizedA = normalizeComparableURI(uriA, options);
3710
3931
  const normalizedB = normalizeComparableURI(uriB, options);
3711
- return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3932
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3712
3933
  }
3713
3934
  function serialize(cmpts, opts) {
3714
3935
  const component = {
@@ -3729,19 +3950,22 @@ var require_fast_uri = __commonJS({
3729
3950
  };
3730
3951
  const options = Object.assign({}, opts);
3731
3952
  const uriTokens = [];
3953
+ if (component.scheme) {
3954
+ component.scheme = decodeValidScheme(component.scheme);
3955
+ }
3732
3956
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3733
3957
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3958
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3959
+ const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
3734
3960
  if (component.path !== void 0) {
3735
3961
  if (!options.skipEscape) {
3736
- component.path = escapePreservingEscapes(component.path);
3737
- if (component.scheme !== void 0) {
3738
- component.path = component.path.split("%3A").join(":");
3739
- }
3962
+ component.path = serializePathEncoding(component.path, pathNoScheme);
3740
3963
  } else {
3741
3964
  component.path = normalizePercentEncoding(component.path);
3742
3965
  }
3743
3966
  }
3744
3967
  if (options.reference !== "suffix" && component.scheme) {
3968
+ component.scheme = decodeValidScheme(component.scheme);
3745
3969
  uriTokens.push(component.scheme, ":");
3746
3970
  }
3747
3971
  const authority = recomposeAuthority(component);
@@ -3759,16 +3983,19 @@ var require_fast_uri = __commonJS({
3759
3983
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3760
3984
  s = removeDotSegments(s);
3761
3985
  }
3986
+ if (pathNoScheme) {
3987
+ s = serializePathEncoding(s, true);
3988
+ }
3762
3989
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3763
3990
  s = "/%2F" + s.slice(2);
3764
3991
  }
3765
3992
  uriTokens.push(s);
3766
3993
  }
3767
3994
  if (component.query !== void 0) {
3768
- uriTokens.push("?", component.query);
3995
+ uriTokens.push("?", encodeQuery(component.query));
3769
3996
  }
3770
3997
  if (component.fragment !== void 0) {
3771
- uriTokens.push("#", component.fragment);
3998
+ uriTokens.push("#", encodeFragment(component.fragment));
3772
3999
  }
3773
4000
  return uriTokens.join("");
3774
4001
  }
@@ -3784,6 +4011,35 @@ var require_fast_uri = __commonJS({
3784
4011
  }
3785
4012
  return void 0;
3786
4013
  }
4014
+ function hasMalformedPercentEncoding(component) {
4015
+ if (component === void 0) return false;
4016
+ let percent = component.indexOf("%");
4017
+ while (percent !== -1) {
4018
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4019
+ return true;
4020
+ }
4021
+ percent = component.indexOf("%", percent + 3);
4022
+ }
4023
+ return false;
4024
+ }
4025
+ function isIPLiteral(host) {
4026
+ return host[0] === "[" && host[host.length - 1] === "]";
4027
+ }
4028
+ function hasMalformedComponentPercentEncoding(matches) {
4029
+ const host = matches[4];
4030
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4031
+ }
4032
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4033
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4034
+ try {
4035
+ parsed.host = new URL("http://" + parsed.host).hostname;
4036
+ } catch (e) {
4037
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4038
+ return true;
4039
+ }
4040
+ }
4041
+ return false;
4042
+ }
3787
4043
  function parseWithStatus(uri, opts) {
3788
4044
  const options = Object.assign({}, opts);
3789
4045
  const parsed = {
@@ -3796,6 +4052,11 @@ var require_fast_uri = __commonJS({
3796
4052
  fragment: void 0
3797
4053
  };
3798
4054
  let malformedAuthorityOrPort = false;
4055
+ let malformedPercentEncoding = false;
4056
+ let malformedSchemeSpecific = false;
4057
+ let malformedHost = false;
4058
+ let malformedIPLiteral = false;
4059
+ let malformedScheme = false;
3799
4060
  let isIP = false;
3800
4061
  if (options.reference === "suffix") {
3801
4062
  if (options.scheme) {
@@ -3832,6 +4093,19 @@ var require_fast_uri = __commonJS({
3832
4093
  parsed.path = matches[6] || "";
3833
4094
  parsed.query = matches[7];
3834
4095
  parsed.fragment = matches[8];
4096
+ if (parsed.scheme !== void 0) {
4097
+ const decodedScheme = unescape(parsed.scheme);
4098
+ if (VALID_SCHEME.test(decodedScheme)) {
4099
+ parsed.scheme = decodedScheme.toLowerCase();
4100
+ } else {
4101
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4102
+ malformedScheme = true;
4103
+ }
4104
+ }
4105
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4106
+ if (malformedPercentEncoding) {
4107
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4108
+ }
3835
4109
  if (isNaN(parsed.port)) {
3836
4110
  parsed.port = matches[5];
3837
4111
  }
@@ -3843,9 +4117,16 @@ var require_fast_uri = __commonJS({
3843
4117
  if (parsed.host) {
3844
4118
  const ipv4result = isIPv4(parsed.host);
3845
4119
  if (ipv4result === false) {
4120
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4121
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3846
4122
  const ipv6result = normalizeIPv6(parsed.host);
3847
- parsed.host = ipv6result.host.toLowerCase();
3848
- isIP = ipv6result.isIPV6;
4123
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4124
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4125
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4126
+ if (malformedIPLiteral) {
4127
+ parsed.error = parsed.error || "URI host is malformed.";
4128
+ malformedAuthorityOrPort = true;
4129
+ }
3849
4130
  } else {
3850
4131
  isIP = true;
3851
4132
  }
@@ -3863,42 +4144,36 @@ var require_fast_uri = __commonJS({
3863
4144
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3864
4145
  }
3865
4146
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3866
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3867
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3868
- try {
3869
- parsed.host = new URL("http://" + parsed.host).hostname;
3870
- } catch (e) {
3871
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3872
- }
3873
- }
4147
+ if (!malformedIPLiteral) {
4148
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3874
4149
  }
3875
4150
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3876
4151
  if (uri.indexOf("%") !== -1) {
3877
- if (parsed.scheme !== void 0) {
3878
- parsed.scheme = unescape(parsed.scheme);
3879
- }
3880
- if (parsed.host !== void 0) {
3881
- parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
4152
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
4153
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4154
+ parsed.host = reescapeHostDelimiters(host, isIP);
3882
4155
  }
3883
4156
  }
3884
4157
  if (parsed.path) {
3885
4158
  parsed.path = normalizePathEncoding(parsed.path);
3886
4159
  }
4160
+ if (parsed.query) {
4161
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
4162
+ }
3887
4163
  if (parsed.fragment) {
3888
- try {
3889
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3890
- } catch {
3891
- parsed.error = parsed.error || "URI malformed";
3892
- }
4164
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3893
4165
  }
3894
4166
  }
3895
4167
  if (schemeHandler && schemeHandler.parse) {
3896
4168
  schemeHandler.parse(parsed, options);
4169
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4170
+ malformedSchemeSpecific = true;
4171
+ }
3897
4172
  }
3898
4173
  } else {
3899
4174
  parsed.error = parsed.error || "URI can not be parsed.";
3900
4175
  }
3901
- return { parsed, malformedAuthorityOrPort };
4176
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3902
4177
  }
3903
4178
  function parse3(uri, opts) {
3904
4179
  return parseWithStatus(uri, opts).parsed;
@@ -3907,20 +4182,28 @@ var require_fast_uri = __commonJS({
3907
4182
  return normalizeStringWithStatus(uri, opts).normalized;
3908
4183
  }
3909
4184
  function normalizeStringWithStatus(uri, opts) {
3910
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4185
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3911
4186
  return {
3912
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3913
- malformedAuthorityOrPort
4187
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4188
+ malformedAuthorityOrPort,
4189
+ malformedPercentEncoding,
4190
+ malformedSchemeSpecific,
4191
+ malformedHost,
4192
+ malformedScheme
3914
4193
  };
3915
4194
  }
3916
4195
  function normalizeComparableURI(uri, opts) {
3917
- if (typeof uri === "string") {
3918
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3919
- return malformedAuthorityOrPort ? void 0 : normalized;
4196
+ if (typeof uri !== "string" && typeof uri !== "object") {
4197
+ return void 0;
3920
4198
  }
3921
- if (typeof uri === "object") {
3922
- return serialize(uri, opts);
4199
+ let value;
4200
+ try {
4201
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
4202
+ } catch {
4203
+ return void 0;
3923
4204
  }
4205
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4206
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3924
4207
  }
3925
4208
  var fastUri = {
3926
4209
  SCHEMES,
@@ -23042,7 +23325,7 @@ function activeExecutor() {
23042
23325
  return runExecutor.getStore() ?? defaultExecutor;
23043
23326
  }
23044
23327
  var TIMEOUT_MS = 3e4;
23045
- var MIN_GOG_VERSION = "0.38.1";
23328
+ var MIN_GOG_VERSION = "0.39.0";
23046
23329
  function readonlyEnvEnabled() {
23047
23330
  return readEnvVar("GOG_READONLY") !== void 0 && parseBoolEnv("GOG_READONLY", { default: true });
23048
23331
  }
@@ -24321,6 +24604,30 @@ function registerChatTools(server) {
24321
24604
  pushPaginationFlags(args, { max, pageToken, page, all });
24322
24605
  return runOrDiagnose(args, { account });
24323
24606
  });
24607
+ server.registerTool("gog_chat_messages_search", {
24608
+ description: 'Search Chat messages ACROSS every space and DM the account can see (gog >= 0.39.0) \u2014 the tool to reach for when the user asks "where did we discuss X" without naming a room, since gog_chat_messages_list needs a space up front. The query is Google Chat filter syntax, so it takes plain keywords or filters like sender, space, date, mention, unread, link and attachment. It is a search, NOT an export: Chat excludes some conversations (muted spaces among them), so an empty result does not prove a message never existed. view="full" adds each hit\'s read state and space mute setting; read state works on an ordinary chat grant, but the mute setting needs chat.users.spacesettings, which gog\'s chat scope set does NOT request (re-auth with extraScopes to get it). Missing metadata is OMITTED rather than defaulted, so an absent `read` means unknown while an explicit false means unread.' + workspaceOnlyNote,
24609
+ annotations: { readOnlyHint: true },
24610
+ inputSchema: {
24611
+ query: external_exports.string().describe('Google Chat filter-syntax query \u2014 keywords, or filters such as "from:alice@example.com budget"'),
24612
+ order: external_exports.enum(["create_time desc", "relevance desc"]).optional().describe(
24613
+ `Sort order. NOTE the snake_case, which differs from gog_chat_messages_list's camelCase. "relevance desc" needs Google Developer Preview access and errors without it`
24614
+ ),
24615
+ view: external_exports.enum(["basic", "full"]).optional().describe(
24616
+ 'Result view (default "basic"). "full" also requests read state (covered by an ordinary chat grant) and space mute setting (needs chat.users.spacesettings, which that grant does not include)'
24617
+ ),
24618
+ markup: external_exports.enum(["chat", "markdown"]).optional().describe("Syntax to render each hit's formatted text in"),
24619
+ ...paginationParams,
24620
+ max: external_exports.number().int().min(1).max(100).optional().describe("Max results per page (1-100; Chat search caps a page at 100)"),
24621
+ account: accountParam
24622
+ }
24623
+ }, async ({ query, order, view, markup, max, pageToken, page, all, account }) => {
24624
+ const args = ["chat", "messages", "search", query];
24625
+ if (order) args.push(`--order=${order}`);
24626
+ if (view) args.push(`--view=${view}`);
24627
+ if (markup) args.push(`--markup=${markup}`);
24628
+ pushPaginationFlags(args, { max, pageToken, page, all });
24629
+ return runOrDiagnose(args, { account });
24630
+ });
24324
24631
  server.registerTool("gog_chat_messages_send", {
24325
24632
  description: "Post a message to a Chat space. THIS IS IMMEDIATELY VISIBLE TO EVERYONE IN THE SPACE and cannot be unsent through this tool, so treat it like sending mail, not like saving a draft. Pass `thread` to reply inside an existing conversation (from gog_chat_threads_list or a message's thread field); omit it to start a new one. Text supports Chat's markdown-ish formatting (*bold*, _italic_, `code`)." + workspaceOnlyNote,
24326
24633
  inputSchema: {
@@ -25733,7 +26040,7 @@ function registerTasksTools(server) {
25733
26040
  }
25734
26041
 
25735
26042
  // src/server.ts
25736
- var VERSION = true ? "2.27.0" : "0.0.0";
26043
+ var VERSION = true ? "2.28.0" : "0.0.0";
25737
26044
  var BASE_TOOL_REGISTRARS = [
25738
26045
  registerApiTools,
25739
26046
  registerAppScriptTools,