Repository navigation
refactor: share hostname part check and base URL setting - #387
Open
cunninghamcard-bit wants to merge 8 commits into
Open
cunninghamcard-bit wants to merge 8 commits into
cunninghamcard-bit wants to merge 8 commits into
Conversation
isValidHostnamePart as @ai-sdk/provider-utils 5.0.55, with its upstream tests, and the explicit-or-environment base URL setting the native packages build from loadOptionalSetting. Both move here from aimux-providers' shared module (RFC-0046 R1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Azure, Amazon Bedrock, Anthropic AWS and Google Vertex check their host parts, and OpenAI and Anthropic read their base URLs, through the provider-utils functions; the shared copies are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
cunninghamcard-bit
marked this pull request as ready for review
October 28, 2026 00:43
30 of 57 tasks
…name-part-check-and-base-url-setting # Conflicts: # aimux-provider-utils/src/lib.rs # aimux-provider-utils/src/tests/mod.rs
…name-part-check-and-base-url-setting # Conflicts: # aimux-providers/src/azure/openai_provider.rs
…name-part-check-and-base-url-setting # Conflicts: # CHANGELOG.md # aimux-provider-utils/src/tests/mod.rs
Contributor
Author
Generated by Claude Code |
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
仅 rebase + CHANGELOG/tests union;hostname/base URL 逻辑与批准时一致,16/16 CI 通过。Approve。
…name-part-check-and-base-url-setting # Conflicts: # CHANGELOG.md
Contributor
Author
Generated by Claude Code |
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Rebase 仅 CHANGELOG 插入,diff 与批准时一致,16/16 CI 通过。Re-approve。
…name-part-check-and-base-url-setting # Conflicts: # aimux-provider-utils/src/tests/mod.rs
Contributor
Author
|
合上 master
本地 Generated by Claude Code |
This branch has not been deployed
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.
RFC-0046 R1 的第 9 个小 PR(清单见 #328):把
isValidHostnamePart和“显式值或环境变量的 base URL”两个函数从aimux-providers/src/shared/mod.rs挪进aimux-provider-utils,调用方改从 provider-utils 用。Before:
is_valid_hostname_part、base_url_setting是 providers 里shared模块的pub(crate)函数。前者是上游 provider-utils 的公开函数,后者是上游loadOptionalSetting+withoutTrailingSlash在 OpenAI、Anthropic 工厂里的固定写法。After:两个函数在
aimux_provider_utils公开导出,Azure、Amazon Bedrock、Anthropic AWS、Google Vertex 的主机名校验和 OpenAI、Anthropic 的 base URL 都从这里取。行为不变。一、体系现状(概览)
上游:
aimux(master 9f9f5ab):
二、本 PR 改动(细节)
base_url_setting上游没有同名函数,名字沿用。外层Err是显式值不合法(工厂失败),内层Err是环境变量不合法(每次请求报错),与上游“创建时不校验环境变量、首个请求失败”一致。测试:
src/tests/is_valid_hostname_part.rsis-valid-hostname-part.test.ts的两张it.each表(accepts 6 行、rejects 17 行),每张表一个用例。5.0.55 的 npm 包不带测试,取自上游仓库,源码与 5.0.55 逐字相同base_url_setting的行为由 OpenAI、Anthropic 已有的OPENAI_BASE_URL、ANTHROPIC_BASE_URL用例覆盖,原样通过。工作区测试数不变(4380),provider-utils 另加 2 个。改动规模:
公开 API 与行为
aimux_provider_utils::is_valid_hostname_part、aimux_provider_utils::base_url_setting。pub(crate)函数,没有 Breaking;行为不变。CHANGELOG 的 Added 一条。检查
cargo fmt --check、scripts/check_provider_boundaries.sh、cargo +1.99 clippy(providers 与 provider-utils,-D warnings)、cargo check --workspace、cargo doc、全部测试均通过。Generated by Claude Code