gogcli-mcp-contacts 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/dist/index.js +321 -54
- package/manifest.json +1 -1
- package/package.json +1 -1
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
|
|
|
@@ -31572,7 +31591,7 @@ function registerRunTool(server, options) {
|
|
|
31572
31591
|
function errorText(err) {
|
|
31573
31592
|
return err instanceof Error ? `Error: ${err.message}` : String(err);
|
|
31574
31593
|
}
|
|
31575
|
-
var DEFINITE_AUTH_PATTERN = /\b(
|
|
31594
|
+
var DEFINITE_AUTH_PATTERN = /\b(?:unauthorized|invalid_grant)\b|\b(?:error|status|code|http|responded|response)["']?[\s:=(,]{0,4}401\b/i;
|
|
31576
31595
|
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
31596
|
var AUTH_ERROR_PATTERN = new RegExp(`${DEFINITE_AUTH_PATTERN.source}|${STALE_TOKEN_PATTERN.source}`, "i");
|
|
31578
31597
|
var INVALID_GRANT_PATTERN = /invalid_grant|token has been expired or revoked/i;
|
|
@@ -31582,6 +31601,14 @@ var AUTH_HINT = "\n\nAuthentication may have expired. Use gog_auth_add to re-aut
|
|
|
31582
31601
|
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
31602
|
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
31603
|
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.";
|
|
31604
|
+
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.";
|
|
31605
|
+
var RUNNER_TRANSPORT_HINTS = {
|
|
31606
|
+
"transport-auth": RUNNER_TRANSPORT_AUTH_HINT,
|
|
31607
|
+
// The request itself was malformed, so the runner will refuse it identically
|
|
31608
|
+
// every time. Nothing to advise beyond the message the runner already gave.
|
|
31609
|
+
"transport-request": "",
|
|
31610
|
+
"transport-retryable": TRANSIENT_HINT
|
|
31611
|
+
};
|
|
31585
31612
|
function formatAccountList(raw) {
|
|
31586
31613
|
try {
|
|
31587
31614
|
const parsed = JSON.parse(raw);
|
|
@@ -31594,11 +31621,12 @@ function formatAccountList(raw) {
|
|
|
31594
31621
|
}
|
|
31595
31622
|
async function diagnose(err) {
|
|
31596
31623
|
const errText = errorText(err);
|
|
31624
|
+
const transportHint = isRunnerTransportError(err) ? RUNNER_TRANSPORT_HINTS[err.kind] : void 0;
|
|
31597
31625
|
const isInvalidGrant = INVALID_GRANT_PATTERN.test(errText);
|
|
31598
31626
|
const isTransientError = !DEFINITE_AUTH_PATTERN.test(errText) && TRANSIENT_ERROR_PATTERN.test(errText);
|
|
31599
31627
|
const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
|
|
31600
31628
|
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 : "";
|
|
31629
|
+
const hint = transportHint ?? (isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "");
|
|
31602
31630
|
try {
|
|
31603
31631
|
const accounts = formatAccountList(await run(["auth", "list"]));
|
|
31604
31632
|
return errorResult(`${errText}
|
|
@@ -31848,7 +31876,25 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
31848
31876
|
);
|
|
31849
31877
|
|
|
31850
31878
|
// ../gogcli-mcp/src/server.ts
|
|
31851
|
-
var VERSION = true ? "2.21.
|
|
31879
|
+
var VERSION = true ? "2.21.1" : "0.0.0";
|
|
31880
|
+
|
|
31881
|
+
// ../gogcli-mcp/src/auth-log.ts
|
|
31882
|
+
var FAILURES = /* @__PURE__ */ new Set([
|
|
31883
|
+
"token.mint-failed",
|
|
31884
|
+
"grant.dead",
|
|
31885
|
+
"replay.failed",
|
|
31886
|
+
"runner.auth-failed"
|
|
31887
|
+
]);
|
|
31888
|
+
var PREFIX = "gog-auth ";
|
|
31889
|
+
var TAG_CHARS = 12;
|
|
31890
|
+
function credentialTag(cacheKeyHash) {
|
|
31891
|
+
return cacheKeyHash.slice(0, TAG_CHARS);
|
|
31892
|
+
}
|
|
31893
|
+
function logAuthTransition(event, context) {
|
|
31894
|
+
const record2 = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...context });
|
|
31895
|
+
const write = FAILURES.has(event) ? console.error : console.warn;
|
|
31896
|
+
write(PREFIX + redactSecrets2(record2));
|
|
31897
|
+
}
|
|
31852
31898
|
|
|
31853
31899
|
// ../gogcli-mcp/src/google-token.ts
|
|
31854
31900
|
var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
|
|
@@ -31875,22 +31921,73 @@ function makeAccessTokenSource(env) {
|
|
|
31875
31921
|
);
|
|
31876
31922
|
};
|
|
31877
31923
|
}
|
|
31878
|
-
|
|
31879
|
-
|
|
31880
|
-
|
|
31881
|
-
|
|
31882
|
-
|
|
31924
|
+
let keyPromise;
|
|
31925
|
+
const key = () => keyPromise ??= cacheKey(refreshToken, clientId);
|
|
31926
|
+
const logCacheHits = parseBoolEnv("GOG_AUTH_LOG_CACHE_HITS", { env });
|
|
31927
|
+
const read = async () => {
|
|
31928
|
+
const k = await key();
|
|
31929
|
+
const hit = cache.get(k);
|
|
31930
|
+
if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) {
|
|
31931
|
+
if (logCacheHits) logAuthTransition("token.cache-hit", { credential: credentialTag(k) });
|
|
31932
|
+
return hit.accessToken;
|
|
31933
|
+
}
|
|
31934
|
+
let pending = inFlight.get(k);
|
|
31883
31935
|
if (!pending) {
|
|
31884
31936
|
pending = exchange(refreshToken, clientId, clientSecret).then((minted2) => {
|
|
31885
|
-
cache.set(
|
|
31937
|
+
cache.set(k, minted2);
|
|
31938
|
+
logAuthTransition("token.minted", {
|
|
31939
|
+
credential: credentialTag(k),
|
|
31940
|
+
reason: `valid for ${Math.round((minted2.expiresAt - Date.now()) / 1e3)}s`
|
|
31941
|
+
});
|
|
31886
31942
|
return minted2;
|
|
31887
|
-
}).
|
|
31888
|
-
|
|
31943
|
+
}).catch((err) => {
|
|
31944
|
+
logAuthTransition(err.grantDead ? "grant.dead" : "token.mint-failed", {
|
|
31945
|
+
credential: credentialTag(k),
|
|
31946
|
+
reason: err.message
|
|
31947
|
+
});
|
|
31948
|
+
throw err;
|
|
31949
|
+
}).finally(() => inFlight.delete(k));
|
|
31950
|
+
inFlight.set(k, pending);
|
|
31889
31951
|
}
|
|
31890
31952
|
const minted = await pending;
|
|
31891
31953
|
return minted.accessToken;
|
|
31892
31954
|
};
|
|
31955
|
+
const invalidate = async (rejected) => {
|
|
31956
|
+
const k = await key();
|
|
31957
|
+
const hit = cache.get(k);
|
|
31958
|
+
if (!hit || hit.accessToken !== rejected) {
|
|
31959
|
+
logAuthTransition("token.evict-noop", {
|
|
31960
|
+
credential: credentialTag(k),
|
|
31961
|
+
reason: hit ? "a concurrent caller had already replaced this credential\u2019s token" : "no token was cached for this credential"
|
|
31962
|
+
});
|
|
31963
|
+
return false;
|
|
31964
|
+
}
|
|
31965
|
+
cache.delete(k);
|
|
31966
|
+
logAuthTransition("token.evicted", {
|
|
31967
|
+
credential: credentialTag(k),
|
|
31968
|
+
reason: "Google rejected this access token; the next read will mint a new one"
|
|
31969
|
+
});
|
|
31970
|
+
return true;
|
|
31971
|
+
};
|
|
31972
|
+
return Object.assign(read, {
|
|
31973
|
+
invalidate,
|
|
31974
|
+
credentialId: async () => credentialTag(await key())
|
|
31975
|
+
});
|
|
31893
31976
|
}
|
|
31977
|
+
var TokenExchangeError = class extends Error {
|
|
31978
|
+
/**
|
|
31979
|
+
* The REFRESH token is dead (Google's `invalid_grant`), not merely the access
|
|
31980
|
+
* token. Carried as a flag rather than re-read from the message, because
|
|
31981
|
+
* inferring the author of a failure from prose several authors can produce is
|
|
31982
|
+
* precisely the mistake this branch exists to undo. `instanceof` is safe: the
|
|
31983
|
+
* class is thrown and caught inside this one module.
|
|
31984
|
+
*/
|
|
31985
|
+
grantDead;
|
|
31986
|
+
constructor(message, grantDead) {
|
|
31987
|
+
super(message);
|
|
31988
|
+
this.grantDead = grantDead;
|
|
31989
|
+
}
|
|
31990
|
+
};
|
|
31894
31991
|
async function exchange(refreshToken, clientId, clientSecret) {
|
|
31895
31992
|
let res;
|
|
31896
31993
|
try {
|
|
@@ -31905,23 +32002,29 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
31905
32002
|
}).toString()
|
|
31906
32003
|
});
|
|
31907
32004
|
} catch (err) {
|
|
31908
|
-
throw new
|
|
31909
|
-
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}
|
|
32005
|
+
throw new TokenExchangeError(
|
|
32006
|
+
`the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`,
|
|
32007
|
+
false
|
|
31910
32008
|
);
|
|
31911
32009
|
}
|
|
31912
32010
|
const body = await res.json().catch(() => ({}));
|
|
31913
32011
|
if (!res.ok) {
|
|
31914
32012
|
if (body.error === "invalid_grant") {
|
|
31915
|
-
throw new
|
|
31916
|
-
'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.'
|
|
32013
|
+
throw new TokenExchangeError(
|
|
32014
|
+
'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.',
|
|
32015
|
+
true
|
|
31917
32016
|
);
|
|
31918
32017
|
}
|
|
31919
|
-
throw new
|
|
31920
|
-
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})
|
|
32018
|
+
throw new TokenExchangeError(
|
|
32019
|
+
`the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`,
|
|
32020
|
+
false
|
|
31921
32021
|
);
|
|
31922
32022
|
}
|
|
31923
32023
|
if (!body.access_token) {
|
|
31924
|
-
throw new
|
|
32024
|
+
throw new TokenExchangeError(
|
|
32025
|
+
"the access token could not be refreshed: Google returned no access_token",
|
|
32026
|
+
false
|
|
32027
|
+
);
|
|
31925
32028
|
}
|
|
31926
32029
|
const expiresInMs = (body.expires_in ?? 3600) * 1e3;
|
|
31927
32030
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
@@ -31930,54 +32033,218 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
31930
32033
|
// ../gogcli-mcp/src/connector-runtime.ts
|
|
31931
32034
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
31932
32035
|
var DEADLINE_GRACE_MS = 5e3;
|
|
32036
|
+
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
31933
32037
|
var RUNNER_GOG_FAILED = 422;
|
|
31934
32038
|
var RUNNER_DRAINING = 503;
|
|
32039
|
+
var RUNNER_BAD_REQUEST = 400;
|
|
32040
|
+
var RUNNER_BAD_KEY = 401;
|
|
32041
|
+
var GogFailedError = class extends Error {
|
|
32042
|
+
/** gog's stderr alone, with no echoed argv mixed in. */
|
|
32043
|
+
stderr;
|
|
32044
|
+
constructor(message, stderr) {
|
|
32045
|
+
super(message);
|
|
32046
|
+
this.stderr = stderr;
|
|
32047
|
+
}
|
|
32048
|
+
};
|
|
32049
|
+
var GOOGLE_TOKEN_REJECTED_PATTERN = /Google API error \(401\b|invalid[ _]authentication[ _]credentials|\bACCESS_TOKEN_EXPIRED\b|\binvalid_token\b/i;
|
|
32050
|
+
var REFRESH_TOKEN_DEAD_PATTERN = /\binvalid_grant\b/i;
|
|
32051
|
+
var READ_ONLY_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
32052
|
+
"cat",
|
|
32053
|
+
"describe",
|
|
32054
|
+
"get",
|
|
32055
|
+
"info",
|
|
32056
|
+
"list",
|
|
32057
|
+
"list-slides",
|
|
32058
|
+
"ls",
|
|
32059
|
+
"metadata",
|
|
32060
|
+
"read-slide",
|
|
32061
|
+
"search",
|
|
32062
|
+
"services",
|
|
32063
|
+
"status",
|
|
32064
|
+
"structure"
|
|
32065
|
+
]);
|
|
32066
|
+
function gogTarget(args) {
|
|
32067
|
+
const words = args.filter((arg) => typeof arg === "string");
|
|
32068
|
+
let service;
|
|
32069
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
32070
|
+
const word = words[i];
|
|
32071
|
+
if (word.startsWith("-")) {
|
|
32072
|
+
if (word === "--account") i += 1;
|
|
32073
|
+
continue;
|
|
32074
|
+
}
|
|
32075
|
+
if (service === void 0) {
|
|
32076
|
+
service = word;
|
|
32077
|
+
continue;
|
|
32078
|
+
}
|
|
32079
|
+
return { service, subcommand: word };
|
|
32080
|
+
}
|
|
32081
|
+
return { service };
|
|
32082
|
+
}
|
|
32083
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
32084
|
+
if (!(err instanceof GogFailedError)) return void 0;
|
|
32085
|
+
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
32086
|
+
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
32087
|
+
const { service, subcommand } = gogTarget(args);
|
|
32088
|
+
const credential = await readAccessToken?.credentialId?.();
|
|
32089
|
+
const where = { credential, service };
|
|
32090
|
+
if (grantDead) {
|
|
32091
|
+
logAuthTransition("grant.dead", {
|
|
32092
|
+
...where,
|
|
32093
|
+
reason: "gog reported invalid_grant: the stored refresh token is dead, so no token can be minted and this account must be re-authorized"
|
|
32094
|
+
});
|
|
32095
|
+
return void 0;
|
|
32096
|
+
}
|
|
32097
|
+
if (!used) {
|
|
32098
|
+
logAuthTransition("replay.declined", {
|
|
32099
|
+
...where,
|
|
32100
|
+
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
32101
|
+
});
|
|
32102
|
+
return void 0;
|
|
32103
|
+
}
|
|
32104
|
+
if (!readAccessToken?.invalidate) {
|
|
32105
|
+
logAuthTransition("replay.declined", {
|
|
32106
|
+
...where,
|
|
32107
|
+
reason: "this token source cannot mint a replacement, so a replay would resend the rejected token"
|
|
32108
|
+
});
|
|
32109
|
+
return void 0;
|
|
32110
|
+
}
|
|
32111
|
+
const evicted = await readAccessToken.invalidate(used);
|
|
32112
|
+
if (subcommand === void 0 || !READ_ONLY_SUBCOMMANDS.has(subcommand)) {
|
|
32113
|
+
logAuthTransition("replay.declined", {
|
|
32114
|
+
...where,
|
|
32115
|
+
reason: `not replayable: '${subcommand ?? "(none)"}' is not a known read-only subcommand and a write could double-apply`
|
|
32116
|
+
});
|
|
32117
|
+
return void 0;
|
|
32118
|
+
}
|
|
32119
|
+
if (!evicted) {
|
|
32120
|
+
logAuthTransition("replay.declined", {
|
|
32121
|
+
...where,
|
|
32122
|
+
reason: "the rejected token was already superseded, so the cache holds the token a replay would send"
|
|
32123
|
+
});
|
|
32124
|
+
return void 0;
|
|
32125
|
+
}
|
|
32126
|
+
const fresh = await readAccessToken();
|
|
32127
|
+
if (!fresh) {
|
|
32128
|
+
logAuthTransition("replay.declined", {
|
|
32129
|
+
...where,
|
|
32130
|
+
reason: "the token source produced no token after eviction; replaying without one would act as the backend"
|
|
32131
|
+
});
|
|
32132
|
+
return void 0;
|
|
32133
|
+
}
|
|
32134
|
+
const budgetMs = deadlineAt - Date.now();
|
|
32135
|
+
if (budgetMs < MIN_REPLAY_BUDGET_MS) {
|
|
32136
|
+
logAuthTransition("replay.declined", {
|
|
32137
|
+
...where,
|
|
32138
|
+
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`
|
|
32139
|
+
});
|
|
32140
|
+
return void 0;
|
|
32141
|
+
}
|
|
32142
|
+
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
32143
|
+
}
|
|
31935
32144
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
31936
32145
|
return async (args, opts) => {
|
|
31937
32146
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
31938
32147
|
const accessToken = await readAccessToken?.();
|
|
31939
|
-
|
|
32148
|
+
const deadlineAt = Date.now() + deadlineMs;
|
|
31940
32149
|
try {
|
|
31941
|
-
|
|
31942
|
-
method: "POST",
|
|
31943
|
-
headers: {
|
|
31944
|
-
Authorization: "Bearer " + key,
|
|
31945
|
-
"Content-Type": "application/json"
|
|
31946
|
-
},
|
|
31947
|
-
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
31948
|
-
signal: AbortSignal.timeout(deadlineMs)
|
|
31949
|
-
});
|
|
32150
|
+
return await attempt(endpoint, key, args, accessToken, deadlineMs);
|
|
31950
32151
|
} catch (err) {
|
|
31951
|
-
const
|
|
31952
|
-
|
|
31953
|
-
|
|
31954
|
-
|
|
31955
|
-
|
|
32152
|
+
const replay = await remintAfterGoogleRejection(
|
|
32153
|
+
err,
|
|
32154
|
+
accessToken,
|
|
32155
|
+
args,
|
|
32156
|
+
readAccessToken,
|
|
32157
|
+
deadlineAt
|
|
32158
|
+
);
|
|
32159
|
+
if (replay === void 0) throw err;
|
|
32160
|
+
const where = { credential: replay.credential, service: replay.service, endpoint };
|
|
32161
|
+
logAuthTransition("replay.attempted", {
|
|
32162
|
+
...where,
|
|
32163
|
+
reason: "Google rejected the access token; replaying this read once with a freshly minted one"
|
|
32164
|
+
});
|
|
32165
|
+
try {
|
|
32166
|
+
const stdout = await attempt(endpoint, key, args, replay.token, replay.budgetMs);
|
|
32167
|
+
logAuthTransition("replay.succeeded", where);
|
|
32168
|
+
return stdout;
|
|
32169
|
+
} catch (replayErr) {
|
|
32170
|
+
logAuthTransition("replay.failed", { ...where, reason: String(replayErr) });
|
|
32171
|
+
if (replayErr instanceof GogFailedError && GOOGLE_TOKEN_REJECTED_PATTERN.test(replayErr.stderr)) {
|
|
32172
|
+
await replay.invalidate(replay.token);
|
|
32173
|
+
}
|
|
32174
|
+
throw replayErr;
|
|
31956
32175
|
}
|
|
31957
|
-
throw err;
|
|
31958
32176
|
}
|
|
31959
|
-
|
|
31960
|
-
|
|
31961
|
-
|
|
32177
|
+
};
|
|
32178
|
+
}
|
|
32179
|
+
async function attempt(endpoint, key, args, accessToken, deadlineMs) {
|
|
32180
|
+
let res;
|
|
32181
|
+
try {
|
|
32182
|
+
res = await fetch(endpoint + "/run", {
|
|
32183
|
+
method: "POST",
|
|
32184
|
+
headers: {
|
|
32185
|
+
Authorization: "Bearer " + key,
|
|
32186
|
+
"Content-Type": "application/json"
|
|
32187
|
+
},
|
|
32188
|
+
body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
|
|
32189
|
+
signal: AbortSignal.timeout(deadlineMs)
|
|
32190
|
+
});
|
|
32191
|
+
} catch (err) {
|
|
32192
|
+
const name = err instanceof Error ? err.name : "";
|
|
32193
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
32194
|
+
throw new RunnerTransportError(
|
|
32195
|
+
`gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`,
|
|
32196
|
+
"transport-retryable"
|
|
32197
|
+
);
|
|
32198
|
+
}
|
|
32199
|
+
throw err;
|
|
32200
|
+
}
|
|
32201
|
+
if (!res.ok) {
|
|
32202
|
+
const body = await res.json().catch(() => null);
|
|
32203
|
+
const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
|
|
31962
32204
|
${body.stderr}` : body.error : "";
|
|
31963
|
-
|
|
31964
|
-
|
|
31965
|
-
|
|
31966
|
-
|
|
31967
|
-
throw new Error(
|
|
31968
|
-
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`
|
|
31969
|
-
);
|
|
31970
|
-
}
|
|
31971
|
-
if (detail) {
|
|
31972
|
-
throw new Error(detail);
|
|
31973
|
-
}
|
|
31974
|
-
throw new Error(
|
|
31975
|
-
`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.`
|
|
32205
|
+
if (res.status === RUNNER_GOG_FAILED) {
|
|
32206
|
+
throw new GogFailedError(
|
|
32207
|
+
detail || "gog failed on the runner (no detail supplied)",
|
|
32208
|
+
typeof body?.stderr === "string" ? body.stderr : ""
|
|
31976
32209
|
);
|
|
31977
32210
|
}
|
|
31978
|
-
|
|
31979
|
-
|
|
31980
|
-
|
|
32211
|
+
if (res.status === RUNNER_BAD_KEY) {
|
|
32212
|
+
logAuthTransition("runner.auth-failed", {
|
|
32213
|
+
service: gogTarget(args).service,
|
|
32214
|
+
endpoint,
|
|
32215
|
+
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"
|
|
32216
|
+
});
|
|
32217
|
+
throw new RunnerTransportError(
|
|
32218
|
+
"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.",
|
|
32219
|
+
"transport-auth",
|
|
32220
|
+
res.status
|
|
32221
|
+
);
|
|
32222
|
+
}
|
|
32223
|
+
if (res.status === RUNNER_BAD_REQUEST) {
|
|
32224
|
+
throw new RunnerTransportError(
|
|
32225
|
+
detail || "gog-runner rejected the request (no detail supplied)",
|
|
32226
|
+
"transport-request",
|
|
32227
|
+
res.status
|
|
32228
|
+
);
|
|
32229
|
+
}
|
|
32230
|
+
if (res.status === RUNNER_DRAINING || body?.retryable === true) {
|
|
32231
|
+
throw new RunnerTransportError(
|
|
32232
|
+
`gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`,
|
|
32233
|
+
"transport-retryable",
|
|
32234
|
+
res.status
|
|
32235
|
+
);
|
|
32236
|
+
}
|
|
32237
|
+
if (detail) {
|
|
32238
|
+
throw new Error(detail);
|
|
32239
|
+
}
|
|
32240
|
+
throw new RunnerTransportError(
|
|
32241
|
+
`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.`,
|
|
32242
|
+
"transport-retryable",
|
|
32243
|
+
res.status
|
|
32244
|
+
);
|
|
32245
|
+
}
|
|
32246
|
+
const { stdout } = await res.json();
|
|
32247
|
+
return stdout;
|
|
31981
32248
|
}
|
|
31982
32249
|
|
|
31983
32250
|
// ../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-contacts",
|
|
5
5
|
"display_name": "gogcli (Contacts)",
|
|
6
|
-
"version": "2.21.
|
|
6
|
+
"version": "2.21.1",
|
|
7
7
|
"description": "Extended Google Contacts for Claude via gogcli — auth + Contacts + Workspace directory (People API)",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gogcli-mcp-contacts",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"mcpName": "io.github.chrischall/gogcli-mcp-contacts",
|
|
5
5
|
"description": "Extended Google Contacts + People MCP server via gogcli — auth + Contacts + Workspace directory (People API)",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|