gogcli-mcp-docs 4.2.4 → 4.3.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/index.js CHANGED
@@ -2092,8 +2092,8 @@ function emoji() {
2092
2092
  }
2093
2093
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
2094
2094
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
2095
- var mac = (delimiter2) => {
2096
- const escapedDelim = escapeRegex(delimiter2 ?? ":");
2095
+ var mac = (delimiter3) => {
2096
+ const escapedDelim = escapeRegex(delimiter3 ?? ":");
2097
2097
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
2098
2098
  };
2099
2099
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -5121,7 +5121,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
5121
5121
  var NONE = 0;
5122
5122
  var ASSUMED = 1;
5123
5123
  var PROVEN = 2;
5124
- function isRecursive(inst, stack, resolve) {
5124
+ function isRecursive(inst, stack, resolve4) {
5125
5125
  const cached2 = recursive.get(inst);
5126
5126
  if (cached2 !== void 0)
5127
5127
  return cached2 ? PROVEN : NONE;
@@ -5131,7 +5131,7 @@ function isRecursive(inst, stack, resolve) {
5131
5131
  let result = NONE;
5132
5132
  const check2 = (child) => {
5133
5133
  if (result !== PROVEN && child?._zod) {
5134
- const answer = isRecursive(child, stack, resolve);
5134
+ const answer = isRecursive(child, stack, resolve4);
5135
5135
  if (answer > result)
5136
5136
  result = answer;
5137
5137
  }
@@ -5142,7 +5142,7 @@ function isRecursive(inst, stack, resolve) {
5142
5142
  const desc = Object.getOwnPropertyDescriptor(sh, key);
5143
5143
  if (spread && !desc.enumerable)
5144
5144
  continue;
5145
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
5145
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve4) : NONE;
5146
5146
  if (child > answer)
5147
5147
  answer = child;
5148
5148
  }
@@ -5206,7 +5206,7 @@ function isRecursive(inst, stack, resolve) {
5206
5206
  break;
5207
5207
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
5208
5208
  case "lazy": {
5209
- const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
5209
+ const inner = def._cachedInner ?? (resolve4 ? inst._zod.innerType : void 0);
5210
5210
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
5211
5211
  break;
5212
5212
  }
@@ -24106,14 +24106,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
24106
24106
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
24107
24107
  }
24108
24108
  function sleep(ms, signal) {
24109
- return new Promise((resolve, reject) => {
24109
+ return new Promise((resolve4, reject) => {
24110
24110
  if (signal?.aborted) {
24111
24111
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
24112
24112
  return;
24113
24113
  }
24114
24114
  const timer = setTimeout(() => {
24115
24115
  signal?.removeEventListener("abort", onAbort);
24116
- resolve();
24116
+ resolve4();
24117
24117
  }, ms);
24118
24118
  const onAbort = () => {
24119
24119
  clearTimeout(timer);
@@ -24907,7 +24907,7 @@ var Protocol = class {
24907
24907
  const flowStartedAt = Date.now();
24908
24908
  let onAbort;
24909
24909
  let cleanupMessageId;
24910
- return new Promise((resolve, reject) => {
24910
+ return new Promise((resolve4, reject) => {
24911
24911
  const earlyReject = (error62) => {
24912
24912
  reject(error62);
24913
24913
  };
@@ -24975,7 +24975,7 @@ var Protocol = class {
24975
24975
  }
24976
24976
  if (decoded.kind === "invalid") return reject(decoded.error);
24977
24977
  if (decoded.kind === "input_required") {
24978
- if (options?.allowInputRequired === true) return resolve(manualInputRequiredValue(decoded));
24978
+ if (options?.allowInputRequired === true) return resolve4(manualInputRequiredValue(decoded));
24979
24979
  const flow = {
24980
24980
  codec: codec2,
24981
24981
  request,
@@ -24987,11 +24987,11 @@ var Protocol = class {
24987
24987
  params
24988
24988
  }, resultSchema, legOptions)
24989
24989
  };
24990
- return resolve(this._resolveNonCompleteResult(decoded, flow));
24990
+ return resolve4(this._resolveNonCompleteResult(decoded, flow));
24991
24991
  }
24992
24992
  const result = decoded.result;
24993
24993
  validateStandardSchema(resultSchema, result).then((parseResult) => {
24994
- if (parseResult.success) resolve(parseResult.data);
24994
+ if (parseResult.success) resolve4(parseResult.data);
24995
24995
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
24996
24996
  }, reject);
24997
24997
  });
@@ -27903,7 +27903,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
27903
27903
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
27904
27904
  const schOrFunc = root.refs[ref];
27905
27905
  if (schOrFunc) return schOrFunc;
27906
- let _sch = resolve.call(this, root, ref);
27906
+ let _sch = resolve4.call(this, root, ref);
27907
27907
  if (_sch === void 0) {
27908
27908
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
27909
27909
  const { schemaId } = this.opts;
@@ -27929,7 +27929,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
27929
27929
  function sameSchemaEnv(s1, s2) {
27930
27930
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
27931
27931
  }
27932
- function resolve(root, ref) {
27932
+ function resolve4(root, ref) {
27933
27933
  let sch;
27934
27934
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
27935
27935
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -28379,47 +28379,47 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28379
28379
  else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
28380
28380
  return uri;
28381
28381
  }
28382
- function resolve(baseURI, relativeURI, options) {
28382
+ function resolve4(baseURI, relativeURI, options) {
28383
28383
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
28384
28384
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
28385
28385
  schemelessOptions.skipEscape = true;
28386
28386
  return serialize(resolved, schemelessOptions);
28387
28387
  }
28388
- function resolveComponent(base, relative, options, skipNormalization) {
28388
+ function resolveComponent(base, relative3, options, skipNormalization) {
28389
28389
  const target = {};
28390
28390
  if (!skipNormalization) {
28391
28391
  base = parse3(serialize(base, options), options);
28392
- relative = parse3(serialize(relative, options), options);
28392
+ relative3 = parse3(serialize(relative3, options), options);
28393
28393
  }
28394
28394
  options = options || {};
28395
- if (!options.tolerant && relative.scheme) {
28396
- target.scheme = relative.scheme;
28397
- target.userinfo = relative.userinfo;
28398
- target.host = relative.host;
28399
- target.port = relative.port;
28400
- target.path = removeDotSegments(relative.path || "");
28401
- target.query = relative.query;
28395
+ if (!options.tolerant && relative3.scheme) {
28396
+ target.scheme = relative3.scheme;
28397
+ target.userinfo = relative3.userinfo;
28398
+ target.host = relative3.host;
28399
+ target.port = relative3.port;
28400
+ target.path = removeDotSegments(relative3.path || "");
28401
+ target.query = relative3.query;
28402
28402
  } else {
28403
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
28404
- target.userinfo = relative.userinfo;
28405
- target.host = relative.host;
28406
- target.port = relative.port;
28407
- target.path = removeDotSegments(relative.path || "");
28408
- target.query = relative.query;
28403
+ if (relative3.userinfo !== void 0 || relative3.host !== void 0 || relative3.port !== void 0) {
28404
+ target.userinfo = relative3.userinfo;
28405
+ target.host = relative3.host;
28406
+ target.port = relative3.port;
28407
+ target.path = removeDotSegments(relative3.path || "");
28408
+ target.query = relative3.query;
28409
28409
  } else {
28410
- if (!relative.path) {
28410
+ if (!relative3.path) {
28411
28411
  target.path = base.path;
28412
- if (relative.query !== void 0) target.query = relative.query;
28412
+ if (relative3.query !== void 0) target.query = relative3.query;
28413
28413
  else target.query = base.query;
28414
28414
  } else {
28415
- if (relative.path[0] === "/") target.path = removeDotSegments(relative.path);
28415
+ if (relative3.path[0] === "/") target.path = removeDotSegments(relative3.path);
28416
28416
  else {
28417
- if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative.path;
28418
- else if (!base.path) target.path = relative.path;
28419
- else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
28417
+ if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative3.path;
28418
+ else if (!base.path) target.path = relative3.path;
28419
+ else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative3.path;
28420
28420
  target.path = removeDotSegments(target.path);
28421
28421
  }
28422
- target.query = relative.query;
28422
+ target.query = relative3.query;
28423
28423
  }
28424
28424
  target.userinfo = base.userinfo;
28425
28425
  target.host = base.host;
@@ -28427,7 +28427,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28427
28427
  }
28428
28428
  target.scheme = base.scheme;
28429
28429
  }
28430
- target.fragment = relative.fragment;
28430
+ target.fragment = relative3.fragment;
28431
28431
  return target;
28432
28432
  }
28433
28433
  function equal(uriA, uriB, options) {
@@ -28553,7 +28553,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28553
28553
  const fastUri = {
28554
28554
  SCHEMES,
28555
28555
  normalize,
28556
- resolve,
28556
+ resolve: resolve4,
28557
28557
  resolveComponent,
28558
28558
  equal,
28559
28559
  serialize,
@@ -29335,14 +29335,14 @@ var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
29335
29335
  function ucs2length(str) {
29336
29336
  const len = str.length;
29337
29337
  let length = 0;
29338
- let pos = 0;
29338
+ let pos2 = 0;
29339
29339
  let value;
29340
- while (pos < len) {
29340
+ while (pos2 < len) {
29341
29341
  length++;
29342
- value = str.charCodeAt(pos++);
29343
- if (value >= 55296 && value <= 56319 && pos < len) {
29344
- value = str.charCodeAt(pos);
29345
- if ((value & 64512) === 56320) pos++;
29342
+ value = str.charCodeAt(pos2++);
29343
+ if (value >= 55296 && value <= 56319 && pos2 < len) {
29344
+ value = str.charCodeAt(pos2);
29345
+ if ((value & 64512) === 56320) pos2++;
29346
29346
  }
29347
29347
  }
29348
29348
  return length;
@@ -33926,7 +33926,7 @@ var StdioServerTransport = class {
33926
33926
  }
33927
33927
  send(message) {
33928
33928
  if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
33929
- return new Promise((resolve, reject) => {
33929
+ return new Promise((resolve4, reject) => {
33930
33930
  const json2 = serializeMessage(message);
33931
33931
  let settled = false;
33932
33932
  const onError = (error62) => {
@@ -33941,14 +33941,14 @@ var StdioServerTransport = class {
33941
33941
  settled = true;
33942
33942
  this._stdout.off("error", onError);
33943
33943
  this._stdout.off("drain", onDrain);
33944
- resolve();
33944
+ resolve4();
33945
33945
  };
33946
33946
  this._stdout.once("error", onError);
33947
33947
  if (this._stdout.write(json2)) {
33948
33948
  if (settled) return;
33949
33949
  settled = true;
33950
33950
  this._stdout.off("error", onError);
33951
- resolve();
33951
+ resolve4();
33952
33952
  } else if (!settled) this._stdout.once("drain", onDrain);
33953
33953
  });
33954
33954
  }
@@ -34002,14 +34002,14 @@ var StdioConnectionChannel = class {
34002
34002
  */
34003
34003
  async whenRequestsAnswered(timeoutMs) {
34004
34004
  if (this._closed || this._pendingRequests.size === 0) return true;
34005
- return await new Promise((resolve) => {
34005
+ return await new Promise((resolve4) => {
34006
34006
  const waiter = () => {
34007
34007
  clearTimeout(timer);
34008
- resolve(true);
34008
+ resolve4(true);
34009
34009
  };
34010
34010
  const timer = setTimeout(() => {
34011
34011
  this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
34012
- resolve(false);
34012
+ resolve4(false);
34013
34013
  }, timeoutMs);
34014
34014
  this._drainWaiters.push(waiter);
34015
34015
  });
@@ -34379,13 +34379,28 @@ var API_KEY_RE = new RegExp([
34379
34379
  "whsec_[A-Za-z0-9]{16,}\\b"
34380
34380
  // webhook signing secret (Stripe-style)
34381
34381
  ].map((p) => `\\b${p}`).join("|"), "g");
34382
- var QUERY_SECRET_RE = /([?&](?:access_token|refresh_token|client_secret|api_?key|signature|token|key|sig)=)[^&#\s"'<>`]+/gi;
34382
+ var QUERY_SECRET_RE = /([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig)=)[^&#\s"'<>`]+/gi;
34383
+ var OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
34384
+ var FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
34385
+ var HEADER_SECRET_RE = /(\b(?:x[-_][a-z0-9_-]*?(?:api[-_]?key|token|secret|auth)[a-z0-9_-]*|api[-_]?key)\s*:\s*)[^\s,;"'<>`]+/gi;
34383
34386
  var AWS_SIGV4_RE = /([?&]X-Amz-(?:Signature|Security-Token|Credential)=)[^&#\s"'<>`]+/gi;
34384
- var JSON_SECRET_KEYS = "access_token|refresh_token|client_secret|api_?key|password|passwd|secret|token";
34385
- var JSON_SECRET_DQ_RE = new RegExp(`("(?:${JSON_SECRET_KEYS})"\\s*:\\s*")[^"]*(")`, "gi");
34386
- var JSON_SECRET_SQ_RE = new RegExp(`('(?:${JSON_SECRET_KEYS})'\\s*:\\s*')[^']*(')`, "gi");
34387
+ var JSON_SECRET_KEYS = [
34388
+ "(?:access|refresh|id|auth|session|bearer|csrf|xsrf)[_-]?token",
34389
+ "client[_-]?secret",
34390
+ "api[_-]?secret",
34391
+ "(?:x[_-])?api[_-]?key",
34392
+ "private[_-]?key",
34393
+ "x[_-][a-z0-9_-]*?(?:api[_-]?key|token|secret|auth)[a-z0-9_-]*",
34394
+ "(?:proxy-)?authorization",
34395
+ "password",
34396
+ "passwd",
34397
+ "secret",
34398
+ "token"
34399
+ ].join("|");
34400
+ var JSON_SECRET_DQ_RE = new RegExp(`("(?:${JSON_SECRET_KEYS})"\\s*:\\s*")(?:[^"\\\\]|\\\\.)*(")`, "gi");
34401
+ var JSON_SECRET_SQ_RE = new RegExp(`('(?:${JSON_SECRET_KEYS})'\\s*:\\s*')(?:[^'\\\\]|\\\\.)*(')`, "gi");
34387
34402
  function redactSecrets(text) {
34388
- return text.replace(BEARER_RE, "$1[REDACTED]").replace(BASIC_AUTH_RE, "$1[REDACTED]").replace(SET_COOKIE_RE, "$1$2=[REDACTED]").replace(COOKIE_HEADER_RE, (_m, prefix, pairs) => `${prefix}${pairs.replace(/=[^;,\s]*/g, "=[REDACTED]")}`).replace(API_KEY_RE, "[REDACTED]").replace(QUERY_SECRET_RE, "$1[REDACTED]").replace(AWS_SIGV4_RE, "$1[REDACTED]").replace(JSON_SECRET_DQ_RE, "$1[REDACTED]$2").replace(JSON_SECRET_SQ_RE, "$1[REDACTED]$2").replace(JWT_RE, "[REDACTED]");
34403
+ return text.replace(BEARER_RE, "$1[REDACTED]").replace(BASIC_AUTH_RE, "$1[REDACTED]").replace(SET_COOKIE_RE, "$1$2=[REDACTED]").replace(COOKIE_HEADER_RE, (_m, prefix, pairs) => `${prefix}${pairs.replace(/=[^;,\s]*/g, "=[REDACTED]")}`).replace(API_KEY_RE, "[REDACTED]").replace(HEADER_SECRET_RE, "$1[REDACTED]").replace(QUERY_SECRET_RE, "$1[REDACTED]").replace(OAUTH_CODE_RE, "$1[REDACTED]").replace(FORM_PASSWORD_RE, "$1[REDACTED]").replace(AWS_SIGV4_RE, "$1[REDACTED]").replace(JSON_SECRET_DQ_RE, "$1[REDACTED]$2").replace(JSON_SECRET_SQ_RE, "$1[REDACTED]$2").replace(JWT_RE, "[REDACTED]");
34389
34404
  }
34390
34405
 
34391
34406
  // ../../node_modules/@chrischall/mcp-utils/dist/response/view.js
@@ -34547,13 +34562,47 @@ async function createMcpServer(opts) {
34547
34562
  }
34548
34563
  return server;
34549
34564
  }
34565
+ var DEFAULT_SHUTDOWN_TIMEOUT_MS = 5e3;
34566
+ var DEFAULT_REPEAT_SIGNAL_GRACE_MS = 500;
34550
34567
  function withGracefulShutdown(target, opts = {}) {
34551
34568
  const shouldExit = opts.exit ?? true;
34569
+ if (opts.timeoutMs !== void 0 && !(Number.isFinite(opts.timeoutMs) && opts.timeoutMs > 0)) {
34570
+ throw new RangeError("withGracefulShutdown: timeoutMs must be a finite number greater than 0.");
34571
+ }
34572
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS;
34573
+ if (opts.repeatSignalGraceMs !== void 0 && !(Number.isFinite(opts.repeatSignalGraceMs) && opts.repeatSignalGraceMs >= 0)) {
34574
+ throw new RangeError("withGracefulShutdown: repeatSignalGraceMs must be a finite number >= 0.");
34575
+ }
34576
+ const repeatGraceMs = opts.repeatSignalGraceMs ?? DEFAULT_REPEAT_SIGNAL_GRACE_MS;
34552
34577
  let shuttingDown = false;
34578
+ let firstSignalAt = 0;
34579
+ let exited = false;
34580
+ const exitOnce = () => {
34581
+ if (exited)
34582
+ return;
34583
+ exited = true;
34584
+ process.exit(0);
34585
+ };
34553
34586
  const handler = (signal) => {
34554
- if (shuttingDown)
34587
+ if (shuttingDown) {
34588
+ if (Date.now() - firstSignalAt < repeatGraceMs)
34589
+ return;
34590
+ if (shouldExit) {
34591
+ console.error(`[mcp-utils] second ${signal} during shutdown \u2014 exiting now`);
34592
+ exitOnce();
34593
+ }
34555
34594
  return;
34595
+ }
34556
34596
  shuttingDown = true;
34597
+ firstSignalAt = Date.now();
34598
+ let timer;
34599
+ if (shouldExit) {
34600
+ timer = setTimeout(() => {
34601
+ console.error(`[mcp-utils] graceful shutdown on ${signal} did not finish in ${timeoutMs}ms \u2014 exiting`);
34602
+ exitOnce();
34603
+ }, timeoutMs);
34604
+ timer.unref?.();
34605
+ }
34557
34606
  void (async () => {
34558
34607
  try {
34559
34608
  if (opts.onSignal)
@@ -34562,8 +34611,10 @@ function withGracefulShutdown(target, opts = {}) {
34562
34611
  } catch (err) {
34563
34612
  console.error(`[mcp-utils] error during graceful shutdown on ${signal}: ${err instanceof Error ? err.message : String(err)}`);
34564
34613
  } finally {
34614
+ if (timer !== void 0)
34615
+ clearTimeout(timer);
34565
34616
  if (shouldExit)
34566
- process.exit(0);
34617
+ exitOnce();
34567
34618
  }
34568
34619
  })();
34569
34620
  };
@@ -34593,6 +34644,8 @@ function runMcp(opts) {
34593
34644
  }
34594
34645
 
34595
34646
  // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34647
+ import { homedir } from "node:os";
34648
+ import { isAbsolute, join, resolve } from "node:path";
34596
34649
  var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34597
34650
  function readEnvVar(key, opts = {}) {
34598
34651
  const env = opts.env ?? process.env;
@@ -34619,6 +34672,50 @@ function parseBoolEnv(key, opts = {}) {
34619
34672
  return false;
34620
34673
  return fallback;
34621
34674
  }
34675
+ function expandPath(p) {
34676
+ let expanded = p;
34677
+ if (p === "~") {
34678
+ expanded = homedir();
34679
+ } else if (p.startsWith("~/")) {
34680
+ expanded = join(homedir(), p.slice(2));
34681
+ }
34682
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
34683
+ }
34684
+
34685
+ // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
34686
+ import { existsSync, realpathSync } from "node:fs";
34687
+ import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
34688
+ function isInside(root, target) {
34689
+ const rel = relative(root, target);
34690
+ return rel === "" || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute2(rel);
34691
+ }
34692
+ function realPathAllowingMissing(p) {
34693
+ const abs = resolve2(p);
34694
+ let existing = abs;
34695
+ const tail = [];
34696
+ while (!existsSync(existing)) {
34697
+ const parent = dirname(existing);
34698
+ if (parent === existing)
34699
+ break;
34700
+ tail.unshift(existing.slice(parent.length).replace(/^[/\\]+/, ""));
34701
+ existing = parent;
34702
+ }
34703
+ let real;
34704
+ try {
34705
+ real = realpathSync(existing);
34706
+ } catch {
34707
+ real = existing;
34708
+ }
34709
+ return tail.length > 0 ? resolve2(real, ...tail) : real;
34710
+ }
34711
+ function assertPathWithinRoots(path, roots) {
34712
+ const target = realPathAllowingMissing(expandPath(path));
34713
+ for (const root of roots) {
34714
+ if (isInside(realPathAllowingMissing(expandPath(root)), target))
34715
+ return target;
34716
+ }
34717
+ throw new Error(`Path is outside the allowed directories: ${path}`);
34718
+ }
34622
34719
 
34623
34720
  // ../../node_modules/@chrischall/mcp-utils/dist/zod/index.js
34624
34721
  var PositiveInt = external_exports.number().int().positive();
@@ -34640,7 +34737,7 @@ var pageSchema = {
34640
34737
  };
34641
34738
 
34642
34739
  // ../gogcli-mcp/src/runner.ts
34643
- import { delimiter, join } from "node:path";
34740
+ import { delimiter, join as join2 } from "node:path";
34644
34741
 
34645
34742
  // ../gogcli-mcp/src/timestamps.ts
34646
34743
  var DEFAULT_DISPLAY_TZ = "America/New_York";
@@ -34841,9 +34938,48 @@ function normalizeTimestamps(text, tz = displayTimeZone(), naiveTz = naiveSource
34841
34938
  return JSON.stringify(parsed, null, detectIndent(text));
34842
34939
  }
34843
34940
 
34941
+ // ../gogcli-mcp/src/arg-guard.ts
34942
+ var FORBIDDEN_LONG_FLAG = /^--(readonly|enable-commands|enable-commands-exact|disable-commands|access-token|home|account|acct|client|gmail-no-send|no-input|non-interactive|noninteractive)(=|$)/i;
34943
+ var SHORT_ACCOUNT_CLUSTER = /^-(?!-)[A-Za-z]*a/;
34944
+ function forbiddenArgReason(arg) {
34945
+ if (arg === "--") {
34946
+ return 'The argument "--" is not allowed: it ends flag parsing and would disable safety flags appended after it.';
34947
+ }
34948
+ const match = FORBIDDEN_LONG_FLAG.exec(arg);
34949
+ if (match) {
34950
+ return `The flag ${arg} is not allowed here: --${match[1].toLowerCase()} is a safety/credential control set by the server operator, not a per-call option.`;
34951
+ }
34952
+ if (SHORT_ACCOUNT_CLUSTER.test(arg)) {
34953
+ return `The flag ${arg} is not allowed here: -a selects the account. Use the tool's account parameter instead.`;
34954
+ }
34955
+ return void 0;
34956
+ }
34957
+ function assertSafeForwardedArgs(args) {
34958
+ for (const arg of args) {
34959
+ const reason = forbiddenArgReason(arg);
34960
+ if (reason) throw new Error(reason);
34961
+ }
34962
+ }
34963
+ var SUBCOMMAND_SHAPE = /^[a-z][a-z0-9-]*$/;
34964
+ function assertSafeSubcommand(subcommand) {
34965
+ if (!SUBCOMMAND_SHAPE.test(subcommand)) {
34966
+ throw new Error(
34967
+ `Invalid subcommand ${JSON.stringify(subcommand)}: pass a single gog subcommand name such as "list" or "mark-read", and put its arguments in args.`
34968
+ );
34969
+ }
34970
+ }
34971
+
34972
+ // ../gogcli-mcp/src/argv.ts
34973
+ function pos(value) {
34974
+ return { kind: "positional", value };
34975
+ }
34976
+ function isGogPositional(arg) {
34977
+ return typeof arg === "object" && arg !== null && arg.kind === "positional";
34978
+ }
34979
+
34844
34980
  // ../gogcli-mcp/src/runner.ts
34845
34981
  function isGogFileArg(arg) {
34846
- return typeof arg !== "string";
34982
+ return typeof arg !== "string" && arg.kind === "file";
34847
34983
  }
34848
34984
  var TIMEOUT_MS = 3e4;
34849
34985
  function readonlyEnvEnabled() {
@@ -34927,8 +35063,8 @@ function formatTimeout(ms) {
34927
35063
  }
34928
35064
  async function spawnWithTempFiles(args, opts) {
34929
35065
  const { mkdtemp, mkdir, writeFile, rm } = await import("node:fs/promises");
34930
- const { tmpdir } = await import("node:os");
34931
- const dir = await mkdtemp(join(tmpdir(), "gogcli-mcp-"));
35066
+ const { tmpdir: tmpdir2 } = await import("node:os");
35067
+ const dir = await mkdtemp(join2(tmpdir2(), "gogcli-mcp-"));
34932
35068
  try {
34933
35069
  const argv = [];
34934
35070
  let seq = 0;
@@ -34937,10 +35073,10 @@ async function spawnWithTempFiles(args, opts) {
34937
35073
  argv.push(arg);
34938
35074
  continue;
34939
35075
  }
34940
- const sub = join(dir, String(seq));
35076
+ const sub = join2(dir, String(seq));
34941
35077
  seq += 1;
34942
35078
  await mkdir(sub, { recursive: true, mode: 448 });
34943
- const path = join(sub, arg.filename ?? `${arg.flag}.${arg.ext ?? "txt"}`);
35079
+ const path = join2(sub, arg.filename ?? `${arg.flag}.${arg.ext ?? "txt"}`);
34944
35080
  const data = arg.encoding === "base64" ? Buffer.from(arg.contents, "base64") : Buffer.from(arg.contents, "utf8");
34945
35081
  await writeFile(path, data, { mode: 384 });
34946
35082
  argv.push(arg.positional ? path : `--${arg.flag}=${path}`);
@@ -34958,10 +35094,10 @@ function spawnExecutor(args, opts) {
34958
35094
  return spawnGog(args, opts);
34959
35095
  }
34960
35096
  async function spawnGog(fullArgs, opts) {
34961
- const { timeout, interactive = false, spawner, binary = false } = opts;
35097
+ const { timeout, interactive = false, spawner, binary = false, maxOutputBytes } = opts;
34962
35098
  const spawn = spawner ?? (await import("node:child_process")).spawn;
34963
35099
  const effectiveTimeout = timeout ?? TIMEOUT_MS;
34964
- return new Promise((resolve, reject) => {
35100
+ return new Promise((resolve4, reject) => {
34965
35101
  const childEnv = { ...sanitizedEnv(), GOG_TIMEZONE: naiveSourceTimeZone(), PATH: augmentedPath() };
34966
35102
  const child = spawn(readEnvVar("GOG_PATH") ?? "gog", fullArgs, { env: childEnv });
34967
35103
  const stdoutChunks = [];
@@ -34979,7 +35115,17 @@ async function spawnGog(fullArgs, opts) {
34979
35115
  child.kill();
34980
35116
  reject(new Error(`gog timed out after ${formatTimeout(effectiveTimeout)}`));
34981
35117
  }, effectiveTimeout);
35118
+ let stdoutBytes = 0;
34982
35119
  child.stdout.on("data", (chunk) => {
35120
+ if (settled) return;
35121
+ stdoutBytes += chunk.length;
35122
+ if (maxOutputBytes !== void 0 && stdoutBytes > maxOutputBytes) {
35123
+ settled = true;
35124
+ stopWatching();
35125
+ child.kill();
35126
+ reject(new Error(`gog output exceeded the limit: more than ${maxOutputBytes} bytes`));
35127
+ return;
35128
+ }
34983
35129
  stdoutChunks.push(chunk);
34984
35130
  });
34985
35131
  child.stderr.on("data", (chunk) => {
@@ -34996,14 +35142,14 @@ async function spawnGog(fullArgs, opts) {
34996
35142
  const stderr = Buffer.concat(stderrChunks).toString().trim();
34997
35143
  if (code === 0) {
34998
35144
  if (binary) {
34999
- resolve(Buffer.concat(stdoutChunks).toString("base64"));
35145
+ resolve4(Buffer.concat(stdoutChunks).toString("base64"));
35000
35146
  return;
35001
35147
  }
35002
35148
  const stdout = Buffer.concat(stdoutChunks).toString();
35003
35149
  if (interactive && stderr) {
35004
- resolve(stdout + "\n" + stderr);
35150
+ resolve4(stdout + "\n" + stderr);
35005
35151
  } else {
35006
- resolve(stdout);
35152
+ resolve4(stdout);
35007
35153
  }
35008
35154
  } else {
35009
35155
  reject(new Error(stderr || `gog exited with code ${code}`));
@@ -35023,7 +35169,33 @@ async function spawnGog(fullArgs, opts) {
35023
35169
  });
35024
35170
  });
35025
35171
  }
35172
+ function placePositionals(args) {
35173
+ const flags = [];
35174
+ const positionals = [];
35175
+ let afterSeparator = false;
35176
+ for (const arg of args) {
35177
+ if (arg === "--") {
35178
+ afterSeparator = true;
35179
+ } else if (isGogPositional(arg)) {
35180
+ positionals.push(arg.value);
35181
+ } else if (afterSeparator || isGogFileArg(arg) && arg.positional) {
35182
+ positionals.push(arg);
35183
+ } else {
35184
+ flags.push(arg);
35185
+ }
35186
+ }
35187
+ return { flags, positionals };
35188
+ }
35189
+ function assertNoSafetyOverrides(flags) {
35190
+ for (const arg of flags) {
35191
+ if (typeof arg !== "string") continue;
35192
+ const reason = forbiddenArgReason(arg);
35193
+ if (reason) throw new Error(reason);
35194
+ }
35195
+ }
35026
35196
  function assembleArgs(args, opts) {
35197
+ const { flags, positionals } = placePositionals(args);
35198
+ assertNoSafetyOverrides(flags);
35027
35199
  const effectiveAccount = opts.account ?? readEnvVar("GOG_ACCOUNT");
35028
35200
  const fullArgs = ["--json", "--color=never"];
35029
35201
  if (!opts.interactive) {
@@ -35032,17 +35204,21 @@ function assembleArgs(args, opts) {
35032
35204
  if (opts.readonly || readonlyEnvEnabled()) {
35033
35205
  fullArgs.push("--readonly");
35034
35206
  }
35207
+ if (opts.gmailNoSend) {
35208
+ fullArgs.push("--gmail-no-send");
35209
+ }
35035
35210
  if (effectiveAccount) {
35036
35211
  fullArgs.push("--account", effectiveAccount);
35037
35212
  }
35038
- fullArgs.push(...args);
35213
+ fullArgs.push(...flags);
35214
+ if (positionals.length > 0) fullArgs.push("--", ...positionals);
35039
35215
  return fullArgs;
35040
35216
  }
35041
35217
  async function run(args, options = {}) {
35042
- const { account, spawner, interactive = false, timeout, readonly: readonly2 = false, redactMode = "full", opaqueFields } = options;
35218
+ const { account, spawner, interactive = false, timeout, readonly: readonly2 = false, redactMode = "full", opaqueFields, gmailNoSend = false } = options;
35043
35219
  const base = redactMode === "tokens" ? redactGoogleTokens : redactSecrets2;
35044
35220
  const redact = opaqueFields?.length ? (text) => redactPreservingOpaqueFields(text, opaqueFields, base) : base;
35045
- const fullArgs = assembleArgs(args, { account, interactive, readonly: readonly2 });
35221
+ const fullArgs = assembleArgs(args, { account, interactive, readonly: readonly2, gmailNoSend });
35046
35222
  try {
35047
35223
  return redact(await spawnExecutor(fullArgs, { timeout, interactive, spawner }));
35048
35224
  } catch (err) {
@@ -35070,6 +35246,107 @@ function stripConsumedPageToken(text) {
35070
35246
  return JSON.stringify(obj, null, detectIndent2(text));
35071
35247
  }
35072
35248
 
35249
+ // ../gogcli-mcp/src/file-roots.ts
35250
+ import { homedir as homedir2 } from "node:os";
35251
+ import { delimiter as delimiter2, join as join4 } from "node:path";
35252
+
35253
+ // ../gogcli-mcp/src/attachment-root.ts
35254
+ import { tmpdir, userInfo } from "node:os";
35255
+ import { dirname as dirname2, join as join3, relative as relative2, resolve as resolve3, isAbsolute as isAbsolute3, sep as sep2 } from "node:path";
35256
+ var ATTACHMENT_DOWNLOAD_ROOT = join3(tmpdir(), `gogcli-mcp-attachments-${userInfo().uid}`);
35257
+ var ATTACHMENT_TTL_MS = 24 * 60 * 60 * 1e3;
35258
+
35259
+ // ../gogcli-mcp/src/file-roots.ts
35260
+ var FILE_ROOTS_ENV = "GOG_FILE_ROOTS";
35261
+ function defaultFileRoot() {
35262
+ return join4(homedir2(), "gogcli-mcp-files");
35263
+ }
35264
+ function fileRoots() {
35265
+ const raw = readEnvVar(FILE_ROOTS_ENV);
35266
+ const roots = (raw ?? "").split(delimiter2).map((r) => r.trim()).filter(Boolean);
35267
+ return roots.length > 0 ? roots : [defaultFileRoot()];
35268
+ }
35269
+ function confinePath(path, param, opts = {}) {
35270
+ if (opts.allowDash && path === "-") return path;
35271
+ const roots = [...fileRoots(), ATTACHMENT_DOWNLOAD_ROOT];
35272
+ try {
35273
+ assertPathWithinRoots(path, roots);
35274
+ } catch {
35275
+ throw new Error(
35276
+ `${param} ${JSON.stringify(path)} is outside the directories this server may read or write (${roots.join(", ")}). Put the file in one of them, or ask the server operator to widen ${FILE_ROOTS_ENV}.`
35277
+ );
35278
+ }
35279
+ return path;
35280
+ }
35281
+
35282
+ // ../gogcli-mcp/src/run-path-guard.ts
35283
+ var POSITIONAL_PATH_SUBCOMMANDS = {
35284
+ appscript: { pull: "gog_appscript_pull" },
35285
+ drive: { upload: "gog_drive_upload", sync: "gog_drive_sync_push" },
35286
+ gmail: { import: "gog_gmail_import" },
35287
+ slides: {
35288
+ "add-slide": "gog_slides_add_slide",
35289
+ "insert-image": "gog_slides_insert_image",
35290
+ "replace-slide": "gog_slides_replace_slide"
35291
+ }
35292
+ };
35293
+ var PATH_FLAGS = /* @__PURE__ */ new Set(["out", "output", "out-dir", "output-dir", "dir", "worker-dir", "attach", "file", "key", "cert", "replacements"]);
35294
+ var ID_FLAGS = {
35295
+ drive: /* @__PURE__ */ new Set(["file", "filter-file"])
35296
+ };
35297
+ var EXEC_FLAGS = /* @__PURE__ */ new Set(["on-change", "on-new", "mmdc"]);
35298
+ var SHORT_PATH_CLUSTER = /^-(?!-)[A-Za-z]*[of]/;
35299
+ var LONG_FLAG = /^--([A-Za-z0-9][A-Za-z0-9-]*)(?:=([\s\S]*))?$/;
35300
+ function isPathFlag(service, name) {
35301
+ if (ID_FLAGS[service]?.has(name)) return false;
35302
+ return PATH_FLAGS.has(name) || name.endsWith("-file");
35303
+ }
35304
+ function confineFlagValue(flag, value) {
35305
+ if (value === "-") return;
35306
+ confinePath(value, flag);
35307
+ for (const part of value.split(",")) {
35308
+ if (part !== "" && part !== "-") confinePath(part, flag);
35309
+ }
35310
+ }
35311
+ function positionalPathTool(service, subcommand) {
35312
+ return POSITIONAL_PATH_SUBCOMMANDS[service]?.[subcommand];
35313
+ }
35314
+ function assertRunPathsConfined(service, subcommand, args) {
35315
+ const dedicated = positionalPathTool(service, subcommand);
35316
+ if (dedicated) {
35317
+ throw new Error(
35318
+ `gog ${service} ${subcommand} reads or writes a local path given as a positional argument, so it is not available through gog_${service}_run. Use ${dedicated}, which confines the path to GOG_FILE_ROOTS.`
35319
+ );
35320
+ }
35321
+ for (let i = 0; i < args.length; i++) {
35322
+ const arg = args[i];
35323
+ if (SHORT_PATH_CLUSTER.test(arg)) {
35324
+ throw new Error(
35325
+ `The flag ${arg} is not allowed here: spell a path flag out as --out or --file (e.g. --out=<path>) so its path can be checked against GOG_FILE_ROOTS.`
35326
+ );
35327
+ }
35328
+ const match = LONG_FLAG.exec(arg);
35329
+ if (!match) continue;
35330
+ const name = match[1].toLowerCase();
35331
+ if (EXEC_FLAGS.has(name)) {
35332
+ throw new Error(`The flag --${name} is not allowed here: it runs a local program chosen by the caller.`);
35333
+ }
35334
+ const isJson = name.endsWith("-json");
35335
+ if (!isJson && !isPathFlag(service, name)) continue;
35336
+ let value = match[2];
35337
+ if (value === void 0) {
35338
+ value = args[i + 1];
35339
+ if (value === void 0) continue;
35340
+ i++;
35341
+ }
35342
+ if (isJson) {
35343
+ if (value.startsWith("@")) confineFlagValue(`--${name}`, value.slice(1));
35344
+ continue;
35345
+ }
35346
+ confineFlagValue(`--${name}`, value);
35347
+ }
35348
+ }
35349
+
35073
35350
  // ../gogcli-mcp/src/tools/utils.ts
35074
35351
  var PAYLOAD_INLINE_MAX = 4096;
35075
35352
  function payloadArg(inlineFlag, fileFlag, value, ext) {
@@ -35127,9 +35404,17 @@ function pushPaginationFlags(args, p) {
35127
35404
  if (p.all) args.push("--all");
35128
35405
  }
35129
35406
  function registerRunTool(server, options) {
35130
- const { service, examples, omitAccount = false, note } = options;
35407
+ const { service, examples, omitAccount = false, note, allowedSubcommands, vet, gmailNoSend = false } = options;
35408
+ for (const [, example] of examples.matchAll(/"([^"]+)"/g)) {
35409
+ const refused = allowedSubcommands && !allowedSubcommands.includes(example) || vet?.(example, []) || positionalPathTool(service, example);
35410
+ if (refused) {
35411
+ throw new Error(`gog_${service}_run example "${example}" is refused by the tool itself; list a subcommand it runs.`);
35412
+ }
35413
+ }
35131
35414
  const baseDescription = `Run any gog ${service} subcommand not covered by the other tools. Run \`gog ${service} --help\` for the full list of subcommands, or \`gog ${service} <subcommand> --help\` for flags on a specific subcommand.`;
35132
- const description = note ? `${baseDescription} ${note}` : baseDescription;
35415
+ const restriction = allowedSubcommands ? ` Only these subcommands are available: ${allowedSubcommands.join(", ")}.` : "";
35416
+ const safety = ' Flags that override server safety controls (--readonly, --enable-commands, --disable-commands, --account, --access-token, --home, --client, --gmail-no-send, --no-input) and a bare "--" are refused. Local file paths (--out, --out-dir, --attach, --file, --*-file, @file JSON) must be inside GOG_FILE_ROOTS; subcommands that take a local path positionally (e.g. drive upload) are refused in favour of their dedicated tools.';
35417
+ const description = `${baseDescription}${restriction}${safety}${note ? ` ${note}` : ""}`;
35133
35418
  const inputSchema = {
35134
35419
  subcommand: external_exports.string().describe(`The gog ${service} subcommand to run, e.g. ${examples}`),
35135
35420
  args: external_exports.array(external_exports.string()).describe("Additional positional args and flags")
@@ -35143,7 +35428,21 @@ function registerRunTool(server, options) {
35143
35428
  inputSchema: external_exports.object(inputSchema)
35144
35429
  }, async (rawArgs) => {
35145
35430
  const { subcommand, args, account } = rawArgs;
35146
- return runOrDiagnose([service, subcommand, ...args], { account });
35431
+ try {
35432
+ assertSafeSubcommand(subcommand);
35433
+ assertSafeForwardedArgs(args);
35434
+ if (allowedSubcommands && !allowedSubcommands.includes(subcommand)) {
35435
+ throw new Error(
35436
+ `gog ${service} ${subcommand} is not available through gog_${service}_run. Allowed: ${allowedSubcommands.join(", ")}.`
35437
+ );
35438
+ }
35439
+ const refusal = vet?.(subcommand, args);
35440
+ if (refusal) throw new Error(refusal);
35441
+ assertRunPathsConfined(service, subcommand, args);
35442
+ } catch (err) {
35443
+ return errorResult(errorText(err));
35444
+ }
35445
+ return runOrDiagnose([service, subcommand, ...args], gmailNoSend ? { account, gmailNoSend } : { account });
35147
35446
  });
35148
35447
  }
35149
35448
  function errorText(err) {
@@ -35265,6 +35564,7 @@ function formatAuthHealth(raw, now) {
35265
35564
  }
35266
35565
 
35267
35566
  // ../gogcli-mcp/src/tools/auth.ts
35567
+ var AUTH_RUN_SUBCOMMANDS = ["list", "status", "services", "remove", "alias"];
35268
35568
  function registerAuthToolsWith(server, defaultServices) {
35269
35569
  const servicesDescribe = `Services to authorize: "all" or comma-separated list (e.g. "sheets,gmail,calendar"). Default: "${defaultServices}". Prefer the narrowest set you need \u2014 requesting a service whose Google API is not enabled on the OAuth client's project makes Google reject the WHOLE request with invalid_scope.`;
35270
35570
  const extraScopesDescribe = "Additional raw OAuth scope URIs to request, comma-separated, on top of the ones `services` implies. Use for scopes no service covers \u2014 e.g. https://www.googleapis.com/auth/bigquery.readonly, required before gog_sheets_datasource_* can read BigQuery-backed Connected Sheets. Leave unset otherwise: an extra scope whose API is not enabled on the OAuth client project makes Google reject the WHOLE authorization with invalid_scope.";
@@ -35322,7 +35622,7 @@ function registerAuthToolsWith(server, defaultServices) {
35322
35622
  })
35323
35623
  }, async ({ email: email3, services = defaultServices, extraScopes }) => {
35324
35624
  try {
35325
- const args = ["auth", "add", email3, "--services", services];
35625
+ const args = ["auth", "add", pos(email3), "--services", services];
35326
35626
  if (extraScopes) args.push(`--extra-scopes=${extraScopes}`, "--force-consent");
35327
35627
  return rawTextResult(await run(args, {
35328
35628
  interactive: true,
@@ -35342,7 +35642,7 @@ function registerAuthToolsWith(server, defaultServices) {
35342
35642
  })
35343
35643
  }, async ({ email: email3, services = defaultServices, extraScopes }) => {
35344
35644
  try {
35345
- const args = ["auth", "add", email3, "--remote", "--step", "1", "--services", services, "--force-consent"];
35645
+ const args = ["auth", "add", pos(email3), "--remote", "--step", "1", "--services", services, "--force-consent"];
35346
35646
  if (extraScopes) args.push(`--extra-scopes=${extraScopes}`);
35347
35647
  return rawTextResult(await run(args, { redactMode: "tokens" }));
35348
35648
  } catch (err) {
@@ -35369,7 +35669,7 @@ function registerAuthToolsWith(server, defaultServices) {
35369
35669
  const args = [
35370
35670
  "auth",
35371
35671
  "add",
35372
- email3,
35672
+ pos(email3),
35373
35673
  "--remote",
35374
35674
  "--step",
35375
35675
  "2",
@@ -35389,6 +35689,7 @@ function registerAuthToolsWith(server, defaultServices) {
35389
35689
  service: "auth",
35390
35690
  examples: '"remove", "alias", "list"',
35391
35691
  omitAccount: true,
35692
+ allowedSubcommands: AUTH_RUN_SUBCOMMANDS,
35392
35693
  note: "For browser-based authorization, use gog_auth_add instead."
35393
35694
  });
35394
35695
  }
@@ -35436,7 +35737,7 @@ function registerDocsTools(server) {
35436
35737
  account: accountParam
35437
35738
  })
35438
35739
  }, async ({ docId, account }) => {
35439
- return runOrDiagnose(["docs", "info", docId], { account });
35740
+ return runOrDiagnose(["docs", "info", pos(docId)], { account });
35440
35741
  });
35441
35742
  server.registerTool("gog_docs_cat", {
35442
35743
  description: "Read a Google Doc as plain text.",
@@ -35447,7 +35748,7 @@ function registerDocsTools(server) {
35447
35748
  account: accountParam
35448
35749
  })
35449
35750
  }, async ({ docId, chips, account }) => {
35450
- const args = ["docs", "cat", docId];
35751
+ const args = ["docs", "cat", pos(docId)];
35451
35752
  if (chips) args.push("--chips");
35452
35753
  return runOrDiagnose(args, { account });
35453
35754
  });
@@ -35459,7 +35760,7 @@ function registerDocsTools(server) {
35459
35760
  account: accountParam
35460
35761
  })
35461
35762
  }, async ({ title, account }) => {
35462
- return runOrDiagnose(["docs", "create", title], { account });
35763
+ return runOrDiagnose(["docs", "create", pos(title)], { account });
35463
35764
  });
35464
35765
  server.registerTool("gog_docs_write", {
35465
35766
  description: "Write text content to a Google Doc, replacing existing body content by default. Set append=true to add after existing content.",
@@ -35484,7 +35785,7 @@ function registerDocsTools(server) {
35484
35785
  account: accountParam
35485
35786
  })
35486
35787
  }, async ({ docId, text, append, checkOrphans, bullets, bulletPreset, ordered, noBullets, indentStart, indentEnd, indentFirstLine, spaceAbove, spaceBelow, keepLinesTogether, keepWithNext, batch, account }) => {
35487
- const args = ["docs", "write", docId, `--text=${text}`];
35788
+ const args = ["docs", "write", pos(docId), `--text=${text}`];
35488
35789
  if (append) args.push("--append");
35489
35790
  if (checkOrphans) args.push("--check-orphans");
35490
35791
  if (bullets) args.push("--bullets");
@@ -35511,7 +35812,7 @@ function registerDocsTools(server) {
35511
35812
  account: accountParam
35512
35813
  })
35513
35814
  }, async ({ docId, find, replace, account }) => {
35514
- return runOrDiagnose(["docs", "find-replace", docId, find, replace], { account });
35815
+ return runOrDiagnose(["docs", "find-replace", pos(docId), pos(find), pos(replace)], { account });
35515
35816
  });
35516
35817
  server.registerTool("gog_docs_structure", {
35517
35818
  description: "Show a Google Doc's structure with numbered paragraphs. Useful for understanding the document layout before making index-based edits.",
@@ -35521,7 +35822,7 @@ function registerDocsTools(server) {
35521
35822
  account: accountParam
35522
35823
  })
35523
35824
  }, async ({ docId, account }) => {
35524
- return runOrDiagnose(["docs", "structure", docId], { account });
35825
+ return runOrDiagnose(["docs", "structure", pos(docId)], { account });
35525
35826
  });
35526
35827
  registerRunTool(server, { service: "docs", examples: '"copy", "clear", "insert", "sed", "export"' });
35527
35828
  }
@@ -35538,7 +35839,7 @@ var replySchema = {
35538
35839
  remove: external_exports.array(external_exports.string()).optional().describe("Remove these recipients from all fields (repeatable) \u2014 e.g. to drop someone from a reply-all."),
35539
35840
  subject: external_exports.string().optional().describe('Override reply subject (default: "Re: <original>"). A changed subject starts a NEW Gmail thread.'),
35540
35841
  noQuote: external_exports.boolean().optional().describe("Do not include the original message quoted below the reply (default: the original is quoted)"),
35541
- attach: external_exports.array(external_exports.string()).optional().describe(`File paths to attach (repeatable), resolved ON THE GOG SERVER's filesystem \u2014 NOT this client's. Only usable when gog runs on the same machine you do (local stdio); on a hosted deployment (e.g. mcp-host) these paths do not exist and the call fails with "no such file or directory" \u2014 use attachInline there. Read on the server, base64-encoded with a MIME type inferred from the extension.`),
35842
+ attach: external_exports.array(external_exports.string()).optional().describe(`File paths to attach (repeatable), resolved ON THE GOG SERVER's filesystem \u2014 NOT this client's. Only usable when gog runs on the same machine you do (local stdio); on a hosted deployment (e.g. mcp-host) these paths do not exist and the call fails with "no such file or directory" \u2014 use attachInline there. Read on the server, base64-encoded with a MIME type inferred from the extension. Must be inside the server's GOG_FILE_ROOTS directories (default ~/gogcli-mcp-files).`),
35542
35843
  attachInline: attachInlineParam,
35543
35844
  from: external_exports.string().optional().describe("Send from this email address (must be a verified send-as alias)"),
35544
35845
  autoFromAddressedAlias: external_exports.boolean().optional().describe("When from is omitted, send from the verified send-as alias the original message was addressed TO, instead of the account's primary address \u2014 so a reply to mail sent to an alias goes back out from that alias. Ignored when from is set."),
@@ -35559,10 +35860,10 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
35559
35860
  );
35560
35861
 
35561
35862
  // ../gogcli-mcp/src/server.ts
35562
- var VERSION = true ? "4.2.4" : "0.0.0";
35863
+ var VERSION = true ? "4.3.0" : "0.0.0";
35563
35864
 
35564
35865
  // ../gogcli-mcp/src/bootstrap-auth.ts
35565
- import { join as join2 } from "node:path";
35866
+ import { join as join5 } from "node:path";
35566
35867
  var AUTH_BOOTSTRAP_MARKER = "auth-bootstrap.sha256";
35567
35868
  var VARS = ["GOG_CLIENT_ID", "GOG_CLIENT_SECRET", "GOG_REFRESH_TOKEN", "GOG_ACCOUNT"];
35568
35869
  var log = (line) => {
@@ -35599,8 +35900,8 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
35599
35900
  const { createHash } = await import("node:crypto");
35600
35901
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
35601
35902
  const home = options.home ?? (await import("node:os")).homedir();
35602
- const dir = join2(home, ".gogcli-mcp");
35603
- const marker = join2(dir, AUTH_BOOTSTRAP_MARKER);
35903
+ const dir = join5(home, ".gogcli-mcp");
35904
+ const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
35604
35905
  const fingerprint = createHash("sha256").update(values.join("\0")).digest("hex");
35605
35906
  const previous = await readFile(marker, "utf8").catch(() => void 0);
35606
35907
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
@@ -35645,7 +35946,7 @@ function registerExtraDocsTools(server) {
35645
35946
  account: accountParam
35646
35947
  })
35647
35948
  }, async ({ docId, title, parent, account }) => {
35648
- const args = ["docs", "copy", docId, title];
35949
+ const args = ["docs", "copy", pos(docId), pos(title)];
35649
35950
  if (parent) args.push(`--parent=${parent}`);
35650
35951
  return runOrDiagnose(args, { account });
35651
35952
  });
@@ -35668,7 +35969,7 @@ function registerExtraDocsTools(server) {
35668
35969
  const args = ["docs", "delete"];
35669
35970
  if (start !== void 0) args.push(`--start=${start}`);
35670
35971
  if (end !== void 0) args.push(`--end=${end}`);
35671
- args.push(docId);
35972
+ args.push(pos(docId));
35672
35973
  if (at) args.push(`--at=${at}`);
35673
35974
  if (occurrence !== void 0) args.push(`--occurrence=${occurrence}`);
35674
35975
  if (matchCase) args.push("--match-case");
@@ -35685,7 +35986,7 @@ function registerExtraDocsTools(server) {
35685
35986
  account: accountParam
35686
35987
  })
35687
35988
  }, async ({ docId, account }) => {
35688
- return runOrDiagnose(["drive", "delete", docId, "--force"], { account });
35989
+ return runOrDiagnose(["drive", "delete", pos(docId), "--force"], { account });
35689
35990
  });
35690
35991
  server.registerTool("gog_docs_edit", {
35691
35992
  description: "Edit a Google Doc by finding and replacing text (stream-edit style).",
@@ -35698,7 +35999,7 @@ function registerExtraDocsTools(server) {
35698
35999
  account: accountParam
35699
36000
  })
35700
36001
  }, async ({ docId, find, replace, matchCase, account }) => {
35701
- const args = ["docs", "edit", docId, find, replace];
36002
+ const args = ["docs", "edit", pos(docId), pos(find), pos(replace)];
35702
36003
  if (matchCase) args.push("--match-case");
35703
36004
  return runOrDiagnose(args, { account });
35704
36005
  });
@@ -35716,12 +36017,12 @@ function registerExtraDocsTools(server) {
35716
36017
  })
35717
36018
  }, async ({ docId, format, tab, allTabs, maxBytes, chips, account }) => {
35718
36019
  if (format === "json") {
35719
- const args2 = ["docs", "raw", docId, "--pretty"];
36020
+ const args2 = ["docs", "raw", pos(docId), "--pretty"];
35720
36021
  if (tab) args2.push(`--tab=${tab}`);
35721
36022
  if (allTabs) args2.push("--all-tabs");
35722
36023
  return runOrDiagnose(args2, { account, lossless: true });
35723
36024
  }
35724
- const args = ["docs", "cat", docId];
36025
+ const args = ["docs", "cat", pos(docId)];
35725
36026
  if (tab) args.push(`--tab=${tab}`);
35726
36027
  if (allTabs) args.push("--all-tabs");
35727
36028
  if (maxBytes !== void 0) args.push(`--max-bytes=${maxBytes}`);
@@ -35774,7 +36075,7 @@ function registerExtraDocsTools(server) {
35774
36075
  })
35775
36076
  }, async (args) => {
35776
36077
  const a = args;
35777
- const argv = ["docs", "format", a.docId];
36078
+ const argv = ["docs", "format", pos(a.docId)];
35778
36079
  if (a.match) argv.push(`--match=${a.match}`);
35779
36080
  if (a.matchAll) argv.push("--match-all");
35780
36081
  if (a.matchCase) argv.push("--match-case");
@@ -35823,13 +36124,14 @@ function registerExtraDocsTools(server) {
35823
36124
  account: accountParam
35824
36125
  })
35825
36126
  }, async ({ docId, tab, account }) => {
35826
- const args = ["docs", "suggestions", "list", docId];
36127
+ const args = ["docs", "suggestions", "list", pos(docId)];
35827
36128
  if (tab) args.push(`--tab=${tab}`);
35828
36129
  return runOrDiagnose(args, { account });
35829
36130
  });
35830
36131
  server.registerTool("gog_docs_export", {
35831
36132
  description: "Export a Google Doc as PDF, plain text, HTML, DOCX, or other format.",
35832
- annotations: { readOnlyHint: true },
36133
+ // Writes a file on the gog host and can overwrite one: not read-only (audit SEC-4).
36134
+ annotations: { readOnlyHint: false, destructiveHint: true },
35833
36135
  inputSchema: external_exports.object({
35834
36136
  docId: external_exports.string().describe("Doc ID (from the URL)"),
35835
36137
  format: external_exports.string().optional().describe("Export format: pdf, txt, html, docx, rtf, odt, epub (default: pdf)"),
@@ -35838,7 +36140,8 @@ function registerExtraDocsTools(server) {
35838
36140
  account: accountParam
35839
36141
  })
35840
36142
  }, async ({ docId, format, out, overwrite, account }) => {
35841
- const args = ["docs", "export", docId];
36143
+ if (out) confinePath(out, "out");
36144
+ const args = ["docs", "export", pos(docId)];
35842
36145
  if (format) args.push(`--format=${format}`);
35843
36146
  if (out) args.push(`--out=${out}`);
35844
36147
  if (overwrite) args.push("--overwrite");
@@ -35861,8 +36164,9 @@ function registerExtraDocsTools(server) {
35861
36164
  account: accountParam
35862
36165
  })
35863
36166
  }, async ({ docId, content, index, file: file2, at, occurrence, matchCase, tabId, segment, batch, account }) => {
35864
- const args = ["docs", "insert", docId];
35865
- if (content) args.push(content);
36167
+ if (file2) confinePath(file2, "file");
36168
+ const args = ["docs", "insert", pos(docId)];
36169
+ if (content) args.push(pos(content));
35866
36170
  if (index !== void 0) args.push(`--index=${index}`);
35867
36171
  if (file2) args.push(`--file=${file2}`);
35868
36172
  if (at) args.push(`--at=${at}`);
@@ -35885,7 +36189,8 @@ function registerExtraDocsTools(server) {
35885
36189
  account: accountParam
35886
36190
  })
35887
36191
  }, async ({ docId, text, file: file2, markdown, tab, account }) => {
35888
- const args = ["docs", "write", docId, "--append"];
36192
+ if (file2) confinePath(file2, "file");
36193
+ const args = ["docs", "write", pos(docId), "--append"];
35889
36194
  if (text) args.push(`--text=${text}`);
35890
36195
  if (file2) args.push(`--file=${file2}`);
35891
36196
  if (markdown) args.push("--markdown");
@@ -35900,7 +36205,7 @@ function registerExtraDocsTools(server) {
35900
36205
  account: accountParam
35901
36206
  })
35902
36207
  }, async ({ docId, account }) => {
35903
- return runOrDiagnose(["docs", "list-tabs", docId], { account });
36208
+ return runOrDiagnose(["docs", "list-tabs", pos(docId)], { account });
35904
36209
  });
35905
36210
  server.registerTool("gog_docs_sed", {
35906
36211
  description: "Stream-edit a Google Doc with sed-like regex expressions (s/find/replace/ syntax).",
@@ -35914,8 +36219,9 @@ function registerExtraDocsTools(server) {
35914
36219
  account: accountParam
35915
36220
  })
35916
36221
  }, async ({ docId, expression, expressions, file: file2, tab, account }) => {
35917
- const args = ["docs", "sed", docId];
35918
- if (expression) args.push(expression);
36222
+ if (file2) confinePath(file2, "file");
36223
+ const args = ["docs", "sed", pos(docId)];
36224
+ if (expression) args.push(pos(expression));
35919
36225
  if (expressions) {
35920
36226
  for (const expr of expressions) {
35921
36227
  args.push(`--expressions=${expr}`);
@@ -35945,7 +36251,8 @@ function registerExtraDocsTools(server) {
35945
36251
  account: accountParam
35946
36252
  })
35947
36253
  }, async ({ docId, text, file: file2, index, replaceRange, markdown, at, occurrence, matchCase, tabId, segment, pageless, batch, account }) => {
35948
- const args = ["docs", "update", docId];
36254
+ if (file2) confinePath(file2, "file");
36255
+ const args = ["docs", "update", pos(docId)];
35949
36256
  if (text) args.push(`--text=${text}`);
35950
36257
  if (file2) args.push(`--file=${file2}`);
35951
36258
  if (index !== void 0) args.push(`--index=${index}`);
@@ -35973,7 +36280,7 @@ function registerExtraDocsTools(server) {
35973
36280
  account: accountParam
35974
36281
  })
35975
36282
  }, async ({ docId, includeResolved, since, locate, tab, max, page, all, account }) => {
35976
- const args = ["docs", "comments", "list", docId];
36283
+ const args = ["docs", "comments", "list", pos(docId)];
35977
36284
  if (includeResolved) args.push("--include-resolved");
35978
36285
  if (since) args.push(`--since=${since}`);
35979
36286
  if (locate) args.push("--locate");
@@ -35990,7 +36297,7 @@ function registerExtraDocsTools(server) {
35990
36297
  account: accountParam
35991
36298
  })
35992
36299
  }, async ({ docId, commentId, account }) => {
35993
- return runOrDiagnose(["docs", "comments", "get", docId, commentId], { account });
36300
+ return runOrDiagnose(["docs", "comments", "get", pos(docId), pos(commentId)], { account });
35994
36301
  });
35995
36302
  server.registerTool("gog_docs_comments_add", {
35996
36303
  description: "Add a comment to a Google Doc. Optionally attach quoted text that appears as the highlighted passage in the Google Docs UI.",
@@ -36002,7 +36309,7 @@ function registerExtraDocsTools(server) {
36002
36309
  account: accountParam
36003
36310
  })
36004
36311
  }, async ({ docId, content, quoted, account }) => {
36005
- const args = ["docs", "comments", "add", docId, content];
36312
+ const args = ["docs", "comments", "add", pos(docId), pos(content)];
36006
36313
  if (quoted) args.push(`--quoted=${quoted}`);
36007
36314
  return runOrDiagnose(args, { account });
36008
36315
  });
@@ -36016,7 +36323,7 @@ function registerExtraDocsTools(server) {
36016
36323
  account: accountParam
36017
36324
  })
36018
36325
  }, async ({ docId, commentId, content, account }) => {
36019
- return runOrDiagnose(["docs", "comments", "reply", docId, commentId, content], { account });
36326
+ return runOrDiagnose(["docs", "comments", "reply", pos(docId), pos(commentId), pos(content)], { account });
36020
36327
  });
36021
36328
  server.registerTool("gog_docs_comments_resolve", {
36022
36329
  description: "Resolve a comment (mark as done). Optionally include a closing message.",
@@ -36028,7 +36335,7 @@ function registerExtraDocsTools(server) {
36028
36335
  account: accountParam
36029
36336
  })
36030
36337
  }, async ({ docId, commentId, message, account }) => {
36031
- const args = ["docs", "comments", "resolve", docId, commentId];
36338
+ const args = ["docs", "comments", "resolve", pos(docId), pos(commentId)];
36032
36339
  if (message) args.push(`--message=${message}`);
36033
36340
  return runOrDiagnose(args, { account });
36034
36341
  });
@@ -36041,7 +36348,7 @@ function registerExtraDocsTools(server) {
36041
36348
  account: accountParam
36042
36349
  })
36043
36350
  }, async ({ docId, commentId, account }) => {
36044
- return runOrDiagnose(["docs", "comments", "delete", docId, commentId, "--force"], { account });
36351
+ return runOrDiagnose(["docs", "comments", "delete", pos(docId), pos(commentId), "--force"], { account });
36045
36352
  });
36046
36353
  server.registerTool("gog_docs_comments_reopen", {
36047
36354
  description: "Reopen a previously resolved comment (flip resolved \u2192 open).",
@@ -36052,7 +36359,7 @@ function registerExtraDocsTools(server) {
36052
36359
  account: accountParam
36053
36360
  })
36054
36361
  }, async ({ docId, commentId, account }) => {
36055
- return runOrDiagnose(["docs", "comments", "reopen", docId, commentId], { account });
36362
+ return runOrDiagnose(["docs", "comments", "reopen", pos(docId), pos(commentId)], { account });
36056
36363
  });
36057
36364
  server.registerTool("gog_docs_comments_locate", {
36058
36365
  description: "Locate a comment's anchor in a Google Doc \u2014 resolves the comment's quoted text to its current Docs API index range, or reports the comment as orphaned if the quote can no longer be found (e.g. the anchored text was edited away). Read-only; useful before an index-based edit near a comment.",
@@ -36066,7 +36373,7 @@ function registerExtraDocsTools(server) {
36066
36373
  account: accountParam
36067
36374
  })
36068
36375
  }, async ({ docId, commentId, matchCase, normalizeWhitespace, tab, account }) => {
36069
- const args = ["docs", "comments", "locate", docId, commentId];
36376
+ const args = ["docs", "comments", "locate", pos(docId), pos(commentId)];
36070
36377
  if (matchCase) args.push("--match-case");
36071
36378
  if (normalizeWhitespace) args.push("--normalize-whitespace");
36072
36379
  if (tab) args.push(`--tab=${tab}`);
@@ -36088,7 +36395,7 @@ function registerExtraDocsTools(server) {
36088
36395
  account: accountParam
36089
36396
  })
36090
36397
  }, async ({ docId, text, occurrence, matchCase, normalizeWhitespace, all, failEmpty, tab, segment, account }) => {
36091
- const args = ["docs", "find-range", docId, text];
36398
+ const args = ["docs", "find-range", pos(docId), pos(text)];
36092
36399
  if (occurrence !== void 0) args.push(`--occurrence=${occurrence}`);
36093
36400
  if (matchCase) args.push("--match-case");
36094
36401
  if (normalizeWhitespace) args.push("--normalize-whitespace");
@@ -36121,7 +36428,7 @@ function registerExtraDocsTools(server) {
36121
36428
  account: accountParam
36122
36429
  })
36123
36430
  }, async ({ batchId, autoSplit, continueOnError, account }) => {
36124
- const args = ["batch", "end", batchId];
36431
+ const args = ["batch", "end", pos(batchId)];
36125
36432
  if (autoSplit) args.push("--auto-split");
36126
36433
  if (continueOnError) args.push("--continue-on-error");
36127
36434
  return runOrDiagnose(args, { account });
@@ -36134,7 +36441,7 @@ function registerExtraDocsTools(server) {
36134
36441
  account: accountParam
36135
36442
  })
36136
36443
  }, async ({ batchId, account }) => {
36137
- return runOrDiagnose(["batch", "abort", batchId], { account });
36444
+ return runOrDiagnose(["batch", "abort", pos(batchId)], { account });
36138
36445
  });
36139
36446
  server.registerTool("gog_batch_list", {
36140
36447
  description: "List persisted Docs request batches (id, doc, label, request count, status).",
@@ -36153,7 +36460,7 @@ function registerExtraDocsTools(server) {
36153
36460
  account: accountParam
36154
36461
  })
36155
36462
  }, async ({ batchId, account }) => {
36156
- return runOrDiagnose(["batch", "show", batchId], { account });
36463
+ return runOrDiagnose(["batch", "show", pos(batchId)], { account });
36157
36464
  });
36158
36465
  server.registerTool("gog_batch_prune", {
36159
36466
  description: "Delete stale persisted batches (not updated within olderThan).",
@@ -36181,7 +36488,7 @@ function registerExtraDocsTools(server) {
36181
36488
  account: accountParam
36182
36489
  })
36183
36490
  }, async ({ docId, col, width, evenlyDistributed, tableIndex, tab, batch, account }) => {
36184
- const args = ["docs", "table-column-width", docId];
36491
+ const args = ["docs", "table-column-width", pos(docId)];
36185
36492
  if (col !== void 0) args.push(`--col=${col}`);
36186
36493
  if (width !== void 0) args.push(`--width=${width}`);
36187
36494
  if (evenlyDistributed) args.push("--evenly-distributed");
@@ -36203,7 +36510,7 @@ function registerExtraDocsTools(server) {
36203
36510
  account: accountParam
36204
36511
  })
36205
36512
  }, async ({ docId, table, at, valuesJson, tab, account }) => {
36206
- const args = ["docs", "table-row", "insert", docId];
36513
+ const args = ["docs", "table-row", "insert", pos(docId)];
36207
36514
  if (table) args.push(`--table=${table}`);
36208
36515
  if (at) args.push(`--at=${at}`);
36209
36516
  if (valuesJson) args.push(`--values-json=${valuesJson}`);
@@ -36221,7 +36528,7 @@ function registerExtraDocsTools(server) {
36221
36528
  account: accountParam
36222
36529
  })
36223
36530
  }, async ({ docId, row, table, tab, account }) => {
36224
- const args = ["docs", "table-row", "delete", docId, `--row=${row}`];
36531
+ const args = ["docs", "table-row", "delete", pos(docId), `--row=${row}`];
36225
36532
  if (table) args.push(`--table=${table}`);
36226
36533
  if (tab) args.push(`--tab=${tab}`);
36227
36534
  return runOrDiagnose(args, { account });
@@ -36237,7 +36544,7 @@ function registerExtraDocsTools(server) {
36237
36544
  account: accountParam
36238
36545
  })
36239
36546
  }, async ({ docId, table, at, tab, account }) => {
36240
- const args = ["docs", "table-column", "insert", docId];
36547
+ const args = ["docs", "table-column", "insert", pos(docId)];
36241
36548
  if (at) args.push(`--at=${at}`);
36242
36549
  if (table) args.push(`--table=${table}`);
36243
36550
  if (tab) args.push(`--tab=${tab}`);
@@ -36254,7 +36561,7 @@ function registerExtraDocsTools(server) {
36254
36561
  account: accountParam
36255
36562
  })
36256
36563
  }, async ({ docId, col, table, tab, account }) => {
36257
- const args = ["docs", "table-column", "delete", docId, `--col=${col}`];
36564
+ const args = ["docs", "table-column", "delete", pos(docId), `--col=${col}`];
36258
36565
  if (table) args.push(`--table=${table}`);
36259
36566
  if (tab) args.push(`--tab=${tab}`);
36260
36567
  return runOrDiagnose(args, { account });
@@ -36270,7 +36577,7 @@ function registerExtraDocsTools(server) {
36270
36577
  account: accountParam
36271
36578
  })
36272
36579
  }, async ({ docId, range, table, tab, account }) => {
36273
- const args = ["docs", "table-merge", docId, `--range=${range}`];
36580
+ const args = ["docs", "table-merge", pos(docId), `--range=${range}`];
36274
36581
  if (table) args.push(`--table=${table}`);
36275
36582
  if (tab) args.push(`--tab=${tab}`);
36276
36583
  return runOrDiagnose(args, { account });
@@ -36286,7 +36593,7 @@ function registerExtraDocsTools(server) {
36286
36593
  account: accountParam
36287
36594
  })
36288
36595
  }, async ({ docId, cell, table, tab, account }) => {
36289
- const args = ["docs", "table-unmerge", docId, `--cell=${cell}`];
36596
+ const args = ["docs", "table-unmerge", pos(docId), `--cell=${cell}`];
36290
36597
  if (table) args.push(`--table=${table}`);
36291
36598
  if (tab) args.push(`--tab=${tab}`);
36292
36599
  return runOrDiagnose(args, { account });
@@ -36306,7 +36613,7 @@ function registerExtraDocsTools(server) {
36306
36613
  account: accountParam
36307
36614
  })
36308
36615
  }, async ({ docId, name, at, occurrence, matchCase, start, end, tab, account }) => {
36309
- const args = ["docs", "named-range", "create", docId, `--name=${name}`];
36616
+ const args = ["docs", "named-range", "create", pos(docId), `--name=${name}`];
36310
36617
  if (at) args.push(`--at=${at}`);
36311
36618
  if (occurrence !== void 0) args.push(`--occurrence=${occurrence}`);
36312
36619
  if (matchCase) args.push("--match-case");
@@ -36325,7 +36632,7 @@ function registerExtraDocsTools(server) {
36325
36632
  account: accountParam
36326
36633
  })
36327
36634
  }, async ({ docId, name, tab, account }) => {
36328
- const args = ["docs", "named-range", "list", docId];
36635
+ const args = ["docs", "named-range", "list", pos(docId)];
36329
36636
  if (name) args.push(`--name=${name}`);
36330
36637
  if (tab) args.push(`--tab=${tab}`);
36331
36638
  return runOrDiagnose(args, { account });
@@ -36340,7 +36647,7 @@ function registerExtraDocsTools(server) {
36340
36647
  account: accountParam
36341
36648
  })
36342
36649
  }, async ({ docId, nameOrId, tab, account }) => {
36343
- const args = ["docs", "named-range", "delete", docId, nameOrId];
36650
+ const args = ["docs", "named-range", "delete", pos(docId), pos(nameOrId)];
36344
36651
  if (tab) args.push(`--tab=${tab}`);
36345
36652
  return runOrDiagnose(args, { account });
36346
36653
  });
@@ -36356,7 +36663,8 @@ function registerExtraDocsTools(server) {
36356
36663
  account: accountParam
36357
36664
  })
36358
36665
  }, async ({ docId, nameOrId, text, file: file2, tab, account }) => {
36359
- const args = ["docs", "named-range", "replace", docId, nameOrId];
36666
+ if (file2) confinePath(file2, "file");
36667
+ const args = ["docs", "named-range", "replace", pos(docId), pos(nameOrId)];
36360
36668
  if (text !== void 0) args.push(`--text=${text}`);
36361
36669
  if (file2) args.push(`--file=${file2}`);
36362
36670
  if (tab) args.push(`--tab=${tab}`);
@@ -36371,7 +36679,7 @@ function registerExtraDocsTools(server) {
36371
36679
  account: accountParam
36372
36680
  })
36373
36681
  }, async ({ docId, tab, account }) => {
36374
- const args = ["docs", "tables", "list", docId];
36682
+ const args = ["docs", "tables", "list", pos(docId)];
36375
36683
  if (tab) args.push(`--tab=${tab}`);
36376
36684
  return runOrDiagnose(args, { account });
36377
36685
  });
