gogcli-mcp-classroom 2.21.0 → 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 +436 -58
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
10
|
-
"version": "2.
|
|
10
|
+
"version": "2.22.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "gogcli (Classroom)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.22.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-classroom",
|
|
3
3
|
"displayName": "gogcli (Classroom)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.22.0",
|
|
5
5
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
package/dist/index.js
CHANGED
|
@@ -31140,6 +31140,21 @@ import { delimiter, join } from "node:path";
|
|
|
31140
31140
|
function isGogFileArg(arg) {
|
|
31141
31141
|
return typeof arg !== "string";
|
|
31142
31142
|
}
|
|
31143
|
+
var RUNNER_TRANSPORT_BRAND = /* @__PURE__ */ Symbol.for("gogcli.RunnerTransportError");
|
|
31144
|
+
var RunnerTransportError = class extends Error {
|
|
31145
|
+
kind;
|
|
31146
|
+
status;
|
|
31147
|
+
constructor(message, kind, status) {
|
|
31148
|
+
super(message);
|
|
31149
|
+
this.name = "RunnerTransportError";
|
|
31150
|
+
this.kind = kind;
|
|
31151
|
+
this.status = status;
|
|
31152
|
+
Object.defineProperty(this, RUNNER_TRANSPORT_BRAND, { value: true });
|
|
31153
|
+
}
|
|
31154
|
+
};
|
|
31155
|
+
function isRunnerTransportError(err) {
|
|
31156
|
+
return err instanceof Error && err[RUNNER_TRANSPORT_BRAND] === true;
|
|
31157
|
+
}
|
|
31143
31158
|
var runExecutor = new AsyncLocalStorage();
|
|
31144
31159
|
var defaultExecutor;
|
|
31145
31160
|
function setDefaultGogExecutor(executor) {
|
|
@@ -31320,7 +31335,11 @@ async function run(args, options = {}) {
|
|
|
31320
31335
|
}
|
|
31321
31336
|
return redact(output);
|
|
31322
31337
|
} catch (err) {
|
|
31323
|
-
|
|
31338
|
+
const message = redact(err instanceof Error ? err.message : String(err));
|
|
31339
|
+
if (isRunnerTransportError(err)) {
|
|
31340
|
+
throw new RunnerTransportError(message, err.kind, err.status);
|
|
31341
|
+
}
|
|
31342
|
+
throw new Error(message);
|
|
31324
31343
|
}
|
|
31325
31344
|
}
|
|
31326
31345
|
|
|
@@ -31411,6 +31430,13 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
31411
31430
|
// Calendar event start/end
|
|
31412
31431
|
"internalDate",
|
|
31413
31432
|
// Gmail, epoch milliseconds (authoritative)
|
|
31433
|
+
// gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
|
|
31434
|
+
// (RFC3339 from internalDate), so it needs no offset repair — it is
|
|
31435
|
+
// allowlisted purely to gain a Display sibling, and to be re-rendered in
|
|
31436
|
+
// DISPLAY_TZ like every other instant. Separately sourced from the sibling
|
|
31437
|
+
// `date`, which is a naive re-format of the sender's Date header; the two may
|
|
31438
|
+
// legitimately disagree. See docs/timestamps.md.
|
|
31439
|
+
"internalDateIso",
|
|
31414
31440
|
"modifiedTime",
|
|
31415
31441
|
// Drive
|
|
31416
31442
|
"createdTime",
|
|
@@ -31572,7 +31598,7 @@ function registerRunTool(server, options) {
|
|
|
31572
31598
|
function errorText(err) {
|
|
31573
31599
|
return err instanceof Error ? `Error: ${err.message}` : String(err);
|
|
31574
31600
|
}
|
|
31575
|
-
var DEFINITE_AUTH_PATTERN = /\b(
|
|
31601
|
+
var DEFINITE_AUTH_PATTERN = /\b(?:unauthorized|invalid_grant)\b|\b(?:error|status|code|http|responded|response)["']?[\s:=(,]{0,4}401\b/i;
|
|
31576
31602
|
var STALE_TOKEN_PATTERN = /\b(?:access[ _-]?)?token\b[^.;\n]{0,40}\b(?:has\s+)?(?:been\s+)?(?:expired|revoked)\b|\b(?:expired|revoked)\s+(?:access[ _-]?)?token\b/i;
|
|
31577
31603
|
var AUTH_ERROR_PATTERN = new RegExp(`${DEFINITE_AUTH_PATTERN.source}|${STALE_TOKEN_PATTERN.source}`, "i");
|
|
31578
31604
|
var INVALID_GRANT_PATTERN = /invalid_grant|token has been expired or revoked/i;
|
|
@@ -31582,6 +31608,14 @@ var AUTH_HINT = "\n\nAuthentication may have expired. Use gog_auth_add to re-aut
|
|
|
31582
31608
|
var INVALID_GRANT_HINT = '\n\nThe stored refresh token was rejected (invalid_grant): it has expired or been revoked, so the whole account is signed out and re-authorization is required. The most common cause is the 7-day refresh-token limit Google applies to OAuth apps whose consent screen is still in "Testing" mode. Re-authorize with gog_auth_add (opens a browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless). To stop this recurring, publish the OAuth consent screen to "In production" in the Google Cloud project that owns the OAuth client. Ask the user if they would like to re-authenticate.';
|
|
31583
31609
|
var TRANSIENT_HINT = "\n\nThis error is often transient. Retry the same call before trying a different approach (do not fall back to smaller writes or row-by-row operations).";
|
|
31584
31610
|
var GRID_LIMIT_HINT = "\n\nThe target range is outside the sheet's current grid. Add the missing rows or columns first with gog_sheets_insert (dimension: rows or cols), then retry the write.";
|
|
31611
|
+
var RUNNER_TRANSPORT_AUTH_HINT = "\n\nThis is the CONNECTOR's own transport auth failing, not your Google sign-in. The gog-runner backend rejected the bearer token this server sent, so the request never reached gog and no Google credential was checked \u2014 the Google account is not the problem and re-authorizing it cannot fix this. An operator must make the Worker secret GOG_RUNNER_KEY equal RUNNER_KEY on the Fly app (wrangler secret put GOG_RUNNER_KEY / fly secrets set RUNNER_KEY), then retry.";
|
|
31612
|
+
var RUNNER_TRANSPORT_HINTS = {
|
|
31613
|
+
"transport-auth": RUNNER_TRANSPORT_AUTH_HINT,
|
|
31614
|
+
// The request itself was malformed, so the runner will refuse it identically
|
|
31615
|
+
// every time. Nothing to advise beyond the message the runner already gave.
|
|
31616
|
+
"transport-request": "",
|
|
31617
|
+
"transport-retryable": TRANSIENT_HINT
|
|
31618
|
+
};
|
|
31585
31619
|
function formatAccountList(raw) {
|
|
31586
31620
|
try {
|
|
31587
31621
|
const parsed = JSON.parse(raw);
|
|
@@ -31594,11 +31628,12 @@ function formatAccountList(raw) {
|
|
|
31594
31628
|
}
|
|
31595
31629
|
async function diagnose(err) {
|
|
31596
31630
|
const errText = errorText(err);
|
|
31631
|
+
const transportHint = isRunnerTransportError(err) ? RUNNER_TRANSPORT_HINTS[err.kind] : void 0;
|
|
31597
31632
|
const isInvalidGrant = INVALID_GRANT_PATTERN.test(errText);
|
|
31598
31633
|
const isTransientError = !DEFINITE_AUTH_PATTERN.test(errText) && TRANSIENT_ERROR_PATTERN.test(errText);
|
|
31599
31634
|
const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
|
|
31600
31635
|
const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
|
|
31601
|
-
const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
|
|
31636
|
+
const hint = transportHint ?? (isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "");
|
|
31602
31637
|
try {
|
|
31603
31638
|
const accounts = formatAccountList(await run(["auth", "list"]));
|
|
31604
31639
|
return errorResult(`${errText}
|
|
@@ -31631,8 +31666,8 @@ function formatOneAccountHealth(a, now) {
|
|
|
31631
31666
|
const age = ageInDays(a.created_at, now);
|
|
31632
31667
|
const ageStr = age === null ? "" : ` Authorized ${age.toFixed(1)} day(s) ago.`;
|
|
31633
31668
|
if (a.valid === false) {
|
|
31634
|
-
const
|
|
31635
|
-
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${
|
|
31669
|
+
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";
|
|
31670
|
+
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).`;
|
|
31636
31671
|
}
|
|
31637
31672
|
if (a.valid === true) {
|
|
31638
31673
|
let line = `\u2713 ${email3}: token valid.${ageStr}`;
|
|
@@ -31674,7 +31709,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31674
31709
|
}
|
|
31675
31710
|
});
|
|
31676
31711
|
server.registerTool("gog_auth_status", {
|
|
31677
|
-
description: "Show gogcli auth
|
|
31712
|
+
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.",
|
|
31678
31713
|
annotations: { readOnlyHint: true },
|
|
31679
31714
|
inputSchema: {}
|
|
31680
31715
|
}, async () => {
|
|
@@ -31685,7 +31720,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31685
31720
|
}
|
|
31686
31721
|
});
|
|
31687
31722
|
server.registerTool("gog_auth_health", {
|
|
31688
|
-
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.',
|
|
31723
|
+
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.',
|
|
31689
31724
|
annotations: { readOnlyHint: true },
|
|
31690
31725
|
inputSchema: {}
|
|
31691
31726
|
}, async () => {
|
|
@@ -32162,7 +32197,40 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
32162
32197
|
);
|
|
32163
32198
|
|
|
32164
32199
|
// ../gogcli-mcp/src/server.ts
|
|
32165
|
-
var VERSION = true ? "2.
|
|
32200
|
+
var VERSION = true ? "2.22.0" : "0.0.0";
|
|
32201
|
+
|
|
32202
|
+
// ../gogcli-mcp/src/auth-log.ts
|
|
32203
|
+
var FAILURES = /* @__PURE__ */ new Set([
|
|
32204
|
+
"token.mint-failed",
|
|
32205
|
+
"grant.dead",
|
|
32206
|
+
"replay.failed",
|
|
32207
|
+
"runner.auth-failed",
|
|
32208
|
+
"connect.key-rejected",
|
|
32209
|
+
// An enrolment that could not proceed is a failure even though nobody is at
|
|
32210
|
+
// fault: it is the only trace a half-enrolled connector leaves behind, and
|
|
32211
|
+
// the absence of exactly this record is why DEFECT 4 could not be explained.
|
|
32212
|
+
"connect.runner-unreachable",
|
|
32213
|
+
"connect.google-unhealthy",
|
|
32214
|
+
"refusal.google-unhealthy",
|
|
32215
|
+
// The loudest record on this branch, and the only one that means "we cannot
|
|
32216
|
+
// explain this". Google refused a real call while a live check of the same
|
|
32217
|
+
// credential, taken seconds later, succeeded — so neither the 7-day cliff nor
|
|
32218
|
+
// a revoked grant accounts for it. It is filed as a failure precisely because
|
|
32219
|
+
// it is the record nobody may scroll past: it is the only evidence that could
|
|
32220
|
+
// ever justify building something on the hosted path, and its absence over
|
|
32221
|
+
// time is what retires that theory for good.
|
|
32222
|
+
"refusal.google-ok"
|
|
32223
|
+
]);
|
|
32224
|
+
var PREFIX = "gog-auth ";
|
|
32225
|
+
var TAG_CHARS = 12;
|
|
32226
|
+
function credentialTag(cacheKeyHash) {
|
|
32227
|
+
return cacheKeyHash.slice(0, TAG_CHARS);
|
|
32228
|
+
}
|
|
32229
|
+
function logAuthTransition(event, context) {
|
|
32230
|
+
const record2 = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...context });
|
|
32231
|
+
const write = FAILURES.has(event) ? console.error : console.warn;
|
|
32232
|
+
write(PREFIX + redactSecrets2(record2));
|
|
32233
|
+
}
|
|
32166
32234
|
|
|
32167
32235
|
// ../gogcli-mcp/src/google-token.ts
|
|
32168
32236
|
var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
@@ -32189,22 +32257,73 @@ function makeAccessTokenSource(env) {
|
|
|
32189
32257
|
);
|
|
32190
32258
|
};
|
|
32191
32259
|
}
|
|
32192
|
-
|
|
32193
|
-
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
|
|
32260
|
+
let keyPromise;
|
|
32261
|
+
const key = () => keyPromise ??= cacheKey(refreshToken, clientId);
|
|
32262
|
+
const logCacheHits = parseBoolEnv("GOG_AUTH_LOG_CACHE_HITS", { env });
|
|
32263
|
+
const read = async () => {
|
|
32264
|
+
const k = await key();
|
|
32265
|
+
const hit = cache.get(k);
|
|
32266
|
+
if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) {
|
|
32267
|
+
if (logCacheHits) logAuthTransition("token.cache-hit", { credential: credentialTag(k) });
|
|
32268
|
+
return hit.accessToken;
|
|
32269
|
+
}
|
|
32270
|
+
let pending = inFlight.get(k);
|
|
32197
32271
|
if (!pending) {
|
|
32198
32272
|
pending = exchange(refreshToken, clientId, clientSecret).then((minted2) => {
|
|
32199
|
-
cache.set(
|
|
32273
|
+
cache.set(k, minted2);
|
|
32274
|
+
logAuthTransition("token.minted", {
|
|
32275
|
+
credential: credentialTag(k),
|
|
32276
|
+
reason: `valid for ${Math.round((minted2.expiresAt - Date.now()) / 1e3)}s`
|
|
32277
|
+
});
|
|
32200
32278
|
return minted2;
|
|
32201
|
-
}).
|
|
32202
|
-
|
|
32279
|
+
}).catch((err) => {
|
|
32280
|
+
logAuthTransition(err.grantDead ? "grant.dead" : "token.mint-failed", {
|
|
32281
|
+
credential: credentialTag(k),
|
|
32282
|
+
reason: err.message
|
|
32283
|
+
});
|
|
32284
|
+
throw err;
|
|
32285
|
+
}).finally(() => inFlight.delete(k));
|
|
32286
|
+
inFlight.set(k, pending);
|
|
32203
32287
|
}
|
|
32204
32288
|
const minted = await pending;
|
|
32205
32289
|
return minted.accessToken;
|
|
32206
32290
|
};
|
|
32291
|
+
const invalidate = async (rejected) => {
|
|
32292
|
+
const k = await key();
|
|
32293
|
+
const hit = cache.get(k);
|
|
32294
|
+
if (!hit || hit.accessToken !== rejected) {
|
|
32295
|
+
logAuthTransition("token.evict-noop", {
|
|
32296
|
+
credential: credentialTag(k),
|
|
32297
|
+
reason: hit ? "a concurrent caller had already replaced this credential\u2019s token" : "no token was cached for this credential"
|
|
32298
|
+
});
|
|
32299
|
+
return false;
|
|
32300
|
+
}
|
|
32301
|
+
cache.delete(k);
|
|
32302
|
+
logAuthTransition("token.evicted", {
|
|
32303
|
+
credential: credentialTag(k),
|
|
32304
|
+
reason: "Google rejected this access token; the next read will mint a new one"
|
|
32305
|
+
});
|
|
32306
|
+
return true;
|
|
32307
|
+
};
|
|
32308
|
+
return Object.assign(read, {
|
|
32309
|
+
invalidate,
|
|
32310
|
+
credentialId: async () => credentialTag(await key())
|
|
32311
|
+
});
|
|
32207
32312
|
}
|
|
32313
|
+
var TokenExchangeError = class extends Error {
|
|
32314
|
+
/**
|
|
32315
|
+
* The REFRESH token is dead (Google's `invalid_grant`), not merely the access
|
|
32316
|
+
* token. Carried as a flag rather than re-read from the message, because
|
|
32317
|
+
* inferring the author of a failure from prose several authors can produce is
|
|
32318
|
+
* precisely the mistake this branch exists to undo. `instanceof` is safe: the
|
|
32319
|
+
* class is thrown and caught inside this one module.
|
|
32320
|
+
*/
|
|
32321
|
+
grantDead;
|
|
32322
|
+
constructor(message, grantDead) {
|
|
32323
|
+
super(message);
|
|
32324
|
+
this.grantDead = grantDead;
|
|
32325
|
+
}
|
|
32326
|
+
};
|
|
32208
32327
|
async function exchange(refreshToken, clientId, clientSecret) {
|
|
32209
32328
|
let res;
|
|
32210
32329
|
try {
|
|
@@ -32219,79 +32338,338 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
32219
32338
|
}).toString()
|
|
32220
32339
|
});
|
|
32221
32340
|
} catch (err) {
|
|
32222
|
-
throw new
|
|
32223
|
-
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}
|
|
32341
|
+
throw new TokenExchangeError(
|
|
32342
|
+
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`,
|
|
32343
|
+
false
|
|
32224
32344
|
);
|
|
32225
32345
|
}
|
|
32226
32346
|
const body = await res.json().catch(() => ({}));
|
|
32227
32347
|
if (!res.ok) {
|
|
32228
32348
|
if (body.error === "invalid_grant") {
|
|
32229
|
-
throw new
|
|
32230
|
-
'the stored refresh token has expired or been revoked, so this account must be re-authorized (commonly the 7-day limit on OAuth consent screens still in "Testing" mode). Re-enrol with gog_auth_add_url + gog_auth_add_complete and store the new refresh token.'
|
|
32349
|
+
throw new TokenExchangeError(
|
|
32350
|
+
'the stored refresh token was rejected (invalid_grant): it has expired or been revoked, so this account must be re-authorized (commonly the 7-day limit on OAuth consent screens still in "Testing" mode). Re-enrol with gog_auth_add_url + gog_auth_add_complete and store the new refresh token.',
|
|
32351
|
+
true
|
|
32231
32352
|
);
|
|
32232
32353
|
}
|
|
32233
|
-
throw new
|
|
32234
|
-
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})
|
|
32354
|
+
throw new TokenExchangeError(
|
|
32355
|
+
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`,
|
|
32356
|
+
false
|
|
32235
32357
|
);
|
|
32236
32358
|
}
|
|
32237
32359
|
if (!body.access_token) {
|
|
32238
|
-
throw new
|
|
32360
|
+
throw new TokenExchangeError(
|
|
32361
|
+
"the access token could not be refreshed: Google returned no access_token",
|
|
32362
|
+
false
|
|
32363
|
+
);
|
|
32239
32364
|
}
|
|
32240
32365
|
const expiresInMs = (body.expires_in ?? 3600) * 1e3;
|
|
32241
32366
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
32242
32367
|
}
|
|
32243
32368
|
|
|
32369
|
+
// ../gogcli-mcp/src/google-probe.ts
|
|
32370
|
+
var bool = (value) => typeof value === "boolean" ? value : void 0;
|
|
32371
|
+
var cause = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
32372
|
+
function readGoogleProbe(body) {
|
|
32373
|
+
const record2 = typeof body === "object" && body !== null ? body : {};
|
|
32374
|
+
const measured = bool(record2.measured);
|
|
32375
|
+
const reported = cause(record2.error);
|
|
32376
|
+
if (measured === false) {
|
|
32377
|
+
return {
|
|
32378
|
+
kind: "unmeasured",
|
|
32379
|
+
reason: reported ?? "the runner reported it could not measure the Google layer"
|
|
32380
|
+
};
|
|
32381
|
+
}
|
|
32382
|
+
if (measured === true) {
|
|
32383
|
+
if (bool(record2.ok) === true) return { kind: "ok" };
|
|
32384
|
+
return {
|
|
32385
|
+
kind: "unhealthy",
|
|
32386
|
+
reason: reported ?? "the runner reported the Google layer unhealthy with no cause"
|
|
32387
|
+
};
|
|
32388
|
+
}
|
|
32389
|
+
return {
|
|
32390
|
+
kind: "unmeasured",
|
|
32391
|
+
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"
|
|
32392
|
+
};
|
|
32393
|
+
}
|
|
32394
|
+
|
|
32244
32395
|
// ../gogcli-mcp/src/connector-runtime.ts
|
|
32245
32396
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
32246
32397
|
var DEADLINE_GRACE_MS = 5e3;
|
|
32398
|
+
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
32399
|
+
var REFUSAL_PROBE_TIMEOUT_MS = 4e3;
|
|
32400
|
+
var MIN_PROBE_BUDGET_MS = 1e3;
|
|
32401
|
+
var PROBE_INTERVAL_MS = 6e4;
|
|
32247
32402
|
var RUNNER_GOG_FAILED = 422;
|
|
32248
32403
|
var RUNNER_DRAINING = 503;
|
|
32404
|
+
var RUNNER_BAD_REQUEST = 400;
|
|
32405
|
+
var RUNNER_BAD_KEY = 401;
|
|
32406
|
+
var GogFailedError = class extends Error {
|
|
32407
|
+
/** gog's stderr alone, with no echoed argv mixed in. */
|
|
32408
|
+
stderr;
|
|
32409
|
+
constructor(message, stderr) {
|
|
32410
|
+
super(message);
|
|
32411
|
+
this.stderr = stderr;
|
|
32412
|
+
}
|
|
32413
|
+
};
|
|
32414
|
+
var GOOGLE_TOKEN_REJECTED_PATTERN = /Google API error \(401\b|invalid[ _]authentication[ _]credentials|\bACCESS_TOKEN_EXPIRED\b|\binvalid_token\b/i;
|
|
32415
|
+
var REFRESH_TOKEN_DEAD_PATTERN = /\binvalid_grant\b/i;
|
|
32416
|
+
var READ_ONLY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
32417
|
+
"cat",
|
|
32418
|
+
"describe",
|
|
32419
|
+
"get",
|
|
32420
|
+
"info",
|
|
32421
|
+
"list",
|
|
32422
|
+
"list-slides",
|
|
32423
|
+
"ls",
|
|
32424
|
+
"metadata",
|
|
32425
|
+
"read-slide",
|
|
32426
|
+
"search",
|
|
32427
|
+
"services",
|
|
32428
|
+
"status",
|
|
32429
|
+
"structure"
|
|
32430
|
+
]);
|
|
32431
|
+
function gogTarget(args) {
|
|
32432
|
+
const words = args.filter((arg) => typeof arg === "string");
|
|
32433
|
+
let service;
|
|
32434
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
32435
|
+
const word = words[i];
|
|
32436
|
+
if (word.startsWith("-")) {
|
|
32437
|
+
if (word === "--account") i += 1;
|
|
32438
|
+
continue;
|
|
32439
|
+
}
|
|
32440
|
+
if (service === void 0) {
|
|
32441
|
+
service = word;
|
|
32442
|
+
continue;
|
|
32443
|
+
}
|
|
32444
|
+
return { service, subcommand: word };
|
|
32445
|
+
}
|
|
32446
|
+
return { service };
|
|
32447
|
+
}
|
|
32448
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt, probeGoogle) {
|
|
32449
|
+
if (!(err instanceof GogFailedError)) return void 0;
|
|
32450
|
+
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
32451
|
+
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
32452
|
+
const { service, subcommand } = gogTarget(args);
|
|
32453
|
+
const credential = await readAccessToken?.credentialId?.();
|
|
32454
|
+
const where = { credential, service };
|
|
32455
|
+
if (grantDead) {
|
|
32456
|
+
logAuthTransition("grant.dead", {
|
|
32457
|
+
...where,
|
|
32458
|
+
reason: "gog reported invalid_grant: the stored refresh token is dead, so no token can be minted and this account must be re-authorized"
|
|
32459
|
+
});
|
|
32460
|
+
return void 0;
|
|
32461
|
+
}
|
|
32462
|
+
if (!used) {
|
|
32463
|
+
await probeGoogle(where);
|
|
32464
|
+
logAuthTransition("replay.declined", {
|
|
32465
|
+
...where,
|
|
32466
|
+
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
32467
|
+
});
|
|
32468
|
+
return void 0;
|
|
32469
|
+
}
|
|
32470
|
+
if (!readAccessToken?.invalidate) {
|
|
32471
|
+
logAuthTransition("replay.declined", {
|
|
32472
|
+
...where,
|
|
32473
|
+
reason: "this token source cannot mint a replacement, so a replay would resend the rejected token"
|
|
32474
|
+
});
|
|
32475
|
+
return void 0;
|
|
32476
|
+
}
|
|
32477
|
+
const evicted = await readAccessToken.invalidate(used);
|
|
32478
|
+
if (subcommand === void 0 || !READ_ONLY_SUBCOMMANDS.has(subcommand)) {
|
|
32479
|
+
logAuthTransition("replay.declined", {
|
|
32480
|
+
...where,
|
|
32481
|
+
reason: `not replayable: '${subcommand ?? "(none)"}' is not a known read-only subcommand and a write could double-apply`
|
|
32482
|
+
});
|
|
32483
|
+
return void 0;
|
|
32484
|
+
}
|
|
32485
|
+
if (!evicted) {
|
|
32486
|
+
logAuthTransition("replay.declined", {
|
|
32487
|
+
...where,
|
|
32488
|
+
reason: "the rejected token was already superseded, so the cache holds the token a replay would send"
|
|
32489
|
+
});
|
|
32490
|
+
return void 0;
|
|
32491
|
+
}
|
|
32492
|
+
const fresh = await readAccessToken();
|
|
32493
|
+
if (!fresh) {
|
|
32494
|
+
logAuthTransition("replay.declined", {
|
|
32495
|
+
...where,
|
|
32496
|
+
reason: "the token source produced no token after eviction; replaying without one would act as the backend"
|
|
32497
|
+
});
|
|
32498
|
+
return void 0;
|
|
32499
|
+
}
|
|
32500
|
+
const budgetMs = deadlineAt - Date.now();
|
|
32501
|
+
if (budgetMs < MIN_REPLAY_BUDGET_MS) {
|
|
32502
|
+
logAuthTransition("replay.declined", {
|
|
32503
|
+
...where,
|
|
32504
|
+
reason: `only ${budgetMs}ms of the call\u2019s deadline remained, so a replay could only time out; the rejected token was evicted, so the next call mints a fresh one`
|
|
32505
|
+
});
|
|
32506
|
+
return void 0;
|
|
32507
|
+
}
|
|
32508
|
+
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
32509
|
+
}
|
|
32249
32510
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
32511
|
+
let lastProbeAt = Number.NEGATIVE_INFINITY;
|
|
32512
|
+
const probeGoogleAfterRefusal = async (where, deadlineAt) => {
|
|
32513
|
+
const record2 = { ...where, endpoint };
|
|
32514
|
+
const now = Date.now();
|
|
32515
|
+
const remainingMs = deadlineAt - now;
|
|
32516
|
+
if (remainingMs < MIN_PROBE_BUDGET_MS) {
|
|
32517
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
32518
|
+
...record2,
|
|
32519
|
+
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`
|
|
32520
|
+
});
|
|
32521
|
+
return;
|
|
32522
|
+
}
|
|
32523
|
+
if (now - lastProbeAt < PROBE_INTERVAL_MS) {
|
|
32524
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
32525
|
+
...record2,
|
|
32526
|
+
// "attempted", not "measured". `lastProbeAt` is stamped before the
|
|
32527
|
+
// fetch and is deliberately NOT reset when the probe comes back with no
|
|
32528
|
+
// verdict (a 404 from a runner too old to have the endpoint, a timeout,
|
|
32529
|
+
// a dead socket) — the backend cost this throttle exists to bound was
|
|
32530
|
+
// paid either way, and resetting it would let a retry loop storm a
|
|
32531
|
+
// runner that is already unwell. So the timestamp stays and the sentence
|
|
32532
|
+
// has to be the true one: on this branch a log line may not assert a
|
|
32533
|
+
// measurement that never happened, and the previous probe may well have
|
|
32534
|
+
// measured nothing at all.
|
|
32535
|
+
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"
|
|
32536
|
+
});
|
|
32537
|
+
return;
|
|
32538
|
+
}
|
|
32539
|
+
lastProbeAt = now;
|
|
32540
|
+
let event;
|
|
32541
|
+
let reason;
|
|
32542
|
+
try {
|
|
32543
|
+
const res = await fetch(`${endpoint}/health/google`, {
|
|
32544
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
32545
|
+
// Never more than the probe's own budget, never more than the call has
|
|
32546
|
+
// left. `Math.min` rather than a plain constant because the second
|
|
32547
|
+
// bound is the caller's, and it outranks ours.
|
|
32548
|
+
signal: AbortSignal.timeout(Math.min(REFUSAL_PROBE_TIMEOUT_MS, remainingMs))
|
|
32549
|
+
});
|
|
32550
|
+
if (!res.ok) {
|
|
32551
|
+
event = "refusal.google-unmeasured";
|
|
32552
|
+
reason = `the runner did not answer the Google probe (HTTP ${res.status})`;
|
|
32553
|
+
} else {
|
|
32554
|
+
const verdict = readGoogleProbe(await res.json());
|
|
32555
|
+
if (verdict.kind === "ok") {
|
|
32556
|
+
event = "refusal.google-ok";
|
|
32557
|
+
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";
|
|
32558
|
+
} else {
|
|
32559
|
+
event = verdict.kind === "unhealthy" ? "refusal.google-unhealthy" : "refusal.google-unmeasured";
|
|
32560
|
+
reason = verdict.reason;
|
|
32561
|
+
}
|
|
32562
|
+
}
|
|
32563
|
+
} catch (err) {
|
|
32564
|
+
event = "refusal.google-unmeasured";
|
|
32565
|
+
reason = err instanceof Error ? err.message : String(err);
|
|
32566
|
+
}
|
|
32567
|
+
logAuthTransition(event, { ...record2, reason });
|
|
32568
|
+
};
|
|
32250
32569
|
return async (args, opts) => {
|
|
32251
32570
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
32252
32571
|
const accessToken = await readAccessToken?.();
|
|
32253
|
-
|
|
32572
|
+
const deadlineAt = Date.now() + deadlineMs;
|
|
32254
32573
|
try {
|
|
32255
|
-
|
|
32256
|
-
method: "POST",
|
|
32257
|
-
headers: {
|
|
32258
|
-
Authorization: "Bearer " + key,
|
|
32259
|
-
"Content-Type": "application/json"
|
|
32260
|
-
},
|
|
32261
|
-
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32262
|
-
signal: AbortSignal.timeout(deadlineMs)
|
|
32263
|
-
});
|
|
32574
|
+
return await attempt(endpoint, key, args, accessToken, deadlineMs);
|
|
32264
32575
|
} catch (err) {
|
|
32265
|
-
const
|
|
32266
|
-
|
|
32267
|
-
|
|
32268
|
-
|
|
32269
|
-
|
|
32576
|
+
const replay = await remintAfterGoogleRejection(
|
|
32577
|
+
err,
|
|
32578
|
+
accessToken,
|
|
32579
|
+
args,
|
|
32580
|
+
readAccessToken,
|
|
32581
|
+
deadlineAt,
|
|
32582
|
+
(where2) => probeGoogleAfterRefusal(where2, deadlineAt)
|
|
32583
|
+
);
|
|
32584
|
+
if (replay === void 0) throw err;
|
|
32585
|
+
const where = { credential: replay.credential, service: replay.service, endpoint };
|
|
32586
|
+
logAuthTransition("replay.attempted", {
|
|
32587
|
+
...where,
|
|
32588
|
+
reason: "Google rejected the access token; replaying this read once with a freshly minted one"
|
|
32589
|
+
});
|
|
32590
|
+
try {
|
|
32591
|
+
const stdout = await attempt(endpoint, key, args, replay.token, replay.budgetMs);
|
|
32592
|
+
logAuthTransition("replay.succeeded", where);
|
|
32593
|
+
return stdout;
|
|
32594
|
+
} catch (replayErr) {
|
|
32595
|
+
logAuthTransition("replay.failed", { ...where, reason: String(replayErr) });
|
|
32596
|
+
if (replayErr instanceof GogFailedError && GOOGLE_TOKEN_REJECTED_PATTERN.test(replayErr.stderr)) {
|
|
32597
|
+
await replay.invalidate(replay.token);
|
|
32598
|
+
}
|
|
32599
|
+
throw replayErr;
|
|
32270
32600
|
}
|
|
32271
|
-
throw err;
|
|
32272
32601
|
}
|
|
32273
|
-
|
|
32274
|
-
|
|
32275
|
-
|
|
32602
|
+
};
|
|
32603
|
+
}
|
|
32604
|
+
async function attempt(endpoint, key, args, accessToken, deadlineMs) {
|
|
32605
|
+
let res;
|
|
32606
|
+
try {
|
|
32607
|
+
res = await fetch(endpoint + "/run", {
|
|
32608
|
+
method: "POST",
|
|
32609
|
+
headers: {
|
|
32610
|
+
Authorization: "Bearer " + key,
|
|
32611
|
+
"Content-Type": "application/json"
|
|
32612
|
+
},
|
|
32613
|
+
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32614
|
+
signal: AbortSignal.timeout(deadlineMs)
|
|
32615
|
+
});
|
|
32616
|
+
} catch (err) {
|
|
32617
|
+
const name = err instanceof Error ? err.name : "";
|
|
32618
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
32619
|
+
throw new RunnerTransportError(
|
|
32620
|
+
`gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`,
|
|
32621
|
+
"transport-retryable"
|
|
32622
|
+
);
|
|
32623
|
+
}
|
|
32624
|
+
throw err;
|
|
32625
|
+
}
|
|
32626
|
+
if (!res.ok) {
|
|
32627
|
+
const body = await res.json().catch(() => null);
|
|
32628
|
+
const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
|
|
32276
32629
|
${body.stderr}` : body.error : "";
|
|
32277
|
-
|
|
32278
|
-
|
|
32279
|
-
|
|
32280
|
-
|
|
32281
|
-
throw new Error(
|
|
32282
|
-
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`
|
|
32283
|
-
);
|
|
32284
|
-
}
|
|
32285
|
-
if (detail) {
|
|
32286
|
-
throw new Error(detail);
|
|
32287
|
-
}
|
|
32288
|
-
throw new Error(
|
|
32289
|
-
`gog-runner HTTP ${res.status}: the response did not come from the runner, so the request never reached gog. The backend Machine was most likely starting or shutting down \u2014 this is transient, retry the same call.`
|
|
32630
|
+
if (res.status === RUNNER_GOG_FAILED) {
|
|
32631
|
+
throw new GogFailedError(
|
|
32632
|
+
detail || "gog failed on the runner (no detail supplied)",
|
|
32633
|
+
typeof body?.stderr === "string" ? body.stderr : ""
|
|
32290
32634
|
);
|
|
32291
32635
|
}
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32636
|
+
if (res.status === RUNNER_BAD_KEY) {
|
|
32637
|
+
logAuthTransition("runner.auth-failed", {
|
|
32638
|
+
service: gogTarget(args).service,
|
|
32639
|
+
endpoint,
|
|
32640
|
+
reason: "the gog-runner rejected the connector\u2019s bearer token, so gog never ran and no Google credential was read; GOG_RUNNER_KEY does not match the Fly app\u2019s RUNNER_KEY"
|
|
32641
|
+
});
|
|
32642
|
+
throw new RunnerTransportError(
|
|
32643
|
+
"gog-runner rejected the connector's bearer token, so the request never reached gog and no Google credential was involved. The Worker secret GOG_RUNNER_KEY no longer matches RUNNER_KEY on the Fly app; set them to the same value (wrangler secret put GOG_RUNNER_KEY / fly secrets set RUNNER_KEY) and retry.",
|
|
32644
|
+
"transport-auth",
|
|
32645
|
+
res.status
|
|
32646
|
+
);
|
|
32647
|
+
}
|
|
32648
|
+
if (res.status === RUNNER_BAD_REQUEST) {
|
|
32649
|
+
throw new RunnerTransportError(
|
|
32650
|
+
detail || "gog-runner rejected the request (no detail supplied)",
|
|
32651
|
+
"transport-request",
|
|
32652
|
+
res.status
|
|
32653
|
+
);
|
|
32654
|
+
}
|
|
32655
|
+
if (res.status === RUNNER_DRAINING || body?.retryable === true) {
|
|
32656
|
+
throw new RunnerTransportError(
|
|
32657
|
+
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`,
|
|
32658
|
+
"transport-retryable",
|
|
32659
|
+
res.status
|
|
32660
|
+
);
|
|
32661
|
+
}
|
|
32662
|
+
if (detail) {
|
|
32663
|
+
throw new Error(detail);
|
|
32664
|
+
}
|
|
32665
|
+
throw new RunnerTransportError(
|
|
32666
|
+
`gog-runner HTTP ${res.status}: the response did not come from the runner, so the request never reached gog. The backend Machine was most likely starting or shutting down \u2014 this is transient, retry the same call.`,
|
|
32667
|
+
"transport-retryable",
|
|
32668
|
+
res.status
|
|
32669
|
+
);
|
|
32670
|
+
}
|
|
32671
|
+
const { stdout } = await res.json();
|
|
32672
|
+
return stdout;
|
|
32295
32673
|
}
|
|
32296
32674
|
|
|
32297
32675
|
// ../gogcli-mcp/src/remote-runner.ts
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "gogcli-mcp-classroom",
|
|
5
5
|
"display_name": "gogcli (Classroom)",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.22.0",
|
|
7
7
|
"description": "Extended Google Classroom for Claude via gogcli — auth + full Classroom support (courses, rosters, coursework, submissions, announcements, topics, invitations)",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-classroom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"mcpName": "io.github.chrischall/gogcli-mcp-classroom",
|
|
5
5
|
"description": "Extended Google Classroom MCP server via gogcli — auth + full Classroom support",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"source": "github",
|
|
8
8
|
"subfolder": "packages/gogcli-mcp-classroom"
|
|
9
9
|
},
|
|
10
|
-
"version": "2.
|
|
10
|
+
"version": "2.22.0",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "gogcli-mcp-classroom",
|
|
15
|
-
"version": "2.
|
|
15
|
+
"version": "2.22.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|