feat(admin-dashboard): add support for Bedrock and OpenAI-compatible LLM slices in admin router config

- Implemented `buildBedrockSlice` function to handle multi-kilobyte Bedrock bearer tokens.
- Enhanced `createAdminRouterConfigService` to classify Bedrock and OpenAI-compatible LLM upstreams by baseURL.
- Added new interfaces for `AdminRouterBedrockSlice` and `AdminRouterOpenAICompatibleSlice`.
- Updated router config form to support Bedrock and OpenAI-compatible slices.
- Created tests for Bedrock and OpenAI-compatible slice compilation and behavior.
- Modified UI components to accommodate new slice types and improve user experience.
- Ensured proper normalization of API server URLs to HTTPS when necessary.
This commit is contained in:
RainbowBird
2026-07-01 02:14:12 +08:00
parent f9f20b88ff
commit 4f80affcd3
17 changed files with 684 additions and 50 deletions
@@ -29,6 +29,13 @@ describe('ui-server-auth bootstrap context', () => {
)?.apiServerUrl).toBe('http://127.0.0.1:3000')
})
it('normalizes known production API hosts to HTTPS when typed with HTTP', () => {
expect(resolveStandaloneServerAuthContext(
'https://accounts.airi.build/ui/sign-in?api_server_url=http%3A%2F%2Fapi.airi.build',
'http://localhost:3000',
)?.apiServerUrl).toBe('https://api.airi.build')
})
it('falls back to the standalone query context when the static placeholder script is still present', () => {
document.body.innerHTML = '<script id="airi-server-auth-context" type="application/json">__AIRI_SERVER_AUTH_CONTEXT__</script>'
window.history.replaceState(
@@ -19,6 +19,13 @@ const TRUSTED_STANDALONE_API_SERVER_ORIGINS = [
'https://airi-server-dev.up.railway.app',
]
const TRUSTED_HTTPS_API_SERVER_HOSTS = new Map(
TRUSTED_STANDALONE_API_SERVER_ORIGINS.map((origin) => {
const url = new URL(origin)
return [url.hostname, origin]
}),
)
const TRUSTED_LOCAL_API_SERVER_ORIGIN_PATTERNS = [
/^http:\/\/localhost(:\d+)?$/,
/^http:\/\/127\.0\.0\.1(:\d+)?$/,
@@ -89,7 +96,12 @@ function normalizeTrustedApiServerUrl(value: string | null): string | null {
return null
try {
const origin = new URL(value).origin
const url = new URL(value)
const normalizedHttpsOrigin = TRUSTED_HTTPS_API_SERVER_HOSTS.get(url.hostname)
if (normalizedHttpsOrigin)
return normalizedHttpsOrigin
const origin = url.origin
if (TRUSTED_STANDALONE_API_SERVER_ORIGINS.includes(origin))
return origin