@@ -36384,7 +36692,7 @@ function registerExtraDocsTools(server) {
36384
36692
  account: accountParam
36385
36693
  })
36386
36694
  }, async ({ docId, tab, account }) => {
36387
- const args = ["docs", "images", "list", docId];
36695
+ const args = ["docs", "images", "list", pos(docId)];
36388
36696
  if (tab) args.push(`--tab=${tab}`);
36389
36697
  return runOrDiagnose(args, { account });
36390
36698
  });
@@ -36398,7 +36706,7 @@ function registerExtraDocsTools(server) {
36398
36706
  account: accountParam
36399
36707
  })
36400
36708
  }, async ({ docId, level, tab, account }) => {
36401
- const args = ["docs", "headings", "list", docId];
36709
+ const args = ["docs", "headings", "list", pos(docId)];
36402
36710
  if (level !== void 0) args.push(`--level=${level}`);
36403
36711
  if (tab) args.push(`--tab=${tab}`);
36404
36712
  return runOrDiagnose(args, { account });
@@ -36413,7 +36721,7 @@ function registerExtraDocsTools(server) {
36413
36721
  account: accountParam
36414
36722
  })
36415
36723
  }, async ({ docId, style, tab, account }) => {
36416
- const args = ["docs", "paragraphs", "list", docId];
36724
+ const args = ["docs", "paragraphs", "list", pos(docId)];
36417
36725
  if (style) args.push(`--style=${style}`);
36418
36726
  if (tab) args.push(`--tab=${tab}`);
36419
36727
  return runOrDiagnose(args, { account });
@@ -36433,7 +36741,7 @@ function registerExtraDocsTools(server) {
36433
36741
  account: accountParam
36434
36742
  })
