gogcli-mcp-docs 2.21.0 → 2.21.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/index.js +321 -54
- 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 Docs for Claude via gogcli — auth + full Docs and comments support",
|
|
10
|
-
"version": "2.21.
|
|
10
|
+
"version": "2.21.1"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "gogcli (Docs)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
|
|
18
|
-
"version": "2.21.
|
|
18
|
+
"version": "2.21.1",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
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
|
|
|
@@ -31584,7 +31603,7 @@ function registerRunTool(server, options) {
|
|
|
31584
31603
|
function errorText(err) {
|
|
31585
31604
|
return err instanceof Error ? `Error: ${err.message}` : String(err);
|
|
31586
31605
|
}
|
|
31587
|
-
var DEFINITE_AUTH_PATTERN = /\b(
|
|
31606
|
+
var DEFINITE_AUTH_PATTERN = /\b(?:unauthorized|invalid_grant)\b|\b(?:error|status|code|http|responded|response)["']?[\s:=(,]{0,4}401\b/i;
|
|
31588
31607
|
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;
|
|
31589
31608
|
var AUTH_ERROR_PATTERN = new RegExp(`${DEFINITE_AUTH_PATTERN.source}|${STALE_TOKEN_PATTERN.source}`, "i");
|
|
31590
31609
|
var INVALID_GRANT_PATTERN = /invalid_grant|token has been expired or revoked/i;
|
|
@@ -31594,6 +31613,14 @@ var AUTH_HINT = "\n\nAuthentication may have expired. Use gog_auth_add to re-aut
|
|
|
31594
31613
|
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.';
|
|
31595
31614
|
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).";
|
|
31596
31615
|
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.";
|
|
31616
|
+
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.";
|
|
31617
|
+
var RUNNER_TRANSPORT_HINTS = {
|
|
31618
|
+
"transport-auth": RUNNER_TRANSPORT_AUTH_HINT,
|
|
31619
|
+
// The request itself was malformed, so the runner will refuse it identically
|
|
31620
|
+
// every time. Nothing to advise beyond the message the runner already gave.
|
|
31621
|
+
"transport-request": "",
|
|
31622
|
+
"transport-retryable": TRANSIENT_HINT
|
|
31623
|
+
};
|
|
31597
31624
|
function formatAccountList(raw) {
|
|
31598
31625
|
try {
|
|
31599
31626
|
const parsed = JSON.parse(raw);
|
|
@@ -31606,11 +31633,12 @@ function formatAccountList(raw) {
|
|
|
31606
31633
|
}
|
|
31607
31634
|
async function diagnose(err) {
|
|
31608
31635
|
const errText = errorText(err);
|
|
31636
|
+
const transportHint = isRunnerTransportError(err) ? RUNNER_TRANSPORT_HINTS[err.kind] : void 0;
|
|
31609
31637
|
const isInvalidGrant = INVALID_GRANT_PATTERN.test(errText);
|
|
31610
31638
|
const isTransientError = !DEFINITE_AUTH_PATTERN.test(errText) && TRANSIENT_ERROR_PATTERN.test(errText);
|
|
31611
31639
|
const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
|
|
31612
31640
|
const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
|
|
31613
|
-
const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
|
|
31641
|
+
const hint = transportHint ?? (isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "");
|
|
31614
31642
|
try {
|
|
31615
31643
|
const accounts = formatAccountList(await run(["auth", "list"]));
|
|
31616
31644
|
return errorResult(`${errText}
|
|
@@ -31904,7 +31932,25 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
31904
31932
|
);
|
|
31905
31933
|
|
|
31906
31934
|
// ../gogcli-mcp/src/server.ts
|
|
31907
|
-
var VERSION = true ? "2.21.
|
|
31935
|
+
var VERSION = true ? "2.21.1" : "0.0.0";
|
|
31936
|
+
|
|
31937
|
+
// ../gogcli-mcp/src/auth-log.ts
|
|
31938
|
+
var FAILURES = /* @__PURE__ */ new Set([
|
|
31939
|
+
"token.mint-failed",
|
|
31940
|
+
"grant.dead",
|
|
31941
|
+
"replay.failed",
|
|
31942
|
+
"runner.auth-failed"
|
|
31943
|
+
]);
|
|
31944
|
+
var PREFIX = "gog-auth ";
|
|
31945
|
+
var TAG_CHARS = 12;
|
|
31946
|
+
function credentialTag(cacheKeyHash) {
|
|
31947
|
+
return cacheKeyHash.slice(0, TAG_CHARS);
|
|
31948
|
+
}
|
|
31949
|
+
function logAuthTransition(event, context) {
|
|
31950
|
+
const record2 = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...context });
|
|
31951
|
+
const write = FAILURES.has(event) ? console.error : console.warn;
|
|
31952
|
+
write(PREFIX + redactSecrets2(record2));
|
|
31953
|
+
}
|
|
31908
31954
|
|
|
31909
31955
|
// ../gogcli-mcp/src/google-token.ts
|
|
31910
31956
|
var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
@@ -31931,22 +31977,73 @@ function makeAccessTokenSource(env) {
|
|
|
31931
31977
|
);
|
|
31932
31978
|
};
|
|
31933
31979
|
}
|
|
31934
|
-
|
|
31935
|
-
|
|
31936
|
-
|
|
31937
|
-
|
|
31938
|
-
|
|
31980
|
+
let keyPromise;
|
|
31981
|
+
const key = () => keyPromise ??= cacheKey(refreshToken, clientId);
|
|
31982
|
+
const logCacheHits = parseBoolEnv("GOG_AUTH_LOG_CACHE_HITS", { env });
|
|
31983
|
+
const read = async () => {
|
|
31984
|
+
const k = await key();
|
|
31985
|
+
const hit = cache.get(k);
|
|
31986
|
+
if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) {
|
|
31987
|
+
if (logCacheHits) logAuthTransition("token.cache-hit", { credential: credentialTag(k) });
|
|
31988
|
+
return hit.accessToken;
|
|
31989
|
+
}
|
|
31990
|
+
let pending = inFlight.get(k);
|
|
31939
31991
|
if (!pending) {
|
|
31940
31992
|
pending = exchange(refreshToken, clientId, clientSecret).then((minted2) => {
|
|
31941
|
-
cache.set(
|
|
31993
|
+
cache.set(k, minted2);
|
|
31994
|
+
logAuthTransition("token.minted", {
|
|
31995
|
+
credential: credentialTag(k),
|
|
31996
|
+
reason: `valid for ${Math.round((minted2.expiresAt - Date.now()) / 1e3)}s`
|
|
31997
|
+
});
|
|
31942
31998
|
return minted2;
|
|
31943
|
-
}).
|
|
31944
|
-
|
|
31999
|
+
}).catch((err) => {
|
|
32000
|
+
logAuthTransition(err.grantDead ? "grant.dead" : "token.mint-failed", {
|
|
32001
|
+
credential: credentialTag(k),
|
|
32002
|
+
reason: err.message
|
|
32003
|
+
});
|
|
32004
|
+
throw err;
|
|
32005
|
+
}).finally(() => inFlight.delete(k));
|
|
32006
|
+
inFlight.set(k, pending);
|
|
31945
32007
|
}
|
|
31946
32008
|
const minted = await pending;
|
|
31947
32009
|
return minted.accessToken;
|
|
31948
32010
|
};
|
|
32011
|
+
const invalidate = async (rejected) => {
|
|
32012
|
+
const k = await key();
|
|
32013
|
+
const hit = cache.get(k);
|
|
32014
|
+
if (!hit || hit.accessToken !== rejected) {
|
|
32015
|
+
logAuthTransition("token.evict-noop", {
|
|
32016
|
+
credential: credentialTag(k),
|
|
32017
|
+
reason: hit ? "a concurrent caller had already replaced this credential\u2019s token" : "no token was cached for this credential"
|
|
32018
|
+
});
|
|
32019
|
+
return false;
|
|
32020
|
+
}
|
|
32021
|
+
cache.delete(k);
|
|
32022
|
+
logAuthTransition("token.evicted", {
|
|
32023
|
+
credential: credentialTag(k),
|
|
32024
|
+
reason: "Google rejected this access token; the next read will mint a new one"
|
|
32025
|
+
});
|
|
32026
|
+
return true;
|
|
32027
|
+
};
|
|
32028
|
+
return Object.assign(read, {
|
|
32029
|
+
invalidate,
|
|
32030
|
+
credentialId: async () => credentialTag(await key())
|
|
32031
|
+
});
|
|
31949
32032
|
}
|
|
32033
|
+
var TokenExchangeError = class extends Error {
|
|
32034
|
+
/**
|
|
32035
|
+
* The REFRESH token is dead (Google's `invalid_grant`), not merely the access
|
|
32036
|
+
* token. Carried as a flag rather than re-read from the message, because
|
|
32037
|
+
* inferring the author of a failure from prose several authors can produce is
|
|
32038
|
+
* precisely the mistake this branch exists to undo. `instanceof` is safe: the
|
|
32039
|
+
* class is thrown and caught inside this one module.
|
|
32040
|
+
*/
|
|
32041
|
+
grantDead;
|
|
32042
|
+
constructor(message, grantDead) {
|
|
32043
|
+
super(message);
|
|
32044
|
+
this.grantDead = grantDead;
|
|
32045
|
+
}
|
|
32046
|
+
};
|
|
31950
32047
|
async function exchange(refreshToken, clientId, clientSecret) {
|
|
31951
32048
|
let res;
|
|
31952
32049
|
try {
|
|
@@ -31961,23 +32058,29 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
31961
32058
|
}).toString()
|
|
31962
32059
|
});
|
|
31963
32060
|
} catch (err) {
|
|
31964
|
-
throw new
|
|
31965
|
-
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}
|
|
32061
|
+
throw new TokenExchangeError(
|
|
32062
|
+
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`,
|
|
32063
|
+
false
|
|
31966
32064
|
);
|
|
31967
32065
|
}
|
|
31968
32066
|
const body = await res.json().catch(() => ({}));
|
|
31969
32067
|
if (!res.ok) {
|
|
31970
32068
|
if (body.error === "invalid_grant") {
|
|
31971
|
-
throw new
|
|
31972
|
-
'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.'
|
|
32069
|
+
throw new TokenExchangeError(
|
|
32070
|
+
'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.',
|
|
32071
|
+
true
|
|
31973
32072
|
);
|
|
31974
32073
|
}
|
|
31975
|
-
throw new
|
|
31976
|
-
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})
|
|
32074
|
+
throw new TokenExchangeError(
|
|
32075
|
+
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`,
|
|
32076
|
+
false
|
|
31977
32077
|
);
|
|
31978
32078
|
}
|
|
31979
32079
|
if (!body.access_token) {
|
|
31980
|
-
throw new
|
|
32080
|
+
throw new TokenExchangeError(
|
|
32081
|
+
"the access token could not be refreshed: Google returned no access_token",
|
|
32082
|
+
false
|
|
32083
|
+
);
|
|
31981
32084
|
}
|
|
31982
32085
|
const expiresInMs = (body.expires_in ?? 3600) * 1e3;
|
|
31983
32086
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
@@ -31986,54 +32089,218 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
31986
32089
|
// ../gogcli-mcp/src/connector-runtime.ts
|
|
31987
32090
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
31988
32091
|
var DEADLINE_GRACE_MS = 5e3;
|
|
32092
|
+
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
31989
32093
|
var RUNNER_GOG_FAILED = 422;
|
|
31990
32094
|
var RUNNER_DRAINING = 503;
|
|
32095
|
+
var RUNNER_BAD_REQUEST = 400;
|
|
32096
|
+
var RUNNER_BAD_KEY = 401;
|
|
32097
|
+
var GogFailedError = class extends Error {
|
|
32098
|
+
/** gog's stderr alone, with no echoed argv mixed in. */
|
|
32099
|
+
stderr;
|
|
32100
|
+
constructor(message, stderr) {
|
|
32101
|
+
super(message);
|
|
32102
|
+
this.stderr = stderr;
|
|
32103
|
+
}
|
|
32104
|
+
};
|
|
32105
|
+
var GOOGLE_TOKEN_REJECTED_PATTERN = /Google API error \(401\b|invalid[ _]authentication[ _]credentials|\bACCESS_TOKEN_EXPIRED\b|\binvalid_token\b/i;
|
|
32106
|
+
var REFRESH_TOKEN_DEAD_PATTERN = /\binvalid_grant\b/i;
|
|
32107
|
+
var READ_ONLY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
32108
|
+
"cat",
|
|
32109
|
+
"describe",
|
|
32110
|
+
"get",
|
|
32111
|
+
"info",
|
|
32112
|
+
"list",
|
|
32113
|
+
"list-slides",
|
|
32114
|
+
"ls",
|
|
32115
|
+
"metadata",
|
|
32116
|
+
"read-slide",
|
|
32117
|
+
"search",
|
|
32118
|
+
"services",
|
|
32119
|
+
"status",
|
|
32120
|
+
"structure"
|
|
32121
|
+
]);
|
|
32122
|
+
function gogTarget(args) {
|
|
32123
|
+
const words = args.filter((arg) => typeof arg === "string");
|
|
32124
|
+
let service;
|
|
32125
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
32126
|
+
const word = words[i];
|
|
32127
|
+
if (word.startsWith("-")) {
|
|
32128
|
+
if (word === "--account") i += 1;
|
|
32129
|
+
continue;
|
|
32130
|
+
}
|
|
32131
|
+
if (service === void 0) {
|
|
32132
|
+
service = word;
|
|
32133
|
+
continue;
|
|
32134
|
+
}
|
|
32135
|
+
return { service, subcommand: word };
|
|
32136
|
+
}
|
|
32137
|
+
return { service };
|
|
32138
|
+
}
|
|
32139
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
32140
|
+
if (!(err instanceof GogFailedError)) return void 0;
|
|
32141
|
+
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
32142
|
+
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
32143
|
+
const { service, subcommand } = gogTarget(args);
|
|
32144
|
+
const credential = await readAccessToken?.credentialId?.();
|
|
32145
|
+
const where = { credential, service };
|
|
32146
|
+
if (grantDead) {
|
|
32147
|
+
logAuthTransition("grant.dead", {
|
|
32148
|
+
...where,
|
|
32149
|
+
reason: "gog reported invalid_grant: the stored refresh token is dead, so no token can be minted and this account must be re-authorized"
|
|
32150
|
+
});
|
|
32151
|
+
return void 0;
|
|
32152
|
+
}
|
|
32153
|
+
if (!used) {
|
|
32154
|
+
logAuthTransition("replay.declined", {
|
|
32155
|
+
...where,
|
|
32156
|
+
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
32157
|
+
});
|
|
32158
|
+
return void 0;
|
|
32159
|
+
}
|
|
32160
|
+
if (!readAccessToken?.invalidate) {
|
|
32161
|
+
logAuthTransition("replay.declined", {
|
|
32162
|
+
...where,
|
|
32163
|
+
reason: "this token source cannot mint a replacement, so a replay would resend the rejected token"
|
|
32164
|
+
});
|
|
32165
|
+
return void 0;
|
|
32166
|
+
}
|
|
32167
|
+
const evicted = await readAccessToken.invalidate(used);
|
|
32168
|
+
if (subcommand === void 0 || !READ_ONLY_SUBCOMMANDS.has(subcommand)) {
|
|
32169
|
+
logAuthTransition("replay.declined", {
|
|
32170
|
+
...where,
|
|
32171
|
+
reason: `not replayable: '${subcommand ?? "(none)"}' is not a known read-only subcommand and a write could double-apply`
|
|
32172
|
+
});
|
|
32173
|
+
return void 0;
|
|
32174
|
+
}
|
|
32175
|
+
if (!evicted) {
|
|
32176
|
+
logAuthTransition("replay.declined", {
|
|
32177
|
+
...where,
|
|
32178
|
+
reason: "the rejected token was already superseded, so the cache holds the token a replay would send"
|
|
32179
|
+
});
|
|
32180
|
+
return void 0;
|
|
32181
|
+
}
|
|
32182
|
+
const fresh = await readAccessToken();
|
|
32183
|
+
if (!fresh) {
|
|
32184
|
+
logAuthTransition("replay.declined", {
|
|
32185
|
+
...where,
|
|
32186
|
+
reason: "the token source produced no token after eviction; replaying without one would act as the backend"
|
|
32187
|
+
});
|
|
32188
|
+
return void 0;
|
|
32189
|
+
}
|
|
32190
|
+
const budgetMs = deadlineAt - Date.now();
|
|
32191
|
+
if (budgetMs < MIN_REPLAY_BUDGET_MS) {
|
|
32192
|
+
logAuthTransition("replay.declined", {
|
|
32193
|
+
...where,
|
|
32194
|
+
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`
|
|
32195
|
+
});
|
|
32196
|
+
return void 0;
|
|
32197
|
+
}
|
|
32198
|
+
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
32199
|
+
}
|
|
31991
32200
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
31992
32201
|
return async (args, opts) => {
|
|
31993
32202
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
31994
32203
|
const accessToken = await readAccessToken?.();
|
|
31995
|
-
|
|
32204
|
+
const deadlineAt = Date.now() + deadlineMs;
|
|
31996
32205
|
try {
|
|
31997
|
-
|
|
31998
|
-
method: "POST",
|
|
31999
|
-
headers: {
|
|
32000
|
-
Authorization: "Bearer " + key,
|
|
32001
|
-
"Content-Type": "application/json"
|
|
32002
|
-
},
|
|
32003
|
-
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32004
|
-
signal: AbortSignal.timeout(deadlineMs)
|
|
32005
|
-
});
|
|
32206
|
+
return await attempt(endpoint, key, args, accessToken, deadlineMs);
|
|
32006
32207
|
} catch (err) {
|
|
32007
|
-
const
|
|
32008
|
-
|
|
32009
|
-
|
|
32010
|
-
|
|
32011
|
-
|
|
32208
|
+
const replay = await remintAfterGoogleRejection(
|
|
32209
|
+
err,
|
|
32210
|
+
accessToken,
|
|
32211
|
+
args,
|
|
32212
|
+
readAccessToken,
|
|
32213
|
+
deadlineAt
|
|
32214
|
+
);
|
|
32215
|
+
if (replay === void 0) throw err;
|
|
32216
|
+
const where = { credential: replay.credential, service: replay.service, endpoint };
|
|
32217
|
+
logAuthTransition("replay.attempted", {
|
|
32218
|
+
...where,
|
|
32219
|
+
reason: "Google rejected the access token; replaying this read once with a freshly minted one"
|
|
32220
|
+
});
|
|
32221
|
+
try {
|
|
32222
|
+
const stdout = await attempt(endpoint, key, args, replay.token, replay.budgetMs);
|
|
32223
|
+
logAuthTransition("replay.succeeded", where);
|
|
32224
|
+
return stdout;
|
|
32225
|
+
} catch (replayErr) {
|
|
32226
|
+
logAuthTransition("replay.failed", { ...where, reason: String(replayErr) });
|
|
32227
|
+
if (replayErr instanceof GogFailedError && GOOGLE_TOKEN_REJECTED_PATTERN.test(replayErr.stderr)) {
|
|
32228
|
+
await replay.invalidate(replay.token);
|
|
32229
|
+
}
|
|
32230
|
+
throw replayErr;
|
|
32012
32231
|
}
|
|
32013
|
-
throw err;
|
|
32014
32232
|
}
|
|
32015
|
-
|
|
32016
|
-
|
|
32017
|
-
|
|
32233
|
+
};
|
|
32234
|
+
}
|
|
32235
|
+
async function attempt(endpoint, key, args, accessToken, deadlineMs) {
|
|
32236
|
+
let res;
|
|
32237
|
+
try {
|
|
32238
|
+
res = await fetch(endpoint + "/run", {
|
|
32239
|
+
method: "POST",
|
|
32240
|
+
headers: {
|
|
32241
|
+
Authorization: "Bearer " + key,
|
|
32242
|
+
"Content-Type": "application/json"
|
|
32243
|
+
},
|
|
32244
|
+
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32245
|
+
signal: AbortSignal.timeout(deadlineMs)
|
|
32246
|
+
});
|
|
32247
|
+
} catch (err) {
|
|
32248
|
+
const name = err instanceof Error ? err.name : "";
|
|
32249
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
32250
|
+
throw new RunnerTransportError(
|
|
32251
|
+
`gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`,
|
|
32252
|
+
"transport-retryable"
|
|
32253
|
+
);
|
|
32254
|
+
}
|
|
32255
|
+
throw err;
|
|
32256
|
+
}
|
|
32257
|
+
if (!res.ok) {
|
|
32258
|
+
const body = await res.json().catch(() => null);
|
|
32259
|
+
const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
|
|
32018
32260
|
${body.stderr}` : body.error : "";
|
|
32019
|
-
|
|
32020
|
-
|
|
32021
|
-
|
|
32022
|
-
|
|
32023
|
-
throw new Error(
|
|
32024
|
-
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`
|
|
32025
|
-
);
|
|
32026
|
-
}
|
|
32027
|
-
if (detail) {
|
|
32028
|
-
throw new Error(detail);
|
|
32029
|
-
}
|
|
32030
|
-
throw new Error(
|
|
32031
|
-
`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.`
|
|
32261
|
+
if (res.status === RUNNER_GOG_FAILED) {
|
|
32262
|
+
throw new GogFailedError(
|
|
32263
|
+
detail || "gog failed on the runner (no detail supplied)",
|
|
32264
|
+
typeof body?.stderr === "string" ? body.stderr : ""
|
|
32032
32265
|
);
|
|
32033
32266
|
}
|
|
32034
|
-
|
|
32035
|
-
|
|
32036
|
-
|
|
32267
|
+
if (res.status === RUNNER_BAD_KEY) {
|
|
32268
|
+
logAuthTransition("runner.auth-failed", {
|
|
32269
|
+
service: gogTarget(args).service,
|
|
32270
|
+
endpoint,
|
|
32271
|
+
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"
|
|
32272
|
+
});
|
|
32273
|
+
throw new RunnerTransportError(
|
|
32274
|
+
"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.",
|
|
32275
|
+
"transport-auth",
|
|
32276
|
+
res.status
|
|
32277
|
+
);
|
|
32278
|
+
}
|
|
32279
|
+
if (res.status === RUNNER_BAD_REQUEST) {
|
|
32280
|
+
throw new RunnerTransportError(
|
|
32281
|
+
detail || "gog-runner rejected the request (no detail supplied)",
|
|
32282
|
+
"transport-request",
|
|
32283
|
+
res.status
|
|
32284
|
+
);
|
|
32285
|
+
}
|
|
32286
|
+
if (res.status === RUNNER_DRAINING || body?.retryable === true) {
|
|
32287
|
+
throw new RunnerTransportError(
|
|
32288
|
+
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`,
|
|
32289
|
+
"transport-retryable",
|
|
32290
|
+
res.status
|
|
32291
|
+
);
|
|
32292
|
+
}
|
|
32293
|
+
if (detail) {
|
|
32294
|
+
throw new Error(detail);
|
|
32295
|
+
}
|
|
32296
|
+
throw new RunnerTransportError(
|
|
32297
|
+
`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.`,
|
|
32298
|
+
"transport-retryable",
|
|
32299
|
+
res.status
|
|
32300
|
+
);
|
|
32301
|
+
}
|
|
32302
|
+
const { stdout } = await res.json();
|
|
32303
|
+
return stdout;
|
|
32037
32304
|
}
|
|
32038
32305
|
|
|
32039
32306
|
// ../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-docs",
|
|
5
5
|
"display_name": "gogcli (Docs)",
|
|
6
|
-
"version": "2.21.
|
|
6
|
+
"version": "2.21.1",
|
|
7
7
|
"description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-docs",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"mcpName": "io.github.chrischall/gogcli-mcp-docs",
|
|
5
5
|
"description": "Extended Google Docs MCP server via gogcli — all base tools plus full Docs 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-docs"
|
|
9
9
|
},
|
|
10
|
-
"version": "2.21.
|
|
10
|
+
"version": "2.21.1",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "gogcli-mcp-docs",
|
|
15
|
-
"version": "2.21.
|
|
15
|
+
"version": "2.21.1",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|