@ai-wendao/ant 0.5.2 → 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 +82 -27
- package/conversation.js +3 -1
- package/delegation.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -183,19 +183,40 @@ window.__ModuleLoader__.load({
|
|
|
183
183
|
return normalized ? new URL('/console', normalized).toString() : null
|
|
184
184
|
}
|
|
185
185
|
const versionParts = (value) => {
|
|
186
|
-
if (typeof value !== 'string'
|
|
187
|
-
|
|
186
|
+
if (typeof value !== 'string') return null
|
|
187
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-((?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u.exec(value)
|
|
188
|
+
if (!match) return null
|
|
189
|
+
return { core: match.slice(1, 4), prerelease: match[4]?.split('.') ?? null }
|
|
190
|
+
}
|
|
191
|
+
const compareNumericVersionIdentifiers = (left, right) => {
|
|
192
|
+
const normalizedLeft = left.replace(/^0+(?=\d)/u, '')
|
|
193
|
+
const normalizedRight = right.replace(/^0+(?=\d)/u, '')
|
|
194
|
+
if (normalizedLeft.length !== normalizedRight.length) return normalizedLeft.length < normalizedRight.length ? -1 : 1
|
|
195
|
+
return normalizedLeft === normalizedRight ? 0 : normalizedLeft < normalizedRight ? -1 : 1
|
|
188
196
|
}
|
|
189
197
|
const newerVersion = (candidate, current) => {
|
|
190
198
|
const next = versionParts(candidate)
|
|
191
199
|
const installed = versionParts(current)
|
|
192
200
|
if (!next || !installed) return false
|
|
193
|
-
for (let index = 0; index < next.length; index += 1) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
for (let index = 0; index < next.core.length; index += 1) {
|
|
202
|
+
const order = compareNumericVersionIdentifiers(next.core[index], installed.core[index])
|
|
203
|
+
if (order !== 0) return order > 0
|
|
204
|
+
}
|
|
205
|
+
if (!next.prerelease) return Boolean(installed.prerelease)
|
|
206
|
+
if (!installed.prerelease) return false
|
|
207
|
+
for (let index = 0; index < Math.max(next.prerelease.length, installed.prerelease.length); index += 1) {
|
|
208
|
+
const nextIdentifier = next.prerelease[index]
|
|
209
|
+
const installedIdentifier = installed.prerelease[index]
|
|
210
|
+
if (nextIdentifier === undefined) return false
|
|
211
|
+
if (installedIdentifier === undefined) return true
|
|
212
|
+
if (nextIdentifier === installedIdentifier) continue
|
|
213
|
+
const nextIsNumeric = /^\d+$/u.test(nextIdentifier)
|
|
214
|
+
const installedIsNumeric = /^\d+$/u.test(installedIdentifier)
|
|
215
|
+
if (nextIsNumeric && installedIsNumeric) {
|
|
216
|
+
return compareNumericVersionIdentifiers(nextIdentifier, installedIdentifier) > 0
|
|
217
|
+
}
|
|
218
|
+
if (nextIsNumeric !== installedIsNumeric) return !nextIsNumeric
|
|
219
|
+
return nextIdentifier > installedIdentifier
|
|
199
220
|
}
|
|
200
221
|
return false
|
|
201
222
|
}
|
|
@@ -2298,17 +2319,15 @@ window.__ModuleLoader__.load({
|
|
|
2298
2319
|
legacy: true,
|
|
2299
2320
|
}] : []
|
|
2300
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 {}
|
|
2301
2327
|
let excludedGroups = options.excludedGroups
|
|
2328
|
+
if (!Array.isArray(excludedGroups) && savedExcludedGroups) excludedGroups = savedExcludedGroups
|
|
2302
2329
|
if (!Array.isArray(excludedGroups)) {
|
|
2303
|
-
|
|
2304
|
-
const saved = JSON.parse(localStorage.getItem(providerSyncPreferenceKey(normalized)) || 'null')
|
|
2305
|
-
if (Array.isArray(saved)) excludedGroups = saved
|
|
2306
|
-
} catch {}
|
|
2307
|
-
}
|
|
2308
|
-
if (!Array.isArray(excludedGroups)) {
|
|
2309
|
-
// Existing installs keep their current legacy alias group; first-time installs get all routes.
|
|
2310
|
-
excludedGroups = previousRoutes.length && compatibilityRoutes.length
|
|
2311
|
-
&& !compatibilityRoutes.some((route) => previousRoutes.includes(route)) ? ['legacy-openai-chat'] : []
|
|
2330
|
+
excludedGroups = []
|
|
2312
2331
|
}
|
|
2313
2332
|
excludedGroups = [...new Set(excludedGroups.filter((key) => allGroups.some((group) => group.key === key)))]
|
|
2314
2333
|
const excludedGroupSet = new Set(excludedGroups)
|
|
@@ -2325,8 +2344,13 @@ window.__ModuleLoader__.load({
|
|
|
2325
2344
|
const initialDefault = syncedDefaultMatch || (rawDefaultModel == null ? syncedModels[0] : null)
|
|
2326
2345
|
if (Array.isArray(options.excludedGroups)) {
|
|
2327
2346
|
const intentionallyRemovedRoutes = [...excluded].filter((route) => previousRoutes.includes(route))
|
|
2328
|
-
|
|
2329
|
-
|
|
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)) {
|
|
2330
2354
|
throw new Error('已取消同步范围更改;本机 DSH 设置未修改。')
|
|
2331
2355
|
}
|
|
2332
2356
|
const currentSelection = await readDshDefaultSelection()
|
|
@@ -2877,6 +2901,28 @@ window.__ModuleLoader__.load({
|
|
|
2877
2901
|
? isSynced ? '刷新后同步到 DSH' : '刷新后从 DSH 移除'
|
|
2878
2902
|
: isSynced ? '已同步到 DSH' : '未同步到 DSH'))
|
|
2879
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)))
|
|
2880
2926
|
const connectionPanel = h('section', { style: { ...settingsPanelStyle, display: activeTab === 'connection' ? 'grid' : 'none' } },
|
|
2881
2927
|
h('div', null,
|
|
2882
2928
|
h('h3', { style: sectionTitleStyle }, 'ANT 团队账号'),
|
|
@@ -2973,16 +3019,20 @@ window.__ModuleLoader__.load({
|
|
|
2973
3019
|
defaultModelMessage ? h('p', { role: 'status', style: mutedTextStyle }, defaultModelMessage) : null),
|
|
2974
3020
|
providerSyncGroups.length ? h('section', { style: { ...infoNoticeStyle, gap: 8 } },
|
|
2975
3021
|
h('strong', null, '同步到本机 DSH 的 provider'),
|
|
2976
|
-
h('p', { style: mutedTextStyle }, '
|
|
3022
|
+
h('p', { style: mutedTextStyle }, '旧会话兼容路由默认开启。取消勾选并刷新后,该 provider 会从本机 DSH 移除;使用它的历史会话可能暂时无法继续,重新勾选并刷新可恢复。'),
|
|
2977
3023
|
h('p', { style: mutedTextStyle }, '至少保留一个常规模型 provider;旧会话兼容组只供已有会话使用。'),
|
|
2978
3024
|
hasPendingSyncChanges ? h('p', { role: 'status', style: mutedTextStyle }, '同步范围尚未应用;点击“刷新团队模型”后生效。') : null,
|
|
2979
|
-
...providerSyncGroups.map((group) =>
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
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,
|
|
2986
3036
|
h('div', { role: 'list', 'aria-label': '获准模型', style: { display: 'grid', gap: 0, borderTop: '1px solid var(--dsw-alias-border-l2)' } },
|
|
2987
3037
|
modelRows.length ? modelRows : h('div', { style: { display: 'grid', gap: 8, padding: '12px 0' } },
|
|
2988
3038
|
h('p', { style: mutedTextStyle }, credentialConfigured === true && modelMessage.startsWith('正在') ? modelMessage
|
|
@@ -2990,6 +3040,11 @@ window.__ModuleLoader__.load({
|
|
|
2990
3040
|
: '连接并验证工作邮箱后,这里会列出逐个获准模型。'),
|
|
2991
3041
|
credentialConfigured !== true ? h('button', { type: 'button', onClick: () => onSelectTab('connection'),
|
|
2992
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,
|
|
2993
3048
|
h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 10 } },
|
|
2994
3049
|
h('button', { type: 'button', disabled: busy || defaultModelBusy || !bindingReady || credentialConfigured !== true,
|
|
2995
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))
|