36435
36743
  }, async ({ docId, index, atEnd, at, occurrence, matchCase, tab, batch, account }) => {
36436
- const args = ["docs", "insert-page-break", docId];
36744
+ const args = ["docs", "insert-page-break", pos(docId)];
36437
36745
  if (index !== void 0) args.push(`--index=${index}`);
36438
36746
  if (atEnd) args.push("--at-end");
36439
36747
  if (at) args.push(`--at=${at}`);
@@ -36459,7 +36767,7 @@ function registerExtraDocsTools(server) {
36459
36767
  account: accountParam
36460
36768
  })
36461
36769
  }, async ({ docId, layout, pageSize, pageWidth, pageHeight, marginTop, marginBottom, marginLeft, marginRight, account }) => {
36462
- const args = ["docs", "page-layout", docId];
36770
+ const args = ["docs", "page-layout", pos(docId)];
36463
36771
  if (layout) args.push(`--layout=${layout}`);
36464
36772
  if (pageSize) args.push(`--page-size=${pageSize}`);
36465
36773
  if (pageWidth) args.push(`--page-width=${pageWidth}`);
@@ -36484,7 +36792,7 @@ function registerExtraDocsTools(server) {
36484
36792
  account: accountParam
36485
36793
  })
36486
36794
  }, async ({ docId, rows, cols, index, atEnd, valuesJson, tab, account }) => {
36487
- const args = ["docs", "insert-table", docId, `--rows=${rows}`, `--cols=${cols}`];
36795
+ const args = ["docs", "insert-table", pos(docId), `--rows=${rows}`, `--cols=${cols}`];
36488
36796
  if (index !== void 0) args.push(`--index=${index}`);
36489
36797
  if (atEnd) args.push("--at-end");
36490
36798
  if (valuesJson !== void 0) args.push(`--values-json=${valuesJson}`);
@@ -36507,12 +36815,13 @@ function registerExtraDocsTools(server) {
36507
36815
  account: accountParam
36508
36816
  })
