fix: align xAI tool auth profiles#79453
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. source-level: current main's manifest tool availability accepts xAI auth profiles, but the xAI lazy factories and execution resolver only check plugin config and env credentials. The related reporter comment confirms the same auth-profile-only setup fails in practice. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the focused PR after maintainer review, keeping xAI tool registration and execution aligned with auth profiles while preserving explicit config and SecretRef blocking semantics. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main's manifest tool availability accepts xAI auth profiles, but the xAI lazy factories and execution resolver only check plugin config and env credentials. The related reporter comment confirms the same auth-profile-only setup fails in practice. Is this the best way to solve the issue? Yes. The PR moves the existing auth-profile ordering and key-resolution helpers into the plugin tool context and uses xAI-owned resolver helpers, which is the narrow fix while preserving current config and SecretRef behavior. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against e84eb59ea288. |
54b74c7 to
56aa604
Compare
|
Addressed the ClawSweeper feedback and force-pushed What changed:
Validation run locally from
Fresh CI is pending on the new head. |
56aa604 to
97944aa
Compare
|
Rebased this branch onto current Validation after the rebase:
|
97944aa to
a92ede3
Compare
|
Landed via temp rebase onto main.
Thanks @brokemac79! |
Summary
Fixes #79353.
x_searchandcode_executiontools to register and execute with an xAI auth profile, while preserving existing plugin config/env precedence and blocked SecretRef behavior.Real behavior proof (required for external PRs)
x_searchandcode_executionfailed to register when the only xAI credential was an OpenClaw xAI auth profile rather than plugin config orXAI_API_KEY.corepack pnpm exec tsx -with a local script that imports./extensions/xai/index.ts, registers the real xAI plugin through a minimal plugin API, supplies an xAI auth-profile provider helper, and callsresolveXaiToolApiKeyWithAuth.corepack pnpm test extensions/xai/src/tool-auth-shared.test.ts extensions/xai/index.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts src/plugins/tools.optional.test.ts src/secrets/runtime-web-tools.test.ts src/config/config.web-search-provider.test.ts src/agents/openclaw-tools.browser-plugin.integration.test.tsSupplemental note: an earlier local execution attempt with a deliberately fake xAI auth-profile key reached xAI and failed with xAI's expected invalid-key response, confirming the auth-profile credential flowed into the real request path; I did not include that full error output because no valid live xAI credential is available here.
hasAuthForProvider("xai")is true, and the shared xAI tool auth resolver returns the auth-profile API key for execution.Verification
corepack pnpm test extensions/xai/src/tool-auth-shared.test.ts extensions/xai/index.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts src/plugins/tools.optional.test.ts src/secrets/runtime-web-tools.test.ts src/config/config.web-search-provider.test.ts src/agents/openclaw-tools.browser-plugin.integration.test.tscorepack pnpm exec oxfmt --check --threads=1 extensions/xai/index.ts extensions/xai/src/tool-auth-shared.ts extensions/xai/x-search.ts extensions/xai/x-search-tool-shared.ts extensions/xai/code-execution.ts extensions/xai/src/web-search-provider.runtime.ts src/agents/openclaw-plugin-tools.ts src/plugins/tool-types.ts src/agents/openclaw-tools.browser-plugin.integration.test.ts extensions/xai/src/tool-auth-shared.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts docs/providers/xai.md docs/tools/web.md docs/tools/code-execution.md docs/tools/grok-search.md CHANGELOG.mdgit diff --check origin/main...HEADcorepack pnpm check:changelog-attributionscorepack pnpm check:changedcorepack pnpm exec tsgo -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfocorepack pnpm exec tsgo -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfocorepack pnpm exec tsgo -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfocorepack pnpm exec tsgo -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfocorepack pnpm exec tsgo -p tsconfig.plugin-sdk.dts.json --declaration truecorepack pnpm docs:check-mdxcorepack pnpm docs:check-i18n-glossarycorepack pnpm docs:check-linksNotes:
corepack pnpm buildreached bundled plugin assets/postbuild, then hit the local Windows path-with-space wrapper issue inbuild:plugin-sdk:dts(New projectsplit by the wrapper). The direct plugin SDK dts command above passed. Fullcheck:docsis similarly blocked locally because its package script invokes barepnpm; direct docs checks above passed, while markdownlint also reports an unrelated pre-existingdocs/CLAUDE.mdnewline issue.