Repository navigation
Conversation
…tials and curated+live model list
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3e9638a24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ProviderConfig.Kind.Vertex -> { | ||
| val p = provider(cfg.providerId) | ||
| val raw = apiKey.orEmpty().trim() | ||
| val token: BearerToken = if (raw.startsWith("{")) { |
There was a problem hiding this comment.
Preserve service-account JSON before selecting the token provider
When a user pastes a service-account JSON, probe() and apiKey() first pass it through KeyPoolManager.parseKeys(), which splits on commas and newlines. raw here is therefore a field fragment rather than the JSON object, so this branch selects BearerToken.fixed and sends that fragment as a bearer token instead of using VertexTokenProvider; initial testing and subsequent chats with service-account credentials fail. Preserve or detect the raw JSON before key-pool parsing.
Useful? React with 👍 / 👎.
| val parsedProject = if (raw.startsWith("{")) { | ||
| runCatching { VertexServiceAccount.parse(raw).projectId }.getOrDefault("") | ||
| } else "" | ||
| val project = p?.projectId?.trim().orEmpty().ifBlank { parsedProject } |
There was a problem hiding this comment.
Collect a project ID for pasted OAuth bearer tokens
When a user supplies an OAuth/ADC bearer token instead of service-account JSON, parsedProject is empty and a newly connected provider keeps the blank default projectId; the setup UI has no field that populates it. This passes an empty ID to VertexModel, whose constructor rejects it before making a request, so bearer-token users cannot test or use models. Collect a project ID or provide another reliable source for it.
Useful? React with 👍 / 👎.
| .withHeaders(headers) | ||
| .removeHeader("x-goog-api-key") | ||
| .headerOrReject("Authorization", "Bearer $accessToken") | ||
| .headerOrReject("x-goog-user-project", cleanProjectId) |
There was a problem hiding this comment.
Avoid forcing a quota-project header without its permission
If a service-account caller has permission to invoke Vertex AI but lacks serviceusage.services.use on this project, setting x-goog-user-project makes Google treat it as the quota project and reject the request with 403, even though the project is already present in the resource URL. Omit this header unless a separate quota project is explicitly configured.
Useful? React with 👍 / 👎.
Summary
Adds Vertex AI as a first-class model provider in Mika, supporting Google Cloud Service Account JSON (RS256 JWT exchange with automatic caching/refresh) and Application Default Credentials / OAuth2 bearer tokens against the Vertex AI
generateContentAPI.What's included
core/oauth/VertexAuth.kt):VertexServiceAccount: parses Service Account JSON (client_email,private_key,project_id,token_uri), builds & signs RS256 JWTs, and exchanges them for short-lived OAuth2 bearer tokens.VertexTokenProvider: implementsBearerTokenwith thread-safe in-memory token caching, early expiry refresh, and single-flight refresh on 401.VertexEndpoints: builds regional (https://{location}-aiplatform.googleapis.com) andglobal(https://aiplatform.googleapis.com)generateContentand publisher-model listing URLs.core/model/VertexModel.kt,core/model/GeminiCodec.kt):VertexModel: implementsChatModelover Vertex AIgenerateContentwithAuthorization: Bearer <token>, 401 refresh-and-retry, 429/5xx error classification, multimodal images, tool calls, and reasoning effort.GeminiCodec: shared request/response codec forgenerateContentpayloads used byVertexModel.core/model/ModelCatalog.kt):catalog.vertex(...)listing from Vertex AI publisher models (globalwith automaticus-central1fallback), filtering out non-chat models (imagen,veo,embedding,chirp,lyria, etc.).CURATED_VERTEX_MODELS: Gemini 4 Hydrogen (gemini-4-hydrogen), Gemini 3.8 Flash (gemini-3.8-flash), and Gemini 3.5 Flash-Lite (gemini-3.5-flash-lite), plus custom model ID fallback via manual entry.app/.../settings/ProviderStore.kt,ProviderPresets.kt,ProviderKeySites.kt,ReasoningOptions.kt,AllowanceRoute.kt,ui/ModelSetupScreen.kt,ui/ModelsScreen.kt):ProviderConfig.Kind.Vertexand theVertex AIpreset (https://aiplatform.googleapis.com).ProviderStore's encryptedKeyCipher/ Android Keystore storage (provider-keys.json), never in plaintextproviders.json.projectIdandlocationfields onProvider(automatically falls back toproject_idembedded in the Service Account JSON andgloballocation).README.mdanddocs/readme/README.zh-CN.mdvia./gradlew updateReadme.VertexAuthTest,VertexModelTest(including curated model assertions),GeminiCodecTest.Adaptations for upstream
mainwangzan101/Mika:main(9c7aabd8) with zero fork-specific code (no branding/package changes, no Antigravity, no unrelated UI rewrites).CallOptions/forceToolCallwiring fromVertexModelandGeminiCodecso this PR is completely standalone and cleanly compiles against upstreamChatModel.ProviderStore.buildModelso Service Account JSON works both during pre-save "Test & Save" probes and after saving in encrypted storage.How to test
gemini-4-hydrogen,gemini-3.8-flash,gemini-3.5-flash-lite) and manual custom model ID entry, and run a chat/tool call.