gogcli-mcp-sheets 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 Sheets for Claude via gogcli — auth + full Sheets 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 (Sheets)",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "Extended Google Sheets for Claude via gogcli — auth + full Sheets 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
|
|
|
@@ -31579,7 +31598,7 @@ function registerRunTool(server, options) {
|
|
|
31579
31598
|
function errorText(err) {
|
|
31580
31599
|
return err instanceof Error ? `Error: ${err.message}` : String(err);
|
|
31581
31600
|
}
|
|
31582
|
-
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;
|
|
31583
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;
|
|
31584
31603
|
var AUTH_ERROR_PATTERN = new RegExp(`${DEFINITE_AUTH_PATTERN.source}|${STALE_TOKEN_PATTERN.source}`, "i");
|
|
31585
31604
|
var INVALID_GRANT_PATTERN = /invalid_grant|token has been expired or revoked/i;
|
|
@@ -31589,6 +31608,14 @@ var AUTH_HINT = "\n\nAuthentication may have expired. Use gog_auth_add to re-aut
|
|
|
31589
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.';
|
|
31590
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).";
|
|
31591
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
|
+
};
|
|
31592
31619
|
function formatAccountList(raw) {
|
|
31593
31620
|
try {
|
|
31594
31621
|
const parsed = JSON.parse(raw);
|
|
@@ -31601,11 +31628,12 @@ function formatAccountList(raw) {
|
|
|
31601
31628
|
}
|
|
31602
31629
|
async function diagnose(err) {
|
|
31603
31630
|
const errText = errorText(err);
|
|
31631
|
+
const transportHint = isRunnerTransportError(err) ? RUNNER_TRANSPORT_HINTS[err.kind] : void 0;
|
|
31604
31632
|
const isInvalidGrant = INVALID_GRANT_PATTERN.test(errText);
|
|
31605
31633
|
const isTransientError = !DEFINITE_AUTH_PATTERN.test(errText) && TRANSIENT_ERROR_PATTERN.test(errText);
|
|
31606
31634
|
const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
|
|
31607
31635
|
const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
|
|
31608
|
-
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 : "");
|
|
31609
31637
|
try {
|
|
31610
31638
|
const accounts = formatAccountList(await run(["auth", "list"]));
|
|
31611
31639
|
return errorResult(`${errText}
|
|
@@ -31958,7 +31986,25 @@ function registerSheetsTools(server) {
|
|
|
31958
31986
|
}
|
|
31959
31987
|
|
|
31960
31988
|
// ../gogcli-mcp/src/server.ts
|
|
31961
|
-
var VERSION = true ? "2.21.
|
|
31989
|
+
var VERSION = true ? "2.21.1" : "0.0.0";
|
|
31990
|
+
|
|
31991
|
+
// ../gogcli-mcp/src/auth-log.ts
|
|
31992
|
+
var FAILURES = /* @__PURE__ */ new Set([
|
|
31993
|
+
"token.mint-failed",
|
|
31994
|
+
"grant.dead",
|
|
31995
|
+
"replay.failed",
|
|
31996
|
+
"runner.auth-failed"
|
|
31997
|
+
]);
|
|
31998
|
+
var PREFIX = "gog-auth ";
|
|
31999
|
+
var TAG_CHARS = 12;
|
|
32000
|
+
function credentialTag(cacheKeyHash) {
|
|
32001
|
+
return cacheKeyHash.slice(0, TAG_CHARS);
|
|
32002
|
+
}
|
|
32003
|
+
function logAuthTransition(event, context) {
|
|
32004
|
+
const record2 = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...context });
|
|
32005
|
+
const write = FAILURES.has(event) ? console.error : console.warn;
|
|
32006
|
+
write(PREFIX + redactSecrets2(record2));
|
|
32007
|
+
}
|
|
31962
32008
|
|
|
31963
32009
|
// ../gogcli-mcp/src/google-token.ts
|
|
31964
32010
|
var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
@@ -31985,22 +32031,73 @@ function makeAccessTokenSource(env) {
|
|
|
31985
32031
|
);
|
|
31986
32032
|
};
|
|
31987
32033
|
}
|
|
31988
|
-
|
|
31989
|
-
|
|
31990
|
-
|
|
31991
|
-
|
|
31992
|
-
|
|
32034
|
+
let keyPromise;
|
|
32035
|
+
const key = () => keyPromise ??= cacheKey(refreshToken, clientId);
|
|
32036
|
+
const logCacheHits = parseBoolEnv("GOG_AUTH_LOG_CACHE_HITS", { env });
|
|
32037
|
+
const read = async () => {
|
|
32038
|
+
const k = await key();
|
|
32039
|
+
const hit = cache.get(k);
|
|
32040
|
+
if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) {
|
|
32041
|
+
if (logCacheHits) logAuthTransition("token.cache-hit", { credential: credentialTag(k) });
|
|
32042
|
+
return hit.accessToken;
|
|
32043
|
+
}
|
|
32044
|
+
let pending = inFlight.get(k);
|
|
31993
32045
|
if (!pending) {
|
|
31994
32046
|
pending = exchange(refreshToken, clientId, clientSecret).then((minted2) => {
|
|
31995
|
-
cache.set(
|
|
32047
|
+
cache.set(k, minted2);
|
|
32048
|
+
logAuthTransition("token.minted", {
|
|
32049
|
+
credential: credentialTag(k),
|
|
32050
|
+
reason: `valid for ${Math.round((minted2.expiresAt - Date.now()) / 1e3)}s`
|
|
32051
|
+
});
|
|
31996
32052
|
return minted2;
|
|
31997
|
-
}).
|
|
31998
|
-
|
|
32053
|
+
}).catch((err) => {
|
|
32054
|
+
logAuthTransition(err.grantDead ? "grant.dead" : "token.mint-failed", {
|
|
32055
|
+
credential: credentialTag(k),
|
|
32056
|
+
reason: err.message
|
|
32057
|
+
});
|
|
32058
|
+
throw err;
|
|
32059
|
+
}).finally(() => inFlight.delete(k));
|
|
32060
|
+
inFlight.set(k, pending);
|
|
31999
32061
|
}
|
|
32000
32062
|
const minted = await pending;
|
|
32001
32063
|
return minted.accessToken;
|
|
32002
32064
|
};
|
|
32065
|
+
const invalidate = async (rejected) => {
|
|
32066
|
+
const k = await key();
|
|
32067
|
+
const hit = cache.get(k);
|
|
32068
|
+
if (!hit || hit.accessToken !== rejected) {
|
|
32069
|
+
logAuthTransition("token.evict-noop", {
|
|
32070
|
+
credential: credentialTag(k),
|
|
32071
|
+
reason: hit ? "a concurrent caller had already replaced this credential\u2019s token" : "no token was cached for this credential"
|
|
32072
|
+
});
|
|
32073
|
+
return false;
|
|
32074
|
+
}
|
|
32075
|
+
cache.delete(k);
|
|
32076
|
+
logAuthTransition("token.evicted", {
|
|
32077
|
+
credential: credentialTag(k),
|
|
32078
|
+
reason: "Google rejected this access token; the next read will mint a new one"
|
|
32079
|
+
});
|
|
32080
|
+
return true;
|
|
32081
|
+
};
|
|
32082
|
+
return Object.assign(read, {
|
|
32083
|
+
invalidate,
|
|
32084
|
+
credentialId: async () => credentialTag(await key())
|
|
32085
|
+
});
|
|
32003
32086
|
}
|
|
32087
|
+
var TokenExchangeError = class extends Error {
|
|
32088
|
+
/**
|
|
32089
|
+
* The REFRESH token is dead (Google's `invalid_grant`), not merely the access
|
|
32090
|
+
* token. Carried as a flag rather than re-read from the message, because
|
|
32091
|
+
* inferring the author of a failure from prose several authors can produce is
|
|
32092
|
+
* precisely the mistake this branch exists to undo. `instanceof` is safe: the
|
|
32093
|
+
* class is thrown and caught inside this one module.
|
|
32094
|
+
*/
|
|
32095
|
+
grantDead;
|
|
32096
|
+
constructor(message, grantDead) {
|
|
32097
|
+
super(message);
|
|
32098
|
+
this.grantDead = grantDead;
|
|
32099
|
+
}
|
|
32100
|
+
};
|
|
32004
32101
|
async function exchange(refreshToken, clientId, clientSecret) {
|
|
32005
32102
|
let res;
|
|
32006
32103
|
try {
|
|
@@ -32015,23 +32112,29 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
32015
32112
|
}).toString()
|
|
32016
32113
|
});
|
|
32017
32114
|
} catch (err) {
|
|
32018
|
-
throw new
|
|
32019
|
-
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}
|
|
32115
|
+
throw new TokenExchangeError(
|
|
32116
|
+
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`,
|
|
32117
|
+
false
|
|
32020
32118
|
);
|
|
32021
32119
|
}
|
|
32022
32120
|
const body = await res.json().catch(() => ({}));
|
|
32023
32121
|
if (!res.ok) {
|
|
32024
32122
|
if (body.error === "invalid_grant") {
|
|
32025
|
-
throw new
|
|
32026
|
-
'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.'
|
|
32123
|
+
throw new TokenExchangeError(
|
|
32124
|
+
'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.',
|
|
32125
|
+
true
|
|
32027
32126
|
);
|
|
32028
32127
|
}
|
|
32029
|
-
throw new
|
|
32030
|
-
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})
|
|
32128
|
+
throw new TokenExchangeError(
|
|
32129
|
+
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`,
|
|
32130
|
+
false
|
|
32031
32131
|
);
|
|
32032
32132
|
}
|
|
32033
32133
|
if (!body.access_token) {
|
|
32034
|
-
throw new
|
|
32134
|
+
throw new TokenExchangeError(
|
|
32135
|
+
"the access token could not be refreshed: Google returned no access_token",
|
|
32136
|
+
false
|
|
32137
|
+
);
|
|
32035
32138
|
}
|
|
32036
32139
|
const expiresInMs = (body.expires_in ?? 3600) * 1e3;
|
|
32037
32140
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
@@ -32040,54 +32143,218 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
32040
32143
|
// ../gogcli-mcp/src/connector-runtime.ts
|
|
32041
32144
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
32042
32145
|
var DEADLINE_GRACE_MS = 5e3;
|
|
32146
|
+
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
32043
32147
|
var RUNNER_GOG_FAILED = 422;
|
|
32044
32148
|
var RUNNER_DRAINING = 503;
|
|
32149
|
+
var RUNNER_BAD_REQUEST = 400;
|
|
32150
|
+
var RUNNER_BAD_KEY = 401;
|
|
32151
|
+
var GogFailedError = class extends Error {
|
|
32152
|
+
/** gog's stderr alone, with no echoed argv mixed in. */
|
|
32153
|
+
stderr;
|
|
32154
|
+
constructor(message, stderr) {
|
|
32155
|
+
super(message);
|
|
32156
|
+
this.stderr = stderr;
|
|
32157
|
+
}
|
|
32158
|
+
};
|
|
32159
|
+
var GOOGLE_TOKEN_REJECTED_PATTERN = /Google API error \(401\b|invalid[ _]authentication[ _]credentials|\bACCESS_TOKEN_EXPIRED\b|\binvalid_token\b/i;
|
|
32160
|
+
var REFRESH_TOKEN_DEAD_PATTERN = /\binvalid_grant\b/i;
|
|
32161
|
+
var READ_ONLY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
32162
|
+
"cat",
|
|
32163
|
+
"describe",
|
|
32164
|
+
"get",
|
|
32165
|
+
"info",
|
|
32166
|
+
"list",
|
|
32167
|
+
"list-slides",
|
|
32168
|
+
"ls",
|
|
32169
|
+
"metadata",
|
|
32170
|
+
"read-slide",
|
|
32171
|
+
"search",
|
|
32172
|
+
"services",
|
|
32173
|
+
"status",
|
|
32174
|
+
"structure"
|
|
32175
|
+
]);
|
|
32176
|
+
function gogTarget(args) {
|
|
32177
|
+
const words = args.filter((arg) => typeof arg === "string");
|
|
32178
|
+
let service;
|
|
32179
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
32180
|
+
const word = words[i];
|
|
32181
|
+
if (word.startsWith("-")) {
|
|
32182
|
+
if (word === "--account") i += 1;
|
|
32183
|
+
continue;
|
|
32184
|
+
}
|
|
32185
|
+
if (service === void 0) {
|
|
32186
|
+
service = word;
|
|
32187
|
+
continue;
|
|
32188
|
+
}
|
|
32189
|
+
return { service, subcommand: word };
|
|
32190
|
+
}
|
|
32191
|
+
return { service };
|
|
32192
|
+
}
|
|
32193
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
32194
|
+
if (!(err instanceof GogFailedError)) return void 0;
|
|
32195
|
+
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
32196
|
+
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
32197
|
+
const { service, subcommand } = gogTarget(args);
|
|
32198
|
+
const credential = await readAccessToken?.credentialId?.();
|
|
32199
|
+
const where = { credential, service };
|
|
32200
|
+
if (grantDead) {
|
|
32201
|
+
logAuthTransition("grant.dead", {
|
|
32202
|
+
...where,
|
|
32203
|
+
reason: "gog reported invalid_grant: the stored refresh token is dead, so no token can be minted and this account must be re-authorized"
|
|
32204
|
+
});
|
|
32205
|
+
return void 0;
|
|
32206
|
+
}
|
|
32207
|
+
if (!used) {
|
|
32208
|
+
logAuthTransition("replay.declined", {
|
|
32209
|
+
...where,
|
|
32210
|
+
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
32211
|
+
});
|
|
32212
|
+
return void 0;
|
|
32213
|
+
}
|
|
32214
|
+
if (!readAccessToken?.invalidate) {
|
|
32215
|
+
logAuthTransition("replay.declined", {
|
|
32216
|
+
...where,
|
|
32217
|
+
reason: "this token source cannot mint a replacement, so a replay would resend the rejected token"
|
|
32218
|
+
});
|
|
32219
|
+
return void 0;
|
|
32220
|
+
}
|
|
32221
|
+
const evicted = await readAccessToken.invalidate(used);
|
|
32222
|
+
if (subcommand === void 0 || !READ_ONLY_SUBCOMMANDS.has(subcommand)) {
|
|
32223
|
+
logAuthTransition("replay.declined", {
|
|
32224
|
+
...where,
|
|
32225
|
+
reason: `not replayable: '${subcommand ?? "(none)"}' is not a known read-only subcommand and a write could double-apply`
|
|
32226
|
+
});
|
|
32227
|
+
return void 0;
|
|
32228
|
+
}
|
|
32229
|
+
if (!evicted) {
|
|
32230
|
+
logAuthTransition("replay.declined", {
|
|
32231
|
+
...where,
|
|
32232
|
+
reason: "the rejected token was already superseded, so the cache holds the token a replay would send"
|
|
32233
|
+
});
|
|
32234
|
+
return void 0;
|
|
32235
|
+
}
|
|
32236
|
+
const fresh = await readAccessToken();
|
|
32237
|
+
if (!fresh) {
|
|
32238
|
+
logAuthTransition("replay.declined", {
|
|
32239
|
+
...where,
|
|
32240
|
+
reason: "the token source produced no token after eviction; replaying without one would act as the backend"
|
|
32241
|
+
});
|
|
32242
|
+
return void 0;
|
|
32243
|
+
}
|
|
32244
|
+
const budgetMs = deadlineAt - Date.now();
|
|
32245
|
+
if (budgetMs < MIN_REPLAY_BUDGET_MS) {
|
|
32246
|
+
logAuthTransition("replay.declined", {
|
|
32247
|
+
...where,
|
|
32248
|
+
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`
|
|
32249
|
+
});
|
|
32250
|
+
return void 0;
|
|
32251
|
+
}
|
|
32252
|
+
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
32253
|
+
}
|
|
32045
32254
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
32046
32255
|
return async (args, opts) => {
|
|
32047
32256
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
32048
32257
|
const accessToken = await readAccessToken?.();
|
|
32049
|
-
|
|
32258
|
+
const deadlineAt = Date.now() + deadlineMs;
|
|
32050
32259
|
try {
|
|
32051
|
-
|
|
32052
|
-
method: "POST",
|
|
32053
|
-
headers: {
|
|
32054
|
-
Authorization: "Bearer " + key,
|
|
32055
|
-
"Content-Type": "application/json"
|
|
32056
|
-
},
|
|
32057
|
-
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32058
|
-
signal: AbortSignal.timeout(deadlineMs)
|
|
32059
|
-
});
|
|
32260
|
+
return await attempt(endpoint, key, args, accessToken, deadlineMs);
|
|
32060
32261
|
} catch (err) {
|
|
32061
|
-
const
|
|
32062
|
-
|
|
32063
|
-
|
|
32064
|
-
|
|
32065
|
-
|
|
32262
|
+
const replay = await remintAfterGoogleRejection(
|
|
32263
|
+
err,
|
|
32264
|
+
accessToken,
|
|
32265
|
+
args,
|
|
32266
|
+
readAccessToken,
|
|
32267
|
+
deadlineAt
|
|
32268
|
+
);
|
|
32269
|
+
if (replay === void 0) throw err;
|
|
32270
|
+
const where = { credential: replay.credential, service: replay.service, endpoint };
|
|
32271
|
+
logAuthTransition("replay.attempted", {
|
|
32272
|
+
...where,
|
|
32273
|
+
reason: "Google rejected the access token; replaying this read once with a freshly minted one"
|
|
32274
|
+
});
|
|
32275
|
+
try {
|
|
32276
|
+
const stdout = await attempt(endpoint, key, args, replay.token, replay.budgetMs);
|
|
32277
|
+
logAuthTransition("replay.succeeded", where);
|
|
32278
|
+
return stdout;
|
|
32279
|
+
} catch (replayErr) {
|
|
32280
|
+
logAuthTransition("replay.failed", { ...where, reason: String(replayErr) });
|
|
32281
|
+
if (replayErr instanceof GogFailedError && GOOGLE_TOKEN_REJECTED_PATTERN.test(replayErr.stderr)) {
|
|
32282
|
+
await replay.invalidate(replay.token);
|
|
32283
|
+
}
|
|
32284
|
+
throw replayErr;
|
|
32066
32285
|
}
|
|
32067
|
-
throw err;
|
|
32068
32286
|
}
|
|
32069
|
-
|
|
32070
|
-
|
|
32071
|
-
|
|
32287
|
+
};
|
|
32288
|
+
}
|
|
32289
|
+
async function attempt(endpoint, key, args, accessToken, deadlineMs) {
|
|
32290
|
+
let res;
|
|
32291
|
+
try {
|
|
32292
|
+
res = await fetch(endpoint + "/run", {
|
|
32293
|
+
method: "POST",
|
|
32294
|
+
headers: {
|
|
32295
|
+
Authorization: "Bearer " + key,
|
|
32296
|
+
"Content-Type": "application/json"
|
|
32297
|
+
},
|
|
32298
|
+
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32299
|
+
signal: AbortSignal.timeout(deadlineMs)
|
|
32300
|
+
});
|
|
32301
|
+
} catch (err) {
|
|
32302
|
+
const name = err instanceof Error ? err.name : "";
|
|
32303
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
32304
|
+
throw new RunnerTransportError(
|
|
32305
|
+
`gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`,
|
|
32306
|
+
"transport-retryable"
|
|
32307
|
+
);
|
|
32308
|
+
}
|
|
32309
|
+
throw err;
|
|
32310
|
+
}
|
|
32311
|
+
if (!res.ok) {
|
|
32312
|
+
const body = await res.json().catch(() => null);
|
|
32313
|
+
const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
|
|
32072
32314
|
${body.stderr}` : body.error : "";
|
|
32073
|
-
|
|
32074
|
-
|
|
32075
|
-
|
|
32076
|
-
|
|
32077
|
-
throw new Error(
|
|
32078
|
-
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`
|
|
32079
|
-
);
|
|
32080
|
-
}
|
|
32081
|
-
if (detail) {
|
|
32082
|
-
throw new Error(detail);
|
|
32083
|
-
}
|
|
32084
|
-
throw new Error(
|
|
32085
|
-
`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.`
|
|
32315
|
+
if (res.status === RUNNER_GOG_FAILED) {
|
|
32316
|
+
throw new GogFailedError(
|
|
32317
|
+
detail || "gog failed on the runner (no detail supplied)",
|
|
32318
|
+
typeof body?.stderr === "string" ? body.stderr : ""
|
|
32086
32319
|
);
|
|
32087
32320
|
}
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32321
|
+
if (res.status === RUNNER_BAD_KEY) {
|
|
32322
|
+
logAuthTransition("runner.auth-failed", {
|
|
32323
|
+
service: gogTarget(args).service,
|
|
32324
|
+
endpoint,
|
|
32325
|
+
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"
|
|
32326
|
+
});
|
|
32327
|
+
throw new RunnerTransportError(
|
|
32328
|
+
"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.",
|
|
32329
|
+
"transport-auth",
|
|
32330
|
+
res.status
|
|
32331
|
+
);
|
|
32332
|
+
}
|
|
32333
|
+
if (res.status === RUNNER_BAD_REQUEST) {
|
|
32334
|
+
throw new RunnerTransportError(
|
|
32335
|
+
detail || "gog-runner rejected the request (no detail supplied)",
|
|
32336
|
+
"transport-request",
|
|
32337
|
+
res.status
|
|
32338
|
+
);
|
|
32339
|
+
}
|
|
32340
|
+
if (res.status === RUNNER_DRAINING || body?.retryable === true) {
|
|
32341
|
+
throw new RunnerTransportError(
|
|
32342
|
+
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`,
|
|
32343
|
+
"transport-retryable",
|
|
32344
|
+
res.status
|
|
32345
|
+
);
|
|
32346
|
+
}
|
|
32347
|
+
if (detail) {
|
|
32348
|
+
throw new Error(detail);
|
|
32349
|
+
}
|
|
32350
|
+
throw new RunnerTransportError(
|
|
32351
|
+
`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.`,
|
|
32352
|
+
"transport-retryable",
|
|
32353
|
+
res.status
|
|
32354
|
+
);
|
|
32355
|
+
}
|
|
32356
|
+
const { stdout } = await res.json();
|
|
32357
|
+
return stdout;
|
|
32091
32358
|
}
|
|
32092
32359
|
|
|
32093
32360
|
// ../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-sheets",
|
|
5
5
|
"display_name": "gogcli (Sheets)",
|
|
6
|
-
"version": "2.21.
|
|
6
|
+
"version": "2.21.1",
|
|
7
7
|
"description": "Extended Google Sheets for Claude via gogcli — auth + full Sheets support",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-sheets",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"mcpName": "io.github.chrischall/gogcli-mcp-sheets",
|
|
5
5
|
"description": "Extended Google Sheets MCP server via gogcli — all base tools plus full Sheets 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-sheets"
|
|
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-sheets",
|
|
15
|
-
"version": "2.21.
|
|
15
|
+
"version": "2.21.1",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|