36509
36817
  }, async ({ docId, row, col, content, contentFile, append, format, tableIndex, tab, account }) => {
36818
+ if (contentFile) confinePath(contentFile, "contentFile");
36510
36819
  if (content !== void 0 && contentFile) {
36511
36820
  throw new Error(
36512
36821
  'gog_docs_cell_update accepts content or contentFile, not both \u2014 gog refuses the combination ("cannot use both --content and --content-file"). Drop one of them.'
36513
36822
  );
36514
36823
  }
36515
- const args = ["docs", "cell-update", docId, `--row=${row}`, `--col=${col}`];
36824
+ const args = ["docs", "cell-update", pos(docId), `--row=${row}`, `--col=${col}`];
36516
36825
  if (content !== void 0) args.push(payloadArg("content", "content-file", content, "md"));
36517
36826
  if (contentFile) args.push(`--content-file=${contentFile}`);
36518
36827
  if (append) args.push("--append");
@@ -36552,7 +36861,7 @@ function registerExtraDocsTools(server) {
36552
36861
  account: accountParam
36553
36862
  })
36554
36863
  }, async ({ docId, row, col, rowSpan, colSpan, backgroundColor, textColor, bold, italic, underline, borderAll, borderTop, borderBottom, borderLeft, borderRight, paddingAll, paddingTop, paddingBottom, paddingLeft, paddingRight, contentAlign, tableIndex, tab, batch, account }) => {
36555
- const args = ["docs", "cell-style", docId, `--row=${row}`, `--col=${col}`];
36864
+ const args = ["docs", "cell-style", pos(docId), `--row=${row}`, `--col=${col}`];
36556
36865
  if (rowSpan !== void 0) args.push(`--row-span=${rowSpan}`);
36557
36866
  if (colSpan !== void 0) args.push(`--col-span=${colSpan}`);
36558
36867
  if (backgroundColor) args.push(`--background-color=${backgroundColor}`);
@@ -36595,7 +36904,8 @@ function registerExtraDocsTools(server) {
36595
36904
  account: accountParam
36596
36905
  })
