refactor(providers): share google and xai provider helpers#60722
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e9fdf28dd
ℹ️ 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".
| resolveGoogleGenerativeAiHttpRequestConfig({ | ||
| apiKey: params.apiKey, | ||
| baseUrl: params.baseUrl ?? params.defaultBaseUrl, |
There was a problem hiding this comment.
Keep private-network disabled for default media endpoint
This call now passes params.baseUrl ?? params.defaultBaseUrl into resolveGoogleGenerativeAiHttpRequestConfig, but that helper sets allowPrivateNetwork from whether baseUrl is non-empty. Since defaultBaseUrl is always set, audio/video requests now enable private-network access even when the user did not configure a custom base URL. Previously this path only enabled private-network when params.baseUrl was explicitly provided, so this change silently weakens the network guard for the default Google endpoint.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR is a focused refactoring that extracts duplicated provider helpers into shared modules for both the Google and xAI extensions, without changing any observable provider behavior. Google changes:
xAI changes:
One issue found:
Confidence Score: 4/5Safe to merge after removing two unused imports; no behavioral changes introduced. The refactoring is well-scoped, all shared helpers have accompanying unit tests, and the extraction follows existing extension patterns. The only issue is two unused extensions/xai/src/x-search-shared.ts and extensions/xai/src/code-execution-shared.ts — both carry an unused import of Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/xai/src/x-search-shared.ts
Line: 12
Comment:
**Unused import introduced by this refactor**
`extractXaiWebSearchContent` is imported here but is never used anywhere in this module — it does not appear in `resolveXaiXSearchConfig`, `resolveXaiXSearchModel`, `requestXaiXSearch`, `buildXaiXSearchPayload`, or the `__testing` export. The same pattern appears in `extensions/xai/src/code-execution-shared.ts:12`. Both were likely copied from an earlier draft before the function was moved to live exclusively in `web-search-shared.ts`.
Remove the dead binding from both import statements:
```suggestion
import { type XaiWebSearchResponse } from "./web-search-shared.js";
```
And in `extensions/xai/src/code-execution-shared.ts` line 12:
```ts
import { type XaiWebSearchResponse } from "./web-search-shared.js";
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(xai): re-export shared web search ex..." | Re-trigger Greptile |
| resolveNormalizedXaiToolModel, | ||
| resolvePositiveIntegerToolConfig, | ||
| } from "./tool-config-shared.js"; | ||
| import { extractXaiWebSearchContent, type XaiWebSearchResponse } from "./web-search-shared.js"; |
There was a problem hiding this comment.
Unused import introduced by this refactor
extractXaiWebSearchContent is imported here but is never used anywhere in this module — it does not appear in resolveXaiXSearchConfig, resolveXaiXSearchModel, requestXaiXSearch, buildXaiXSearchPayload, or the __testing export. The same pattern appears in extensions/xai/src/code-execution-shared.ts:12. Both were likely copied from an earlier draft before the function was moved to live exclusively in web-search-shared.ts.
Remove the dead binding from both import statements:
| import { extractXaiWebSearchContent, type XaiWebSearchResponse } from "./web-search-shared.js"; | |
| import { type XaiWebSearchResponse } from "./web-search-shared.js"; |
And in extensions/xai/src/code-execution-shared.ts line 12:
import { type XaiWebSearchResponse } from "./web-search-shared.js";Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/xai/src/x-search-shared.ts
Line: 12
Comment:
**Unused import introduced by this refactor**
`extractXaiWebSearchContent` is imported here but is never used anywhere in this module — it does not appear in `resolveXaiXSearchConfig`, `resolveXaiXSearchModel`, `requestXaiXSearch`, `buildXaiXSearchPayload`, or the `__testing` export. The same pattern appears in `extensions/xai/src/code-execution-shared.ts:12`. Both were likely copied from an earlier draft before the function was moved to live exclusively in `web-search-shared.ts`.
Remove the dead binding from both import statements:
```suggestion
import { type XaiWebSearchResponse } from "./web-search-shared.js";
```
And in `extensions/xai/src/code-execution-shared.ts` line 12:
```ts
import { type XaiWebSearchResponse } from "./web-search-shared.js";
```
How can I resolve this? If you propose a fix, please make it concise.…60722) * refactor(google): share oauth token helpers * refactor(xai): share tool auth fallback helpers * refactor(xai): share tool auth resolution * refactor(xai): share tool config helpers * refactor(xai): share fallback auth helpers * refactor(xai): share responses tool helpers * refactor(google): share http request config helper * fix(xai): re-export shared web search extractor * fix(xai): import plugin config type * fix(providers): preserve default google network guard
…60722) * refactor(google): share oauth token helpers * refactor(xai): share tool auth fallback helpers * refactor(xai): share tool auth resolution * refactor(xai): share tool config helpers * refactor(xai): share fallback auth helpers * refactor(xai): share responses tool helpers * refactor(google): share http request config helper * fix(xai): re-export shared web search extractor * fix(xai): import plugin config type * fix(providers): preserve default google network guard
…60722) * refactor(google): share oauth token helpers * refactor(xai): share tool auth fallback helpers * refactor(xai): share tool auth resolution * refactor(xai): share tool config helpers * refactor(xai): share fallback auth helpers * refactor(xai): share responses tool helpers * refactor(google): share http request config helper * fix(xai): re-export shared web search extractor * fix(xai): import plugin config type * fix(providers): preserve default google network guard
…60722) * refactor(google): share oauth token helpers * refactor(xai): share tool auth fallback helpers * refactor(xai): share tool auth resolution * refactor(xai): share tool config helpers * refactor(xai): share fallback auth helpers * refactor(xai): share responses tool helpers * refactor(google): share http request config helper * fix(xai): re-export shared web search extractor * fix(xai): import plugin config type * fix(providers): preserve default google network guard
…60722) * refactor(google): share oauth token helpers * refactor(xai): share tool auth fallback helpers * refactor(xai): share tool auth resolution * refactor(xai): share tool config helpers * refactor(xai): share fallback auth helpers * refactor(xai): share responses tool helpers * refactor(google): share http request config helper * fix(xai): re-export shared web search extractor * fix(xai): import plugin config type * fix(providers): preserve default google network guard
Summary
Verification
pnpm exec oxlint extensions/google/api.ts extensions/google/api.test.ts extensions/google/gemini-cli-provider.ts extensions/google/index.ts extensions/google/image-generation-provider.ts extensions/google/media-understanding-provider.ts extensions/google/oauth-token-shared.ts extensions/google/oauth-token-shared.test.ts extensions/google/runtime-api.ts extensions/xai/code-execution.ts extensions/xai/index.ts extensions/xai/src/code-execution-shared.ts extensions/xai/src/responses-tool-shared.ts extensions/xai/src/responses-tool-shared.test.ts extensions/xai/src/tool-auth-shared.ts extensions/xai/src/tool-auth-shared.test.ts extensions/xai/src/tool-config-shared.ts extensions/xai/src/tool-config-shared.test.ts extensions/xai/src/web-search-shared.ts extensions/xai/src/x-search-shared.ts extensions/xai/x-search.tspnpm exec vitest run --config vitest.config.ts extensions/google/api.test.ts extensions/google/oauth-token-shared.test.ts extensions/xai/src/tool-auth-shared.test.ts extensions/xai/src/tool-config-shared.test.ts extensions/xai/src/responses-tool-shared.test.tspnpm buildNotes
pnpm buildran through the expected build chain in this worktree, but the local session wrapper did not emit a final clean exit after subprocess completion. No build subprocesses were left running after the run.