@devries-cameron20 / t3code Mirror · read-only / commits / 7b666f3780
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

fix(server): Grok usage limits tell Legacy-mode xAI accounts to switch to Privacy Mode (#28097)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 3, 2026 at 12:01 UTC 7b666f3780f6ed28a02d29e0176a90a9a6dbe3b8
2 files changed +42
apps/server/src/provider/GrokProvider.test.ts
+30
@@ -722,6 +722,36 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("readGrokAccount"
722 }
723 }),
724 );
725 +
726 + it.effect("tells accounts in Legacy (no storage) to switch to Privacy Mode", () =>
727 + Effect.gen(function* () {
728 + const { usageLimits: limits } = yield* readGrokAccount({
729 + HOME: "/definitely/not/a/grok-home",
730 + GROK_AUTH: '{"https://accounts.x.ai/sign-in":{"key":"private-token"}}',
731 + }).pipe(
732 + Effect.provideService(
733 + HttpClient.HttpClient,
734 + HttpClient.make((request) =>
735 + Effect.succeed(
736 + HttpClientResponse.fromWeb(
737 + request,
738 + Response.json(
739 + {
740 + error:
741 + "Grok Build is not supported in Legacy (no storage). Switch to Privacy Mode to use Grok Build. [WKE=privacy-mode:legacy]",
742 + },
743 + { status: 403 },
744 + ),
745 + ),
746 + ),
747 + ),
748 + ),
749 + );
750 + expect(limits.unavailable?.reason).toBe("probeFailed");
751 + expect(limits.unavailable?.message).toMatch(/Privacy Mode/);
752 + expect(limits.unavailable?.message).not.toMatch(/WKE=|Grok Build is not supported/);
753 + }),
754 + );
755 });
756
757 it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("readGrokAccount email", (it) => {
packages/provider-grok/src/server/usageLimits.ts
+12
@@ -38,6 +38,7 @@ const GrokUsageResponse = Schema.Struct({
38 }),
39 ),
40 });
41 +const GrokErrorResponse = Schema.Struct({ error: Schema.String });
42
43 function parsePeriodBoundary(value: string | undefined) {
44 if (
@@ -182,6 +183,17 @@ export const readGrokAccount = Effect.fn("readGrokAccount")(function* (
183 HttpClientRequest.bearerToken(token),
184 ),
185 );
186 + if (response.status === 403) {
187 + const { error } = yield* HttpClientResponse.schemaBodyJson(GrokErrorResponse)(response);
188 + // xAI refuses Grok Build while the account's privacy setting is a legacy mode.
189 + if (error.includes("WKE=privacy-mode:")) {
190 + return makeUnavailableUsageLimits({
191 + checkedAt,
192 + reason: "probeFailed",
193 + message: "Switch your xAI account to Privacy Mode to show Grok usage limits.",
194 + });
195 + }
196 + }
197 const body = yield* HttpClientResponse.schemaBodyJson(GrokUsageResponse)(
198 yield* HttpClientResponse.filterStatusOk(response),
199 );