36597
36906
  }, async ({ docId, file: file2, url: url2, at, before, after, width, height, name, parent, onRestricted, tab, account }) => {
36598
- const args = ["docs", "insert-image", docId];
36907
+ if (file2) confinePath(file2, "file");
36908
+ const args = ["docs", "insert-image", pos(docId)];
36599
36909
  if (file2) args.push(`--file=${file2}`);
36600
36910
  if (url2) args.push(`--url=${url2}`);
36601
36911
  if (at) args.push(`--at=${at}`);
@@ -36626,7 +36936,7 @@ function registerExtraDocsTools(server) {
36626
36936
  account: accountParam
36627
36937
  })
36628
36938
  }, async ({ docId, email: email3, index, atEnd, at, occurrence, matchCase, tab, batch, account }) => {
36629
- const args = ["docs", "insert-person", docId, `--email=${email3}`];
36939
+ const args = ["docs", "insert-person", pos(docId), `--email=${email3}`];
36630
36940
  if (index !== void 0) args.push(`--index=${index}`);
36631
36941
  if (atEnd) args.push("--at-end");
36632
36942
  if (at) args.push(`--at=${at}`);
@@ -36650,7 +36960,7 @@ function registerExtraDocsTools(server) {
36650
36960
  account: accountParam
36651
36961
  })
