@allbluecn/web-app 0.27.26 → 0.27.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -112,7 +112,7 @@ export const SDK_GROUPS: SdkGroup[] = [
|
|
|
112
112
|
"items": [
|
|
113
113
|
{
|
|
114
114
|
"name": "@allbluecn/web-app",
|
|
115
|
-
"version": "v0.27.
|
|
115
|
+
"version": "v0.27.27",
|
|
116
116
|
"lastUpdate": "Nov 10, 2026",
|
|
117
117
|
"source": "apps/web/package.json",
|
|
118
118
|
"docsUrl": "https://github.com/allbluecn/allblue"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// harness 模型目录展开(多 provider 修复):
|
|
6
|
+
// kernel 种子全目录进 catalog(key=裸模型 id + provider/model 别名),adapterKind
|
|
7
|
+
// 分派正确,未装 adapter 的 kind(gemini/bedrock/harness-*)跳过。
|
|
8
|
+
|
|
9
|
+
import { describe, expect, it } from 'vitest'
|
|
10
|
+
import { SEED_AI_PROVIDERS } from '@allbluecn/kernel'
|
|
11
|
+
import { buildModelCatalog } from '../model-catalog.server'
|
|
12
|
+
|
|
13
|
+
describe('buildModelCatalog(多 provider 目录)', () => {
|
|
14
|
+
const catalog = buildModelCatalog()
|
|
15
|
+
const keys = Object.keys(catalog)
|
|
16
|
+
|
|
17
|
+
it('default 缺省条目存在(OpenRouter auto)', () => {
|
|
18
|
+
expect(keys).toContain('default')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('种子全目录展开:每个 provider×model 都有裸 id + provider/model 别名', () => {
|
|
22
|
+
let seedModelCount = 0
|
|
23
|
+
for (const p of SEED_AI_PROVIDERS) {
|
|
24
|
+
for (const m of p.models ?? []) {
|
|
25
|
+
seedModelCount += 1
|
|
26
|
+
const skippedKind = ['gemini', 'bedrock', 'openrouter'].includes(p.adapterKind) ||
|
|
27
|
+
p.adapterKind.startsWith('harness-')
|
|
28
|
+
if (skippedKind && !['openrouter'].includes(p.adapterKind)) continue
|
|
29
|
+
// 跳过的 kind 无条目;其余 kind 必有裸 id 条目
|
|
30
|
+
if (p.adapterKind === 'gemini' || p.adapterKind === 'bedrock' || p.adapterKind.startsWith('harness-')) {
|
|
31
|
+
continue
|
|
32
|
+
}
|
|
33
|
+
expect(keys).toContain(m.id)
|
|
34
|
+
expect(keys).toContain(`${p.providerId}/${m.id}`)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// 目录规模与种子同量级(default + 每模型两键,跳过的 kind 除外)
|
|
38
|
+
expect(keys.length).toBeGreaterThan(seedModelCount)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('sensenova(openai-compatible)条目存在——真机验收用户的 provider', () => {
|
|
42
|
+
const sensenova = SEED_AI_PROVIDERS.find((p) => p.providerId === 'sensenova')
|
|
43
|
+
expect(sensenova).toBeDefined()
|
|
44
|
+
expect(sensenova!.adapterKind).toBe('openai-compatible')
|
|
45
|
+
for (const m of sensenova!.models ?? []) {
|
|
46
|
+
expect(keys).toContain(m.id)
|
|
47
|
+
expect(keys).toContain(`sensenova/${m.id}`)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('gemini/bedrock/harness-* 不进目录(未装 adapter / 非云端通道)', () => {
|
|
52
|
+
for (const p of SEED_AI_PROVIDERS) {
|
|
53
|
+
if (p.adapterKind === 'gemini' || p.adapterKind === 'bedrock') {
|
|
54
|
+
for (const m of p.models ?? []) {
|
|
55
|
+
expect(keys).not.toContain(`gemini/${m.id}`)
|
|
56
|
+
expect(keys).not.toContain(`bedrock/${m.id}`)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (p.adapterKind.startsWith('harness-')) {
|
|
60
|
+
// harness-* 是本地 ACP 通道(LocalAgentAdapter),不占模型目录
|
|
61
|
+
expect(keys).not.toContain(`${p.providerId}/`)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
|
|
16
16
|
import { keyedAdapter, type AnyTextAdapter, type KeyedAdapter } from '@tanstack/ai'
|
|
17
17
|
import { createOpenRouterText } from '@tanstack/ai-openrouter'
|
|
18
|
+
import { createOpenaiChat } from '@tanstack/ai-openai'
|
|
19
|
+
import { openaiCompatibleText } from '@tanstack/ai-openai/compatible'
|
|
20
|
+
import { createAnthropicChat } from '@tanstack/ai-anthropic'
|
|
21
|
+
import { SEED_AI_PROVIDERS, type AiProviderMeta } from '@allbluecn/kernel'
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* 默认模型条目(OpenRouter,缺省走用户 DB 档 key)。
|
|
@@ -32,20 +36,84 @@ const DEFAULT_MODEL = 'openrouter/auto'
|
|
|
32
36
|
* `default` 是未选模型时的缺省 adapter。生产环境每个用户配置不同,但 keyedAdapter
|
|
33
37
|
* 只在调用时解析 key,故目录本身可以静态共享。
|
|
34
38
|
*/
|
|
39
|
+
/**
|
|
40
|
+
* 单个 provider×model 的 keyedAdapter 工厂(按 adapterKind 分派)。
|
|
41
|
+
*
|
|
42
|
+
* providerId 传平台 providerId——host 以它调 CredentialStore.get({ id }),桥映射到
|
|
43
|
+
* AiProviderConfig.providerId 取该回合用户的 key(T2.2 只读桥)。
|
|
44
|
+
*
|
|
45
|
+
* 未装 adapter 的 kind 跳过(返回 null,不进目录):gemini(无官方包;其
|
|
46
|
+
* OpenAI 兼容端点未实测不冒进)、bedrock(云端专用)、harness-*(本地 ACP
|
|
47
|
+
* 经 LocalAgentAdapter 通道,不进模型目录)、ollama(openai-compatible 通道覆盖)。
|
|
48
|
+
*/
|
|
49
|
+
function keyedAdapterFactory(
|
|
50
|
+
provider: AiProviderMeta,
|
|
51
|
+
modelId: string,
|
|
52
|
+
): KeyedAdapter<AnyTextAdapter> | null {
|
|
53
|
+
const baseURL = provider.defaultBaseUrl
|
|
54
|
+
switch (provider.adapterKind) {
|
|
55
|
+
case 'openai':
|
|
56
|
+
// create*Chat 形式把 apiKey 作独立参数(keyedAdapter 工厂约定);模型 id
|
|
57
|
+
// 越出官方清单(自定义条目)用 as never——运行时按字符串构建 client
|
|
58
|
+
return keyedAdapter(provider.providerId, (key): AnyTextAdapter =>
|
|
59
|
+
createOpenaiChat(modelId as never, key) as unknown as AnyTextAdapter,
|
|
60
|
+
)
|
|
61
|
+
case 'openai-compatible':
|
|
62
|
+
case 'groq':
|
|
63
|
+
case 'grok':
|
|
64
|
+
case 'mistral':
|
|
65
|
+
case 'byteplus':
|
|
66
|
+
case 'ollama':
|
|
67
|
+
// OpenAI 兼容端点(SenseNova/DeepSeek/Groq/Grok/Mistral…):chat-completions
|
|
68
|
+
// API + 各自 defaultBaseUrl。baseURL 缺失的条目不进目录(无法寻址)。
|
|
69
|
+
if (!baseURL) return null
|
|
70
|
+
return keyedAdapter(provider.providerId, (key): AnyTextAdapter =>
|
|
71
|
+
openaiCompatibleText(modelId as never, {
|
|
72
|
+
baseURL,
|
|
73
|
+
apiKey: key,
|
|
74
|
+
api: 'chat-completions',
|
|
75
|
+
}) as unknown as AnyTextAdapter,
|
|
76
|
+
)
|
|
77
|
+
case 'anthropic':
|
|
78
|
+
return keyedAdapter(provider.providerId, (key): AnyTextAdapter =>
|
|
79
|
+
createAnthropicChat(modelId as never, key) as unknown as AnyTextAdapter,
|
|
80
|
+
)
|
|
81
|
+
case 'openrouter':
|
|
82
|
+
// OpenRouter 模型名自带 provider/ 前缀
|
|
83
|
+
return keyedAdapter(provider.providerId, (key): AnyTextAdapter =>
|
|
84
|
+
createOpenRouterText(modelId as never, key, { appTitle: 'AllBlue' }) as unknown as AnyTextAdapter,
|
|
85
|
+
)
|
|
86
|
+
default:
|
|
87
|
+
// gemini / bedrock / harness-*:见函数头注释
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
35
92
|
export function buildModelCatalog(): Record<
|
|
36
93
|
string,
|
|
37
94
|
AnyTextAdapter | KeyedAdapter<AnyTextAdapter>
|
|
38
95
|
> {
|
|
39
|
-
|
|
96
|
+
const catalog: Record<string, AnyTextAdapter | KeyedAdapter<AnyTextAdapter>> = {
|
|
40
97
|
default: keyedAdapter('openrouter', (key): AnyTextAdapter =>
|
|
41
98
|
createOpenRouterText(DEFAULT_MODEL as never, key, {
|
|
42
99
|
appTitle: 'AllBlue',
|
|
43
100
|
}) as unknown as AnyTextAdapter,
|
|
44
101
|
),
|
|
45
|
-
// 多 provider 条目示例(key 存在才可用;展开见后续 Phase):
|
|
46
|
-
// 'openai/gpt-5.5': keyedAdapter('openai', (key) => openaiText('gpt-5.5' as never, { apiKey: key })),
|
|
47
|
-
// 'anthropic/claude-sonnet-5-5': keyedAdapter('anthropic', (key) => anthropicText('claude-sonnet-5-5' as never, { apiKey: key })),
|
|
48
102
|
}
|
|
103
|
+
// 平台全目录(kernel 种子):条目即白名单,可用性由「key 存在 + UI 过滤 +
|
|
104
|
+
// updateThreadSettings 校验」三重决定(设计 §5.6)。
|
|
105
|
+
// key 用**裸模型 id**(与工作台 选择模型/availableModels 同域——UI 发裸 id),
|
|
106
|
+
// 另挂 `${providerId}/${modelId}` 别名。裸 id 跨 provider 撞名时先到先得。
|
|
107
|
+
for (const provider of SEED_AI_PROVIDERS) {
|
|
108
|
+
for (const model of provider.models ?? []) {
|
|
109
|
+
const factory = keyedAdapterFactory(provider, model.id)
|
|
110
|
+
if (!factory) continue
|
|
111
|
+
if (!(model.id in catalog)) catalog[model.id] = factory
|
|
112
|
+
const alias = `${provider.providerId}/${model.id}`
|
|
113
|
+
if (!(alias in catalog)) catalog[alias] = factory
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return catalog
|
|
49
117
|
}
|
|
50
118
|
|
|
51
119
|
/** 供 title 插件等使用同一 keyedAdapter 工厂(设计 §5.6:title 同样用 keyed)。 */
|