gogcli-mcp-classroom 4.4.0 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -956,14 +956,14 @@ function promiseAllObject(promisesObj) {
956
956
  }
957
957
  function randomString(length = 10) {
958
958
  const chars = "abcdefghijklmnopqrstuvwxyz";
959
- let str = "";
959
+ let str2 = "";
960
960
  for (let i = 0; i < length; i++) {
961
- str += chars[Math.floor(Math.random() * chars.length)];
961
+ str2 += chars[Math.floor(Math.random() * chars.length)];
962
962
  }
963
- return str;
963
+ return str2;
964
964
  }
965
- function esc(str) {
966
- return JSON.stringify(str);
965
+ function esc(str2) {
966
+ return JSON.stringify(str2);
967
967
  }
968
968
  function slugify(input2) {
969
969
  return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -1077,8 +1077,8 @@ var primitiveTypes = /* @__PURE__ */ new Set([
1077
1077
  "symbol",
1078
1078
  "undefined"
1079
1079
  ]);
1080
- function escapeRegex(str) {
1081
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1080
+ function escapeRegex(str2) {
1081
+ return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1082
1082
  }
1083
1083
  function clone(inst, def, params) {
1084
1084
  const cl = new inst._zod.constr(def ?? inst._zod.def);
@@ -1332,13 +1332,13 @@ function getSizableOrigin(input2) {
1332
1332
  return "unknown";
1333
1333
  }
1334
1334
  var highSurrogate = /[\uD800-\uDBFF]/;
1335
- function codePointLength(str) {
1336
- const units = str.length;
1337
- if (!highSurrogate.test(str))
1335
+ function codePointLength(str2) {
1336
+ const units = str2.length;
1337
+ if (!highSurrogate.test(str2))
1338
1338
  return units;
1339
1339
  let count = units;
1340
1340
  for (let i = 0; i < units - 1; i++) {
1341
- if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
1341
+ if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
1342
1342
  count--;
1343
1343
  i++;
1344
1344
  }
@@ -25451,7 +25451,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
25451
25451
  }
25452
25452
  exports._ = _;
25453
25453
  const plus = new _Code("+");
25454
- function str(strs, ...args) {
25454
+ function str2(strs, ...args) {
25455
25455
  const expr = [safeStringify(strs[0])];
25456
25456
  let i = 0;
25457
25457
  while (i < args.length) {
@@ -25462,7 +25462,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
25462
25462
  optimize(expr);
25463
25463
  return new _Code(expr);
25464
25464
  }
25465
- exports.str = str;
25465
+ exports.str = str2;
25466
25466
  function addCodeArg(code, arg) {
25467
25467
  if (arg instanceof _Code) code.push(...arg._items);
25468
25468
  else if (arg instanceof Name) code.push(arg);
@@ -25495,7 +25495,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
25495
25495
  if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
25496
25496
  }
25497
25497
  function strConcat(c1, c2) {
25498
- return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
25498
+ return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str2`${c1}${c2}`;
25499
25499
  }
25500
25500
  exports.strConcat = strConcat;
25501
25501
  function interpolate(x) {
@@ -26374,21 +26374,21 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
26374
26374
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
26375
26375
  }
26376
26376
  exports.schemaRefOrVal = schemaRefOrVal;
26377
- function unescapeFragment(str) {
26378
- return unescapeJsonPointer(decodeURIComponent(str));
26377
+ function unescapeFragment(str2) {
26378
+ return unescapeJsonPointer(decodeURIComponent(str2));
26379
26379
  }
26380
26380
  exports.unescapeFragment = unescapeFragment;
26381
- function escapeFragment(str) {
26382
- return encodeURIComponent(escapeJsonPointer(str));
26381
+ function escapeFragment(str2) {
26382
+ return encodeURIComponent(escapeJsonPointer(str2));
26383
26383
  }
26384
26384
  exports.escapeFragment = escapeFragment;
26385
- function escapeJsonPointer(str) {
26386
- if (typeof str == "number") return `${str}`;
26387
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
26385
+ function escapeJsonPointer(str2) {
26386
+ if (typeof str2 == "number") return `${str2}`;
26387
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
26388
26388
  }
26389
26389
  exports.escapeJsonPointer = escapeJsonPointer;
26390
- function unescapeJsonPointer(str) {
26391
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
26390
+ function unescapeJsonPointer(str2) {
26391
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
26392
26392
  }
26393
26393
  exports.unescapeJsonPointer = unescapeJsonPointer;
26394
26394
  function eachItem(xs, f) {
@@ -27274,8 +27274,8 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
27274
27274
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
27275
27275
  }
27276
27276
  }
27277
- function escapeJsonPtr(str) {
27278
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
27277
+ function escapeJsonPtr(str2) {
27278
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
27279
27279
  }
27280
27280
  }));
27281
27281
  var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -28167,9 +28167,9 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28167
28167
  isIPV6: false
28168
28168
  };
28169
28169
  }
28170
- function findToken(str, token) {
28170
+ function findToken(str2, token) {
28171
28171
  let ind = 0;
28172
- for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
28172
+ for (let i = 0; i < str2.length; i++) if (str2[i] === token) ind++;
28173
28173
  return ind;
28174
28174
  }
28175
28175
  function removeDotSegments(path) {
@@ -28684,7 +28684,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
28684
28684
  const util_1 = require_util();
28685
28685
  const $dataRefSchema = require_data();
28686
28686
  const uri_1 = require_uri();
28687
- const defaultRegExp = (str, flags) => new RegExp(str, flags);
28687
+ const defaultRegExp = (str2, flags) => new RegExp(str2, flags);
28688
28688
  defaultRegExp.code = "new RegExp";
28689
28689
  const META_IGNORE_OPTIONS = [
28690
28690
  "removeAdditional",
@@ -29390,16 +29390,16 @@ var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
29390
29390
  }));
29391
29391
  var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
29392
29392
  Object.defineProperty(exports, "__esModule", { value: true });
29393
- function ucs2length(str) {
29394
- const len = str.length;
29393
+ function ucs2length(str2) {
29394
+ const len = str2.length;
29395
29395
  let length = 0;
29396
29396
  let pos2 = 0;
29397
29397
  let value;
29398
29398
  while (pos2 < len) {
29399
29399
  length++;
29400
- value = str.charCodeAt(pos2++);
29400
+ value = str2.charCodeAt(pos2++);
29401
29401
  if (value >= 55296 && value <= 56319 && pos2 < len) {
29402
- value = str.charCodeAt(pos2);
29402
+ value = str2.charCodeAt(pos2);
29403
29403
  if ((value & 64512) === 56320) pos2++;
29404
29404
  }
29405
29405
  }
@@ -32110,8 +32110,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
32110
32110
  30,
32111
32111
  31
32112
32112
  ];
32113
- function date5(str) {
32114
- const matches = DATE.exec(str);
32113
+ function date5(str2) {
32114
+ const matches = DATE.exec(str2);
32115
32115
  if (!matches) return false;
32116
32116
  const year = +matches[1];
32117
32117
  const month = +matches[2];
@@ -32126,8 +32126,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
32126
32126
  }
32127
32127
  const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
32128
32128
  function getTime(strictTimeZone) {
32129
- return function time3(str) {
32130
- const matches = TIME.exec(str);
32129
+ return function time3(str2) {
32130
+ const matches = TIME.exec(str2);
32131
32131
  if (!matches) return false;
32132
32132
  const hr = +matches[1];
32133
32133
  const min = +matches[2];
@@ -32164,8 +32164,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
32164
32164
  const DATE_TIME_SEPARATOR = /t|\s/i;
32165
32165
  function getDateTime(strictTimeZone) {
32166
32166
  const time3 = getTime(strictTimeZone);
32167
- return function date_time(str) {
32168
- const dateTime = str.split(DATE_TIME_SEPARATOR);
32167
+ return function date_time(str2) {
32168
+ const dateTime = str2.split(DATE_TIME_SEPARATOR);
32169
32169
  return dateTime.length === 2 && date5(dateTime[0]) && time3(dateTime[1]);
32170
32170
  };
32171
32171
  }
@@ -32186,13 +32186,13 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
32186
32186
  }
32187
32187
  const NOT_URI_FRAGMENT = /\/|:/;
32188
32188
  const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
32189
- function uri(str) {
32190
- return NOT_URI_FRAGMENT.test(str) && URI.test(str);
32189
+ function uri(str2) {
32190
+ return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
32191
32191
  }
32192
32192
  const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
32193
- function byte(str) {
32193
+ function byte(str2) {
32194
32194
  BYTE.lastIndex = 0;
32195
- return BYTE.test(str);
32195
+ return BYTE.test(str2);
32196
32196
  }
32197
32197
  const MIN_INT32 = -(2 ** 31);
32198
32198
  const MAX_INT32 = 2 ** 31 - 1;
@@ -32206,10 +32206,10 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
32206
32206
  return true;
32207
32207
  }
32208
32208
  const Z_ANCHOR = /[^\\]\\Z/;
32209
- function regex(str) {
32210
- if (Z_ANCHOR.test(str)) return false;
32209
+ function regex(str2) {
32210
+ if (Z_ANCHOR.test(str2)) return false;
32211
32211
  try {
32212
- new RegExp(str);
32212
+ new RegExp(str2);
32213
32213
  return true;
32214
32214
  } catch (e) {
32215
32215
  return false;
@@ -34533,10 +34533,8 @@ function errorResult(message) {
34533
34533
 
34534
34534
  // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34535
34535
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
34536
- var DEFAULT_REQUEST_KEY = "confirmation";
34537
- var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34538
- var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
34539
- var STATE_PREFIX = "mcpu.confirm.v1.";
34536
+
34537
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
34540
34538
  function canonicalJson(value) {
34541
34539
  if (value === null || typeof value === "string" || typeof value === "boolean")
34542
34540
  return JSON.stringify(value);
@@ -34547,7 +34545,7 @@ function canonicalJson(value) {
34547
34545
  if (typeof value === "bigint")
34548
34546
  return `{"$bigint":"${value.toString()}"}`;
34549
34547
  if (typeof value === "function" || typeof value === "symbol") {
34550
- throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
34548
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
34551
34549
  }
34552
34550
  if (Array.isArray(value))
34553
34551
  return `[${value.map(canonicalJson).join(",")}]`;
@@ -34569,7 +34567,7 @@ function canonicalJson(value) {
34569
34567
  }
34570
34568
  const proto = Object.getPrototypeOf(value);
34571
34569
  if (proto !== Object.prototype && proto !== null) {
34572
- throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
34570
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
34573
34571
  }
34574
34572
  const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34575
34573
  return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
@@ -34577,6 +34575,12 @@ function canonicalJson(value) {
34577
34575
  function escapeKey(key) {
34578
34576
  return key.startsWith("$") ? `$${key}` : key;
34579
34577
  }
34578
+
34579
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34580
+ var DEFAULT_REQUEST_KEY = "confirmation";
34581
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34582
+ var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
34583
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34580
34584
  function bindingKey(binding) {
34581
34585
  if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34582
34586
  throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
@@ -34679,6 +34683,264 @@ ${JSON.stringify(preview, null, 2)}`,
34679
34683
  });
34680
34684
  }
34681
34685
 
34686
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
34687
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34688
+ function createSpentTokenStore() {
34689
+ const spent2 = /* @__PURE__ */ new Map();
34690
+ return {
34691
+ has: (nonce) => spent2.has(nonce),
34692
+ add: (nonce, exp) => {
34693
+ spent2.set(nonce, exp);
34694
+ },
34695
+ prune: (now) => {
34696
+ for (const [nonce, exp] of spent2)
34697
+ if (exp < now)
34698
+ spent2.delete(nonce);
34699
+ },
34700
+ clear: () => spent2.clear(),
34701
+ get size() {
34702
+ return spent2.size;
34703
+ }
34704
+ };
34705
+ }
34706
+ var PROCESS_SPENT = createSpentTokenStore();
34707
+ var PREFIX = "mcpu.token.v1.";
34708
+ var DEFAULT_TTL_SECONDS = 600;
34709
+ function tokenKey(key) {
34710
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
34711
+ if (bytes.length < 32)
34712
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
34713
+ return bytes;
34714
+ }
34715
+ function ttlOf(ttlSeconds) {
34716
+ if (ttlSeconds === void 0)
34717
+ return DEFAULT_TTL_SECONDS;
34718
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
34719
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
34720
+ }
34721
+ return ttlSeconds;
34722
+ }
34723
+ function sign(key, body) {
34724
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
34725
+ }
34726
+ function hashConfirmPayload(payload) {
34727
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
34728
+ }
34729
+ function issueConfirmToken(key, binding, options = {}) {
34730
+ const k = tokenKey(key);
34731
+ const now = options.now ?? Date.now();
34732
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
34733
+ const claims = {
34734
+ t: binding.tool,
34735
+ ...binding.account === void 0 ? {} : { a: binding.account },
34736
+ g: binding.target,
34737
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
34738
+ h: binding.payloadHash,
34739
+ exp,
34740
+ n: randomBytes(16).toString("base64url")
34741
+ };
34742
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34743
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
34744
+ }
34745
+ function parseClaims(body) {
34746
+ try {
34747
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34748
+ return claims && typeof claims === "object" ? claims : void 0;
34749
+ } catch {
34750
+ return void 0;
34751
+ }
34752
+ }
34753
+ function verifyConfirmToken(key, token, binding, options = {}) {
34754
+ const k = tokenKey(key);
34755
+ const now = options.now ?? Date.now();
34756
+ const spent2 = options.spent ?? PROCESS_SPENT;
34757
+ spent2.prune(now);
34758
+ if (!token.startsWith(PREFIX))
34759
+ return { ok: false, error: "TOKEN_INVALID" };
34760
+ const rest = token.slice(PREFIX.length);
34761
+ const dot = rest.indexOf(".");
34762
+ const body = dot < 0 ? "" : rest.slice(0, dot);
34763
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
34764
+ const expected = sign(k, body);
34765
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
34766
+ return { ok: false, error: "TOKEN_INVALID" };
34767
+ const claims = parseClaims(body);
34768
+ if (!claims)
34769
+ return { ok: false, error: "TOKEN_INVALID" };
34770
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34771
+ return { ok: false, error: "TOKEN_INVALID" };
34772
+ }
34773
+ if (spent2.has(claims.n))
34774
+ return { ok: false, error: "TOKEN_REUSED" };
34775
+ if (now > claims.exp)
34776
+ return { ok: false, error: "TOKEN_EXPIRED" };
34777
+ if (claims.r !== binding.revision)
34778
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
34779
+ if (claims.h !== binding.payloadHash)
34780
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34781
+ spent2.add(claims.n, claims.exp);
34782
+ return { ok: true };
34783
+ }
34784
+ var CONFIRM_TOKEN_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
34785
+ var confirmTokenParam = external_exports.string().optional().describe(`ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`);
34786
+ var TOKEN_ERROR_NOTE = {
34787
+ TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
34788
+ TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
34789
+ TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
34790
+ };
34791
+ var CHANGED_NOTE = {
34792
+ "revision-changed": "Nothing was sent or changed: the target was edited since the user approved it (its version rotated), so what would happen is not what they saw.",
34793
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34794
+ };
34795
+ function isToolResult(value) {
34796
+ return Array.isArray(value.content);
34797
+ }
34798
+ function rejection2(data) {
34799
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34800
+ }
34801
+ async function tokenConfirmation(action, fb) {
34802
+ const subject = await fb.subject();
34803
+ if (isToolResult(subject))
34804
+ return subject;
34805
+ const binding = {
34806
+ tool: fb.tool,
34807
+ ...fb.account === void 0 ? {} : { account: fb.account },
34808
+ target: subject.target,
34809
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
34810
+ payloadHash: hashConfirmPayload(subject.payload)
34811
+ };
34812
+ const phaseOne = () => {
34813
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
34814
+ return {
34815
+ action,
34816
+ preview: subject.preview,
34817
+ confirmToken: token,
34818
+ expiresAt,
34819
+ ttlSeconds: ttlOf(fb.ttlSeconds),
34820
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
34821
+ };
34822
+ };
34823
+ if (!fb.confirmToken) {
34824
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34825
+ }
34826
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
34827
+ if (verdict.ok)
34828
+ return void 0;
34829
+ if (verdict.error === "DRAFT_CHANGED") {
34830
+ return rejection2({
34831
+ error: "DRAFT_CHANGED",
34832
+ reason: verdict.reason,
34833
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34834
+ ...phaseOne()
34835
+ });
34836
+ }
34837
+ return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
34838
+ }
34839
+ async function requireConfirmationWithFallback(ctx, options) {
34840
+ const { tokenFallback, ...confirmation } = options;
34841
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
34842
+ return tokenConfirmation(options.action, tokenFallback);
34843
+ }
34844
+ return requireConfirmation(ctx, confirmation);
34845
+ }
34846
+
34847
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34848
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
34849
+
34850
+ // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34851
+ import { homedir } from "node:os";
34852
+ import { isAbsolute, join, resolve } from "node:path";
34853
+ var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34854
+ function readEnvVar(key, opts = {}) {
34855
+ const env = opts.env ?? process.env;
34856
+ const raw = env[key];
34857
+ if (typeof raw === "string") {
34858
+ const trimmed = raw.trim();
34859
+ if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34860
+ return trimmed;
34861
+ }
34862
+ }
34863
+ return opts.default;
34864
+ }
34865
+ var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34866
+ var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34867
+ function parseBoolEnv(key, opts = {}) {
34868
+ const fallback = opts.default ?? false;
34869
+ const raw = readEnvVar(key, { env: opts.env });
34870
+ if (raw === void 0)
34871
+ return fallback;
34872
+ const token = raw.toLowerCase();
34873
+ if (TRUE_TOKENS.has(token))
34874
+ return true;
34875
+ if (FALSE_TOKENS.has(token))
34876
+ return false;
34877
+ return fallback;
34878
+ }
34879
+ function expandPath(p) {
34880
+ let expanded = p;
34881
+ if (p === "~") {
34882
+ expanded = homedir();
34883
+ } else if (p.startsWith("~/")) {
34884
+ expanded = join(homedir(), p.slice(2));
34885
+ }
34886
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
34887
+ }
34888
+
34889
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34890
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
34891
+ var DEFAULT_TTL_SECONDS2 = 600;
34892
+ var warned = /* @__PURE__ */ new Set();
34893
+ function readConfirmMode(env = process.env) {
34894
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
34895
+ if (!raw)
34896
+ return "ask-user";
34897
+ if (MODES.has(raw))
34898
+ return raw;
34899
+ if (!warned.has(raw)) {
34900
+ warned.add(raw);
34901
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
34902
+ `);
34903
+ }
34904
+ return "refuse";
34905
+ }
34906
+ function confirmTtlFromEnv(env = process.env) {
34907
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
34908
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
34909
+ }
34910
+ var processKey;
34911
+ function confirmKeyFromEnv(env = process.env) {
34912
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
34913
+ if (secret)
34914
+ return createHash3("sha256").update(secret, "utf8").digest();
34915
+ processKey ??= randomBytes2(32);
34916
+ return processKey;
34917
+ }
34918
+ var CONFIRM_TOKEN_AUTO_INSTRUCTION = "Nothing has been done yet. Review this preview; if it is what was intended, call again with the same arguments plus confirmToken. (This server runs with MCP_CONFIRM_MODE=auto, so the user's approval in chat is not required.)";
34919
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
34920
+ function confirmationFromEnv(options) {
34921
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
34922
+ const mode = readConfirmMode(env);
34923
+ if (mode === "refuse") {
34924
+ return {
34925
+ ...confirmation,
34926
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
34927
+ };
34928
+ }
34929
+ return {
34930
+ ...confirmation,
34931
+ tokenFallback: {
34932
+ key: confirmKeyFromEnv(env),
34933
+ tool,
34934
+ ...account === void 0 ? {} : { account },
34935
+ ...confirmToken === void 0 ? {} : { confirmToken },
34936
+ subject,
34937
+ ttlSeconds: confirmTtlFromEnv(env),
34938
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
34939
+ ...spent2 === void 0 ? {} : { spent: spent2 }
34940
+ }
34941
+ };
34942
+ }
34943
+
34682
34944
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34683
34945
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34684
34946
  "2026-07-28",
@@ -34854,45 +35116,6 @@ function runMcp(opts) {
34854
35116
  return handle;
34855
35117
  }
34856
35118
 
34857
- // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34858
- import { homedir } from "node:os";
34859
- import { isAbsolute, join, resolve } from "node:path";
34860
- var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34861
- function readEnvVar(key, opts = {}) {
34862
- const env = opts.env ?? process.env;
34863
- const raw = env[key];
34864
- if (typeof raw === "string") {
34865
- const trimmed = raw.trim();
34866
- if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34867
- return trimmed;
34868
- }
34869
- }
34870
- return opts.default;
34871
- }
34872
- var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34873
- var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34874
- function parseBoolEnv(key, opts = {}) {
34875
- const fallback = opts.default ?? false;
34876
- const raw = readEnvVar(key, { env: opts.env });
34877
- if (raw === void 0)
34878
- return fallback;
34879
- const token = raw.toLowerCase();
34880
- if (TRUE_TOKENS.has(token))
34881
- return true;
34882
- if (FALSE_TOKENS.has(token))
34883
- return false;
34884
- return fallback;
34885
- }
34886
- function expandPath(p) {
34887
- let expanded = p;
34888
- if (p === "~") {
34889
- expanded = homedir();
34890
- } else if (p.startsWith("~/")) {
34891
- expanded = join(homedir(), p.slice(2));
34892
- }
34893
- return isAbsolute(expanded) ? expanded : resolve(expanded);
34894
- }
34895
-
34896
35119
  // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
34897
35120
  import { existsSync, realpathSync } from "node:fs";
34898
35121
  import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
@@ -35673,6 +35896,7 @@ async function diagnose(err) {
35673
35896
  const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
35674
35897
  const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
35675
35898
  const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
35899
+ if (!isAuthError && !isInvalidGrant) return errorResult(`${errText}${hint}`);
35676
35900
  try {
35677
35901
  const accounts = formatAccountList(await run(["auth", "list"]));
35678
35902
  return errorResult(`${errText}
@@ -35762,91 +35986,9 @@ function formatAuthHealth(raw, now) {
35762
35986
  }
35763
35987
 
35764
35988
  // ../gogcli-mcp/src/send-confirm-token.ts
35765
- import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
35766
- var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
35767
- var PREFIX = "gct1";
35768
- var secret;
35769
- var spent = /* @__PURE__ */ new Map();
35770
- function sendConfirmFallbackEnabled() {
35771
- return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
35772
- }
35773
- function confirmTokenTtlSeconds() {
35774
- const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
35775
- if (raw && /^\d+$/.test(raw)) {
35776
- const n = Number(raw);
35777
- if (n > 0) return n;
35778
- }
35779
- return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
35780
- }
35781
- function hmacKey() {
35782
- if (!secret) {
35783
- const configured = readEnvVar("GOG_CONFIRM_SECRET");
35784
- secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
35785
- }
35786
- return secret;
35787
- }
35788
- function canonicalize(value) {
35789
- if (Array.isArray(value)) return value.map(canonicalize);
35790
- if (value && typeof value === "object") {
35791
- const out = {};
35792
- for (const key of Object.keys(value).sort()) {
35793
- const v = value[key];
35794
- if (v !== void 0) out[key] = canonicalize(v);
35795
- }
35796
- return out;
35797
- }
35798
- return value;
35799
- }
35800
- function hashSendPayload(payload) {
35801
- return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
35802
- }
35803
- function sign(body) {
35804
- return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
35805
- }
35806
- function issueConfirmToken(binding, now = Date.now()) {
35807
- const exp = now + confirmTokenTtlSeconds() * 1e3;
35808
- const claims = {
35809
- t: binding.tool,
35810
- a: binding.account,
35811
- g: binding.target,
35812
- ...binding.revision === void 0 ? {} : { r: binding.revision },
35813
- h: binding.payloadHash,
35814
- iat: now,
35815
- exp,
35816
- n: randomBytes(16).toString("base64url")
35817
- };
35818
- const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
35819
- return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
35820
- }
35821
- function signatureMatches(body, sig) {
35822
- const expected = Buffer.from(sign(body), "utf8");
35823
- const actual = Buffer.from(sig, "utf8");
35824
- return expected.length === actual.length && timingSafeEqual2(expected, actual);
35825
- }
35826
- function parseClaims(body) {
35827
- try {
35828
- return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
35829
- } catch {
35830
- return void 0;
35831
- }
35832
- }
35833
- function verifyConfirmToken(token, binding, now = Date.now()) {
35834
- for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
35835
- const parts = token.split(".");
35836
- if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
35837
- const [, body, sig] = parts;
35838
- if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
35839
- const claims = parseClaims(body);
35840
- if (!claims) return { ok: false, error: "TOKEN_INVALID" };
35841
- if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
35842
- return { ok: false, error: "TOKEN_INVALID" };
35843
- }
35844
- if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
35845
- if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
35846
- if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
35847
- if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
35848
- spent.set(claims.n, claims.exp);
35849
- return { ok: true };
35989
+ var spent = createSpentTokenStore();
35990
+ function confirmSpentStore() {
35991
+ return spent;
35850
35992
  }
35851
35993
 
35852
35994
  // ../gogcli-mcp/src/dispatch-confirmation.ts
@@ -35856,82 +35998,45 @@ function bodyPreview(text) {
35856
35998
  if (text.length <= BODY_PREVIEW_MAX) return text;
35857
35999
  return `${text.slice(0, BODY_PREVIEW_MAX)}\u2026 [${text.length - BODY_PREVIEW_MAX} more characters not shown]`;
35858
36000
  }
35859
- var CONFIRM_ACTION_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
35860
- var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
35861
- var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai) and the server sets GOG_SEND_CONFIRM_FALLBACK=token, a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Show that preview to the user verbatim; only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken. The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing.';
35862
- var confirmTokenParam = external_exports.string().optional().describe(
35863
- `ONLY for the two-step fallback (client without MCP elicitation, server with GOG_SEND_CONFIRM_FALLBACK=token). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`
35864
- );
35865
- var TOKEN_ERROR_NOTE = {
35866
- TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
35867
- TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
35868
- TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
35869
- };
35870
- var DRAFT_CHANGED_NOTE = {
35871
- "message-id-rotated": "Nothing was sent or changed: the target was edited since the user approved it (a draft's messageId or an event's version rotated), so what would happen is not what they saw.",
35872
- "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
35873
- };
35874
- function isToolResult(value) {
35875
- return Array.isArray(value.content);
35876
- }
35877
- function rejection2(data) {
35878
- return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
35879
- }
35880
- async function tokenConfirmation(op, fallback) {
35881
- const subject = await fallback.subject();
35882
- if (isToolResult(subject)) return subject;
35883
- const binding = {
35884
- tool: fallback.tool,
35885
- account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
35886
- target: subject.target,
35887
- ...subject.revision === void 0 ? {} : { revision: subject.revision },
35888
- payloadHash: hashSendPayload(subject.payload)
35889
- };
35890
- const phaseOne = () => {
35891
- const { token, expiresAt } = issueConfirmToken(binding);
35892
- return {
35893
- action: op,
35894
- preview: subject.preview,
35895
- confirmToken: token,
35896
- expiresAt,
35897
- ttlSeconds: confirmTokenTtlSeconds(),
35898
- instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
35899
- };
35900
- };
35901
- if (!fallback.confirmToken) {
35902
- return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
35903
- }
35904
- const verdict = verifyConfirmToken(fallback.confirmToken, binding);
35905
- if (verdict.ok) return void 0;
35906
- if (verdict.error === "DRAFT_CHANGED") {
35907
- return rejection2({
35908
- error: "DRAFT_CHANGED",
35909
- reason: verdict.reason,
35910
- note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
35911
- ...phaseOne()
35912
- });
35913
- }
35914
- return rejection2({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
36001
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
36002
+ var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai), a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Follow its instruction (by default: show the preview to the user verbatim and only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken). The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing. A server set to MCP_CONFIRM_MODE=refuse refuses instead.';
36003
+ function refusedInRun(what, via, does, instead) {
36004
+ return `${what} ${does} and is not available through ${via}. ${instead}`;
35915
36005
  }
35916
36006
  function gatedElsewhere(what, via, does, tool) {
35917
- return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
36007
+ return refusedInRun(what, via, does, `Use ${tool}, which asks the user to confirm.`);
35918
36008
  }
35919
36009
  function hasCommandWord(args, words) {
35920
36010
  return args.find((a) => words.has(a.toLowerCase()));
35921
36011
  }
36012
+ function flagValue(args, name) {
36013
+ const flag = `--${name}`;
36014
+ for (let i = 0; i < args.length; i++) {
36015
+ const a = args[i];
36016
+ if (a === flag) return args[i + 1] ?? "";
36017
+ if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);
36018
+ }
36019
+ return void 0;
36020
+ }
35922
36021
  async function requireDispatchConfirmation(ctx, options) {
35923
36022
  const { action, fallback } = options;
35924
- if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
35925
- return tokenConfirmation(action, fallback);
35926
- }
35927
- const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
35928
- return requireConfirmation(ctx, {
36023
+ const confirmation = {
35929
36024
  action,
35930
36025
  message: options.message,
35931
36026
  details: options.details,
35932
36027
  confirmationLabel: options.confirmationLabel,
35933
- ...note ? { unsupportedNote: note } : {}
35934
- });
36028
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
36029
+ };
36030
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
36031
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
36032
+ ...confirmation,
36033
+ tool: fallback.tool,
36034
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
36035
+ confirmToken: fallback.confirmToken,
36036
+ subject: fallback.subject,
36037
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
36038
+ spent: confirmSpentStore()
36039
+ }));
35935
36040
  }
35936
36041
  function resultText(result) {
35937
36042
  const first = result.content[0];
@@ -36073,6 +36178,27 @@ function authToolsFor(defaultServices) {
36073
36178
  }
36074
36179
 
36075
36180
  // ../gogcli-mcp/src/tools/calendar.ts
36181
+ var ASKS = (tool) => `Use ${tool}, which asks the user to confirm.`;
36182
+ var CALENDAR_REFUSED = {
36183
+ create: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36184
+ add: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36185
+ new: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36186
+ update: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36187
+ edit: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36188
+ set: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36189
+ respond: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36190
+ rsvp: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36191
+ reply: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36192
+ move: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
36193
+ transfer: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
36194
+ delete: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36195
+ del: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36196
+ rm: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36197
+ remove: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36198
+ "delete-calendar": { does: "deletes a calendar and every event on it", instead: ASKS("gog_calendar_delete_calendar") },
36199
+ "out-of-office": { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") },
36200
+ ooo: { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") }
36201
+ };
36076
36202
  var reminderParams = {
36077
36203
  reminders: external_exports.array(external_exports.string()).max(5).optional().describe(
36078
36204
  `Reminders as method:duration, e.g. ["popup:30m", "email:1d"]. Method is popup or email; duration accepts m/h/d (max 40320 minutes = 4 weeks). Google allows at most 5. These REPLACE the event's reminders \u2014 on update, pass an EMPTY array to drop custom reminders and go back to the calendar's defaults. Cannot be combined with noReminders.`
@@ -36104,20 +36230,85 @@ var attachInlineParam = external_exports.array(inlineAttachmentSchema).optional(
36104
36230
 
36105
36231
  // ../gogcli-mcp/src/tools/classroom.ts
36106
36232
  var CLASSROOM_CREATE_WORDS = /* @__PURE__ */ new Set(["create", "add", "new"]);
36107
- var CLASSROOM_GATED = {
36108
- announcements: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
36109
- announcement: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
36110
- ann: { does: "posts to a class", tool: "gog_classroom_announcements_create" },
36111
- invitations: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" },
36112
- invitation: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" },
36113
- invites: { does: "invites someone to a class", tool: "gog_classroom_invitations_create" }
36233
+ var CLASSROOM_DELETE_WORDS = /* @__PURE__ */ new Set(["delete", "rm", "del", "remove"]);
36234
+ var CLASSROOM_UPDATE_WORDS = /* @__PURE__ */ new Set(["update", "edit", "set"]);
36235
+ var CLASSROOM_RETURN_WORDS = /* @__PURE__ */ new Set(["return", "send"]);
36236
+ var CLASSROOM_ASSIGNEE_WORDS = /* @__PURE__ */ new Set(["assignees", "assign"]);
36237
+ var CLASSROOM_GROUPS = {
36238
+ courses: "courses",
36239
+ course: "courses",
36240
+ announcements: "announcements",
36241
+ announcement: "announcements",
36242
+ ann: "announcements",
36243
+ invitations: "invitations",
36244
+ invitation: "invitations",
36245
+ invites: "invitations",
36246
+ coursework: "coursework",
36247
+ work: "coursework",
36248
+ materials: "materials",
36249
+ material: "materials",
36250
+ students: "students",
36251
+ student: "students",
36252
+ teachers: "teachers",
36253
+ teacher: "teachers",
36254
+ submissions: "submissions",
36255
+ submission: "submissions",
36256
+ "guardian-invitations": "guardian-invitations",
36257
+ "guardian-invites": "guardian-invitations"
36114
36258
  };
36259
+ function publishesToStudents(args) {
36260
+ return flagValue(args, "state")?.toUpperCase() === "PUBLISHED" || flagValue(args, "scheduled") !== void 0;
36261
+ }
36262
+ function createsVisibleWork(args) {
36263
+ return flagValue(args, "state")?.toUpperCase() !== "DRAFT" || flagValue(args, "scheduled") !== void 0;
36264
+ }
36265
+ function widensAssignees(args) {
36266
+ return flagValue(args, "mode")?.toUpperCase() === "ALL_STUDENTS" || flagValue(args, "add-student") !== void 0;
36267
+ }
36115
36268
  function vetClassroomRun(subcommand, args) {
36116
36269
  const sub = subcommand.toLowerCase();
36117
- const gated = Object.hasOwn(CLASSROOM_GATED, sub) ? CLASSROOM_GATED[sub] : void 0;
36118
- if (!gated) return void 0;
36119
- const word = hasCommandWord(args, CLASSROOM_CREATE_WORDS);
36120
- return word ? gatedElsewhere(`gog classroom ${sub} ${word.toLowerCase()}`, "gog_classroom_run", gated.does, gated.tool) : void 0;
36270
+ if (!Object.hasOwn(CLASSROOM_GROUPS, sub)) return void 0;
36271
+ const group = CLASSROOM_GROUPS[sub];
36272
+ const via = "gog_classroom_run";
36273
+ const what = (word) => `gog classroom ${sub} ${word.toLowerCase()}`;
36274
+ const create = hasCommandWord(args, CLASSROOM_CREATE_WORDS);
36275
+ const update = hasCommandWord(args, CLASSROOM_UPDATE_WORDS);
36276
+ const remove = hasCommandWord(args, CLASSROOM_DELETE_WORDS);
36277
+ const widenedAssignees = () => {
36278
+ const word = hasCommandWord(args, CLASSROOM_ASSIGNEE_WORDS);
36279
+ return word && widensAssignees(args) ? refusedInRun(what(word), via, "shows it to more students", "Ask the user to change who it is assigned to from Classroom.") : void 0;
36280
+ };
36281
+ switch (group) {
36282
+ case "courses":
36283
+ return remove ? gatedElsewhere(what(remove), via, "deletes a course", "gog_classroom_courses_delete") : void 0;
36284
+ case "announcements":
36285
+ if (create) return gatedElsewhere(what(create), via, "posts to a class", "gog_classroom_announcements_create");
36286
+ if (update && publishesToStudents(args)) return gatedElsewhere(what(update), via, "publishes an announcement to a class", "gog_classroom_announcements_update");
36287
+ return widenedAssignees();
36288
+ case "invitations":
36289
+ return create ? gatedElsewhere(what(create), via, "invites someone to a class", "gog_classroom_invitations_create") : void 0;
36290
+ case "coursework":
36291
+ if (create && createsVisibleWork(args)) return gatedElsewhere(what(create), via, "posts coursework to a class", "gog_classroom_coursework_create");
36292
+ if (remove) return gatedElsewhere(what(remove), via, "deletes coursework and every submission to it", "gog_classroom_coursework_delete");
36293
+ if (update && publishesToStudents(args)) return gatedElsewhere(what(update), via, "publishes work to students", "gog_classroom_coursework_update");
36294
+ return widenedAssignees();
36295
+ case "materials":
36296
+ if (create && createsVisibleWork(args)) {
36297
+ return refusedInRun(what(create), via, "publishes material to students", "Create it with --state=DRAFT and no --scheduled; ask the user to publish it from Classroom.");
36298
+ }
36299
+ if (update && publishesToStudents(args)) return refusedInRun(what(update), via, "publishes material to students", "Ask the user to publish it from Classroom.");
36300
+ return void 0;
36301
+ case "students":
36302
+ return create ? gatedElsewhere(what(create), via, "enrols someone in a class", "gog_classroom_students_add") : void 0;
36303
+ case "teachers":
36304
+ return create ? gatedElsewhere(what(create), via, "gives someone a teacher's access to a class and its roster", "gog_classroom_teachers_add") : void 0;
36305
+ case "submissions": {
36306
+ const word = hasCommandWord(args, CLASSROOM_RETURN_WORDS);
36307
+ return word ? gatedElsewhere(what(word), via, "returns work to a student, who is notified", "gog_classroom_submissions_return") : void 0;
36308
+ }
36309
+ case "guardian-invitations":
36310
+ return create ? refusedInRun(what(create), via, "emails a guardian invitation", "Ask the user to invite the guardian from Classroom.") : void 0;
36311
+ }
36121
36312
  }
36122
36313
  async function readCourse(courseId, account, runner = runOrDiagnose) {
36123
36314
  const got = await runner(["classroom", "courses", "get", pos(courseId)], { account });
@@ -36136,6 +36327,63 @@ async function readCourse(courseId, account, runner = runOrDiagnose) {
36136
36327
  }
36137
36328
  };
36138
36329
  }
36330
+ function nested(raw, key) {
36331
+ try {
36332
+ const parsed = JSON.parse(raw);
36333
+ const inner = parsed?.[key];
36334
+ return inner && typeof inner === "object" ? inner : void 0;
36335
+ } catch {
36336
+ return void 0;
36337
+ }
36338
+ }
36339
+ var str = (v) => typeof v === "string" ? v : void 0;
36340
+ var num = (v) => typeof v === "number" ? v : void 0;
36341
+ async function readCoursework(courseId, courseworkId, account, runner = runOrDiagnose) {
36342
+ const got = await runner(["classroom", "coursework", "get", pos(courseId), pos(courseworkId)], { account });
36343
+ if (got.isError) return { error: got };
36344
+ const work = nested(resultText(got), "coursework");
36345
+ const title = str(work?.title);
36346
+ return { coursework: { id: courseworkId, ...title !== void 0 ? { title } : {} } };
36347
+ }
36348
+ async function readClassroomWork(kind, courseId, itemId, account, runner = runOrDiagnose) {
36349
+ const got = await runner(["classroom", kind, "get", pos(courseId), pos(itemId)], { account });
36350
+ if (got.isError) return { error: got };
36351
+ const item = nested(resultText(got), kind === "announcements" ? "announcement" : "coursework");
36352
+ const work = { id: itemId };
36353
+ for (const key of ["text", "title", "description", "state", "updateTime"]) {
36354
+ const value = str(item?.[key]);
36355
+ if (value !== void 0) work[key] = value;
36356
+ }
36357
+ return { work };
36358
+ }
36359
+ async function readSubmission(courseId, courseworkId, submissionId, account, runner = runOrDiagnose) {
36360
+ const got = await runner(["classroom", "submissions", "get", pos(courseId), pos(courseworkId), pos(submissionId)], { account });
36361
+ if (got.isError) return { error: got };
36362
+ const sub = nested(resultText(got), "submission");
36363
+ const fields = {
36364
+ student: str(sub?.userId),
36365
+ state: str(sub?.state),
36366
+ draftGrade: num(sub?.draftGrade),
36367
+ assignedGrade: num(sub?.assignedGrade)
36368
+ };
36369
+ const updateTime = str(sub?.updateTime);
36370
+ return {
36371
+ submission: {
36372
+ id: submissionId,
36373
+ ...Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== void 0))
36374
+ },
36375
+ ...updateTime !== void 0 ? { updateTime } : {}
36376
+ };
36377
+ }
36378
+ async function studentLabel(courseId, userId, account, runner = runOrDiagnose) {
36379
+ const got = await runner(["classroom", "students", "get", pos(courseId), pos(userId)], { account });
36380
+ if (got.isError) return userId;
36381
+ const profile = nested(resultText(got), "student")?.profile;
36382
+ const name = str(profile?.name?.fullName);
36383
+ const email3 = str(profile?.emailAddress);
36384
+ if (name && email3) return `${name} <${email3}>`;
36385
+ return name ?? email3 ?? userId;
36386
+ }
36139
36387
  function registerClassroomTools(server) {
36140
36388
  server.registerTool("gog_classroom_courses_list", {
36141
36389
  description: "List Google Classroom courses.",
@@ -36348,15 +36596,38 @@ function registerClassroomTools(server) {
36348
36596
  return runOrDiagnose(args, { account });
36349
36597
  });
36350
36598
  server.registerTool("gog_classroom_submissions_return", {
36351
- description: "Return a graded submission to the student.",
36599
+ description: "Return a graded submission to the student, who is notified and sees the grade. Reads the course, the coursework and the submission and asks the MCP host to show the user a confirmation prompt with the class, the assignment, the student and the grade being returned; nothing is returned unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
36352
36600
  annotations: { destructiveHint: true },
36353
36601
  inputSchema: external_exports.object({
36354
36602
  courseId: external_exports.string().describe("Course ID"),
36355
36603
  courseworkId: external_exports.string().describe("Coursework ID"),
36356
36604
  submissionId: external_exports.string().describe("Submission ID"),
36357
- account: accountParam
36605
+ account: accountParam,
36606
+ confirmToken: confirmTokenParam
36358
36607
  })
36359
- }, async ({ courseId, courseworkId, submissionId, account }) => {
36608
+ }, async ({ courseId, courseworkId, submissionId, account, confirmToken }, ctx) => {
36609
+ const course = await readCourse(courseId, account);
36610
+ if (course.error) return course.error;
36611
+ const work = await readCoursework(courseId, courseworkId, account);
36612
+ if (work.error) return work.error;
36613
+ const sub = await readSubmission(courseId, courseworkId, submissionId, account);
36614
+ if (sub.error) return sub.error;
36615
+ const submission = sub.submission.student ? { ...sub.submission, student: await studentLabel(courseId, sub.submission.student, account) } : sub.submission;
36616
+ const view = { course: course.course, coursework: work.coursework, submission };
36617
+ const confirmation = await requireDispatchConfirmation(ctx, {
36618
+ action: "classroom.submission-return",
36619
+ message: "Review and confirm returning this work \u2014 the student is notified and sees the grade:",
36620
+ confirmationLabel: "Confirm that this submission should be returned to the student now.",
36621
+ details: view,
36622
+ unsupportedNote: "Ask the user to return it from Classroom.",
36623
+ fallback: {
36624
+ tool: "gog_classroom_submissions_return",
36625
+ account,
36626
+ confirmToken,
36627
+ subject: () => ({ target: `${courseId}/${courseworkId}/${submissionId}`, revision: sub.updateTime, payload: view, preview: view })
36628
+ }
36629
+ });
36630
+ if (confirmation) return confirmation;
36360
36631
  return runOrDiagnose(["classroom", "submissions", "return", pos(courseId), pos(courseworkId), pos(submissionId)], { account });
36361
36632
  });
36362
36633
  server.registerTool("gog_classroom_submissions_turn_in", {
@@ -36418,13 +36689,13 @@ function registerClassroomTools(server) {
36418
36689
  return runOrDiagnose(["classroom", "announcements", "get", pos(courseId), pos(announcementId)], { account });
36419
36690
  });
36420
36691
  server.registerTool("gog_classroom_announcements_create", {
36421
- description: "Create an announcement in a Google Classroom course. Unless state is DRAFT (which students cannot see), this reads the course and asks the MCP host to show the user a confirmation prompt with the class, the full text and when it publishes; nothing is posted unless they accept. To stage one without asking, pass state DRAFT." + CONFIRM_FALLBACK_DESCRIPTION,
36692
+ description: "Create an announcement in a Google Classroom course. Unless state is DRAFT with no scheduled time (which students cannot see; a scheduled draft publishes itself), this reads the course and asks the MCP host to show the user a confirmation prompt with the class, the full text and when it publishes; nothing is posted unless they accept. To stage one without asking, pass state DRAFT and no scheduled time." + CONFIRM_FALLBACK_DESCRIPTION,
36422
36693
  annotations: { destructiveHint: true },
36423
36694
  inputSchema: external_exports.object({
36424
36695
  courseId: external_exports.string().describe("Course ID"),
36425
36696
  text: external_exports.string().describe("Announcement text"),
36426
- state: external_exports.enum(["PUBLISHED", "DRAFT"]).optional().describe("State (DRAFT is visible only to teachers and needs no confirmation)"),
36427
- scheduled: external_exports.string().optional().describe("Scheduled publish time"),
36697
+ state: external_exports.enum(["PUBLISHED", "DRAFT"]).optional().describe("State (an unscheduled DRAFT is visible only to teachers and needs no confirmation)"),
36698
+ scheduled: external_exports.string().optional().describe("Scheduled publish time (asks the user to confirm, even for a DRAFT)"),
36428
36699
  account: accountParam,
36429
36700
  confirmToken: confirmTokenParam
36430
36701
  })
@@ -36432,7 +36703,7 @@ function registerClassroomTools(server) {
36432
36703
  const args = ["classroom", "announcements", "create", pos(courseId), `--text=${text}`];
36433
36704
  if (state) args.push(`--state=${state}`);
36434
36705
  if (scheduled) args.push(`--scheduled=${scheduled}`);
36435
- if (state !== "DRAFT") {
36706
+ if (state !== "DRAFT" || scheduled) {
36436
36707
  const read = await readCourse(courseId, account);
36437
36708
  if (read.error) return read.error;
36438
36709
  const publishes = scheduled ? `at ${scheduled}` : "immediately";
@@ -36581,7 +36852,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
36581
36852
  );
36582
36853
 
36583
36854
  // ../gogcli-mcp/src/server.ts
36584
- var VERSION = true ? "4.4.0" : "0.0.0";
36855
+ var VERSION = true ? "4.5.1" : "0.0.0";
36585
36856
 
36586
36857
  // ../gogcli-mcp/src/bootstrap-auth.ts
36587
36858
  import { join as join5 } from "node:path";
@@ -36618,12 +36889,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
36618
36889
  const [clientId, clientSecret, refreshToken, account] = values;
36619
36890
  const { spawner } = options;
36620
36891
  try {
36621
- const { createHash: createHash3 } = await import("node:crypto");
36892
+ const { createHash: createHash4 } = await import("node:crypto");
36622
36893
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
36623
36894
  const home = options.home ?? (await import("node:os")).homedir();
36624
36895
  const dir = join5(home, ".gogcli-mcp");
36625
36896
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
36626
- const fingerprint = createHash3("sha256").update(values.join("\0")).digest("hex");
36897
+ const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
36627
36898
  const previous = await readFile(marker, "utf8").catch(() => void 0);
36628
36899
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
36629
36900
  await run(
@@ -36659,6 +36930,11 @@ var MAX_BLOB_UPLOAD_BYTES = 100 * 1024 * 1024;
36659
36930
  var courseState = external_exports.enum(["ACTIVE", "ARCHIVED", "PROVISIONED", "DECLINED", "SUSPENDED"]);
36660
36931
  var workState = external_exports.enum(["PUBLISHED", "DRAFT"]);
36661
36932
  var workType = external_exports.enum(["ASSIGNMENT", "SHORT_ANSWER_QUESTION", "MULTIPLE_CHOICE_QUESTION"]);
36933
+ function publishesWhen(state, scheduled) {
36934
+ if (scheduled) return `at ${scheduled}`;
36935
+ return state === "PUBLISHED" ? "immediately" : void 0;
36936
+ }
36937
+ var PUBLISH_DESCRIPTION = " Publishing it (state PUBLISHED, or a scheduled time) reads the course and the item and asks the MCP host to show the user a confirmation prompt with the class and what students will see; nothing is published unless they accept. Other edits, and a return to DRAFT, need no confirmation." + CONFIRM_FALLBACK_DESCRIPTION;
36662
36938
  var courseSharedFields = {
36663
36939
  owner: external_exports.string().optional().describe('Owner user ID (default "me" on create)'),
36664
36940
  section: external_exports.string().optional().describe("Section"),
@@ -36718,13 +36994,31 @@ function registerExtraClassroomTools(server) {
36718
36994
  return runOrDiagnose(args, { account });
36719
36995
  });
36720
36996
  server.registerTool("gog_classroom_courses_delete", {
36721
- description: "Delete a Google Classroom course.",
36997
+ description: "Delete a Google Classroom course \u2014 its coursework, submissions and grades go with it, for good. Reads the course and asks the MCP host to show the user a confirmation prompt naming it first; nothing is deleted unless they accept. gog_classroom_courses_archive is the reversible alternative." + CONFIRM_FALLBACK_DESCRIPTION,
36722
36998
  annotations: { destructiveHint: true },
36723
36999
  inputSchema: external_exports.object({
36724
37000
  courseId: external_exports.string().describe("Course ID"),
36725
- account: accountParam
37001
+ account: accountParam,
37002
+ confirmToken: confirmTokenParam
36726
37003
  })
36727
- }, async ({ courseId, account }) => {
37004
+ }, async ({ courseId, account, confirmToken }, ctx) => {
37005
+ const read = await readCourse(courseId, account, runOrDiagnose);
37006
+ if (read.error) return read.error;
37007
+ const view = { course: read.course, deletes: "the course with all of its coursework, submissions and grades, for good" };
37008
+ const confirmation = await requireDispatchConfirmation(ctx, {
37009
+ action: "classroom.course-delete",
37010
+ message: "Review and confirm PERMANENTLY deleting this course:",
37011
+ confirmationLabel: "Confirm that this course should be deleted now.",
37012
+ details: view,
37013
+ unsupportedNote: "Archive it with gog_classroom_courses_archive instead, or ask the user to delete it from Classroom.",
37014
+ fallback: {
37015
+ tool: "gog_classroom_courses_delete",
37016
+ account,
37017
+ confirmToken,
37018
+ subject: () => ({ target: courseId, payload: view, preview: view })
37019
+ }
37020
+ });
37021
+ if (confirmation) return confirmation;
36728
37022
  return runOrDiagnose(["classroom", "courses", "delete", pos(courseId), "--force"], { account });
36729
37023
  });
36730
37024
  server.registerTool("gog_classroom_courses_archive", {
@@ -36748,17 +37042,37 @@ function registerExtraClassroomTools(server) {
36748
37042
  return runOrDiagnose(["classroom", "courses", "unarchive", pos(courseId)], { account });
36749
37043
  });
36750
37044
  server.registerTool("gog_classroom_students_add", {
36751
- description: "Add a student to a Google Classroom course.",
37045
+ description: 'Add a student to a Google Classroom course. Adding someone else gives them the class stream and materials, so this reads the course and asks the MCP host to show the user a confirmation prompt with the class and the student first; enrolling yourself ("me") does not ask.' + CONFIRM_FALLBACK_DESCRIPTION,
36752
37046
  annotations: { destructiveHint: true },
36753
37047
  inputSchema: external_exports.object({
36754
37048
  courseId: external_exports.string().describe("Course ID"),
36755
- userId: external_exports.string().describe('Student user ID (or "me")'),
37049
+ userId: external_exports.string().describe('Student user ID or email (or "me")'),
36756
37050
  enrollmentCode: external_exports.string().optional().describe("Enrollment code (required if adding self via code)"),
36757
- account: accountParam
37051
+ account: accountParam,
37052
+ confirmToken: confirmTokenParam
36758
37053
  })
36759
- }, async ({ courseId, userId, enrollmentCode, account }) => {
37054
+ }, async ({ courseId, userId, enrollmentCode, account, confirmToken }, ctx) => {
36760
37055
  const args = ["classroom", "students", "add", pos(courseId), pos(userId)];
36761
37056
  if (enrollmentCode) args.push(`--enrollment-code=${enrollmentCode}`);
37057
+ if (userId.toLowerCase() !== "me") {
37058
+ const read = await readCourse(courseId, account, runOrDiagnose);
37059
+ if (read.error) return read.error;
37060
+ const view = { course: read.course, student: userId };
37061
+ const confirmation = await requireDispatchConfirmation(ctx, {
37062
+ action: "classroom.student-add",
37063
+ message: "Review and confirm adding this student to the class:",
37064
+ confirmationLabel: "Confirm that this person should be added to the class now.",
37065
+ details: view,
37066
+ unsupportedNote: "Ask the user to add them from Classroom, or invite them with gog_classroom_invitations_create.",
37067
+ fallback: {
37068
+ tool: "gog_classroom_students_add",
37069
+ account,
37070
+ confirmToken,
37071
+ subject: () => ({ target: `${courseId}/${userId}`, payload: view, preview: view })
37072
+ }
37073
+ });
37074
+ if (confirmation) return confirmation;
37075
+ }
36762
37076
  return runOrDiagnose(args, { account });
36763
37077
  });
36764
37078
  server.registerTool("gog_classroom_students_remove", {
@@ -36773,14 +37087,32 @@ function registerExtraClassroomTools(server) {
36773
37087
  return runOrDiagnose(["classroom", "students", "remove", pos(courseId), pos(userId), "--force"], { account });
36774
37088
  });
36775
37089
  server.registerTool("gog_classroom_teachers_add", {
36776
- description: "Add a teacher to a Google Classroom course.",
37090
+ description: "Add a teacher to a Google Classroom course. A co-teacher sees every student's work and grades, so this reads the course and asks the MCP host to show the user a confirmation prompt with the class and the teacher first; nothing changes unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
36777
37091
  annotations: { destructiveHint: true },
36778
37092
  inputSchema: external_exports.object({
36779
37093
  courseId: external_exports.string().describe("Course ID"),
36780
- userId: external_exports.string().describe("Teacher user ID"),
36781
- account: accountParam
37094
+ userId: external_exports.string().describe("Teacher user ID or email"),
37095
+ account: accountParam,
37096
+ confirmToken: confirmTokenParam
36782
37097
  })
36783
- }, async ({ courseId, userId, account }) => {
37098
+ }, async ({ courseId, userId, account, confirmToken }, ctx) => {
37099
+ const read = await readCourse(courseId, account, runOrDiagnose);
37100
+ if (read.error) return read.error;
37101
+ const view = { course: read.course, teacher: userId, grants: "teacher access: every student's work, grades and roster" };
37102
+ const confirmation = await requireDispatchConfirmation(ctx, {
37103
+ action: "classroom.teacher-add",
37104
+ message: "Review and confirm giving this person teacher access to the class:",
37105
+ confirmationLabel: "Confirm that this person should become a teacher of the class now.",
37106
+ details: view,
37107
+ unsupportedNote: "Ask the user to add them from Classroom, or invite them with gog_classroom_invitations_create.",
37108
+ fallback: {
37109
+ tool: "gog_classroom_teachers_add",
37110
+ account,
37111
+ confirmToken,
37112
+ subject: () => ({ target: `${courseId}/${userId}`, payload: view, preview: view })
37113
+ }
37114
+ });
37115
+ if (confirmation) return confirmation;
36784
37116
  return runOrDiagnose(["classroom", "teachers", "add", pos(courseId), pos(userId)], { account });
36785
37117
  });
36786
37118
  server.registerTool("gog_classroom_teachers_remove", {
@@ -36795,15 +37127,16 @@ function registerExtraClassroomTools(server) {
36795
37127
  return runOrDiagnose(["classroom", "teachers", "remove", pos(courseId), pos(userId), "--force"], { account });
36796
37128
  });
36797
37129
  server.registerTool("gog_classroom_coursework_create", {
36798
- description: "Create a new coursework item (assignment, question, etc.) in a course.",
37130
+ description: "Create a new coursework item (assignment, question, etc.) in a course. Unless state is DRAFT with no scheduled time (which students cannot see; a scheduled draft publishes itself), the class is notified, so this reads the course and asks the MCP host to show the user a confirmation prompt with the class, the title, the text, the due date and when it publishes; nothing is posted unless they accept. To stage one without asking, pass state DRAFT and no scheduled time." + CONFIRM_FALLBACK_DESCRIPTION,
36799
37131
  annotations: { destructiveHint: true },
36800
37132
  inputSchema: external_exports.object({
36801
37133
  courseId: external_exports.string().describe("Course ID"),
36802
37134
  title: external_exports.string().describe("Coursework title"),
36803
37135
  ...courseworkSharedFields,
36804
- account: accountParam
37136
+ account: accountParam,
37137
+ confirmToken: confirmTokenParam
36805
37138
  })
36806
- }, async ({ courseId, title, description, type, state, maxPoints, due, dueDate, dueTime, scheduled, topic, account }) => {
37139
+ }, async ({ courseId, title, description, type, state, maxPoints, due, dueDate, dueTime, scheduled, topic, account, confirmToken }, ctx) => {
36807
37140
  const args = ["classroom", "coursework", "create", pos(courseId), `--title=${title}`];
36808
37141
  if (description) args.push(`--description=${description}`);
36809
37142
  if (type) args.push(`--type=${type}`);
@@ -36814,19 +37147,49 @@ function registerExtraClassroomTools(server) {
36814
37147
  if (dueTime) args.push(`--due-time=${dueTime}`);
36815
37148
  if (scheduled) args.push(`--scheduled=${scheduled}`);
36816
37149
  if (topic) args.push(`--topic=${topic}`);
37150
+ if (state !== "DRAFT" || scheduled) {
37151
+ const read = await readCourse(courseId, account, runOrDiagnose);
37152
+ if (read.error) return read.error;
37153
+ const work = {
37154
+ course: read.course,
37155
+ title,
37156
+ type: type ?? "ASSIGNMENT",
37157
+ publishes: scheduled ? `at ${scheduled}` : "immediately",
37158
+ due: due ?? ([dueDate, dueTime].filter(Boolean).join(" ") || void 0),
37159
+ maxPoints
37160
+ };
37161
+ const confirmation = await requireDispatchConfirmation(ctx, {
37162
+ action: "classroom.coursework-create",
37163
+ message: "Review and confirm posting this coursework to the class:",
37164
+ confirmationLabel: "Confirm that this coursework should be posted to the class.",
37165
+ details: { ...work, descriptionPreview: bodyPreview(description) },
37166
+ unsupportedNote: "Create it with state DRAFT instead; the user can review and post it from Classroom.",
37167
+ fallback: {
37168
+ tool: "gog_classroom_coursework_create",
37169
+ account,
37170
+ confirmToken,
37171
+ subject: () => {
37172
+ const view = { ...work, description };
37173
+ return { target: courseId, payload: view, preview: view };
37174
+ }
37175
+ }
37176
+ });
37177
+ if (confirmation) return confirmation;
37178
+ }
36817
37179
  return runOrDiagnose(args, { account });
36818
37180
  });
36819
37181
  server.registerTool("gog_classroom_coursework_update", {
36820
- description: "Update an existing coursework item.",
37182
+ description: "Update an existing coursework item." + PUBLISH_DESCRIPTION,
36821
37183
  annotations: { destructiveHint: true },
36822
37184
  inputSchema: external_exports.object({
36823
37185
  courseId: external_exports.string().describe("Course ID"),
36824
37186
  courseworkId: external_exports.string().describe("Coursework ID"),
36825
37187
  title: external_exports.string().optional().describe("New title"),
36826
37188
  ...courseworkSharedFields,
36827
- account: accountParam
37189
+ account: accountParam,
37190
+ confirmToken: confirmTokenParam
36828
37191
  })
36829
- }, async ({ courseId, courseworkId, title, description, type, state, maxPoints, due, dueDate, dueTime, scheduled, topic, account }) => {
37192
+ }, async ({ courseId, courseworkId, title, description, type, state, maxPoints, due, dueDate, dueTime, scheduled, topic, account, confirmToken }, ctx) => {
36830
37193
  const args = ["classroom", "coursework", "update", pos(courseId), pos(courseworkId)];
36831
37194
  if (title) args.push(`--title=${title}`);
36832
37195
  if (description) args.push(`--description=${description}`);
@@ -36838,35 +37201,123 @@ function registerExtraClassroomTools(server) {
36838
37201
  if (dueTime) args.push(`--due-time=${dueTime}`);
36839
37202
  if (scheduled) args.push(`--scheduled=${scheduled}`);
36840
37203
  if (topic) args.push(`--topic=${topic}`);
37204
+ const publishes = publishesWhen(state, scheduled);
37205
+ if (publishes) {
37206
+ const read = await readCourse(courseId, account, runOrDiagnose);
37207
+ if (read.error) return read.error;
37208
+ const current = await readClassroomWork("coursework", courseId, courseworkId, account, runOrDiagnose);
37209
+ if (current.error) return current.error;
37210
+ const published = description || current.work.description;
37211
+ const publishedTitle = title || current.work.title;
37212
+ const view = {
37213
+ course: read.course,
37214
+ coursework: { id: courseworkId, title: publishedTitle, state: current.work.state },
37215
+ publishes,
37216
+ descriptionPreview: bodyPreview(published)
37217
+ };
37218
+ const confirmation = await requireDispatchConfirmation(ctx, {
37219
+ action: "classroom.coursework-publish",
37220
+ message: "Review and confirm publishing this Classroom coursework to students:",
37221
+ confirmationLabel: "Confirm that this coursework should be published to the class.",
37222
+ details: view,
37223
+ unsupportedNote: "Leave it as a DRAFT; the user can review and publish it from Classroom.",
37224
+ fallback: {
37225
+ tool: "gog_classroom_coursework_update",
37226
+ account,
37227
+ confirmToken,
37228
+ subject: () => ({
37229
+ target: `${courseId}/${courseworkId}`,
37230
+ revision: current.work.updateTime,
37231
+ payload: { course: read.course, courseworkId, title: publishedTitle, description: published, type, state, maxPoints, due, dueDate, dueTime, scheduled, topic },
37232
+ preview: view
37233
+ })
37234
+ }
37235
+ });
37236
+ if (confirmation) return confirmation;
37237
+ }
36841
37238
  return runOrDiagnose(args, { account });
36842
37239
  });
36843
37240
  server.registerTool("gog_classroom_coursework_delete", {
36844
- description: "Delete a coursework item.",
37241
+ description: "Delete a coursework item \u2014 every student submission to it goes too, for good. Reads the course and the coursework and asks the MCP host to show the user a confirmation prompt naming both first; nothing is deleted unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
36845
37242
  annotations: { destructiveHint: true },
36846
37243
  inputSchema: external_exports.object({
36847
37244
  courseId: external_exports.string().describe("Course ID"),
36848
37245
  courseworkId: external_exports.string().describe("Coursework ID"),
36849
- account: accountParam
37246
+ account: accountParam,
37247
+ confirmToken: confirmTokenParam
36850
37248
  })
36851
- }, async ({ courseId, courseworkId, account }) => {
37249
+ }, async ({ courseId, courseworkId, account, confirmToken }, ctx) => {
37250
+ const course = await readCourse(courseId, account, runOrDiagnose);
37251
+ if (course.error) return course.error;
37252
+ const work = await readCoursework(courseId, courseworkId, account, runOrDiagnose);
37253
+ if (work.error) return work.error;
37254
+ const view = { course: course.course, coursework: work.coursework, deletes: "the coursework and every student submission to it, for good" };
37255
+ const confirmation = await requireDispatchConfirmation(ctx, {
37256
+ action: "classroom.coursework-delete",
37257
+ message: "Review and confirm PERMANENTLY deleting this coursework and its submissions:",
37258
+ confirmationLabel: "Confirm that this coursework should be deleted now.",
37259
+ details: view,
37260
+ unsupportedNote: "Ask the user to delete it from Classroom.",
37261
+ fallback: {
37262
+ tool: "gog_classroom_coursework_delete",
37263
+ account,
37264
+ confirmToken,
37265
+ subject: () => ({ target: `${courseId}/${courseworkId}`, payload: view, preview: view })
37266
+ }
37267
+ });
37268
+ if (confirmation) return confirmation;
36852
37269
  return runOrDiagnose(["classroom", "coursework", "delete", pos(courseId), pos(courseworkId), "--force"], { account });
36853
37270
  });
36854
37271
  server.registerTool("gog_classroom_announcements_update", {
36855
- description: "Update an existing announcement.",
37272
+ description: "Update an existing announcement." + PUBLISH_DESCRIPTION,
36856
37273
  annotations: { destructiveHint: true },
36857
37274
  inputSchema: external_exports.object({
36858
37275
  courseId: external_exports.string().describe("Course ID"),
36859
37276
  announcementId: external_exports.string().describe("Announcement ID"),
36860
37277
  text: external_exports.string().optional().describe("New text"),
36861
- state: workState.optional().describe("State"),
36862
- scheduled: external_exports.string().optional().describe("Scheduled publish time"),
36863
- account: accountParam
37278
+ state: workState.optional().describe("State (PUBLISHED asks the user to confirm; DRAFT does not)"),
37279
+ scheduled: external_exports.string().optional().describe("Scheduled publish time (asks the user to confirm)"),
37280
+ account: accountParam,
37281
+ confirmToken: confirmTokenParam
36864
37282
  })
36865
- }, async ({ courseId, announcementId, text, state, scheduled, account }) => {
37283
+ }, async ({ courseId, announcementId, text, state, scheduled, account, confirmToken }, ctx) => {
36866
37284
  const args = ["classroom", "announcements", "update", pos(courseId), pos(announcementId)];
36867
37285
  if (text) args.push(`--text=${text}`);
36868
37286
  if (state) args.push(`--state=${state}`);
36869
37287
  if (scheduled) args.push(`--scheduled=${scheduled}`);
37288
+ const publishes = publishesWhen(state, scheduled);
37289
+ if (publishes) {
37290
+ const read = await readCourse(courseId, account, runOrDiagnose);
37291
+ if (read.error) return read.error;
37292
+ const current = await readClassroomWork("announcements", courseId, announcementId, account, runOrDiagnose);
37293
+ if (current.error) return current.error;
37294
+ const published = text || current.work.text;
37295
+ const view = {
37296
+ course: read.course,
37297
+ announcement: { id: announcementId, state: current.work.state },
37298
+ publishes,
37299
+ textPreview: bodyPreview(published)
37300
+ };
37301
+ const confirmation = await requireDispatchConfirmation(ctx, {
37302
+ action: "classroom.announcement-publish",
37303
+ message: "Review and confirm publishing this Classroom announcement to the class:",
37304
+ confirmationLabel: "Confirm that this announcement should be published to the class.",
37305
+ details: view,
37306
+ unsupportedNote: "Leave it as a DRAFT; the user can review and publish it from Classroom.",
37307
+ fallback: {
37308
+ tool: "gog_classroom_announcements_update",
37309
+ account,
37310
+ confirmToken,
37311
+ subject: () => ({
37312
+ target: `${courseId}/${announcementId}`,
37313
+ revision: current.work.updateTime,
37314
+ payload: { course: read.course, announcementId, text: published, state, scheduled },
37315
+ preview: view
37316
+ })
37317
+ }
37318
+ });
37319
+ if (confirmation) return confirmation;
37320
+ }
36870
37321
  return runOrDiagnose(args, { account });
36871
37322
  });
36872
37323
  server.registerTool("gog_classroom_announcements_delete", {