36652
36962
  }, async ({ docId, date: date5, format, index, atEnd, tab, batch, account }) => {
36653
- const args = ["docs", "insert-date-chip", docId];
36963
+ const args = ["docs", "insert-date-chip", pos(docId)];
36654
36964
  if (date5) args.push(`--date=${date5}`);
36655
36965
  if (format) args.push(`--format=${format}`);
36656
36966
  if (index !== void 0) args.push(`--index=${index}`);
@@ -36671,7 +36981,7 @@ function registerExtraDocsTools(server) {
36671
36981
  account: accountParam
36672
36982
  })
36673
36983
  }, async ({ docId, title, index, parentTab, iconEmoji, account }) => {
36674
- const args = ["docs", "add-tab", docId];
36984
+ const args = ["docs", "add-tab", pos(docId)];
36675
36985
  if (title) args.push(`--title=${title}`);
36676
36986
  if (index !== void 0) args.push(`--index=${index}`);
36677
36987
  if (parentTab) args.push(`--parent-tab=${parentTab}`);
@@ -36688,7 +36998,7 @@ function registerExtraDocsTools(server) {
36688
36998
  account: accountParam
36689
36999
  })
36690
37000
  }, async ({ docId, tab, title, account }) => {
36691
- const args = ["docs", "rename-tab", docId, `--tab=${tab}`, `--title=${title}`];
37001
+ const args = ["docs", "rename-tab", pos(docId), `--tab=${tab}`, `--title=${title}`];
36692
37002
  return runOrDiagnose(args, { account });
36693
37003
  });
