Merged
Size
XL
Change Breakdown
Refactor80%
Maintenance20%
#60722refactor(providers): share google and xai provider helpers

Provider helpers consolidated across Google and xAI surfaces

OAuth token parsing, HTTP request configuration, and API key resolution logic is being extracted from individual provider entrypoints into shared modules, eliminating hundreds of lines of duplicated code.

The Google and xAI provider implementations had accumulated duplicated logic across multiple files. Functions for parsing OAuth tokens, resolving HTTP request configurations, and handling API key fallback chains were scattered throughout the codebase — often duplicated with minor variations.

OAuth token parsing logic existed in three places for Google providers. API key fallback resolution for xAI tools appeared in four separate locations. Request body construction for the xAI Responses API was duplicated across code execution, web search, and X Search tools.

These helpers are now consolidated into dedicated shared modules. OAuth token parsing lives in . Tool authentication and fallback resolution are centralized in . Tool configuration helpers are in . Responses API request building and content extraction are in .

The net result is a reduction of approximately 400 lines of code across 16 files, with all provider behavior preserved. The shared modules provide a single place to update authentication logic or request construction without hunting through multiple entrypoint files.

View Original GitHub Description

Summary

  • share Google OAuth token and Generative AI HTTP request helpers across provider entrypoints
  • share xAI tool auth, config, fallback auth, and Responses request helpers across plugin/tool surfaces
  • reduce provider-local duplicate parsing and request-body construction without changing provider behavior

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.ts
  • pnpm 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.ts
  • pnpm build

Notes

  • pnpm build ran 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.
© 2026 · via Gitpulse