gogcli-mcp 2.21.1 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/index.js +119 -8
- package/dist/lib.js +119 -8
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/auth-log.ts +59 -1
- package/src/connector-auth.ts +265 -8
- package/src/connector-runtime.ts +186 -1
- package/src/google-probe.ts +113 -0
- package/src/timestamps.ts +7 -0
- package/src/tools/auth.ts +8 -2
- package/src/worker.ts +25 -6
- package/tests/auth-log.test.ts +24 -2
- package/tests/connector-auth.test.ts +539 -8
- package/tests/connector-runtime.test.ts +447 -1
- package/tests/google-probe.test.ts +116 -0
- package/tests/timestamps.test.ts +52 -0
- package/tests/tools/auth.test.ts +28 -0
- package/tests/worker.test.ts +33 -8
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "Google Sheets (and more) for Claude via gogcli — read, write, and manage spreadsheets",
|
|
10
|
-
"version": "2.
|
|
10
|
+
"version": "2.22.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "gogcli",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "Google Sheets (and more) for Claude via gogcli — read, write, and manage spreadsheets",
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.22.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
package/dist/index.js
CHANGED
|
@@ -31440,6 +31440,13 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
31440
31440
|
// Calendar event start/end
|
|
31441
31441
|
"internalDate",
|
|
31442
31442
|
// Gmail, epoch milliseconds (authoritative)
|
|
31443
|
+
// gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
|
|
31444
|
+
// (RFC3339 from internalDate), so it needs no offset repair — it is
|
|
31445
|
+
// allowlisted purely to gain a Display sibling, and to be re-rendered in
|
|
31446
|
+
// DISPLAY_TZ like every other instant. Separately sourced from the sibling
|
|
31447
|
+
// `date`, which is a naive re-format of the sender's Date header; the two may
|
|
31448
|
+
// legitimately disagree. See docs/timestamps.md.
|
|
31449
|
+
"internalDateIso",
|
|
31443
31450
|
"modifiedTime",
|
|
31444
31451
|
// Drive
|
|
31445
31452
|
"createdTime",
|
|
@@ -31676,8 +31683,8 @@ function formatOneAccountHealth(a, now) {
|
|
|
31676
31683
|
const age = ageInDays(a.created_at, now);
|
|
31677
31684
|
const ageStr = age === null ? "" : ` Authorized ${age.toFixed(1)} day(s) ago.`;
|
|
31678
31685
|
if (a.valid === false) {
|
|
31679
|
-
const
|
|
31680
|
-
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${
|
|
31686
|
+
const cause2 = INVALID_GRANT_PATTERN.test(a.error ?? "") ? 'refresh token expired or revoked \u2014 commonly the 7-day limit on OAuth consent screens still in "Testing" mode' : a.error?.trim() || "unknown error";
|
|
31687
|
+
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${cause2}.${ageStr} Re-authorize with gog_auth_add (browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless).`;
|
|
31681
31688
|
}
|
|
31682
31689
|
if (a.valid === true) {
|
|
31683
31690
|
let line = `\u2713 ${email3}: token valid.${ageStr}`;
|
|
@@ -31773,7 +31780,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31773
31780
|
}
|
|
31774
31781
|
});
|
|
31775
31782
|
server.registerTool("gog_auth_status", {
|
|
31776
|
-
description: "Show gogcli auth
|
|
31783
|
+
description: "Show gogcli auth CONFIGURATION: keyring backend, credential files, and auth setup. Despite the name this is not a health check \u2014 it reads local setup and does not contact Google, so it says nothing about whether an account can still authenticate. Use gog_auth_health for that.",
|
|
31777
31784
|
annotations: { readOnlyHint: true },
|
|
31778
31785
|
inputSchema: {}
|
|
31779
31786
|
}, async () => {
|
|
@@ -31784,7 +31791,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31784
31791
|
}
|
|
31785
31792
|
});
|
|
31786
31793
|
server.registerTool("gog_auth_health", {
|
|
31787
|
-
description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task.',
|
|
31794
|
+
description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task. On the hosted connector this is the ONLY check that measures Google: a connector showing "connected" or "refreshed" has verified the connector key that reaches the gog machine, and nothing else \u2014 the Google credential lives on that machine and can be dead while the connection looks perfectly healthy.',
|
|
31788
31795
|
annotations: { readOnlyHint: true },
|
|
31789
31796
|
inputSchema: {}
|
|
31790
31797
|
}, async () => {
|
|
@@ -33131,7 +33138,7 @@ function registerTasksTools(server) {
|
|
|
33131
33138
|
}
|
|
33132
33139
|
|
|
33133
33140
|
// src/server.ts
|
|
33134
|
-
var VERSION = true ? "2.
|
|
33141
|
+
var VERSION = true ? "2.22.0" : "0.0.0";
|
|
33135
33142
|
var BASE_TOOL_REGISTRARS = [
|
|
33136
33143
|
registerApiTools,
|
|
33137
33144
|
registerAuthTools,
|
|
@@ -33151,7 +33158,22 @@ var FAILURES = /* @__PURE__ */ new Set([
|
|
|
33151
33158
|
"token.mint-failed",
|
|
33152
33159
|
"grant.dead",
|
|
33153
33160
|
"replay.failed",
|
|
33154
|
-
"runner.auth-failed"
|
|
33161
|
+
"runner.auth-failed",
|
|
33162
|
+
"connect.key-rejected",
|
|
33163
|
+
// An enrolment that could not proceed is a failure even though nobody is at
|
|
33164
|
+
// fault: it is the only trace a half-enrolled connector leaves behind, and
|
|
33165
|
+
// the absence of exactly this record is why DEFECT 4 could not be explained.
|
|
33166
|
+
"connect.runner-unreachable",
|
|
33167
|
+
"connect.google-unhealthy",
|
|
33168
|
+
"refusal.google-unhealthy",
|
|
33169
|
+
// The loudest record on this branch, and the only one that means "we cannot
|
|
33170
|
+
// explain this". Google refused a real call while a live check of the same
|
|
33171
|
+
// credential, taken seconds later, succeeded — so neither the 7-day cliff nor
|
|
33172
|
+
// a revoked grant accounts for it. It is filed as a failure precisely because
|
|
33173
|
+
// it is the record nobody may scroll past: it is the only evidence that could
|
|
33174
|
+
// ever justify building something on the hosted path, and its absence over
|
|
33175
|
+
// time is what retires that theory for good.
|
|
33176
|
+
"refusal.google-ok"
|
|
33155
33177
|
]);
|
|
33156
33178
|
var PREFIX = "gog-auth ";
|
|
33157
33179
|
var TAG_CHARS = 12;
|
|
@@ -33298,10 +33320,39 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
33298
33320
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
33299
33321
|
}
|
|
33300
33322
|
|
|
33323
|
+
// src/google-probe.ts
|
|
33324
|
+
var bool = (value) => typeof value === "boolean" ? value : void 0;
|
|
33325
|
+
var cause = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
33326
|
+
function readGoogleProbe(body) {
|
|
33327
|
+
const record2 = typeof body === "object" && body !== null ? body : {};
|
|
33328
|
+
const measured = bool(record2.measured);
|
|
33329
|
+
const reported = cause(record2.error);
|
|
33330
|
+
if (measured === false) {
|
|
33331
|
+
return {
|
|
33332
|
+
kind: "unmeasured",
|
|
33333
|
+
reason: reported ?? "the runner reported it could not measure the Google layer"
|
|
33334
|
+
};
|
|
33335
|
+
}
|
|
33336
|
+
if (measured === true) {
|
|
33337
|
+
if (bool(record2.ok) === true) return { kind: "ok" };
|
|
33338
|
+
return {
|
|
33339
|
+
kind: "unhealthy",
|
|
33340
|
+
reason: reported ?? "the runner reported the Google layer unhealthy with no cause"
|
|
33341
|
+
};
|
|
33342
|
+
}
|
|
33343
|
+
return {
|
|
33344
|
+
kind: "unmeasured",
|
|
33345
|
+
reason: reported ? `the runner did not report whether it measured the Google layer; it said: ${reported}` : "the runner did not report whether it measured the Google layer"
|
|
33346
|
+
};
|
|
33347
|
+
}
|
|
33348
|
+
|
|
33301
33349
|
// src/connector-runtime.ts
|
|
33302
33350
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
33303
33351
|
var DEADLINE_GRACE_MS = 5e3;
|
|
33304
33352
|
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
33353
|
+
var REFUSAL_PROBE_TIMEOUT_MS = 4e3;
|
|
33354
|
+
var MIN_PROBE_BUDGET_MS = 1e3;
|
|
33355
|
+
var PROBE_INTERVAL_MS = 6e4;
|
|
33305
33356
|
var RUNNER_GOG_FAILED = 422;
|
|
33306
33357
|
var RUNNER_DRAINING = 503;
|
|
33307
33358
|
var RUNNER_BAD_REQUEST = 400;
|
|
@@ -33348,7 +33399,7 @@ function gogTarget(args) {
|
|
|
33348
33399
|
}
|
|
33349
33400
|
return { service };
|
|
33350
33401
|
}
|
|
33351
|
-
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
33402
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt, probeGoogle) {
|
|
33352
33403
|
if (!(err instanceof GogFailedError)) return void 0;
|
|
33353
33404
|
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
33354
33405
|
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
@@ -33363,6 +33414,7 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
33363
33414
|
return void 0;
|
|
33364
33415
|
}
|
|
33365
33416
|
if (!used) {
|
|
33417
|
+
await probeGoogle(where);
|
|
33366
33418
|
logAuthTransition("replay.declined", {
|
|
33367
33419
|
...where,
|
|
33368
33420
|
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
@@ -33410,6 +33462,64 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
33410
33462
|
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
33411
33463
|
}
|
|
33412
33464
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
33465
|
+
let lastProbeAt = Number.NEGATIVE_INFINITY;
|
|
33466
|
+
const probeGoogleAfterRefusal = async (where, deadlineAt) => {
|
|
33467
|
+
const record2 = { ...where, endpoint };
|
|
33468
|
+
const now = Date.now();
|
|
33469
|
+
const remainingMs = deadlineAt - now;
|
|
33470
|
+
if (remainingMs < MIN_PROBE_BUDGET_MS) {
|
|
33471
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
33472
|
+
...record2,
|
|
33473
|
+
reason: `only ${remainingMs}ms of the call\u2019s deadline remained, so the Google layer was not measured rather than delay the caller\u2019s own error`
|
|
33474
|
+
});
|
|
33475
|
+
return;
|
|
33476
|
+
}
|
|
33477
|
+
if (now - lastProbeAt < PROBE_INTERVAL_MS) {
|
|
33478
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
33479
|
+
...record2,
|
|
33480
|
+
// "attempted", not "measured". `lastProbeAt` is stamped before the
|
|
33481
|
+
// fetch and is deliberately NOT reset when the probe comes back with no
|
|
33482
|
+
// verdict (a 404 from a runner too old to have the endpoint, a timeout,
|
|
33483
|
+
// a dead socket) — the backend cost this throttle exists to bound was
|
|
33484
|
+
// paid either way, and resetting it would let a retry loop storm a
|
|
33485
|
+
// runner that is already unwell. So the timestamp stays and the sentence
|
|
33486
|
+
// has to be the true one: on this branch a log line may not assert a
|
|
33487
|
+
// measurement that never happened, and the previous probe may well have
|
|
33488
|
+
// measured nothing at all.
|
|
33489
|
+
reason: "a Google probe was attempted recently, so another was not sent: this probe spawns gog on the backend and takes the keyring\u2019s exclusive lock"
|
|
33490
|
+
});
|
|
33491
|
+
return;
|
|
33492
|
+
}
|
|
33493
|
+
lastProbeAt = now;
|
|
33494
|
+
let event;
|
|
33495
|
+
let reason;
|
|
33496
|
+
try {
|
|
33497
|
+
const res = await fetch(`${endpoint}/health/google`, {
|
|
33498
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
33499
|
+
// Never more than the probe's own budget, never more than the call has
|
|
33500
|
+
// left. `Math.min` rather than a plain constant because the second
|
|
33501
|
+
// bound is the caller's, and it outranks ours.
|
|
33502
|
+
signal: AbortSignal.timeout(Math.min(REFUSAL_PROBE_TIMEOUT_MS, remainingMs))
|
|
33503
|
+
});
|
|
33504
|
+
if (!res.ok) {
|
|
33505
|
+
event = "refusal.google-unmeasured";
|
|
33506
|
+
reason = `the runner did not answer the Google probe (HTTP ${res.status})`;
|
|
33507
|
+
} else {
|
|
33508
|
+
const verdict = readGoogleProbe(await res.json());
|
|
33509
|
+
if (verdict.kind === "ok") {
|
|
33510
|
+
event = "refusal.google-ok";
|
|
33511
|
+
reason = "Google refused this call, yet a live token check on the same volume succeeded \u2014 so a dead or expired refresh token does not explain this refusal";
|
|
33512
|
+
} else {
|
|
33513
|
+
event = verdict.kind === "unhealthy" ? "refusal.google-unhealthy" : "refusal.google-unmeasured";
|
|
33514
|
+
reason = verdict.reason;
|
|
33515
|
+
}
|
|
33516
|
+
}
|
|
33517
|
+
} catch (err) {
|
|
33518
|
+
event = "refusal.google-unmeasured";
|
|
33519
|
+
reason = err instanceof Error ? err.message : String(err);
|
|
33520
|
+
}
|
|
33521
|
+
logAuthTransition(event, { ...record2, reason });
|
|
33522
|
+
};
|
|
33413
33523
|
return async (args, opts) => {
|
|
33414
33524
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
33415
33525
|
const accessToken = await readAccessToken?.();
|
|
@@ -33422,7 +33532,8 @@ function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
|
33422
33532
|
accessToken,
|
|
33423
33533
|
args,
|
|
33424
33534
|
readAccessToken,
|
|
33425
|
-
deadlineAt
|
|
33535
|
+
deadlineAt,
|
|
33536
|
+
(where2) => probeGoogleAfterRefusal(where2, deadlineAt)
|
|
33426
33537
|
);
|
|
33427
33538
|
if (replay === void 0) throw err;
|
|
33428
33539
|
const where = { credential: replay.credential, service: replay.service, endpoint };
|
package/dist/lib.js
CHANGED
|
@@ -23319,6 +23319,13 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
23319
23319
|
// Calendar event start/end
|
|
23320
23320
|
"internalDate",
|
|
23321
23321
|
// Gmail, epoch milliseconds (authoritative)
|
|
23322
|
+
// gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
|
|
23323
|
+
// (RFC3339 from internalDate), so it needs no offset repair — it is
|
|
23324
|
+
// allowlisted purely to gain a Display sibling, and to be re-rendered in
|
|
23325
|
+
// DISPLAY_TZ like every other instant. Separately sourced from the sibling
|
|
23326
|
+
// `date`, which is a naive re-format of the sender's Date header; the two may
|
|
23327
|
+
// legitimately disagree. See docs/timestamps.md.
|
|
23328
|
+
"internalDateIso",
|
|
23322
23329
|
"modifiedTime",
|
|
23323
23330
|
// Drive
|
|
23324
23331
|
"createdTime",
|
|
@@ -23560,8 +23567,8 @@ function formatOneAccountHealth(a, now) {
|
|
|
23560
23567
|
const age = ageInDays(a.created_at, now);
|
|
23561
23568
|
const ageStr = age === null ? "" : ` Authorized ${age.toFixed(1)} day(s) ago.`;
|
|
23562
23569
|
if (a.valid === false) {
|
|
23563
|
-
const
|
|
23564
|
-
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${
|
|
23570
|
+
const cause2 = INVALID_GRANT_PATTERN.test(a.error ?? "") ? 'refresh token expired or revoked \u2014 commonly the 7-day limit on OAuth consent screens still in "Testing" mode' : a.error?.trim() || "unknown error";
|
|
23571
|
+
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${cause2}.${ageStr} Re-authorize with gog_auth_add (browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless).`;
|
|
23565
23572
|
}
|
|
23566
23573
|
if (a.valid === true) {
|
|
23567
23574
|
let line = `\u2713 ${email3}: token valid.${ageStr}`;
|
|
@@ -23657,7 +23664,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
23657
23664
|
}
|
|
23658
23665
|
});
|
|
23659
23666
|
server.registerTool("gog_auth_status", {
|
|
23660
|
-
description: "Show gogcli auth
|
|
23667
|
+
description: "Show gogcli auth CONFIGURATION: keyring backend, credential files, and auth setup. Despite the name this is not a health check \u2014 it reads local setup and does not contact Google, so it says nothing about whether an account can still authenticate. Use gog_auth_health for that.",
|
|
23661
23668
|
annotations: { readOnlyHint: true },
|
|
23662
23669
|
inputSchema: {}
|
|
23663
23670
|
}, async () => {
|
|
@@ -23668,7 +23675,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
23668
23675
|
}
|
|
23669
23676
|
});
|
|
23670
23677
|
server.registerTool("gog_auth_health", {
|
|
23671
|
-
description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task.',
|
|
23678
|
+
description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task. On the hosted connector this is the ONLY check that measures Google: a connector showing "connected" or "refreshed" has verified the connector key that reaches the gog machine, and nothing else \u2014 the Google credential lives on that machine and can be dead while the connection looks perfectly healthy.',
|
|
23672
23679
|
annotations: { readOnlyHint: true },
|
|
23673
23680
|
inputSchema: {}
|
|
23674
23681
|
}, async () => {
|
|
@@ -25018,7 +25025,7 @@ function registerTasksTools(server) {
|
|
|
25018
25025
|
}
|
|
25019
25026
|
|
|
25020
25027
|
// src/server.ts
|
|
25021
|
-
var VERSION = true ? "2.
|
|
25028
|
+
var VERSION = true ? "2.22.0" : "0.0.0";
|
|
25022
25029
|
var BASE_TOOL_REGISTRARS = [
|
|
25023
25030
|
registerApiTools,
|
|
25024
25031
|
registerAuthTools,
|
|
@@ -25038,7 +25045,22 @@ var FAILURES = /* @__PURE__ */ new Set([
|
|
|
25038
25045
|
"token.mint-failed",
|
|
25039
25046
|
"grant.dead",
|
|
25040
25047
|
"replay.failed",
|
|
25041
|
-
"runner.auth-failed"
|
|
25048
|
+
"runner.auth-failed",
|
|
25049
|
+
"connect.key-rejected",
|
|
25050
|
+
// An enrolment that could not proceed is a failure even though nobody is at
|
|
25051
|
+
// fault: it is the only trace a half-enrolled connector leaves behind, and
|
|
25052
|
+
// the absence of exactly this record is why DEFECT 4 could not be explained.
|
|
25053
|
+
"connect.runner-unreachable",
|
|
25054
|
+
"connect.google-unhealthy",
|
|
25055
|
+
"refusal.google-unhealthy",
|
|
25056
|
+
// The loudest record on this branch, and the only one that means "we cannot
|
|
25057
|
+
// explain this". Google refused a real call while a live check of the same
|
|
25058
|
+
// credential, taken seconds later, succeeded — so neither the 7-day cliff nor
|
|
25059
|
+
// a revoked grant accounts for it. It is filed as a failure precisely because
|
|
25060
|
+
// it is the record nobody may scroll past: it is the only evidence that could
|
|
25061
|
+
// ever justify building something on the hosted path, and its absence over
|
|
25062
|
+
// time is what retires that theory for good.
|
|
25063
|
+
"refusal.google-ok"
|
|
25042
25064
|
]);
|
|
25043
25065
|
var PREFIX = "gog-auth ";
|
|
25044
25066
|
var TAG_CHARS = 12;
|
|
@@ -25185,10 +25207,39 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
25185
25207
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
25186
25208
|
}
|
|
25187
25209
|
|
|
25210
|
+
// src/google-probe.ts
|
|
25211
|
+
var bool = (value) => typeof value === "boolean" ? value : void 0;
|
|
25212
|
+
var cause = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
25213
|
+
function readGoogleProbe(body) {
|
|
25214
|
+
const record2 = typeof body === "object" && body !== null ? body : {};
|
|
25215
|
+
const measured = bool(record2.measured);
|
|
25216
|
+
const reported = cause(record2.error);
|
|
25217
|
+
if (measured === false) {
|
|
25218
|
+
return {
|
|
25219
|
+
kind: "unmeasured",
|
|
25220
|
+
reason: reported ?? "the runner reported it could not measure the Google layer"
|
|
25221
|
+
};
|
|
25222
|
+
}
|
|
25223
|
+
if (measured === true) {
|
|
25224
|
+
if (bool(record2.ok) === true) return { kind: "ok" };
|
|
25225
|
+
return {
|
|
25226
|
+
kind: "unhealthy",
|
|
25227
|
+
reason: reported ?? "the runner reported the Google layer unhealthy with no cause"
|
|
25228
|
+
};
|
|
25229
|
+
}
|
|
25230
|
+
return {
|
|
25231
|
+
kind: "unmeasured",
|
|
25232
|
+
reason: reported ? `the runner did not report whether it measured the Google layer; it said: ${reported}` : "the runner did not report whether it measured the Google layer"
|
|
25233
|
+
};
|
|
25234
|
+
}
|
|
25235
|
+
|
|
25188
25236
|
// src/connector-runtime.ts
|
|
25189
25237
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
25190
25238
|
var DEADLINE_GRACE_MS = 5e3;
|
|
25191
25239
|
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
25240
|
+
var REFUSAL_PROBE_TIMEOUT_MS = 4e3;
|
|
25241
|
+
var MIN_PROBE_BUDGET_MS = 1e3;
|
|
25242
|
+
var PROBE_INTERVAL_MS = 6e4;
|
|
25192
25243
|
var RUNNER_GOG_FAILED = 422;
|
|
25193
25244
|
var RUNNER_DRAINING = 503;
|
|
25194
25245
|
var RUNNER_BAD_REQUEST = 400;
|
|
@@ -25235,7 +25286,7 @@ function gogTarget(args) {
|
|
|
25235
25286
|
}
|
|
25236
25287
|
return { service };
|
|
25237
25288
|
}
|
|
25238
|
-
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
25289
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt, probeGoogle) {
|
|
25239
25290
|
if (!(err instanceof GogFailedError)) return void 0;
|
|
25240
25291
|
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
25241
25292
|
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
@@ -25250,6 +25301,7 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
25250
25301
|
return void 0;
|
|
25251
25302
|
}
|
|
25252
25303
|
if (!used) {
|
|
25304
|
+
await probeGoogle(where);
|
|
25253
25305
|
logAuthTransition("replay.declined", {
|
|
25254
25306
|
...where,
|
|
25255
25307
|
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
@@ -25297,6 +25349,64 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
25297
25349
|
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
25298
25350
|
}
|
|
25299
25351
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
25352
|
+
let lastProbeAt = Number.NEGATIVE_INFINITY;
|
|
25353
|
+
const probeGoogleAfterRefusal = async (where, deadlineAt) => {
|
|
25354
|
+
const record2 = { ...where, endpoint };
|
|
25355
|
+
const now = Date.now();
|
|
25356
|
+
const remainingMs = deadlineAt - now;
|
|
25357
|
+
if (remainingMs < MIN_PROBE_BUDGET_MS) {
|
|
25358
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
25359
|
+
...record2,
|
|
25360
|
+
reason: `only ${remainingMs}ms of the call\u2019s deadline remained, so the Google layer was not measured rather than delay the caller\u2019s own error`
|
|
25361
|
+
});
|
|
25362
|
+
return;
|
|
25363
|
+
}
|
|
25364
|
+
if (now - lastProbeAt < PROBE_INTERVAL_MS) {
|
|
25365
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
25366
|
+
...record2,
|
|
25367
|
+
// "attempted", not "measured". `lastProbeAt` is stamped before the
|
|
25368
|
+
// fetch and is deliberately NOT reset when the probe comes back with no
|
|
25369
|
+
// verdict (a 404 from a runner too old to have the endpoint, a timeout,
|
|
25370
|
+
// a dead socket) — the backend cost this throttle exists to bound was
|
|
25371
|
+
// paid either way, and resetting it would let a retry loop storm a
|
|
25372
|
+
// runner that is already unwell. So the timestamp stays and the sentence
|
|
25373
|
+
// has to be the true one: on this branch a log line may not assert a
|
|
25374
|
+
// measurement that never happened, and the previous probe may well have
|
|
25375
|
+
// measured nothing at all.
|
|
25376
|
+
reason: "a Google probe was attempted recently, so another was not sent: this probe spawns gog on the backend and takes the keyring\u2019s exclusive lock"
|
|
25377
|
+
});
|
|
25378
|
+
return;
|
|
25379
|
+
}
|
|
25380
|
+
lastProbeAt = now;
|
|
25381
|
+
let event;
|
|
25382
|
+
let reason;
|
|
25383
|
+
try {
|
|
25384
|
+
const res = await fetch(`${endpoint}/health/google`, {
|
|
25385
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
25386
|
+
// Never more than the probe's own budget, never more than the call has
|
|
25387
|
+
// left. `Math.min` rather than a plain constant because the second
|
|
25388
|
+
// bound is the caller's, and it outranks ours.
|
|
25389
|
+
signal: AbortSignal.timeout(Math.min(REFUSAL_PROBE_TIMEOUT_MS, remainingMs))
|
|
25390
|
+
});
|
|
25391
|
+
if (!res.ok) {
|
|
25392
|
+
event = "refusal.google-unmeasured";
|
|
25393
|
+
reason = `the runner did not answer the Google probe (HTTP ${res.status})`;
|
|
25394
|
+
} else {
|
|
25395
|
+
const verdict = readGoogleProbe(await res.json());
|
|
25396
|
+
if (verdict.kind === "ok") {
|
|
25397
|
+
event = "refusal.google-ok";
|
|
25398
|
+
reason = "Google refused this call, yet a live token check on the same volume succeeded \u2014 so a dead or expired refresh token does not explain this refusal";
|
|
25399
|
+
} else {
|
|
25400
|
+
event = verdict.kind === "unhealthy" ? "refusal.google-unhealthy" : "refusal.google-unmeasured";
|
|
25401
|
+
reason = verdict.reason;
|
|
25402
|
+
}
|
|
25403
|
+
}
|
|
25404
|
+
} catch (err) {
|
|
25405
|
+
event = "refusal.google-unmeasured";
|
|
25406
|
+
reason = err instanceof Error ? err.message : String(err);
|
|
25407
|
+
}
|
|
25408
|
+
logAuthTransition(event, { ...record2, reason });
|
|
25409
|
+
};
|
|
25300
25410
|
return async (args, opts) => {
|
|
25301
25411
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
25302
25412
|
const accessToken = await readAccessToken?.();
|
|
@@ -25309,7 +25419,8 @@ function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
|
25309
25419
|
accessToken,
|
|
25310
25420
|
args,
|
|
25311
25421
|
readAccessToken,
|
|
25312
|
-
deadlineAt
|
|
25422
|
+
deadlineAt,
|
|
25423
|
+
(where2) => probeGoogleAfterRefusal(where2, deadlineAt)
|
|
25313
25424
|
);
|
|
25314
25425
|
if (replay === void 0) throw err;
|
|
25315
25426
|
const where = { credential: replay.credential, service: replay.service, endpoint };
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "gogcli-mcp",
|
|
5
5
|
"display_name": "gogcli",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.22.0",
|
|
7
7
|
"description": "Google Sheets (and more) for Claude via gogcli — read, write, and manage spreadsheets",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"source": "github",
|
|
8
8
|
"subfolder": "packages/gogcli-mcp"
|
|
9
9
|
},
|
|
10
|
-
"version": "2.
|
|
10
|
+
"version": "2.22.0",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "gogcli-mcp",
|
|
15
|
-
"version": "2.
|
|
15
|
+
"version": "2.22.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|
package/src/auth-log.ts
CHANGED
|
@@ -78,7 +78,38 @@ export type AuthTransition =
|
|
|
78
78
|
/** The replay failed too; the original failure reaches the caller. */
|
|
79
79
|
| 'replay.failed'
|
|
80
80
|
/** The RUNNER rejected our bearer. gog never ran; no Google credential read. */
|
|
81
|
-
| 'runner.auth-failed'
|
|
81
|
+
| 'runner.auth-failed'
|
|
82
|
+
/** Enrolment: the runner refused the connector key itself (401/403). Layer 1. */
|
|
83
|
+
| 'connect.key-rejected'
|
|
84
|
+
/**
|
|
85
|
+
* Enrolment: the runner never answered, so the key was never judged. A user
|
|
86
|
+
* who saw this was previously told their key was invalid — see
|
|
87
|
+
* `connector-auth.ts`. It is filed separately because the two demand opposite
|
|
88
|
+
* actions from the user: fetch a new key, versus wait and retry.
|
|
89
|
+
*/
|
|
90
|
+
| 'connect.runner-unreachable'
|
|
91
|
+
/** Connect time: the Google layer was measured live and answered healthy. */
|
|
92
|
+
| 'connect.google-ok'
|
|
93
|
+
/**
|
|
94
|
+
* Connect time: the probe reached a VERDICT and the verdict is bad — Google
|
|
95
|
+
* refused the credential, or there is none. The user is connected anyway.
|
|
96
|
+
* Emitted only when the runner asserts `measured:true`; see google-probe.ts.
|
|
97
|
+
*/
|
|
98
|
+
| 'connect.google-unhealthy'
|
|
99
|
+
/** Connect time: the Google layer could NOT be measured. Not evidence of anything. */
|
|
100
|
+
| 'connect.google-unmeasured'
|
|
101
|
+
/**
|
|
102
|
+
* Google refused a call, and a live check taken at that moment says the
|
|
103
|
+
* credential is HEALTHY. The refusal is therefore unexplained.
|
|
104
|
+
*/
|
|
105
|
+
| 'refusal.google-ok'
|
|
106
|
+
/**
|
|
107
|
+
* Google refused a call, and a live check that REACHED A VERDICT
|
|
108
|
+
* (`measured:true`) confirms the credential is refused too.
|
|
109
|
+
*/
|
|
110
|
+
| 'refusal.google-unhealthy'
|
|
111
|
+
/** Google refused a call and the live check could not be taken. Not evidence of anything. */
|
|
112
|
+
| 'refusal.google-unmeasured';
|
|
82
113
|
|
|
83
114
|
/**
|
|
84
115
|
* Which credential, which service, which backend, and why — every field
|
|
@@ -111,8 +142,35 @@ const FAILURES: ReadonlySet<AuthTransition> = new Set<AuthTransition>([
|
|
|
111
142
|
'grant.dead',
|
|
112
143
|
'replay.failed',
|
|
113
144
|
'runner.auth-failed',
|
|
145
|
+
'connect.key-rejected',
|
|
146
|
+
// An enrolment that could not proceed is a failure even though nobody is at
|
|
147
|
+
// fault: it is the only trace a half-enrolled connector leaves behind, and
|
|
148
|
+
// the absence of exactly this record is why DEFECT 4 could not be explained.
|
|
149
|
+
'connect.runner-unreachable',
|
|
150
|
+
'connect.google-unhealthy',
|
|
151
|
+
'refusal.google-unhealthy',
|
|
152
|
+
// The loudest record on this branch, and the only one that means "we cannot
|
|
153
|
+
// explain this". Google refused a real call while a live check of the same
|
|
154
|
+
// credential, taken seconds later, succeeded — so neither the 7-day cliff nor
|
|
155
|
+
// a revoked grant accounts for it. It is filed as a failure precisely because
|
|
156
|
+
// it is the record nobody may scroll past: it is the only evidence that could
|
|
157
|
+
// ever justify building something on the hosted path, and its absence over
|
|
158
|
+
// time is what retires that theory for good.
|
|
159
|
+
'refusal.google-ok',
|
|
114
160
|
]);
|
|
115
161
|
|
|
162
|
+
// `connect.google-unmeasured` and `refusal.google-unmeasured` are deliberately
|
|
163
|
+
// NOT failures, and the distinction
|
|
164
|
+
// is the entire point of the connect-time probe. "Google was asked and said no"
|
|
165
|
+
// is a fact about the user's credential; "the probe did not run" is a fact about
|
|
166
|
+
// the probe. Filing the second under the first would rebuild the defect being
|
|
167
|
+
// fixed — a claim about health that nothing measured — with the alarm inverted.
|
|
168
|
+
//
|
|
169
|
+
// That is not a distinction a call site may re-derive by eye: it was got wrong
|
|
170
|
+
// once, at both call sites, by reading the runner's `ok` field alone. It is now
|
|
171
|
+
// decided in exactly one place — `google-probe.ts`, which reads the runner's
|
|
172
|
+
// `measured` field first — and the events below are only names for its verdicts.
|
|
173
|
+
|
|
116
174
|
/** Marker so one `grep gog-auth` finds every record and nothing else. */
|
|
117
175
|
const PREFIX = 'gog-auth ';
|
|
118
176
|
|