Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/mobile/src/features/threads/thread-work-log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { T3Wordmark } from "../../components/T3Wordmark";
import { BrowserAppIcon } from "./BrowserAppIcon";
import { useAppActive, useReduceMotionEnabled } from "../../lib/appState";
import { cn } from "../../lib/cn";
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
import { THREAD_WORK_ROW_MIN_HEIGHT, type deriveThreadWorkLogSizing } from "../../lib/layout";
import {
formatItemFullDetail,
Expand Down Expand Up @@ -933,7 +934,7 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
? gt("Usage limit reached. Retry after {resetTime}.", { resetTime })
: gt("Usage limit reached.")
: row.summary;
return (
const errorRow = (
<WorkLogPressable
accessibilityLabel={
warning
Expand Down Expand Up @@ -997,6 +998,21 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
</View>
</WorkLogPressable>
);
const verificationUrl = failureItem.failure.verificationUrl;
return verificationUrl === undefined ? (
errorRow
) : (
<View>
{errorRow}
<View className="ml-7 pb-1">
<Button
label={gt("Verify Google account")}
size="compact"
onPress={() => void tryOpenExternalUrl(verificationUrl, "provider-auth")}
/>
</View>
</View>
);
}
const notifiedSubagentThreadId =
row.projectedItem.item.type === "notification"
Expand Down
42 changes: 42 additions & 0 deletions apps/server/src/provider/acp/AntigravityTurnOutcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ const RATE_LIMIT_ERROR = errorPayload(
const INVALID_ARGUMENT_ERROR = errorPayload(
"Error 400, Message: Request contains an invalid argument., Status: INVALID_ARGUMENT, Details: []",
);
const VERIFICATION_URL =
"https://accounts.google.com/v3/signin/continue?plt=fixture&flowName=GlifWebSignIn";
const verificationError = (url: string | undefined) => {
const response = {
error: {
code: 403,
details: [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
domain: "cloudcode-pa.googleapis.com",
metadata: { validation_url: url },
reason: "VALIDATION_REQUIRED",
},
],
message: "Verify your account to continue.",
status: "PERMISSION_DENIED",
},
};
return errorPayload(
`Verification Required\u0012PERMISSION_DENIED (code 403): Verify your account to continue.\u001aHTTP 403 Forbidden\n\n${JSON.stringify(response, null, 2)}\n`,
);
};
// Vertex Claude rejects a resumed history whose saved thinking block lost its signature.
const MISSING_SIGNATURE_ERROR = errorPayload(
'Error 400, Message: {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.0.thinking.signature: Field required"},"request_id":"req_vrtx_test"}, Status: INVALID_ARGUMENT, Details: []',
Expand Down Expand Up @@ -177,6 +199,26 @@ describe("watchAntigravityPromptOutcome", () => {
]))?.failure.retryable,
false,
);
for (const url of [
VERIFICATION_URL,
undefined,
"https://accounts.google.com.example.invalid/v3/signin/continue?plt=fixture",
]) {
assert.deepEqual(
yield* turn([
[USER_INPUT, input],
[ERROR_MESSAGE, verificationError(url)],
]),
reusable({
class: "permission_error",
message: "Verify your Google account, then retry this turn.",
code: "VALIDATION_REQUIRED",
retryable: false,
...(url === VERIFICATION_URL ? { verificationUrl: url } : {}),
}),
);
}
assert.isUndefined(yield* turn([[PLANNER_RESPONSE, verificationError(VERIFICATION_URL)]]));
// A saved thinking block without a valid signature fails every later prompt.
for (const error of [MISSING_SIGNATURE_ERROR, INVALID_SIGNATURE_ERROR]) {
const outcome = yield* turn([
Expand Down
49 changes: 48 additions & 1 deletion apps/server/src/provider/acp/AntigravityTurnOutcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import * as NodeFSP from "node:fs/promises";
import * as NodePath from "node:path";
import * as NodeSqlite from "node:sqlite";

import type { OrchestrationV2ProviderFailure } from "@t3tools/contracts";
import {
GoogleAccountVerificationUrl,
type OrchestrationV2ProviderFailure,
} from "@t3tools/contracts";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
Expand All @@ -23,6 +26,29 @@ const MAX_ERROR_PAYLOAD_BYTES = 16_384;
const API_ERROR = /Error (\d{3}), Message: (.+?), Status: ([A-Z_]+)/s;
// Antigravity 1.5 with a Google account writes "STATUS (code NNN): message".
const STATUS_ERROR = /(?<![A-Z_])([A-Z_]+) \(code (\d{3})\): (\P{Cc}+)/u;
// Newer Antigravity builds attach the pretty-printed HTTP body to the native error step.
const HTTP_ERROR_BODY = /\n(\{\s*"error"\s*:[\s\S]*?\n\})/;
const decodeVerificationError = Schema.decodeUnknownOption(
Schema.fromJsonString(
Schema.Struct({
error: Schema.Struct({
code: Schema.Literal(403),
status: Schema.Literal("PERMISSION_DENIED"),
details: Schema.Array(
Schema.Struct({
"@type": Schema.optionalKey(Schema.String),
domain: Schema.optionalKey(Schema.String),
reason: Schema.optionalKey(Schema.String),
metadata: Schema.optionalKey(
Schema.Struct({ validation_url: Schema.optionalKey(Schema.Unknown) }),
),
}),
),
}),
}),
),
);
const decodeVerificationUrl = Schema.decodeUnknownOption(GoogleAccountVerificationUrl);
const QUOTA_EXHAUSTED = /\breason:QUOTA_EXHAUSTED\b/;
// Claude rejects a saved thinking block without a valid signature. It sits in the native
// history, so every later prompt to that session fails the same way.
Expand Down Expand Up @@ -169,6 +195,27 @@ function turnFailure(
threadDisposition: "broken",
};
}
const response = Option.getOrUndefined(decodeVerificationError(HTTP_ERROR_BODY.exec(text)?.[1]));
const verification = response?.error.details.find(
(detail) =>
detail["@type"] === "type.googleapis.com/google.rpc.ErrorInfo" &&
detail.domain === "cloudcode-pa.googleapis.com" &&
detail.reason === "VALIDATION_REQUIRED",
);
if (verification !== undefined) {
const verificationUrl = Option.getOrUndefined(
decodeVerificationUrl(verification.metadata?.validation_url),
);
return reusable({
...makeProviderFailure({
class: "permission_error",
message: "Verify your Google account, then retry this turn.",
code: "VALIDATION_REQUIRED",
retryable: false,
}),
...(verificationUrl === undefined ? {} : { verificationUrl }),
});
}
if (apiError === null) {
return reusable(
makeProviderFailure({
Expand Down
21 changes: 20 additions & 1 deletion apps/web/src/components/chat/TimelineWorkEntryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ import type { ExpandedImagePreview } from "./ExpandedImagePreview";
import { workGroupImageGallery } from "./markdownImageGallery";
import { McpSignInAction } from "./McpSignInAction";
import * as DateTime from "effect/DateTime";
import { ChevronRightIcon, CircleAlertIcon, XIcon, RotateCcwIcon } from "lucide-react";
import {
ChevronRightIcon,
CircleAlertIcon,
ExternalLinkIcon,
XIcon,
RotateCcwIcon,
} from "lucide-react";
import { Button, InlineButton } from "../ui/button";
import { useAssetUrls } from "../../assets/assetUrls";
import { observeResize } from "../../lib/observeResize";
Expand Down Expand Up @@ -339,6 +345,7 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
if (failureItem?.type === "error" && failureItem.status === "failed") {
const warning = failureItem.failure.class === "usage_limit";
const resetAt = failureItem.failure.resetAt;
const verificationUrl = failureItem.failure.verificationUrl;
// The reset time is the viewer's local time; naming the zone keeps it
// unambiguous. Both read the zone now, since the device's can change.
const timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
Expand Down Expand Up @@ -386,6 +393,18 @@ function WorkEntryLogRow(props: WorkEntryRowProps) {
{failureItem.failure.message}
</p>
) : null}
{verificationUrl !== undefined ? (
<div className="ms-7 pb-1">
<Button
size="xs"
variant="outline"
render={<a href={verificationUrl} target="_blank" rel="noopener noreferrer" />}
>
<T>Verify Google account</T>
<ExternalLinkIcon aria-hidden />
</Button>
</div>
) : null}
{retryRunId !== null && onRetryWorkspacePreparation ? (
<div className="ms-7 pb-1">
<Button
Expand Down
8 changes: 7 additions & 1 deletion packages/contracts/src/orchestrationV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1685,13 +1685,19 @@ const OrchestrationV2ProviderFailureMessage = TrimmedNonEmptyString.check(
);
const OrchestrationV2ProviderFailureCode = TrimmedNonEmptyString.check(Schema.isMaxLength(128));

/** Producers must redact credentials before construction. */
export const GoogleAccountVerificationUrl = TrimmedNonEmptyString.check(
Schema.isMaxLength(4_096),
Schema.isPattern(/^https:\/\/accounts\.google\.com\/v3\/signin\/continue\?[^\s\\#]+$/),
);

/** Producers must redact credentials from diagnostic text before construction. */
export const OrchestrationV2ProviderFailure = Schema.Struct({
class: OrchestrationV2ProviderFailureClass,
message: OrchestrationV2ProviderFailureMessage,
code: Schema.NullOr(OrchestrationV2ProviderFailureCode),
retryable: Schema.NullOr(Schema.Boolean),
resetAt: Schema.optional(Schema.NullOr(IsoDateTime)),
verificationUrl: Schema.optionalKey(GoogleAccountVerificationUrl),
});
export type OrchestrationV2ProviderFailure = typeof OrchestrationV2ProviderFailure.Type;

Expand Down
Loading