gogcli-mcp-calendar 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 +461 -223
- package/manifest.json +5 -5
- package/package.json +2 -2
- package/src/tools/calendar-extra.ts +114 -9
- package/tests/tools/calendar-extra-gates.test.ts +221 -0
- package/tests/tools/calendar-extra.test.ts +5 -1
package/dist/index.js
CHANGED
|
@@ -34554,10 +34554,8 @@ function errorResult(message) {
|
|
|
34554
34554
|
|
|
34555
34555
|
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
34556
34556
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
34557
|
-
|
|
34558
|
-
|
|
34559
|
-
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";
|
|
34560
|
-
var STATE_PREFIX = "mcpu.confirm.v1.";
|
|
34557
|
+
|
|
34558
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
|
|
34561
34559
|
function canonicalJson(value) {
|
|
34562
34560
|
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
34563
34561
|
return JSON.stringify(value);
|
|
@@ -34568,7 +34566,7 @@ function canonicalJson(value) {
|
|
|
34568
34566
|
if (typeof value === "bigint")
|
|
34569
34567
|
return `{"$bigint":"${value.toString()}"}`;
|
|
34570
34568
|
if (typeof value === "function" || typeof value === "symbol") {
|
|
34571
|
-
throw new TypeError(`
|
|
34569
|
+
throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
|
|
34572
34570
|
}
|
|
34573
34571
|
if (Array.isArray(value))
|
|
34574
34572
|
return `[${value.map(canonicalJson).join(",")}]`;
|
|
@@ -34590,7 +34588,7 @@ function canonicalJson(value) {
|
|
|
34590
34588
|
}
|
|
34591
34589
|
const proto = Object.getPrototypeOf(value);
|
|
34592
34590
|
if (proto !== Object.prototype && proto !== null) {
|
|
34593
|
-
throw new TypeError("
|
|
34591
|
+
throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
|
|
34594
34592
|
}
|
|
34595
34593
|
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
34596
34594
|
return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
|
|
@@ -34598,6 +34596,12 @@ function canonicalJson(value) {
|
|
|
34598
34596
|
function escapeKey(key) {
|
|
34599
34597
|
return key.startsWith("$") ? `$${key}` : key;
|
|
34600
34598
|
}
|
|
34599
|
+
|
|
34600
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
34601
|
+
var DEFAULT_REQUEST_KEY = "confirmation";
|
|
34602
|
+
var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
|
|
34603
|
+
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";
|
|
34604
|
+
var STATE_PREFIX = "mcpu.confirm.v1.";
|
|
34601
34605
|
function bindingKey(binding) {
|
|
34602
34606
|
if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
|
|
34603
34607
|
throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
|
|
@@ -34700,6 +34704,264 @@ ${JSON.stringify(preview, null, 2)}`,
|
|
|
34700
34704
|
});
|
|
34701
34705
|
}
|
|
34702
34706
|
|
|
34707
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
|
|
34708
|
+
import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
34709
|
+
function createSpentTokenStore() {
|
|
34710
|
+
const spent2 = /* @__PURE__ */ new Map();
|
|
34711
|
+
return {
|
|
34712
|
+
has: (nonce) => spent2.has(nonce),
|
|
34713
|
+
add: (nonce, exp) => {
|
|
34714
|
+
spent2.set(nonce, exp);
|
|
34715
|
+
},
|
|
34716
|
+
prune: (now) => {
|
|
34717
|
+
for (const [nonce, exp] of spent2)
|
|
34718
|
+
if (exp < now)
|
|
34719
|
+
spent2.delete(nonce);
|
|
34720
|
+
},
|
|
34721
|
+
clear: () => spent2.clear(),
|
|
34722
|
+
get size() {
|
|
34723
|
+
return spent2.size;
|
|
34724
|
+
}
|
|
34725
|
+
};
|
|
34726
|
+
}
|
|
34727
|
+
var PROCESS_SPENT = createSpentTokenStore();
|
|
34728
|
+
var PREFIX = "mcpu.token.v1.";
|
|
34729
|
+
var DEFAULT_TTL_SECONDS = 600;
|
|
34730
|
+
function tokenKey(key) {
|
|
34731
|
+
const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
|
|
34732
|
+
if (bytes.length < 32)
|
|
34733
|
+
throw new RangeError("confirm token: key must be at least 32 bytes.");
|
|
34734
|
+
return bytes;
|
|
34735
|
+
}
|
|
34736
|
+
function ttlOf(ttlSeconds) {
|
|
34737
|
+
if (ttlSeconds === void 0)
|
|
34738
|
+
return DEFAULT_TTL_SECONDS;
|
|
34739
|
+
if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
|
|
34740
|
+
throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
|
|
34741
|
+
}
|
|
34742
|
+
return ttlSeconds;
|
|
34743
|
+
}
|
|
34744
|
+
function sign(key, body) {
|
|
34745
|
+
return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
|
|
34746
|
+
}
|
|
34747
|
+
function hashConfirmPayload(payload) {
|
|
34748
|
+
return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
|
|
34749
|
+
}
|
|
34750
|
+
function issueConfirmToken(key, binding, options = {}) {
|
|
34751
|
+
const k = tokenKey(key);
|
|
34752
|
+
const now = options.now ?? Date.now();
|
|
34753
|
+
const exp = now + ttlOf(options.ttlSeconds) * 1e3;
|
|
34754
|
+
const claims = {
|
|
34755
|
+
t: binding.tool,
|
|
34756
|
+
...binding.account === void 0 ? {} : { a: binding.account },
|
|
34757
|
+
g: binding.target,
|
|
34758
|
+
...binding.revision === void 0 ? {} : { r: binding.revision },
|
|
34759
|
+
h: binding.payloadHash,
|
|
34760
|
+
exp,
|
|
34761
|
+
n: randomBytes(16).toString("base64url")
|
|
34762
|
+
};
|
|
34763
|
+
const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
34764
|
+
return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
|
|
34765
|
+
}
|
|
34766
|
+
function parseClaims(body) {
|
|
34767
|
+
try {
|
|
34768
|
+
const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
34769
|
+
return claims && typeof claims === "object" ? claims : void 0;
|
|
34770
|
+
} catch {
|
|
34771
|
+
return void 0;
|
|
34772
|
+
}
|
|
34773
|
+
}
|
|
34774
|
+
function verifyConfirmToken(key, token, binding, options = {}) {
|
|
34775
|
+
const k = tokenKey(key);
|
|
34776
|
+
const now = options.now ?? Date.now();
|
|
34777
|
+
const spent2 = options.spent ?? PROCESS_SPENT;
|
|
34778
|
+
spent2.prune(now);
|
|
34779
|
+
if (!token.startsWith(PREFIX))
|
|
34780
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
34781
|
+
const rest = token.slice(PREFIX.length);
|
|
34782
|
+
const dot = rest.indexOf(".");
|
|
34783
|
+
const body = dot < 0 ? "" : rest.slice(0, dot);
|
|
34784
|
+
const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
|
|
34785
|
+
const expected = sign(k, body);
|
|
34786
|
+
if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
|
|
34787
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
34788
|
+
const claims = parseClaims(body);
|
|
34789
|
+
if (!claims)
|
|
34790
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
34791
|
+
if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
|
|
34792
|
+
return { ok: false, error: "TOKEN_INVALID" };
|
|
34793
|
+
}
|
|
34794
|
+
if (spent2.has(claims.n))
|
|
34795
|
+
return { ok: false, error: "TOKEN_REUSED" };
|
|
34796
|
+
if (now > claims.exp)
|
|
34797
|
+
return { ok: false, error: "TOKEN_EXPIRED" };
|
|
34798
|
+
if (claims.r !== binding.revision)
|
|
34799
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
|
|
34800
|
+
if (claims.h !== binding.payloadHash)
|
|
34801
|
+
return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
|
|
34802
|
+
spent2.add(claims.n, claims.exp);
|
|
34803
|
+
return { ok: true };
|
|
34804
|
+
}
|
|
34805
|
+
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.";
|
|
34806
|
+
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.`);
|
|
34807
|
+
var TOKEN_ERROR_NOTE = {
|
|
34808
|
+
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.",
|
|
34809
|
+
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.",
|
|
34810
|
+
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."
|
|
34811
|
+
};
|
|
34812
|
+
var CHANGED_NOTE = {
|
|
34813
|
+
"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.",
|
|
34814
|
+
"payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
|
|
34815
|
+
};
|
|
34816
|
+
function isToolResult(value) {
|
|
34817
|
+
return Array.isArray(value.content);
|
|
34818
|
+
}
|
|
34819
|
+
function rejection2(data) {
|
|
34820
|
+
return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
|
|
34821
|
+
}
|
|
34822
|
+
async function tokenConfirmation(action, fb) {
|
|
34823
|
+
const subject = await fb.subject();
|
|
34824
|
+
if (isToolResult(subject))
|
|
34825
|
+
return subject;
|
|
34826
|
+
const binding = {
|
|
34827
|
+
tool: fb.tool,
|
|
34828
|
+
...fb.account === void 0 ? {} : { account: fb.account },
|
|
34829
|
+
target: subject.target,
|
|
34830
|
+
...subject.revision === void 0 ? {} : { revision: subject.revision },
|
|
34831
|
+
payloadHash: hashConfirmPayload(subject.payload)
|
|
34832
|
+
};
|
|
34833
|
+
const phaseOne = () => {
|
|
34834
|
+
const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
|
|
34835
|
+
return {
|
|
34836
|
+
action,
|
|
34837
|
+
preview: subject.preview,
|
|
34838
|
+
confirmToken: token,
|
|
34839
|
+
expiresAt,
|
|
34840
|
+
ttlSeconds: ttlOf(fb.ttlSeconds),
|
|
34841
|
+
instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
|
|
34842
|
+
};
|
|
34843
|
+
};
|
|
34844
|
+
if (!fb.confirmToken) {
|
|
34845
|
+
return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
|
|
34846
|
+
}
|
|
34847
|
+
const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
|
|
34848
|
+
if (verdict.ok)
|
|
34849
|
+
return void 0;
|
|
34850
|
+
if (verdict.error === "DRAFT_CHANGED") {
|
|
34851
|
+
return rejection2({
|
|
34852
|
+
error: "DRAFT_CHANGED",
|
|
34853
|
+
reason: verdict.reason,
|
|
34854
|
+
note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
|
|
34855
|
+
...phaseOne()
|
|
34856
|
+
});
|
|
34857
|
+
}
|
|
34858
|
+
return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
|
|
34859
|
+
}
|
|
34860
|
+
async function requireConfirmationWithFallback(ctx, options) {
|
|
34861
|
+
const { tokenFallback, ...confirmation } = options;
|
|
34862
|
+
if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
|
|
34863
|
+
return tokenConfirmation(options.action, tokenFallback);
|
|
34864
|
+
}
|
|
34865
|
+
return requireConfirmation(ctx, confirmation);
|
|
34866
|
+
}
|
|
34867
|
+
|
|
34868
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
34869
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
34870
|
+
|
|
34871
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
34872
|
+
import { homedir } from "node:os";
|
|
34873
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
34874
|
+
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
34875
|
+
function readEnvVar(key, opts = {}) {
|
|
34876
|
+
const env = opts.env ?? process.env;
|
|
34877
|
+
const raw = env[key];
|
|
34878
|
+
if (typeof raw === "string") {
|
|
34879
|
+
const trimmed = raw.trim();
|
|
34880
|
+
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
34881
|
+
return trimmed;
|
|
34882
|
+
}
|
|
34883
|
+
}
|
|
34884
|
+
return opts.default;
|
|
34885
|
+
}
|
|
34886
|
+
var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
34887
|
+
var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
34888
|
+
function parseBoolEnv(key, opts = {}) {
|
|
34889
|
+
const fallback = opts.default ?? false;
|
|
34890
|
+
const raw = readEnvVar(key, { env: opts.env });
|
|
34891
|
+
if (raw === void 0)
|
|
34892
|
+
return fallback;
|
|
34893
|
+
const token = raw.toLowerCase();
|
|
34894
|
+
if (TRUE_TOKENS.has(token))
|
|
34895
|
+
return true;
|
|
34896
|
+
if (FALSE_TOKENS.has(token))
|
|
34897
|
+
return false;
|
|
34898
|
+
return fallback;
|
|
34899
|
+
}
|
|
34900
|
+
function expandPath(p) {
|
|
34901
|
+
let expanded = p;
|
|
34902
|
+
if (p === "~") {
|
|
34903
|
+
expanded = homedir();
|
|
34904
|
+
} else if (p.startsWith("~/")) {
|
|
34905
|
+
expanded = join(homedir(), p.slice(2));
|
|
34906
|
+
}
|
|
34907
|
+
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
34908
|
+
}
|
|
34909
|
+
|
|
34910
|
+
// ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
|
|
34911
|
+
var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
|
|
34912
|
+
var DEFAULT_TTL_SECONDS2 = 600;
|
|
34913
|
+
var warned = /* @__PURE__ */ new Set();
|
|
34914
|
+
function readConfirmMode(env = process.env) {
|
|
34915
|
+
const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
|
|
34916
|
+
if (!raw)
|
|
34917
|
+
return "ask-user";
|
|
34918
|
+
if (MODES.has(raw))
|
|
34919
|
+
return raw;
|
|
34920
|
+
if (!warned.has(raw)) {
|
|
34921
|
+
warned.add(raw);
|
|
34922
|
+
process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
|
|
34923
|
+
`);
|
|
34924
|
+
}
|
|
34925
|
+
return "refuse";
|
|
34926
|
+
}
|
|
34927
|
+
function confirmTtlFromEnv(env = process.env) {
|
|
34928
|
+
const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
|
|
34929
|
+
return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
|
|
34930
|
+
}
|
|
34931
|
+
var processKey;
|
|
34932
|
+
function confirmKeyFromEnv(env = process.env) {
|
|
34933
|
+
const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
|
|
34934
|
+
if (secret)
|
|
34935
|
+
return createHash3("sha256").update(secret, "utf8").digest();
|
|
34936
|
+
processKey ??= randomBytes2(32);
|
|
34937
|
+
return processKey;
|
|
34938
|
+
}
|
|
34939
|
+
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.)";
|
|
34940
|
+
var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
|
|
34941
|
+
function confirmationFromEnv(options) {
|
|
34942
|
+
const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
|
|
34943
|
+
const mode = readConfirmMode(env);
|
|
34944
|
+
if (mode === "refuse") {
|
|
34945
|
+
return {
|
|
34946
|
+
...confirmation,
|
|
34947
|
+
unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
|
|
34948
|
+
};
|
|
34949
|
+
}
|
|
34950
|
+
return {
|
|
34951
|
+
...confirmation,
|
|
34952
|
+
tokenFallback: {
|
|
34953
|
+
key: confirmKeyFromEnv(env),
|
|
34954
|
+
tool,
|
|
34955
|
+
...account === void 0 ? {} : { account },
|
|
34956
|
+
...confirmToken === void 0 ? {} : { confirmToken },
|
|
34957
|
+
subject,
|
|
34958
|
+
ttlSeconds: confirmTtlFromEnv(env),
|
|
34959
|
+
instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
|
|
34960
|
+
...spent2 === void 0 ? {} : { spent: spent2 }
|
|
34961
|
+
}
|
|
34962
|
+
};
|
|
34963
|
+
}
|
|
34964
|
+
|
|
34703
34965
|
// ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
|
|
34704
34966
|
var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
34705
34967
|
"2026-07-28",
|
|
@@ -34875,45 +35137,6 @@ function runMcp(opts) {
|
|
|
34875
35137
|
return handle;
|
|
34876
35138
|
}
|
|
34877
35139
|
|
|
34878
|
-
// ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
|
|
34879
|
-
import { homedir } from "node:os";
|
|
34880
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
34881
|
-
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
34882
|
-
function readEnvVar(key, opts = {}) {
|
|
34883
|
-
const env = opts.env ?? process.env;
|
|
34884
|
-
const raw = env[key];
|
|
34885
|
-
if (typeof raw === "string") {
|
|
34886
|
-
const trimmed = raw.trim();
|
|
34887
|
-
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
34888
|
-
return trimmed;
|
|
34889
|
-
}
|
|
34890
|
-
}
|
|
34891
|
-
return opts.default;
|
|
34892
|
-
}
|
|
34893
|
-
var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
34894
|
-
var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
34895
|
-
function parseBoolEnv(key, opts = {}) {
|
|
34896
|
-
const fallback = opts.default ?? false;
|
|
34897
|
-
const raw = readEnvVar(key, { env: opts.env });
|
|
34898
|
-
if (raw === void 0)
|
|
34899
|
-
return fallback;
|
|
34900
|
-
const token = raw.toLowerCase();
|
|
34901
|
-
if (TRUE_TOKENS.has(token))
|
|
34902
|
-
return true;
|
|
34903
|
-
if (FALSE_TOKENS.has(token))
|
|
34904
|
-
return false;
|
|
34905
|
-
return fallback;
|
|
34906
|
-
}
|
|
34907
|
-
function expandPath(p) {
|
|
34908
|
-
let expanded = p;
|
|
34909
|
-
if (p === "~") {
|
|
34910
|
-
expanded = homedir();
|
|
34911
|
-
} else if (p.startsWith("~/")) {
|
|
34912
|
-
expanded = join(homedir(), p.slice(2));
|
|
34913
|
-
}
|
|
34914
|
-
return isAbsolute(expanded) ? expanded : resolve(expanded);
|
|
34915
|
-
}
|
|
34916
|
-
|
|
34917
35140
|
// ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
|
|
34918
35141
|
import { existsSync, realpathSync } from "node:fs";
|
|
34919
35142
|
import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
|
|
@@ -35723,6 +35946,7 @@ async function diagnose(err) {
|
|
|
35723
35946
|
const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
|
|
35724
35947
|
const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
|
|
35725
35948
|
const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
|
|
35949
|
+
if (!isAuthError && !isInvalidGrant) return errorResult(`${errText}${hint}`);
|
|
35726
35950
|
try {
|
|
35727
35951
|
const accounts = formatAccountList(await run(["auth", "list"]));
|
|
35728
35952
|
return errorResult(`${errText}
|
|
@@ -35812,167 +36036,48 @@ function formatAuthHealth(raw, now) {
|
|
|
35812
36036
|
}
|
|
35813
36037
|
|
|
35814
36038
|
// ../gogcli-mcp/src/send-confirm-token.ts
|
|
35815
|
-
|
|
35816
|
-
|
|
35817
|
-
|
|
35818
|
-
var secret;
|
|
35819
|
-
var spent = /* @__PURE__ */ new Map();
|
|
35820
|
-
function sendConfirmFallbackEnabled() {
|
|
35821
|
-
return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
|
|
35822
|
-
}
|
|
35823
|
-
function confirmTokenTtlSeconds() {
|
|
35824
|
-
const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
|
|
35825
|
-
if (raw && /^\d+$/.test(raw)) {
|
|
35826
|
-
const n = Number(raw);
|
|
35827
|
-
if (n > 0) return n;
|
|
35828
|
-
}
|
|
35829
|
-
return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
|
|
35830
|
-
}
|
|
35831
|
-
function hmacKey() {
|
|
35832
|
-
if (!secret) {
|
|
35833
|
-
const configured = readEnvVar("GOG_CONFIRM_SECRET");
|
|
35834
|
-
secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
|
|
35835
|
-
}
|
|
35836
|
-
return secret;
|
|
35837
|
-
}
|
|
35838
|
-
function canonicalize(value) {
|
|
35839
|
-
if (Array.isArray(value)) return value.map(canonicalize);
|
|
35840
|
-
if (value && typeof value === "object") {
|
|
35841
|
-
const out = {};
|
|
35842
|
-
for (const key of Object.keys(value).sort()) {
|
|
35843
|
-
const v = value[key];
|
|
35844
|
-
if (v !== void 0) out[key] = canonicalize(v);
|
|
35845
|
-
}
|
|
35846
|
-
return out;
|
|
35847
|
-
}
|
|
35848
|
-
return value;
|
|
35849
|
-
}
|
|
35850
|
-
function hashSendPayload(payload) {
|
|
35851
|
-
return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
|
|
35852
|
-
}
|
|
35853
|
-
function sign(body) {
|
|
35854
|
-
return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
|
|
35855
|
-
}
|
|
35856
|
-
function issueConfirmToken(binding, now = Date.now()) {
|
|
35857
|
-
const exp = now + confirmTokenTtlSeconds() * 1e3;
|
|
35858
|
-
const claims = {
|
|
35859
|
-
t: binding.tool,
|
|
35860
|
-
a: binding.account,
|
|
35861
|
-
g: binding.target,
|
|
35862
|
-
...binding.revision === void 0 ? {} : { r: binding.revision },
|
|
35863
|
-
h: binding.payloadHash,
|
|
35864
|
-
iat: now,
|
|
35865
|
-
exp,
|
|
35866
|
-
n: randomBytes(16).toString("base64url")
|
|
35867
|
-
};
|
|
35868
|
-
const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
|
|
35869
|
-
return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
|
|
35870
|
-
}
|
|
35871
|
-
function signatureMatches(body, sig) {
|
|
35872
|
-
const expected = Buffer.from(sign(body), "utf8");
|
|
35873
|
-
const actual = Buffer.from(sig, "utf8");
|
|
35874
|
-
return expected.length === actual.length && timingSafeEqual2(expected, actual);
|
|
35875
|
-
}
|
|
35876
|
-
function parseClaims(body) {
|
|
35877
|
-
try {
|
|
35878
|
-
return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
35879
|
-
} catch {
|
|
35880
|
-
return void 0;
|
|
35881
|
-
}
|
|
35882
|
-
}
|
|
35883
|
-
function verifyConfirmToken(token, binding, now = Date.now()) {
|
|
35884
|
-
for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
|
|
35885
|
-
const parts = token.split(".");
|
|
35886
|
-
if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
|
|
35887
|
-
const [, body, sig] = parts;
|
|
35888
|
-
if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
|
|
35889
|
-
const claims = parseClaims(body);
|
|
35890
|
-
if (!claims) return { ok: false, error: "TOKEN_INVALID" };
|
|
35891
|
-
if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
|
|
35892
|
-
return { ok: false, error: "TOKEN_INVALID" };
|
|
35893
|
-
}
|
|
35894
|
-
if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
|
|
35895
|
-
if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
|
|
35896
|
-
if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
|
|
35897
|
-
if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
|
|
35898
|
-
spent.set(claims.n, claims.exp);
|
|
35899
|
-
return { ok: true };
|
|
36039
|
+
var spent = createSpentTokenStore();
|
|
36040
|
+
function confirmSpentStore() {
|
|
36041
|
+
return spent;
|
|
35900
36042
|
}
|
|
35901
36043
|
|
|
35902
36044
|
// ../gogcli-mcp/src/dispatch-confirmation.ts
|
|
35903
|
-
var CONFIRM_ACTION_INSTRUCTION =
|
|
35904
|
-
var
|
|
35905
|
-
|
|
35906
|
-
|
|
35907
|
-
`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.`
|
|
35908
|
-
);
|
|
35909
|
-
var TOKEN_ERROR_NOTE = {
|
|
35910
|
-
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.",
|
|
35911
|
-
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.",
|
|
35912
|
-
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."
|
|
35913
|
-
};
|
|
35914
|
-
var DRAFT_CHANGED_NOTE = {
|
|
35915
|
-
"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.",
|
|
35916
|
-
"payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
|
|
35917
|
-
};
|
|
35918
|
-
function isToolResult(value) {
|
|
35919
|
-
return Array.isArray(value.content);
|
|
36045
|
+
var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
|
|
36046
|
+
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.';
|
|
36047
|
+
function refusedInRun(what, via, does, instead) {
|
|
36048
|
+
return `${what} ${does} and is not available through ${via}. ${instead}`;
|
|
35920
36049
|
}
|
|
35921
|
-
function
|
|
35922
|
-
return
|
|
36050
|
+
function gatedElsewhere(what, via, does, tool) {
|
|
36051
|
+
return refusedInRun(what, via, does, `Use ${tool}, which asks the user to confirm.`);
|
|
35923
36052
|
}
|
|
35924
|
-
|
|
35925
|
-
const
|
|
35926
|
-
|
|
35927
|
-
|
|
35928
|
-
|
|
35929
|
-
|
|
35930
|
-
target: subject.target,
|
|
35931
|
-
...subject.revision === void 0 ? {} : { revision: subject.revision },
|
|
35932
|
-
payloadHash: hashSendPayload(subject.payload)
|
|
35933
|
-
};
|
|
35934
|
-
const phaseOne = () => {
|
|
35935
|
-
const { token, expiresAt } = issueConfirmToken(binding);
|
|
35936
|
-
return {
|
|
35937
|
-
action: op,
|
|
35938
|
-
preview: subject.preview,
|
|
35939
|
-
confirmToken: token,
|
|
35940
|
-
expiresAt,
|
|
35941
|
-
ttlSeconds: confirmTokenTtlSeconds(),
|
|
35942
|
-
instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
|
|
35943
|
-
};
|
|
35944
|
-
};
|
|
35945
|
-
if (!fallback.confirmToken) {
|
|
35946
|
-
return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
|
|
35947
|
-
}
|
|
35948
|
-
const verdict = verifyConfirmToken(fallback.confirmToken, binding);
|
|
35949
|
-
if (verdict.ok) return void 0;
|
|
35950
|
-
if (verdict.error === "DRAFT_CHANGED") {
|
|
35951
|
-
return rejection2({
|
|
35952
|
-
error: "DRAFT_CHANGED",
|
|
35953
|
-
reason: verdict.reason,
|
|
35954
|
-
note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
|
|
35955
|
-
...phaseOne()
|
|
35956
|
-
});
|
|
36053
|
+
function flagValue(args, name) {
|
|
36054
|
+
const flag = `--${name}`;
|
|
36055
|
+
for (let i = 0; i < args.length; i++) {
|
|
36056
|
+
const a = args[i];
|
|
36057
|
+
if (a === flag) return args[i + 1] ?? "";
|
|
36058
|
+
if (a.startsWith(`${flag}=`)) return a.slice(flag.length + 1);
|
|
35957
36059
|
}
|
|
35958
|
-
return
|
|
35959
|
-
}
|
|
35960
|
-
function gatedElsewhere(what, via, does, tool) {
|
|
35961
|
-
return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
|
|
36060
|
+
return void 0;
|
|
35962
36061
|
}
|
|
35963
36062
|
async function requireDispatchConfirmation(ctx, options) {
|
|
35964
36063
|
const { action, fallback } = options;
|
|
35965
|
-
|
|
35966
|
-
return tokenConfirmation(action, fallback);
|
|
35967
|
-
}
|
|
35968
|
-
const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
|
|
35969
|
-
return requireConfirmation(ctx, {
|
|
36064
|
+
const confirmation = {
|
|
35970
36065
|
action,
|
|
35971
36066
|
message: options.message,
|
|
35972
36067
|
details: options.details,
|
|
35973
36068
|
confirmationLabel: options.confirmationLabel,
|
|
35974
|
-
...
|
|
35975
|
-
}
|
|
36069
|
+
...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
|
|
36070
|
+
};
|
|
36071
|
+
if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
|
|
36072
|
+
return requireConfirmationWithFallback(ctx, confirmationFromEnv({
|
|
36073
|
+
...confirmation,
|
|
36074
|
+
tool: fallback.tool,
|
|
36075
|
+
account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
|
|
36076
|
+
confirmToken: fallback.confirmToken,
|
|
36077
|
+
subject: fallback.subject,
|
|
36078
|
+
instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
|
|
36079
|
+
spent: confirmSpentStore()
|
|
36080
|
+
}));
|
|
35976
36081
|
}
|
|
35977
36082
|
function resultText(result) {
|
|
35978
36083
|
const first = result.content[0];
|
|
@@ -36114,21 +36219,47 @@ function authToolsFor(defaultServices) {
|
|
|
36114
36219
|
}
|
|
36115
36220
|
|
|
36116
36221
|
// ../gogcli-mcp/src/tools/calendar.ts
|
|
36117
|
-
var
|
|
36118
|
-
|
|
36119
|
-
|
|
36120
|
-
|
|
36121
|
-
|
|
36122
|
-
|
|
36123
|
-
|
|
36124
|
-
|
|
36125
|
-
|
|
36126
|
-
|
|
36222
|
+
var ASKS = (tool) => `Use ${tool}, which asks the user to confirm.`;
|
|
36223
|
+
var CALENDAR_REFUSED = {
|
|
36224
|
+
create: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
|
|
36225
|
+
add: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
|
|
36226
|
+
new: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
|
|
36227
|
+
update: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
|
|
36228
|
+
edit: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
|
|
36229
|
+
set: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
|
|
36230
|
+
respond: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
|
|
36231
|
+
rsvp: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
|
|
36232
|
+
reply: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
|
|
36233
|
+
move: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
|
|
36234
|
+
transfer: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
|
|
36235
|
+
delete: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
|
|
36236
|
+
del: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
|
|
36237
|
+
rm: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
|
|
36238
|
+
remove: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
|
|
36239
|
+
"delete-calendar": { does: "deletes a calendar and every event on it", instead: ASKS("gog_calendar_delete_calendar") },
|
|
36240
|
+
"out-of-office": { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") },
|
|
36241
|
+
ooo: { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") }
|
|
36127
36242
|
};
|
|
36128
|
-
function vetCalendarRun(subcommand,
|
|
36243
|
+
function vetCalendarRun(subcommand, args) {
|
|
36129
36244
|
const sub = subcommand.toLowerCase();
|
|
36130
|
-
const
|
|
36131
|
-
|
|
36245
|
+
const what = `gog calendar ${sub}`;
|
|
36246
|
+
const via = "gog_calendar_run";
|
|
36247
|
+
if (Object.hasOwn(CALENDAR_REFUSED, sub)) {
|
|
36248
|
+
const { does, instead } = CALENDAR_REFUSED[sub];
|
|
36249
|
+
return refusedInRun(what, via, does, instead);
|
|
36250
|
+
}
|
|
36251
|
+
if (sub === "propose-time" && (flagValue(args, "decline") !== void 0 || flagValue(args, "comment") !== void 0)) {
|
|
36252
|
+
return gatedElsewhere(`${what} --decline`, via, "declines the event and notifies the organizer", "gog_calendar_respond");
|
|
36253
|
+
}
|
|
36254
|
+
if ((sub === "focus-time" || sub === "focus") && flagValue(args, "auto-decline")?.toLowerCase() !== "none") {
|
|
36255
|
+
return refusedInRun(
|
|
36256
|
+
what,
|
|
36257
|
+
via,
|
|
36258
|
+
"auto-declines invitations and notifies their organizers (gog defaults --auto-decline to all)",
|
|
36259
|
+
"Pass --auto-decline=none, or ask the user to create it from Google Calendar."
|
|
36260
|
+
);
|
|
36261
|
+
}
|
|
36262
|
+
return void 0;
|
|
36132
36263
|
}
|
|
36133
36264
|
function parseAttendees(value) {
|
|
36134
36265
|
if (!value) return [];
|
|
@@ -36153,6 +36284,8 @@ function eventSnapshot(raw) {
|
|
|
36153
36284
|
organizer: str(event?.organizer?.email),
|
|
36154
36285
|
// Guests are the OTHER people: not this account's own attendee row, not rooms.
|
|
36155
36286
|
guests: (Array.isArray(event?.attendees) ? event.attendees : []).filter((a) => a.self !== true && a.resource !== true && typeof a.email === "string").map((a) => a.email),
|
|
36287
|
+
// A series, or one instance of one: gog's delete --scope defaults to all.
|
|
36288
|
+
...Array.isArray(event?.recurrence) && event.recurrence.length > 0 || typeof event?.recurringEventId === "string" ? { recurring: true } : {},
|
|
36156
36289
|
etag: str(event?.etag)
|
|
36157
36290
|
};
|
|
36158
36291
|
}
|
|
@@ -36374,14 +36507,35 @@ function registerCalendarTools(server) {
|
|
|
36374
36507
|
return runOrDiagnose(args, { account });
|
|
36375
36508
|
});
|
|
36376
36509
|
server.registerTool("gog_calendar_delete", {
|
|
36377
|
-
description: "Delete a calendar event.",
|
|
36510
|
+
description: "Delete a calendar event. It disappears from every guest's calendar too, and for a recurring event gog deletes the WHOLE series, so when the event has guests or recurs this reads it and asks the MCP host to show the user a confirmation prompt with the event as it stands; a guest-free, one-off event is deleted without asking." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36378
36511
|
annotations: { destructiveHint: true },
|
|
36379
36512
|
inputSchema: external_exports.object({
|
|
36380
36513
|
calendarId: external_exports.string().describe("Calendar ID"),
|
|
36381
36514
|
eventId: external_exports.string().describe("Event ID"),
|
|
36382
|
-
account: accountParam
|
|
36515
|
+
account: accountParam,
|
|
36516
|
+
confirmToken: confirmTokenParam
|
|
36383
36517
|
})
|
|
36384
|
-
}, async ({ calendarId, eventId, account }) => {
|
|
36518
|
+
}, async ({ calendarId, eventId, account, confirmToken }, ctx) => {
|
|
36519
|
+
const read = await readEvent(calendarId, eventId, account);
|
|
36520
|
+
if (read.error) return read.error;
|
|
36521
|
+
const { etag, ...event } = read.event;
|
|
36522
|
+
if (event.guests.length > 0 || event.recurring) {
|
|
36523
|
+
const view = { calendarId, eventId, event, scope: event.recurring ? "the whole recurring series" : "this event" };
|
|
36524
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
36525
|
+
action: "calendar.delete",
|
|
36526
|
+
message: event.recurring ? "Review and confirm deleting this ENTIRE recurring series:" : "Review and confirm deleting this event from every guest's calendar:",
|
|
36527
|
+
confirmationLabel: "Confirm that this event should be deleted now.",
|
|
36528
|
+
details: view,
|
|
36529
|
+
unsupportedNote: "Ask the user to delete it from Google Calendar.",
|
|
36530
|
+
fallback: {
|
|
36531
|
+
tool: "gog_calendar_delete",
|
|
36532
|
+
account,
|
|
36533
|
+
confirmToken,
|
|
36534
|
+
subject: () => ({ target: `${calendarId}/${eventId}`, revision: etag, payload: view, preview: view })
|
|
36535
|
+
}
|
|
36536
|
+
});
|
|
36537
|
+
if (confirmation) return confirmation;
|
|
36538
|
+
}
|
|
36385
36539
|
return runOrDiagnose(["calendar", "delete", pos(calendarId), pos(eventId), "--force"], { account });
|
|
36386
36540
|
});
|
|
36387
36541
|
server.registerTool("gog_calendar_respond", {
|
|
@@ -36474,7 +36628,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
36474
36628
|
);
|
|
36475
36629
|
|
|
36476
36630
|
// ../gogcli-mcp/src/server.ts
|
|
36477
|
-
var VERSION = true ? "4.
|
|
36631
|
+
var VERSION = true ? "4.5.1" : "0.0.0";
|
|
36478
36632
|
|
|
36479
36633
|
// ../gogcli-mcp/src/bootstrap-auth.ts
|
|
36480
36634
|
import { join as join5 } from "node:path";
|
|
@@ -36511,12 +36665,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
|
|
|
36511
36665
|
const [clientId, clientSecret, refreshToken, account] = values;
|
|
36512
36666
|
const { spawner } = options;
|
|
36513
36667
|
try {
|
|
36514
|
-
const { createHash:
|
|
36668
|
+
const { createHash: createHash4 } = await import("node:crypto");
|
|
36515
36669
|
const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
|
|
36516
36670
|
const home = options.home ?? (await import("node:os")).homedir();
|
|
36517
36671
|
const dir = join5(home, ".gogcli-mcp");
|
|
36518
36672
|
const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
|
|
36519
|
-
const fingerprint =
|
|
36673
|
+
const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
|
|
36520
36674
|
const previous = await readFile(marker, "utf8").catch(() => void 0);
|
|
36521
36675
|
if (previous === fingerprint && await accountListed(account, spawner)) return "present";
|
|
36522
36676
|
await run(
|
|
@@ -36550,6 +36704,20 @@ var MAX_BLOB_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
|
36550
36704
|
|
|
36551
36705
|
// src/tools/calendar-extra.ts
|
|
36552
36706
|
var meetAccess = external_exports.enum(["open", "trusted", "restricted"]);
|
|
36707
|
+
function calendarSnapshot(raw, calendarId) {
|
|
36708
|
+
let cal;
|
|
36709
|
+
try {
|
|
36710
|
+
const parsed = JSON.parse(raw);
|
|
36711
|
+
cal = parsed?.result ?? parsed ?? void 0;
|
|
36712
|
+
} catch {
|
|
36713
|
+
cal = void 0;
|
|
36714
|
+
}
|
|
36715
|
+
return {
|
|
36716
|
+
id: calendarId,
|
|
36717
|
+
...typeof cal?.summary === "string" ? { summary: cal.summary } : {},
|
|
36718
|
+
...typeof cal?.etag === "string" ? { etag: cal.etag } : {}
|
|
36719
|
+
};
|
|
36720
|
+
}
|
|
36553
36721
|
function registerExtraCalendarTools(server) {
|
|
36554
36722
|
server.registerTool("gog_meet_create", {
|
|
36555
36723
|
description: "Create a Google Meet space and return its meeting code.",
|
|
@@ -36764,34 +36932,56 @@ function registerExtraCalendarTools(server) {
|
|
|
36764
36932
|
return runOrDiagnose(args, { account });
|
|
36765
36933
|
});
|
|
36766
36934
|
server.registerTool("gog_calendar_move", {
|
|
36767
|
-
description: "Move an event from one calendar to another; the destination calendar becomes the organizer.",
|
|
36935
|
+
description: "Move an event from one calendar to another; the destination calendar becomes the organizer. With sendUpdates all or externalOnly Google emails the guests, so this reads the event and asks the MCP host to show the user a confirmation prompt with the event, its guests and the destination first; a move that notifies nobody (the default) is made without asking." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36768
36936
|
annotations: { destructiveHint: false },
|
|
36769
36937
|
inputSchema: external_exports.object({
|
|
36770
36938
|
calendarId: external_exports.string().describe("Source calendar ID"),
|
|
36771
36939
|
eventId: external_exports.string().describe("Event ID"),
|
|
36772
36940
|
destinationCalendarId: external_exports.string().describe("Destination calendar ID that becomes the event organizer"),
|
|
36773
|
-
sendUpdates: external_exports.enum(["all", "externalOnly", "none"]).optional().describe("Notification mode (default: none)"),
|
|
36774
|
-
account: accountParam
|
|
36941
|
+
sendUpdates: external_exports.enum(["all", "externalOnly", "none"]).optional().describe("Notification mode (default: none). all / externalOnly email the guests and ask the user first."),
|
|
36942
|
+
account: accountParam,
|
|
36943
|
+
confirmToken: confirmTokenParam
|
|
36775
36944
|
})
|
|
36776
|
-
}, async ({ calendarId, eventId, destinationCalendarId, sendUpdates, account }) => {
|
|
36945
|
+
}, async ({ calendarId, eventId, destinationCalendarId, sendUpdates, account, confirmToken }, ctx) => {
|
|
36777
36946
|
const args = ["calendar", "move", pos(calendarId), pos(eventId), pos(destinationCalendarId)];
|
|
36778
36947
|
if (sendUpdates) args.push(`--send-updates=${sendUpdates}`);
|
|
36948
|
+
if (sendUpdates === "all" || sendUpdates === "externalOnly") {
|
|
36949
|
+
const got = await runOrDiagnose(["calendar", "event", pos(calendarId), pos(eventId)], { account });
|
|
36950
|
+
if (got.isError) return got;
|
|
36951
|
+
const { etag, ...event } = eventSnapshot(resultText(got));
|
|
36952
|
+
const view = { calendarId, eventId, event, destinationCalendarId, emails: sendUpdates === "all" ? "every guest" : "guests outside your domain" };
|
|
36953
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
36954
|
+
action: "calendar.move",
|
|
36955
|
+
message: "Review and confirm moving this event \u2014 Google will email the guests:",
|
|
36956
|
+
confirmationLabel: "Confirm that this event should be moved and the guests notified now.",
|
|
36957
|
+
details: view,
|
|
36958
|
+
unsupportedNote: "Move it with sendUpdates none instead, which notifies nobody.",
|
|
36959
|
+
fallback: {
|
|
36960
|
+
tool: "gog_calendar_move",
|
|
36961
|
+
account,
|
|
36962
|
+
confirmToken,
|
|
36963
|
+
subject: () => ({ target: `${calendarId}/${eventId}`, revision: etag, payload: view, preview: view })
|
|
36964
|
+
}
|
|
36965
|
+
});
|
|
36966
|
+
if (confirmation) return confirmation;
|
|
36967
|
+
}
|
|
36779
36968
|
return runOrDiagnose(args, { account });
|
|
36780
36969
|
});
|
|
36781
36970
|
server.registerTool("gog_calendar_out_of_office", {
|
|
36782
|
-
description: "Create an Out of Office event that auto-declines invitations during the block.",
|
|
36971
|
+
description: "Create an Out of Office event that auto-declines invitations during the block. gog auto-declines EVERY conflicting meeting by default (autoDecline all), and each organizer is notified, so unless autoDecline is none this asks the MCP host to show the user a confirmation prompt with the window, the decline mode and the message first; nothing is created unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36783
36972
|
annotations: { destructiveHint: true },
|
|
36784
36973
|
inputSchema: external_exports.object({
|
|
36785
36974
|
from: external_exports.string().describe("Start date or datetime (RFC3339 or YYYY-MM-DD)"),
|
|
36786
36975
|
to: external_exports.string().describe("End date or datetime (RFC3339 or YYYY-MM-DD)"),
|
|
36787
36976
|
calendarId: external_exports.string().optional().describe("Calendar ID (default: primary)"),
|
|
36788
36977
|
summary: external_exports.string().optional().describe('Out of office title (default: "Out of office")'),
|
|
36789
|
-
autoDecline: external_exports.enum(["none", "all", "new"]).optional().describe("Auto-decline mode (default: all)"),
|
|
36978
|
+
autoDecline: external_exports.enum(["none", "all", "new"]).optional().describe("Auto-decline mode (default: all \u2014 declines existing AND new conflicting meetings; none notifies nobody and does not ask)"),
|
|
36790
36979
|
declineMessage: external_exports.string().optional().describe("Message for declined invitations"),
|
|
36791
36980
|
allDay: external_exports.boolean().optional().describe("Create as an all-day event"),
|
|
36792
|
-
account: accountParam
|
|
36981
|
+
account: accountParam,
|
|
36982
|
+
confirmToken: confirmTokenParam
|
|
36793
36983
|
})
|
|
36794
|
-
}, async ({ from, to, calendarId, summary, autoDecline, declineMessage, allDay, account }) => {
|
|
36984
|
+
}, async ({ from, to, calendarId, summary, autoDecline, declineMessage, allDay, account, confirmToken }, ctx) => {
|
|
36795
36985
|
const args = ["calendar", "out-of-office"];
|
|
36796
36986
|
if (calendarId) args.push(pos(calendarId));
|
|
36797
36987
|
args.push(`--from=${from}`);
|
|
@@ -36800,6 +36990,32 @@ function registerExtraCalendarTools(server) {
|
|
|
36800
36990
|
if (autoDecline) args.push(`--auto-decline=${autoDecline}`);
|
|
36801
36991
|
if (declineMessage) args.push(`--decline-message=${declineMessage}`);
|
|
36802
36992
|
if (allDay) args.push("--all-day");
|
|
36993
|
+
if (autoDecline !== "none") {
|
|
36994
|
+
const mode = autoDecline ?? "all";
|
|
36995
|
+
const view = {
|
|
36996
|
+
calendarId: calendarId ?? "primary",
|
|
36997
|
+
from,
|
|
36998
|
+
to,
|
|
36999
|
+
allDay: Boolean(allDay),
|
|
37000
|
+
summary: summary ?? "Out of office",
|
|
37001
|
+
declines: mode === "all" ? "every existing and new conflicting meeting" : "new conflicting invitations",
|
|
37002
|
+
declineMessage
|
|
37003
|
+
};
|
|
37004
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
37005
|
+
action: "calendar.out-of-office",
|
|
37006
|
+
message: "Review and confirm this Out of Office block \u2014 conflicting meetings are declined and their organizers notified:",
|
|
37007
|
+
confirmationLabel: "Confirm that meetings in this window should be auto-declined.",
|
|
37008
|
+
details: view,
|
|
37009
|
+
unsupportedNote: "Create it with autoDecline none instead; the user can turn on auto-decline in Google Calendar.",
|
|
37010
|
+
fallback: {
|
|
37011
|
+
tool: "gog_calendar_out_of_office",
|
|
37012
|
+
account,
|
|
37013
|
+
confirmToken,
|
|
37014
|
+
subject: () => ({ target: view.calendarId, payload: view, preview: view })
|
|
37015
|
+
}
|
|
37016
|
+
});
|
|
37017
|
+
if (confirmation) return confirmation;
|
|
37018
|
+
}
|
|
36803
37019
|
return runOrDiagnose(args, { account });
|
|
36804
37020
|
});
|
|
36805
37021
|
server.registerTool("gog_calendar_unsubscribe", {
|
|
@@ -36813,13 +37029,35 @@ function registerExtraCalendarTools(server) {
|
|
|
36813
37029
|
return runOrDiagnose(["calendar", "unsubscribe", pos(calendarId)], { account });
|
|
36814
37030
|
});
|
|
36815
37031
|
server.registerTool("gog_calendar_delete_calendar", {
|
|
36816
|
-
description: "Permanently delete an owned secondary calendar and all its events. Cannot delete your primary calendar. To merely remove a calendar you do not own from your list, use gog_calendar_unsubscribe.",
|
|
37032
|
+
description: "Permanently delete an owned secondary calendar and all its events. Cannot delete your primary calendar. To merely remove a calendar you do not own from your list, use gog_calendar_unsubscribe. Reads the calendar and asks the MCP host to show the user a confirmation prompt naming it first; nothing is deleted unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
|
|
36817
37033
|
annotations: { destructiveHint: true },
|
|
36818
37034
|
inputSchema: external_exports.object({
|
|
36819
37035
|
calendarId: external_exports.string().describe("Owned secondary calendar ID or alias"),
|
|
36820
|
-
account: accountParam
|
|
37036
|
+
account: accountParam,
|
|
37037
|
+
confirmToken: confirmTokenParam
|
|
36821
37038
|
})
|
|
36822
|
-
}, async ({ calendarId, account }) => {
|
|
37039
|
+
}, async ({ calendarId, account, confirmToken }, ctx) => {
|
|
37040
|
+
const got = await runOrDiagnose(
|
|
37041
|
+
["api", "call", "calendar", "v3", "calendars.get", `--params=${JSON.stringify({ calendarId })}`],
|
|
37042
|
+
{ account }
|
|
37043
|
+
);
|
|
37044
|
+
if (got.isError) return got;
|
|
37045
|
+
const { etag, ...calendar } = calendarSnapshot(resultText(got), calendarId);
|
|
37046
|
+
const view = { calendar, deletes: "the calendar and every event on it, for good" };
|
|
37047
|
+
const confirmation = await requireDispatchConfirmation(ctx, {
|
|
37048
|
+
action: "calendar.delete-calendar",
|
|
37049
|
+
message: "Review and confirm PERMANENTLY deleting this calendar and all of its events:",
|
|
37050
|
+
confirmationLabel: "Confirm that this calendar should be deleted now.",
|
|
37051
|
+
details: view,
|
|
37052
|
+
unsupportedNote: "Ask the user to delete it from Google Calendar's settings, or use gog_calendar_unsubscribe to only hide it.",
|
|
37053
|
+
fallback: {
|
|
37054
|
+
tool: "gog_calendar_delete_calendar",
|
|
37055
|
+
account,
|
|
37056
|
+
confirmToken,
|
|
37057
|
+
subject: () => ({ target: calendarId, revision: etag, payload: view, preview: view })
|
|
37058
|
+
}
|
|
37059
|
+
});
|
|
37060
|
+
if (confirmation) return confirmation;
|
|
36823
37061
|
return runOrDiagnose(["calendar", "delete-calendar", pos(calendarId), "--force"], { account });
|
|
36824
37062
|
});
|
|
36825
37063
|
server.registerTool("gog_meet_participants", {
|