36694
37004
  server.registerTool("gog_docs_delete_tab", {
@@ -36700,7 +37010,7 @@ function registerExtraDocsTools(server) {
36700
37010
  account: accountParam
36701
37011
  })
36702
37012
  }, async ({ docId, tab, account }) => {
36703
- const args = ["docs", "delete-tab", docId, `--tab=${tab}`, "--force"];
37013
+ const args = ["docs", "delete-tab", pos(docId), `--tab=${tab}`, "--force"];
36704
37014
  return runOrDiagnose(args, { account });
36705
37015
  });
36706
37016
  server.registerTool("gog_docs_clear", {
@@ -36711,7 +37021,7 @@ function registerExtraDocsTools(server) {
36711
37021
  account: accountParam
36712
37022
  })
36713
37023
  }, async ({ docId, account }) => {
36714
- return runOrDiagnose(["docs", "clear", docId], { account });
37024
+ return runOrDiagnose(["docs", "clear", pos(docId)], { account });
36715
37025
  });
36716
37026
  server.registerTool("gog_docs_insert_footnote", {
36717
37027
  description: "Insert a footnote at a character index (or end-of-doc) and populate its text. The footnote reference mark is placed in the body; the footnote content goes in the new footnote segment.",
@@ -36729,7 +37039,8 @@ function registerExtraDocsTools(server) {
36729
37039
  account: accountParam
36730
37040
  })
36731
37041
  }, async ({ docId, text, file: file2, index, atEnd, at, occurrence, matchCase, tab, account }) => {
36732
- const args = ["docs", "insert-footnote", docId];
37042
+ if (file2) confinePath(file2, "file");
37043
+ const args = ["docs", "insert-footnote", pos(docId)];
36733
37044
  if (text !== void 0) args.push(`--text=${text}`);
36734
37045
  if (file2) args.push(`--file=${file2}`);
36735
37046
  if (index !== void 0) args.push(`--index=${index}`);
@@ -36756,7 +37067,7 @@ function registerExtraDocsTools(server) {
36756
37067
  account: accountParam
36757
37068
  })
