@ai-wendao/ant 0.5.3 → 0.5.4
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/client.js +53 -19
- package/conversation.js +3 -1
- package/delegation.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -2319,17 +2319,15 @@ window.__ModuleLoader__.load({
|
|
|
2319
2319
|
legacy: true,
|
|
2320
2320
|
}] : []
|
|
2321
2321
|
const allGroups = [...providerGroups, ...compatibilityGroup]
|
|
2322
|
+
let savedExcludedGroups = null
|
|
2323
|
+
try {
|
|
2324
|
+
const saved = JSON.parse(localStorage.getItem(providerSyncPreferenceKey(normalized)) || 'null')
|
|
2325
|
+
if (Array.isArray(saved)) savedExcludedGroups = saved
|
|
2326
|
+
} catch {}
|
|
2322
2327
|
let excludedGroups = options.excludedGroups
|
|
2328
|
+
if (!Array.isArray(excludedGroups) && savedExcludedGroups) excludedGroups = savedExcludedGroups
|
|
2323
2329
|
if (!Array.isArray(excludedGroups)) {
|
|
2324
|
-
|
|
2325
|
-
const saved = JSON.parse(localStorage.getItem(providerSyncPreferenceKey(normalized)) || 'null')
|
|
2326
|
-
if (Array.isArray(saved)) excludedGroups = saved
|
|
2327
|
-
} catch {}
|
|
2328
|
-
}
|
|
2329
|
-
if (!Array.isArray(excludedGroups)) {
|
|
2330
|
-
// Existing installs keep their current legacy alias group; first-time installs get all routes.
|
|
2331
|
-
excludedGroups = previousRoutes.length && compatibilityRoutes.length
|
|
2332
|
-
&& !compatibilityRoutes.some((route) => previousRoutes.includes(route)) ? ['legacy-openai-chat'] : []
|
|
2330
|
+
excludedGroups = []
|
|
2333
2331
|
}
|
|
2334
2332
|
excludedGroups = [...new Set(excludedGroups.filter((key) => allGroups.some((group) => group.key === key)))]
|
|
2335
2333
|
const excludedGroupSet = new Set(excludedGroups)
|
|
@@ -2346,8 +2344,13 @@ window.__ModuleLoader__.load({
|
|
|
2346
2344
|
const initialDefault = syncedDefaultMatch || (rawDefaultModel == null ? syncedModels[0] : null)
|
|
2347
2345
|
if (Array.isArray(options.excludedGroups)) {
|
|
2348
2346
|
const intentionallyRemovedRoutes = [...excluded].filter((route) => previousRoutes.includes(route))
|
|
2349
|
-
|
|
2350
|
-
|
|
2347
|
+
const disablingLegacyCompatibility = excludedGroupSet.has('legacy-openai-chat')
|
|
2348
|
+
&& !savedExcludedGroups?.includes('legacy-openai-chat')
|
|
2349
|
+
const needsConfirmation = intentionallyRemovedRoutes.length > 0 || disablingLegacyCompatibility
|
|
2350
|
+
const confirmationMessage = disablingLegacyCompatibility
|
|
2351
|
+
? '关闭旧会话兼容会从本机 DSH 移除兼容路由,可能影响历史会话。重新勾选并刷新可恢复。仍要应用吗?'
|
|
2352
|
+
: '关闭这些 provider 会从本机 DSH 移除对应模型路由,可能影响历史会话。重新勾选并刷新可恢复。仍要应用吗?'
|
|
2353
|
+
if (needsConfirmation && !window.confirm(confirmationMessage)) {
|
|
2351
2354
|
throw new Error('已取消同步范围更改;本机 DSH 设置未修改。')
|
|
2352
2355
|
}
|
|
2353
2356
|
const currentSelection = await readDshDefaultSelection()
|
|
@@ -2898,6 +2901,28 @@ window.__ModuleLoader__.load({
|
|
|
2898
2901
|
? isSynced ? '刷新后同步到 DSH' : '刷新后从 DSH 移除'
|
|
2899
2902
|
: isSynced ? '已同步到 DSH' : '未同步到 DSH'))
|
|
2900
2903
|
})
|
|
2904
|
+
const legacyCompatibilityGroup = providerSyncGroups.find((group) => group.legacy)
|
|
2905
|
+
const legacyCompatibilityModels = legacyCompatibilityGroup
|
|
2906
|
+
? authorizedModels.filter((model) => model.protocol === 'openai'
|
|
2907
|
+
&& (model.provider_id || 'openai-default') === 'openai-default') : []
|
|
2908
|
+
const legacyCompatibilityExcluded = legacyCompatibilityGroup
|
|
2909
|
+
? excludedGroupSet.has(legacyCompatibilityGroup.key) : true
|
|
2910
|
+
const legacyCompatibilityAppliedExcluded = legacyCompatibilityGroup
|
|
2911
|
+
? appliedExcludedGroupSet.has(legacyCompatibilityGroup.key) : true
|
|
2912
|
+
const legacyCompatibilityStatus = legacyCompatibilityExcluded === legacyCompatibilityAppliedExcluded
|
|
2913
|
+
? legacyCompatibilityExcluded ? '未同步到 DSH' : '已同步到 DSH'
|
|
2914
|
+
: legacyCompatibilityExcluded ? '刷新后从 DSH 移除' : '刷新后同步到 DSH'
|
|
2915
|
+
const legacyCompatibilityRows = legacyCompatibilityModels.map((model) => h('div', {
|
|
2916
|
+
key: `legacy-openai-chat:${model.provider_id || ''}:${model.model_id}`, role: 'listitem',
|
|
2917
|
+
style: { display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(120px, auto) minmax(130px, auto)',
|
|
2918
|
+
gap: 12, alignItems: 'center', padding: '10px 2px', borderBottom: '1px solid var(--dsw-alias-border-l2)' },
|
|
2919
|
+
},
|
|
2920
|
+
h('strong', { style: { minWidth: 0, overflowWrap: 'anywhere' } },
|
|
2921
|
+
`${model.display_name || model.model_id}(旧会话兼容)`),
|
|
2922
|
+
h('span', { style: { display: 'inline-flex', justifySelf: 'start', padding: '3px 8px', borderRadius: 999,
|
|
2923
|
+
backgroundColor: 'var(--dsw-alias-bg-layer-2)', color: 'var(--dsw-alias-label-secondary)', fontSize: 12 } },
|
|
2924
|
+
'OpenAI · Chat(旧会话兼容)'),
|
|
2925
|
+
h('span', { style: { ...mutedTextStyle, textAlign: 'right' } }, legacyCompatibilityStatus)))
|
|
2901
2926
|
const connectionPanel = h('section', { style: { ...settingsPanelStyle, display: activeTab === 'connection' ? 'grid' : 'none' } },
|
|
2902
2927
|
h('div', null,
|
|
2903
2928
|
h('h3', { style: sectionTitleStyle }, 'ANT 团队账号'),
|
|
@@ -2994,16 +3019,20 @@ window.__ModuleLoader__.load({
|
|
|
2994
3019
|
defaultModelMessage ? h('p', { role: 'status', style: mutedTextStyle }, defaultModelMessage) : null),
|
|
2995
3020
|
providerSyncGroups.length ? h('section', { style: { ...infoNoticeStyle, gap: 8 } },
|
|
2996
3021
|
h('strong', null, '同步到本机 DSH 的 provider'),
|
|
2997
|
-
h('p', { style: mutedTextStyle }, '
|
|
3022
|
+
h('p', { style: mutedTextStyle }, '旧会话兼容路由默认开启。取消勾选并刷新后,该 provider 会从本机 DSH 移除;使用它的历史会话可能暂时无法继续,重新勾选并刷新可恢复。'),
|
|
2998
3023
|
h('p', { style: mutedTextStyle }, '至少保留一个常规模型 provider;旧会话兼容组只供已有会话使用。'),
|
|
2999
3024
|
hasPendingSyncChanges ? h('p', { role: 'status', style: mutedTextStyle }, '同步范围尚未应用;点击“刷新团队模型”后生效。') : null,
|
|
3000
|
-
...providerSyncGroups.map((group) =>
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3025
|
+
...providerSyncGroups.map((group) => {
|
|
3026
|
+
const label = group.legacy
|
|
3027
|
+
? group.label.replace('(旧会话兼容)', '(旧会话兼容,可选)') : group.label
|
|
3028
|
+
return h('label', { key: group.key,
|
|
3029
|
+
style: { display: 'flex', alignItems: 'center', gap: 9, padding: '5px 0', cursor: busy ? 'default' : 'pointer' } },
|
|
3030
|
+
h('input', { type: 'checkbox', 'aria-label': label,
|
|
3031
|
+
checked: !excludedGroupSet.has(group.key), disabled: busy
|
|
3032
|
+
|| (!group.legacy && !excludedGroupSet.has(group.key) && activePrimaryGroupCount <= 1),
|
|
3033
|
+
onChange: (event) => toggleProviderSyncGroup(group, event.target.checked) }),
|
|
3034
|
+
h('span', null, `${label} · ${group.modelCount} 个模型`))
|
|
3035
|
+
})) : null,
|
|
3007
3036
|
h('div', { role: 'list', 'aria-label': '获准模型', style: { display: 'grid', gap: 0, borderTop: '1px solid var(--dsw-alias-border-l2)' } },
|
|
3008
3037
|
modelRows.length ? modelRows : h('div', { style: { display: 'grid', gap: 8, padding: '12px 0' } },
|
|
3009
3038
|
h('p', { style: mutedTextStyle }, credentialConfigured === true && modelMessage.startsWith('正在') ? modelMessage
|
|
@@ -3011,6 +3040,11 @@ window.__ModuleLoader__.load({
|
|
|
3011
3040
|
: '连接并验证工作邮箱后,这里会列出逐个获准模型。'),
|
|
3012
3041
|
credentialConfigured !== true ? h('button', { type: 'button', onClick: () => onSelectTab('connection'),
|
|
3013
3042
|
style: secondaryButtonStyle }, '前往团队连接') : null)),
|
|
3043
|
+
legacyCompatibilityGroup ? h('section', { style: { ...infoNoticeStyle, gap: 6, marginTop: 14 } },
|
|
3044
|
+
h('strong', null, `旧会话兼容路由 · ${legacyCompatibilityModels.length} 个模型`),
|
|
3045
|
+
h('p', { style: mutedTextStyle }, '复用已获准的 OpenAI 模型,仅供已有会话使用,不增加获准模型数量。'),
|
|
3046
|
+
h('div', { role: 'list', 'aria-label': '旧会话兼容模型',
|
|
3047
|
+
style: { display: 'grid', gap: 0, borderTop: '1px solid var(--dsw-alias-border-l2)' } }, legacyCompatibilityRows)) : null,
|
|
3014
3048
|
h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 10 } },
|
|
3015
3049
|
h('button', { type: 'button', disabled: busy || defaultModelBusy || !bindingReady || credentialConfigured !== true,
|
|
3016
3050
|
onClick: () => void refreshModels(true), style: primaryButtonStyle }, busy ? '刷新中…' : '刷新团队模型'),
|
package/conversation.js
CHANGED
|
@@ -224,7 +224,9 @@ function dshDefaultSelection(ctx) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
export async function modelFor(ctx, memberJson, connection) {
|
|
227
|
-
const catalog = await memberJson(connection, '/api/me/models'
|
|
227
|
+
const catalog = await memberJson(connection, '/api/me/models', {
|
|
228
|
+
headers: { 'x-ant-model-provider-config': '1' },
|
|
229
|
+
})
|
|
228
230
|
const models = catalog.models?.filter((item) => ['openai', 'anthropic'].includes(item.protocol)) || []
|
|
229
231
|
const selection = dshDefaultSelection(ctx)
|
|
230
232
|
const localDefault = selection && models.find((item) => item.model_id === selection.model
|
package/delegation.js
CHANGED
|
@@ -1035,7 +1035,7 @@ function parseGroupPrRequest(text) {
|
|
|
1035
1035
|
export async function memberJson(connection, path, init = {}) {
|
|
1036
1036
|
const response = await fetch(new URL(path, connection.serviceUrl), {
|
|
1037
1037
|
...init,
|
|
1038
|
-
headers: { authorization: `Bearer ${connection.token}`, accept: 'application/json',
|
|
1038
|
+
headers: { ...(init.headers || {}), authorization: `Bearer ${connection.token}`, accept: 'application/json',
|
|
1039
1039
|
...(init.body ? { origin: new URL(connection.serviceUrl).origin, 'content-type': 'application/json' } : {}) },
|
|
1040
1040
|
redirect: 'manual', signal: init.signal
|
|
1041
1041
|
? AbortSignal.any([init.signal, AbortSignal.timeout(12_000)]) : AbortSignal.timeout(12_000),
|
package/index.js
CHANGED
|
@@ -1104,7 +1104,7 @@ export function apply(ctx) {
|
|
|
1104
1104
|
} catch {}
|
|
1105
1105
|
}
|
|
1106
1106
|
}, 'ant-teams: ANT model activity session')
|
|
1107
|
-
connectionCtx.inject?.(['dshIm', 'sessionController', 'sessions', 'agents', 'tools'], (delegationCtx) => {
|
|
1107
|
+
connectionCtx.inject?.(['dshIm', 'sessionController', 'sessions', 'agents', 'tools', 'agentDefaultModel'], (delegationCtx) => {
|
|
1108
1108
|
delegationCtx.effect(() => {
|
|
1109
1109
|
const host = startDelegationHost(delegationCtx,
|
|
1110
1110
|
() => readMemberConnection(delegationCtx.credentials, delegationCtx.settings))
|