Repository navigation
refactor: move the xAI files to the upstream layout - #313
Merged
eric8810 merged 14 commits intoOct 27, 2026
Merged
Conversation
One Rust file per @ai-sdk/xai source file (RFC-0046 §4.2): mod.rs keeps only the module list (index.ts), with the provider in provider.rs and the error and response handlers in error.rs; convert.rs becomes supports_reasoning_effort.rs; speech, transcription and video become *_model.rs. responses/mod.rs becomes responses_language_model.rs (with the request body and tool-name helpers), types.rs becomes responses_api.rs, and responses/convert.rs splits into convert_to_responses_input.rs, convert_responses_usage.rs, map_responses_finish_reason.rs, responses_prepare_tools.rs and responses_language_model_options.rs. The four tests/xai_*_test.rs binaries join their files in src/xai/tests/. Move only: the test count (338) and the test names are unchanged; function bodies change only in module paths. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
This was referenced Oct 20, 2026
RFC-0046 §4.5 item 2: the vendor move PR lists the old public sub-module paths and the replacement entry under Unreleased > Breaking. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
3 tasks done
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
xAI layout refactor:test multiset 338→338,80/80 functions 归一化后一致;公开路径删除已在 CHANGELOG 登记。Approve。
The new xai_transcription_test.rs case (dropping an unpolled stream closes the socket) moves into src/xai/tests/transcription_model.rs with the other transcription cases; its stream_options helper is wiremock_stream_options there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…' into refactor/move-the-xai-files-to-the-upstream-layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
changed the base branch from
test/port-the-upstream-xai-tests
to
master
October 27, 2026 16:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
把 xAI 的源文件按
@ai-sdk/xai@5.0.12一个文件对一个文件拆开(RFC-0046 §4.2),老的四个tests/xai_*_test.rs并进厂商测试目录src/xai/tests/(RFC-0046 §5 的新布局)。只搬不改:函数体只改了模块路径,测试数量、模块路径和函数名前后一致。叠在测试 PR #312 上。已经测试分支
bf71fda9合上 masterb69137eb,冲突按 master 的改动搬到新位置解决(responses/convert.rs的四处改动落到responses/{responses_language_model_options, responses_prepare_tools, convert_to_responses_input}.rs,JSON 解析错误的 cause 落到error.rs,老测试里四处错误模式改成结构体变体);测试数前后仍相等(xAI 338 个,测试分支 lib 262 个加老测试程序 76 个,名字多重集相同)。一、体系现状(概览,测试 PR #312 头
8c30faea)上游同一条路:
createXai(xai-provider.ts)→XaiResponsesLanguageModel.doGenerate(responses/xai-responses-language-model.ts)→convertToXaiResponsesInput、prepareResponsesTools、convertXaiResponsesUsage、mapXaiResponsesFinishReason、supportsReasoningEffort各在自己的文件,错误处理在 xai-error.ts。aimux 把工厂、错误处理和index.ts放在一个 470 行的mod.rs里,5 个上游 responses 文件放在一个 1,013 行的responses/convert.rs里。测试:#312 的新用例在
src/xai/tests/,老用例还在四个独立测试程序里(xai_speech_test17 个、xai_transcription_test20 个、xai_video_test34 个、xai_upstream_e2e_test5 个)。二、本 PR 改动(细节)
mod.rs模块文档、导出xai/mod.rs(只有模块声明和pub use)index.tsmod.rs设置、工厂、默认实例、XAIProviderxai/provider.rsxai-provider.tsmod.rs四个响应/错误处理器xai/error.rsxai-error.tsconvert.rsxai/supports_reasoning_effort.rssupports-reasoning-effort.tsspeech.rs、transcription.rs、video.rsspeech_model.rs、transcription_model.rs、video_model.rsxai-*-model.ts(选项解析在模型文件里,*-model-options.ts也指向它)responses/mod.rs模型和流;responses/convert.rs请求体、工具名帮手responses/responses_language_model.rsxai-responses-language-model.ts(get-response-metadata.ts内联在里面)responses/convert.rs输入转换、convert.rs的 provider reference 和媒体类型帮手responses/convert_to_responses_input.rsconvert-to-xai-responses-input.ts、xai-file-part-options.tsresponses/convert.rs工具准备、provider tool 参数校验responses/responses_prepare_tools.rsxai-responses-prepare-tools.tsresponses/convert.rsproviderOptions.xai校验responses/responses_language_model_options.rsxai-responses-language-model-options.tsresponses/convert.rs用量、finish reasonresponses/convert_responses_usage.rs、responses/map_responses_finish_reason.rsresponses/types.rsresponses/responses_api.rsxai-responses-api.tsxai::responses::convert::*、xai::responses::types::*的公开项由responses/mod.rs再导出为xai::responses::*;xai::convert::supports_reasoning_effort变成xai::supports_reasoning_effort。crate 外没有用这些路径的地方。pub(super)(xai_option、validate_value、string_array、validate_response_options);super::xai_*_handler改成crate::xai::error::/super::error::,模型里用use super::responses_api as types;保持types::不变,函数体不动。options.rs不动(包内的选项帮手,命名空间键只写在这里),边界脚本不用改。xai_speech_test→tests/speech_model.rs,xai_transcription_test→tests/transcription_model.rs,xai_video_test→tests/video_model.rs,xai_upstream_e2e_test→tests/responses/responses_language_model.rs。老 wiremock 帮手放在各文件的「wiremock harness」一节,和 test: port the upstream xAI tests #312 帮手同名的改加wiremock_前缀(speech_model、xai_options、default_body、stream_options、start、completed),内容相同的直接去重(AUDIO和视频的 7 个常量/帮手);aimux_providers::改成crate::。layout.toml的rust字段改到新路径;openai/responses/responses_convert.rs一处指向旧文件的注释改到新文件。CHANGELOG
CHANGELOG Unreleased 的 Breaking 加了一条,列出本家变了的公开子模块路径和替代入口(RFC-0046 §4.5 第 2 条)。
验证
cargo test -p aimux-providers --lib加原四个--test xai_*:前后都是 338 个测试(262 + 76),模块路径(去掉文件前缀后)和函数名完全相同;xAI 的 338 个全过。use和注释后,只有可见性和模块路径的差别。cargo +1.99 clippy -p aimux-providers --lib --tests -- -D warnings、cargo doc -D warnings、cargo fmt --check、scripts/check_provider_boundaries.sh通过。Type of change
Checklist
共享进程状态:测试原来各自是单独的测试程序,现在并进 lib 的同一个测试程序。9 个测试带
#[serial];SOURCE_ID_COUNTER(xai/responses/responses_language_model.rs:47)只有 xAI 用,搬进来后不和别家共享;没有固定临时路径(RFC-0046 §5)。Generated by Claude Code