36758
37069
  }, async ({ docId, type, index, atEnd, at, occurrence, matchCase, tab, batch, account }) => {
36759
- const args = ["docs", "insert-section-break", docId];
37070
+ const args = ["docs", "insert-section-break", pos(docId)];
36760
37071
  if (type) args.push(`--type=${type}`);
36761
37072
  if (index !== void 0) args.push(`--index=${index}`);
36762
37073
  if (atEnd) args.push("--at-end");
@@ -36782,7 +37093,7 @@ function registerExtraDocsTools(server) {
36782
37093
  account: accountParam
36783
37094
  })
36784
37095
  }, async ({ docId, index, atEnd, at, occurrence, matchCase, tab, batch, account }) => {
36785
- const args = ["docs", "insert-horizontal-rule", docId];
37096
+ const args = ["docs", "insert-horizontal-rule", pos(docId)];
36786
37097
  if (index !== void 0) args.push(`--index=${index}`);
36787
37098
  if (atEnd) args.push("--at-end");
36788
37099
  if (at) args.push(`--at=${at}`);
@@ -36809,7 +37120,7 @@ function registerExtraDocsTools(server) {
36809
37120
  account: accountParam
36810
37121
  })
36811
37122
  }, async ({ docId, count, separator, index, atEnd, at, occurrence, matchCase, tab, batch, account }) => {
36812
- const args = ["docs", "section-columns", docId, `--count=${count}`];
37123
+ const args = ["docs", "section-columns", pos(docId), `--count=${count}`];
36813
37124
  if (separator) args.push(`--separator=${separator}`);
36814
37125
  if (index !== void 0) args.push(`--index=${index}`);
36815
37126
  if (atEnd) args.push("--at-end");
@@ -36829,7 +37140,7 @@ function registerExtraDocsTools(server) {
36829
37140
  account: accountParam
36830
37141
  })
36831
37142
  }, async ({ docId, tab, account }) => {
36832
- const args = ["docs", "header", "list", docId];
37143
+ const args = ["docs", "header", "list", pos(docId)];
36833
37144
  if (tab) args.push(`--tab=${tab}`);
36834
37145
  return runOrDiagnose(args, { account });
36835
37146
  });
@@ -36849,7 +37160,8 @@ function registerExtraDocsTools(server) {
36849
37160
  account: accountParam
36850
37161
  })
36851
37162
  }, async ({ docId, text, file: file2, index, atEnd, at, occurrence, matchCase, tab, account }) => {
36852
- const args = ["docs", "header", "create", docId];
37163
+ if (file2) confinePath(file2, "file");
37164
+ const args = ["docs", "header", "create", pos(docId)];
36853
37165
  if (text !== void 0) args.push(`--text=${text}`);
36854
37166
  if (file2) args.push(`--file=${file2}`);
36855
37167
  if (index !== void 0) args.push(`--index=${index}`);
@@ -36870,7 +37182,7 @@ function registerExtraDocsTools(server) {
36870
37182
  account: accountParam
36871
37183
  })
36872
37184
  }, async ({ docId, headerId, tab, account }) => {
36873
- const args = ["docs", "header", "delete", docId, headerId];
37185
+ const args = ["docs", "header", "delete", pos(docId), pos(headerId)];
36874
37186
  if (tab) args.push(`--tab=${tab}`);
36875
37187
  args.push("--force");
36876
37188
  return runOrDiagnose(args, { account });
@@ -36884,7 +37196,7 @@ function registerExtraDocsTools(server) {
36884
37196
  account: accountParam
36885
37197
  })
36886
37198
  }, async ({ docId, tab, account }) => {
36887
- const args = ["docs", "footer", "list", docId];
37199
+ const args = ["docs", "footer", "list", pos(docId)];
36888
37200
  if (tab) args.push(`--tab=${tab}`);
36889
37201
  return runOrDiagnose(args, { account });
36890
37202
  });
@@ -36904,7 +37216,8 @@ function registerExtraDocsTools(server) {
36904
37216
  account: accountParam
36905
37217
  })
36906
37218
  }, async ({ docId, text, file: file2, index, atEnd, at, occurrence, matchCase, tab, account }) => {
36907
- const args = ["docs", "footer", "create", docId];
37219
+ if (file2) confinePath(file2, "file");
37220
+ const args = ["docs", "footer", "create", pos(docId)];
36908
37221
  if (text !== void 0) args.push(`--text=${text}`);
36909
37222
  if (file2) args.push(`--file=${file2}`);
36910
37223
  if (index !== void 0) args.push(`--index=${index}`);
@@ -36925,7 +37238,7 @@ function registerExtraDocsTools(server) {
36925
37238
  account: accountParam
36926
37239
  })
36927
37240
  }, async ({ docId, footerId, tab, account }) => {
36928
- const args = ["docs", "footer", "delete", docId, footerId];
37241
+ const args = ["docs", "footer", "delete", pos(docId), pos(footerId)];
36929
37242
  if (tab) args.push(`--tab=${tab}`);
36930
37243
  args.push("--force");
36931
37244
  return runOrDiagnose(args, { account });
@@ -36945,7 +37258,8 @@ function registerExtraDocsTools(server) {
36945
37258
  account: accountParam
36946
37259
  })
36947
37260
  }, async ({ docId, file: file2, url: url2, objectId, matchAlt, name, parent, tab, account }) => {
36948
- const args = ["docs", "replace-image", docId];
37261
+ if (file2) confinePath(file2, "file");
37262
+ const args = ["docs", "replace-image", pos(docId)];
36949
37263
  if (file2) args.push(`--file=${file2}`);
36950
37264
  if (url2) args.push(`--url=${url2}`);
36951
37265
  if (objectId) args.push(`--object-id=${objectId}`);
@@ -36967,7 +37281,7 @@ function registerExtraDocsTools(server) {
36967
37281
  account: accountParam
36968
37282
  })
36969
37283
  }, async ({ docId, rows, table, tab, account }) => {
36970
- const args = ["docs", "table-row", "pin-header", docId, `--rows=${rows}`];
37284
+ const args = ["docs", "table-row", "pin-header", pos(docId), `--rows=${rows}`];
36971
37285
  if (table) args.push(`--table=${table}`);
36972
37286
  if (tab) args.push(`--tab=${tab}`);
36973
37287
  return runOrDiagnose(args, { account });
@@ -36985,7 +37299,7 @@ function registerExtraDocsTools(server) {
36985
37299
  account: accountParam
36986
37300
  })
36987
37301
  }, async ({ docId, row, minHeight, preventOverflow, table, tab, account }) => {
36988
- const args = ["docs", "table-row", "style", docId];
37302
+ const args = ["docs", "table-row", "style", pos(docId)];
36989
37303
  if (row !== void 0) args.push(`--row=${row}`);
36990
37304
  if (minHeight) args.push(`--min-height=${minHeight}`);
36991
37305
  if (preventOverflow !== void 0) args.push(preventOverflow ? "--prevent-overflow" : "--no-prevent-overflow");