Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(server): recognize Bedrock-backed Claude as authenticated (#3931)
Pieter van Zyl68ea280388be
diff --git a/apps/server/src/provider/Layers/ClaudeProvider.ts b/apps/server/src/provider/Layers/ClaudeProvider.tsindex d49b4770a..94b24405e 100644--- a/apps/server/src/provider/Layers/ClaudeProvider.ts+++ b/apps/server/src/provider/Layers/ClaudeProvider.ts@@ -480,9 +480,19 @@ function claudeAuthMetadata(input: {return undefined;}+function apiProviderAuthMetadata(+ apiProvider: string | undefined,+): { readonly type: string; readonly label: string } | undefined {+ return apiProvider === "bedrock" ? { type: "bedrock", label: "Amazon Bedrock" } : undefined;+}+// ── SDK capability probe ────────────────────────────────────────────-const CAPABILITIES_PROBE_TIMEOUT_MS = 8_000;+// Amazon Bedrock initializes far slower than first-party auth: the SDK boots the+// Bedrock backend and runs the `awsAuthRefresh` credential hook before returning+// account info. The previous 8s budget expired mid-init, so the probe returned+// `undefined` and left the provider unverified and unselectable in the picker.+const CAPABILITIES_PROBE_TIMEOUT_MS = 25_000;function nonEmptyProbeString(value: string): string | undefined {const candidate = value.trim();@@ -493,6 +503,12 @@ type ClaudeCapabilitiesProbe = {readonly email: string | undefined;readonly subscriptionType: string | undefined;readonly tokenSource: string | undefined;+ /**+ * Active API backend reported by the SDK's `AccountInfo`. Anthropic OAuth+ * login only applies when `"firstParty"`; for Amazon Bedrock (`"bedrock"`)+ * the subscription/token fields are absent and auth is external AWS creds.+ */+ readonly apiProvider: string | undefined;readonly slashCommands: ReadonlyArray<ServerProviderSlashCommand>;};@@ -618,12 +634,14 @@ const probeClaudeCapabilities = (readonly email?: string;readonly subscriptionType?: string;readonly tokenSource?: string;+ readonly apiProvider?: string;}| undefined;return {email: account?.email,subscriptionType: account?.subscriptionType,tokenSource: account?.tokenSource,+ apiProvider: account?.apiProvider,slashCommands: parseClaudeInitializationCommands(init.commands),} satisfies ClaudeCapabilitiesProbe;});@@ -799,10 +817,11 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(});}- const authMetadata = claudeAuthMetadata({- subscriptionType: capabilities.subscriptionType,- authMethod: capabilities.tokenSource,- });+ const authMetadata =+ claudeAuthMetadata({+ subscriptionType: capabilities.subscriptionType,+ authMethod: capabilities.tokenSource,+ }) ?? apiProviderAuthMetadata(capabilities.apiProvider);return buildServerProvider({presentation: CLAUDE_PRESENTATION,enabled: claudeSettings.enabled,diff --git a/apps/server/src/provider/Layers/ProviderRegistry.test.ts b/apps/server/src/provider/Layers/ProviderRegistry.test.tsindex 5456a90bd..78ff5cf49 100644--- a/apps/server/src/provider/Layers/ProviderRegistry.test.ts+++ b/apps/server/src/provider/Layers/ProviderRegistry.test.ts@@ -100,6 +100,7 @@ type TestClaudeCapabilities = {readonly email: string | undefined;readonly subscriptionType: string | undefined;readonly tokenSource: string | undefined;+ readonly apiProvider: string | undefined;readonly slashCommands: ReadonlyArray<ServerProviderSlashCommand>;};@@ -109,6 +110,7 @@ function claudeCapabilities(overrides: Partial<TestClaudeCapabilities> = {}) {email: undefined,subscriptionType: undefined,tokenSource: undefined,+ apiProvider: undefined,slashCommands: [],...overrides,});@@ -1492,6 +1494,30 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te),);+ it.effect("returns ready and labels Bedrock-backed Claude as authenticated", () =>+ Effect.gen(function* () {+ // Bedrock authenticates via external AWS credentials, so the SDK init+ // reports only `apiProvider` with no subscription or token.+ const status = yield* checkClaudeProviderStatus(+ defaultClaudeSettings,+ claudeCapabilities({ apiProvider: "bedrock" }),+ );+ assert.strictEqual(status.status, "ready");+ assert.strictEqual(status.installed, true);+ assert.strictEqual(status.auth.status, "authenticated");+ assert.strictEqual(status.auth.type, "bedrock");+ assert.strictEqual(status.auth.label, "Amazon Bedrock");+ }).pipe(+ Effect.provide(+ mockSpawnerLayer((args) => {+ const joined = args.join(" ");+ if (joined === "--version") return { stdout: "1.0.0\n", stderr: "", code: 0 };+ throw new Error(`Unexpected args: ${joined}`);+ }),+ ),+ ),+ );+it.effect("includes Claude Fable 5 on supported Claude Code versions", () =>Effect.gen(function* () {const status = yield* checkClaudeProviderStatus(