@mergelight/cli 0.1.23 → 0.1.24
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/providers/antigravity.js +23 -1
- package/dist/review.js +2 -1
- package/package.json +1 -1
|
@@ -173,7 +173,13 @@ export function agySettings(apiKey, readable = []) {
|
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
/** What agy says when its login is missing, refused or ran out. Only its own error output is read for this. */
|
|
176
|
-
const LOGIN_FAILURE = /authentication required|authentication failed|authentication expired|please log back in|api key not valid|API_KEY_INVALID|invalid_grant|unauthenticated|(?<![\d.])401(
|
|
176
|
+
const LOGIN_FAILURE = /authentication required|authentication failed|authentication expired|please log back in|api key not valid|API_KEY_INVALID|invalid_grant|unauthenticated|(?<![\d.])401(?!\d|\.\d)/i;
|
|
177
|
+
/**
|
|
178
|
+
* Google refused the login for this use: a Gemini API key whose project doesn't have the API turned on, or
|
|
179
|
+
* that is restricted from it, answers 403 PERMISSION_DENIED. A login problem, not a broken run, so a checker
|
|
180
|
+
* with it hands the check to the reviewer, as with any login that doesn't work.
|
|
181
|
+
*/
|
|
182
|
+
const REFUSED = /PERMISSION_DENIED|(?<![\d.])403(?!\d|\.\d)/;
|
|
177
183
|
const QUOTA = /RESOURCE_EXHAUSTED|quota exceeded|exceeded your current quota|out of credits|rate limit/i;
|
|
178
184
|
export function antigravityLoginMessage() {
|
|
179
185
|
return "The Antigravity login didn't work. Save a new one as the ANTIGRAVITY_AUTH_JSON secret (see docs/github-action.md), or check the GEMINI_API_KEY secret, then push a commit.";
|
|
@@ -340,6 +346,22 @@ export async function runAntigravity(opts) {
|
|
|
340
346
|
throw new LimitError(login.apiKey && !login.token ? "Gemini" : "Antigravity", null);
|
|
341
347
|
if (LOGIN_FAILURE.test(own))
|
|
342
348
|
throw new LoginError(process.env.GITHUB_ACTIONS === "true" ? antigravityLoginMessage() : "Antigravity's login didn't work. Check ANTIGRAVITY_AUTH_JSON or GEMINI_API_KEY.", "Antigravity");
|
|
349
|
+
if (REFUSED.test(own)) {
|
|
350
|
+
// Google's own reason goes along, such as a key reported as leaked, and the steps fit where it ran.
|
|
351
|
+
const actions = process.env.GITHUB_ACTIONS === "true";
|
|
352
|
+
// Google's reason comes first: a checker's fallback logs only the start of the message.
|
|
353
|
+
const said = scrub(own.trim().split("\n").filter(Boolean).slice(-3).join(" ")).slice(0, 400);
|
|
354
|
+
const apiKey = Boolean(login.apiKey && !login.token);
|
|
355
|
+
const what = apiKey ? `the Gemini API key${actions ? "" : " in GEMINI_API_KEY"}` : `the Antigravity login${actions ? "" : " in ANTIGRAVITY_AUTH_JSON"}`;
|
|
356
|
+
const steps = apiKey
|
|
357
|
+
? actions
|
|
358
|
+
? "Check that its Google Cloud project has the Gemini API turned on (Google Cloud Console, APIs & Services) and that the key isn't restricted from it, or save another key as the GEMINI_API_KEY secret. Then push a commit."
|
|
359
|
+
: "Check that its Google Cloud project has the Gemini API turned on (Google Cloud Console, APIs & Services) and that the key isn't restricted from it, or set another key."
|
|
360
|
+
: actions
|
|
361
|
+
? "The account may not be allowed to use Antigravity. Save a login of an account that can, as the ANTIGRAVITY_AUTH_JSON secret, then push a commit."
|
|
362
|
+
: "The account may not be allowed to use Antigravity. Use a login of an account that can.";
|
|
363
|
+
throw new LoginError(`Google refused ${what} (403)${said ? `: ${said.replace(/[.\s]+$/, "")}.` : "."} ${steps}`, "Antigravity");
|
|
364
|
+
}
|
|
343
365
|
const how = parsed ? `status ${parsed.status ?? "unknown"}${parsed.structured_output === undefined && parsed.status === "SUCCESS" ? ", no structured answer" : ""}` : `exit code ${result.code}, no result`;
|
|
344
366
|
const tail = scrub(own.trim().split("\n").slice(-6).join("\n")).slice(0, 600);
|
|
345
367
|
throw new Error(`Antigravity didn't finish (${how}).${opts.logFile ? ` Log: ${opts.logFile}` : ""}\n${tail}`);
|
package/dist/review.js
CHANGED
|
@@ -391,7 +391,8 @@ export async function reviewPullRequest(ref, opts = {}) {
|
|
|
391
391
|
if (verifyWith === provider || !(err instanceof LoginError || err instanceof LimitError || err instanceof SandboxError))
|
|
392
392
|
throw err;
|
|
393
393
|
checkerFailed = err instanceof LimitError ? "limit" : err instanceof SandboxError ? "sandbox" : "login-failed";
|
|
394
|
-
|
|
394
|
+
// Long enough for the reason a provider gives, such as Google's own words on a refused key (at most 400).
|
|
395
|
+
progress(`${PROVIDER_LABEL[verifyWith]} couldn't check (${err.message.slice(0, 500)}), so ${PROVIDER_LABEL[provider]} checks the findings`);
|
|
395
396
|
const fallbackModel = provider === "claude" ? (opts.model ?? "opus") : opts.model;
|
|
396
397
|
// The live comment names the AI that checks now.
|
|
397
398
|
opts.onModels?.({ reviewer: { name: provider, model: servedModelSoFar() }, checker: { name: provider, model: fallbackModel ?? null } });
|