dsh-volcengine-provider 0.2.0 → 0.2.2
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/README.md +4 -4
- package/docs/arkcli-contract.md +4 -0
- package/docs/changelog.md +20 -0
- package/docs/client-journey-preview-empty.png +0 -0
- package/docs/client-journey-preview-mobile.png +0 -0
- package/docs/client-journey-preview.png +0 -0
- package/docs/client-preview-mobile.png +0 -0
- package/docs/client-preview.png +0 -0
- package/docs/development.md +1 -1
- package/docs/usage.md +19 -13
- package/docs/validation.md +33 -4
- package/lib/catalog.mjs +18 -5
- package/lib/client.js +343 -123
- package/lib/index.mjs +7 -0
- package/lib/manager.mjs +84 -21
- package/lib/oauth.mjs +4 -4
- package/lib/state.mjs +61 -10
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:'dsh-volcengine-provider',factory:(require
|
|
1
|
+
window.__ModuleLoader__.load({id:'dsh-volcengine-provider',factory:(require)=>{
|
|
2
2
|
'use strict';
|
|
3
3
|
const PLUGIN_NAME = 'dsh-volcengine-provider';
|
|
4
4
|
function wireCodec(type, parse) {
|
|
@@ -39,7 +39,13 @@ const arkRemote = {
|
|
|
39
39
|
|
|
40
40
|
// DSH 的 ModuleLoader 在工厂里注入 require;构建产物即浏览器端 CommonJS 工厂。
|
|
41
41
|
const react = typeof require === "function" ? require("react") : globalThis.React;
|
|
42
|
-
const h = (...
|
|
42
|
+
const h = (type, props, ...children) => {
|
|
43
|
+
// Inline theme styles must not hide the native disabled state.
|
|
44
|
+
const control = ['button', 'input', 'select', 'textarea'].includes(type);
|
|
45
|
+
const visibleProps = control && props?.disabled
|
|
46
|
+
? { ...props, style: { ...props.style, opacity: 0.5, cursor: 'not-allowed' } } : props;
|
|
47
|
+
return react.createElement(type, visibleProps, ...children);
|
|
48
|
+
};
|
|
43
49
|
|
|
44
50
|
// ── 常量 ─────────────────────────────────────────────────────────────────────
|
|
45
51
|
|
|
@@ -68,6 +74,8 @@ const WINDOW_GROUP_LABELS = {
|
|
|
68
74
|
|
|
69
75
|
/** 处于这三个状态时登录流程仍在进行,页面按秒轮询进度。 */
|
|
70
76
|
const LOGIN_ACTIVE_STATES = ['launching', 'waiting', 'verifying'];
|
|
77
|
+
// UI-only sentinel: never sent as an account ID to the host.
|
|
78
|
+
const NEW_LOGIN_ACCOUNT = '__new__';
|
|
71
79
|
|
|
72
80
|
const LOGIN_STATE_LABELS = {
|
|
73
81
|
idle: '尚未开始登录。',
|
|
@@ -85,7 +93,7 @@ const LOGIN_STATE_LABELS = {
|
|
|
85
93
|
* 用 Map 而不是普通对象,避免原型链上的键被误当成白名单。
|
|
86
94
|
*/
|
|
87
95
|
const SAFE_LOGIN_PATHS = new Map([
|
|
88
|
-
['ark.volcengine.com',
|
|
96
|
+
['ark.volcengine.com', /^(?:\/region:cn-beijing)?\/arkcli\/login\/?$/],
|
|
89
97
|
['signin.volcengine.com', /^\/authorize\//]
|
|
90
98
|
]);
|
|
91
99
|
|
|
@@ -162,7 +170,7 @@ const LOGIN_CONFIRM_NOTES = [
|
|
|
162
170
|
'登录会走官方 CLI 的 volc-sso 授权流程,在系统默认浏览器中打开官方登录页;本插件不读取浏览器 Cookie,只接收官方回调的结果。',
|
|
163
171
|
'登录得到的凭据保存在本插件为该账号准备的隔离目录里,不会改变你原有 CLI 的默认身份。',
|
|
164
172
|
'取消登录或删除账号元数据都不会删除已经保存的凭据;需要清理时请自行处理该账号的隔离目录。',
|
|
165
|
-
'
|
|
173
|
+
'OAuth 登录会绑定该账号可用的个人套餐,模型调用与额度查询使用对应套餐的登录身份,无需另外填写 AK/SK。'
|
|
166
174
|
];
|
|
167
175
|
|
|
168
176
|
/** 账号 ID、凭据引用名、Profile 名的取值规则(与 Host 端 state.mjs 保持一致)。 */
|
|
@@ -215,7 +223,7 @@ const style = {
|
|
|
215
223
|
color: 'var(--dsw-alias-state-error-primary, #dc2626)',
|
|
216
224
|
cursor: 'pointer', font: 'inherit'
|
|
217
225
|
},
|
|
218
|
-
muted: { fontSize: 12, color: 'var(--dsw-alias-label-secondary, inherit)' },
|
|
226
|
+
muted: { margin: 0, lineHeight: 1.5, fontSize: 12, color: 'var(--dsw-alias-label-secondary, inherit)', overflowWrap: 'anywhere' },
|
|
219
227
|
error: { fontSize: 12, color: 'var(--dsw-alias-state-error-primary, #dc2626)', overflowWrap: 'anywhere' },
|
|
220
228
|
warn: { fontSize: 12, color: 'var(--dsw-alias-state-warn-primary, #b45309)', overflowWrap: 'anywhere' },
|
|
221
229
|
success: { fontSize: 12, color: 'var(--dsw-alias-state-success-primary, #16a34a)', overflowWrap: 'anywhere' },
|
|
@@ -436,6 +444,45 @@ function draftFromAccount(account) {
|
|
|
436
444
|
};
|
|
437
445
|
}
|
|
438
446
|
|
|
447
|
+
// 身份只消费后端给出的安全摘要,不枚举或回显未知字段。
|
|
448
|
+
function accountName(account) {
|
|
449
|
+
return account?.displayName || account?.label || account?.id || '未知账号';
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function isOAuth(account) {
|
|
453
|
+
return ['oauth', 'sso', 'arkcli-oauth', 'arkcli-sso'].includes(account?.authMode);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function planAuth(account, plan) {
|
|
457
|
+
const oauth = isOAuth(account);
|
|
458
|
+
const bound = Boolean(account?.oauthProfiles?.[plan]);
|
|
459
|
+
const inference = oauth ? bound : Boolean(account?.hasApiKeys?.[plan]);
|
|
460
|
+
const quota = typeof account?.hasQuotaAccess?.[plan] === 'boolean'
|
|
461
|
+
? account.hasQuotaAccess[plan]
|
|
462
|
+
: oauth ? bound : Boolean(account?.hasQuotaKeys);
|
|
463
|
+
return { oauth, bound, inference, quota };
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function finiteQuotaNumber(value) {
|
|
467
|
+
if (value === null || value === undefined || value === '' || typeof value === 'boolean') return null;
|
|
468
|
+
const number = Number(value);
|
|
469
|
+
return Number.isFinite(number) ? number : null;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function busyMessage(key) {
|
|
473
|
+
if (!key) return '';
|
|
474
|
+
const [operation, plan, model] = key.split(':');
|
|
475
|
+
const target = PLAN_TITLES[plan] || '';
|
|
476
|
+
const messages = {
|
|
477
|
+
use: `正在为${target}启用所选账号…`, select: `正在切换${target}的账号…`, models: `正在拉取${target}的模型目录…`,
|
|
478
|
+
quota: `正在查询${target}的额度…`, provider: `正在更新${target}的启用状态…`,
|
|
479
|
+
model: `正在更新模型 ${model} 的启用状态…`, settings: `正在保存模型 ${model} 的参数…`,
|
|
480
|
+
reset: `正在恢复模型 ${model} 的默认参数…`, login: '正在启动官方网页登录…',
|
|
481
|
+
'cancel-login': '正在取消登录…', save: '正在保存账号…', delete: '正在删除账号…'
|
|
482
|
+
};
|
|
483
|
+
return messages[operation] || '正在处理…';
|
|
484
|
+
}
|
|
485
|
+
|
|
439
486
|
// ── 模型管理(客户端侧校验与载荷组装) ────────────────────────────────────────
|
|
440
487
|
|
|
441
488
|
/**
|
|
@@ -546,11 +593,8 @@ function modelDraftFrom(model) {
|
|
|
546
593
|
* @returns {unknown} 档位映射、false 或 undefined
|
|
547
594
|
*/
|
|
548
595
|
function inheritedEfforts(model) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const defaults = model?.defaults?.reasoningEfforts;
|
|
552
|
-
if (defaults !== undefined) return defaults;
|
|
553
|
-
return undefined;
|
|
596
|
+
// Inheriting removes saved overrides: the effective object still contains those overrides.
|
|
597
|
+
return model?.defaults?.reasoningEfforts;
|
|
554
598
|
}
|
|
555
599
|
|
|
556
600
|
/**
|
|
@@ -575,7 +619,7 @@ function draftTiers(draft, model) {
|
|
|
575
619
|
}
|
|
576
620
|
const inherited = inheritedEfforts(model);
|
|
577
621
|
if (inherited && typeof inherited === 'object') return Object.keys(inherited);
|
|
578
|
-
return [
|
|
622
|
+
return [];
|
|
579
623
|
}
|
|
580
624
|
|
|
581
625
|
/**
|
|
@@ -690,20 +734,20 @@ function parseModelSettings(draft, model) {
|
|
|
690
734
|
function windowSummary(window) {
|
|
691
735
|
const parts = [];
|
|
692
736
|
let tone = 'muted';
|
|
693
|
-
const used =
|
|
694
|
-
if (
|
|
695
|
-
const remaining = Math.max(0, 100 - used);
|
|
737
|
+
const used = finiteQuotaNumber(window?.percent);
|
|
738
|
+
if (used !== null) {
|
|
739
|
+
const remaining = Math.max(0, Math.min(100, 100 - used));
|
|
696
740
|
parts.push(`剩余 ${formatPercent(remaining)}%`);
|
|
697
741
|
if (remaining <= 0) tone = 'error';
|
|
698
742
|
else if (remaining <= 10) tone = 'warn';
|
|
699
743
|
}
|
|
700
744
|
const detail = window?.detail;
|
|
701
|
-
if (detail &&
|
|
745
|
+
if (detail && finiteQuotaNumber(detail.used) !== null && finiteQuotaNumber(detail.limit) !== null) {
|
|
702
746
|
parts.push(`已用 ${detail.used} / ${detail.limit} ${detail.unit ?? ''}`.trim());
|
|
703
747
|
}
|
|
704
748
|
if (window?.resetsAt) parts.push(`重置于 ${formatTime(window.resetsAt)}`);
|
|
705
749
|
if (detail?.scope) parts.push(`范围 ${detail.scope}`);
|
|
706
|
-
return { text: parts.join(' · '), tone };
|
|
750
|
+
return { text: parts.join(' · ') || '额度数据暂不可用', tone };
|
|
707
751
|
}
|
|
708
752
|
|
|
709
753
|
/**
|
|
@@ -713,7 +757,7 @@ function windowSummary(window) {
|
|
|
713
757
|
* @returns {object} 元素树
|
|
714
758
|
*/
|
|
715
759
|
function QuotaWindows({ quota }) {
|
|
716
|
-
if (!quota) return h('p', { style: style.muted }, '
|
|
760
|
+
if (!quota) return h('p', { style: style.muted }, '尚未查询额度,点击「刷新额度」获取当前账号的数据。');
|
|
717
761
|
if (quota.state === 'no-key') {
|
|
718
762
|
// no-key 有两种成因:OAuth 账号没绑定该套餐,或引用名账号缺 AK/SK。
|
|
719
763
|
// 先显示后端给的原因,再补一条网页登录的出路。
|
|
@@ -741,9 +785,17 @@ function QuotaWindows({ quota }) {
|
|
|
741
785
|
group.label ? h('div', { style: { fontSize: 12, fontWeight: 600 } }, group.label) : null,
|
|
742
786
|
group.windows.map((item, position) => {
|
|
743
787
|
const summary = windowSummary(item);
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
788
|
+
const percent = finiteQuotaNumber(item?.percent);
|
|
789
|
+
const label = WINDOW_KIND_LABELS[item?.kind] ?? item?.kind ?? '窗口';
|
|
790
|
+
return h('div', { key: `${item?.kind ?? 'w'}-${position}`, style: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12 } },
|
|
791
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 12 } },
|
|
792
|
+
h('span', { style: { flexShrink: 0, whiteSpace: 'nowrap' } }, label),
|
|
793
|
+
h('span', { style: { textAlign: 'right', minWidth: 0, ...style[summary.tone] } }, summary.text)),
|
|
794
|
+
percent !== null ? h('progress', {
|
|
795
|
+
max: 100, value: Math.max(0, Math.min(100, 100 - percent)),
|
|
796
|
+
'aria-label': `${label}剩余额度`, 'aria-valuetext': `剩余 ${formatPercent(Math.max(0, Math.min(100, 100 - percent)))}%`,
|
|
797
|
+
style: { width: '100%', height: 8, accentColor: summary.tone === 'error' ? 'var(--dsw-alias-state-error-primary, #dc2626)' : summary.tone === 'warn' ? 'var(--dsw-alias-state-warn-primary, #b45309)' : 'var(--dsw-alias-brand-primary, #3b82f6)' }
|
|
798
|
+
}) : null);
|
|
747
799
|
})
|
|
748
800
|
))
|
|
749
801
|
);
|
|
@@ -832,7 +884,7 @@ function ModelSettingsEditor({ model, draft, error, disabled, onChange, onSave,
|
|
|
832
884
|
* @param {object} props 组件属性
|
|
833
885
|
* @returns {object} 元素树
|
|
834
886
|
*/
|
|
835
|
-
function ModelRow({ model, disabled, editor, draftError, onToggle, onOpenEditor, onCloseEditor, onChangeDraft, onSave, onReset }) {
|
|
887
|
+
function ModelRow({ model, disabled, routingError, editor, draftError, onToggle, onOpenEditor, onCloseEditor, onChangeDraft, onSave, onReset }) {
|
|
836
888
|
const enabled = model?.enabled !== false;
|
|
837
889
|
const editing = editor?.modelId === model?.id;
|
|
838
890
|
const effective = describeEffective(model);
|
|
@@ -848,9 +900,9 @@ function ModelRow({ model, disabled, editor, draftError, onToggle, onOpenEditor,
|
|
|
848
900
|
model?.capabilityUnverified ? h('span', { style: style.chip }, '能力未核实') : null,
|
|
849
901
|
enabled ? null : h('span', { style: style.chip }, '已停用'),
|
|
850
902
|
h('button', { type: 'button', style: style.btn, disabled, 'aria-label': `模型参数 ${model?.id ?? ''}`, onClick: () => (editing ? onCloseEditor() : onOpenEditor(model)) }, editing ? '收起参数' : '参数'),
|
|
851
|
-
h('button', { type: 'button', style: style.btn, disabled, 'aria-label': `恢复默认 ${model?.id ?? ''}`, onClick: () => onReset(model) }, '恢复默认')),
|
|
903
|
+
h('button', { type: 'button', style: style.btn, disabled, 'aria-label': `恢复默认 ${model?.id ?? ''}`, title: '清除全部参数覆盖并恢复模型启用状态', onClick: () => onReset(model) }, enabled ? '恢复默认' : '恢复默认并启用')),
|
|
852
904
|
h('p', { style: style.muted }, `当前参数:${describeModelSettings(model)}`),
|
|
853
|
-
effective ? h('p', { style: style.muted },
|
|
905
|
+
effective ? h('p', { style: routingError ? style.warn : style.muted }, `${routingError ? '已保存配置(路由尚未生效)' : '生效值'}:${effective}`) : null,
|
|
854
906
|
editing
|
|
855
907
|
? h(ModelSettingsEditor, {
|
|
856
908
|
model, draft: editor.draft, error: draftError, disabled,
|
|
@@ -869,18 +921,19 @@ function ModelRow({ model, disabled, editor, draftError, onToggle, onOpenEditor,
|
|
|
869
921
|
* @param {object} props 组件属性
|
|
870
922
|
* @returns {object} 元素树
|
|
871
923
|
*/
|
|
872
|
-
function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota, onToggleProvider, onToggleModel, onSaveModelSettings, onResetModelSettings }) {
|
|
924
|
+
function PlanCard({ plan, snapshot, rawQuota, busy, quotaBusy, onSelect, onModels, onQuota, onToggleProvider, onToggleModel, onSaveModelSettings, onResetModelSettings }) {
|
|
873
925
|
const accounts = Array.isArray(snapshot?.accounts) ? snapshot.accounts : [];
|
|
874
926
|
const activeId = snapshot?.active?.[plan] ?? null;
|
|
875
927
|
const account = accounts.find((item) => item?.id === activeId) ?? null;
|
|
876
928
|
const catalog = (Array.isArray(snapshot?.catalogs) ? snapshot.catalogs : [])
|
|
877
929
|
.find((item) => item?.plan === plan && item?.accountId === activeId) ?? null;
|
|
878
930
|
const route = snapshot?.routes?.[plan] ?? null;
|
|
931
|
+
const appliedAccount = snapshot?.appliedAccounts?.[plan];
|
|
879
932
|
// 额度是按账号查的:账号换了就不要再展示上一个账号的窗口。
|
|
880
933
|
const quota = rawQuota && rawQuota.accountId === activeId ? rawQuota : null;
|
|
881
934
|
const disabled = busy !== null;
|
|
882
|
-
const
|
|
883
|
-
const
|
|
935
|
+
const auth = planAuth(account, plan);
|
|
936
|
+
const canPullModels = Boolean(account && (auth.oauth ? auth.bound : account.cliProfile));
|
|
884
937
|
// 旧快照没有 enabled 字段时按启用处理。
|
|
885
938
|
const providerEnabled = providerEnabledOf(snapshot, plan);
|
|
886
939
|
// 旧快照的目录没有 models 明细:安全地当作「没有列表」展示。
|
|
@@ -890,9 +943,16 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
890
943
|
: models.filter((item) => item?.enabled !== false).length;
|
|
891
944
|
|
|
892
945
|
// 参数编辑状态:同一时刻只展开一个模型,避免把卡片撑得过长。
|
|
893
|
-
const [
|
|
946
|
+
const [storedEditor, setEditor] = react.useState(null);
|
|
894
947
|
const [modelsOpen, setModelsOpen] = react.useState(false);
|
|
895
948
|
const [draftError, setDraftError] = react.useState(null);
|
|
949
|
+
// 渲染与提交时立即隔离旧账号草稿,effect 再清掉本地状态。
|
|
950
|
+
const editor = storedEditor?.accountId === activeId ? storedEditor : null;
|
|
951
|
+
react.useEffect(() => {
|
|
952
|
+
setEditor(null);
|
|
953
|
+
setDraftError(null);
|
|
954
|
+
setModelsOpen(false);
|
|
955
|
+
}, [activeId]);
|
|
896
956
|
|
|
897
957
|
const editedModel = editor ? models.find((item) => item?.id === editor.modelId) ?? null : null;
|
|
898
958
|
const editedSignature = JSON.stringify(editedModel?.settings ?? null);
|
|
@@ -905,10 +965,10 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
905
965
|
if (previous.synced === editedSignature) return previous;
|
|
906
966
|
return { ...previous, draft: modelDraftFrom(editedModel), synced: editedSignature };
|
|
907
967
|
});
|
|
908
|
-
}, [editor?.modelId, editedSignature]);
|
|
968
|
+
}, [editor?.modelId, editedModel, editedSignature]);
|
|
909
969
|
|
|
910
970
|
const openEditor = (model) => {
|
|
911
|
-
setEditor({ modelId: model.id, draft: modelDraftFrom(model), synced: JSON.stringify(model?.settings ?? null) });
|
|
971
|
+
setEditor({ accountId: activeId, modelId: model.id, draft: modelDraftFrom(model), synced: JSON.stringify(model?.settings ?? null) });
|
|
912
972
|
setDraftError(null);
|
|
913
973
|
};
|
|
914
974
|
|
|
@@ -918,7 +978,14 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
918
978
|
};
|
|
919
979
|
|
|
920
980
|
const changeDraft = (patch) => {
|
|
921
|
-
setEditor((previous) =>
|
|
981
|
+
setEditor((previous) => {
|
|
982
|
+
if (!previous) return previous;
|
|
983
|
+
const draft = { ...previous.draft, ...patch };
|
|
984
|
+
if (patch.effortsMode !== undefined && !['inherit', 'none'].includes(draft.defaultReasoning)
|
|
985
|
+
&& !draftTiers(draft, editedModel).includes(draft.defaultReasoning)) draft.defaultReasoning = 'inherit';
|
|
986
|
+
return { ...previous, draft };
|
|
987
|
+
});
|
|
988
|
+
setDraftError(null);
|
|
922
989
|
};
|
|
923
990
|
|
|
924
991
|
// 校验不通过时不发 RPC:只在界面上说明原因。
|
|
@@ -940,7 +1007,10 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
940
1007
|
|
|
941
1008
|
return h('section', { style: style.card },
|
|
942
1009
|
h('h3', { style: style.cardTitle }, PLAN_TITLES[plan]),
|
|
943
|
-
h('p', { style:
|
|
1010
|
+
account ? h('p', { style: { margin: 0, fontSize: 13 } }, `${snapshot?.routingError ? '所选账号' : '当前账号'}:${accountName(account)}`) : null,
|
|
1011
|
+
snapshot?.routingError ? h('p', { style: style.warn }, appliedAccount === undefined
|
|
1012
|
+
? '实际生效账号暂不可确认,请排除路由错误后重试。'
|
|
1013
|
+
: appliedAccount ? `实际生效账号:${accountName(appliedAccount)}(${appliedAccount.id}),路由更新尚未完成。` : '该套餐当前没有已生效的模型路由。') : null,
|
|
944
1014
|
h('div', { style: style.row },
|
|
945
1015
|
h('label', { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 13 } },
|
|
946
1016
|
h('input', {
|
|
@@ -950,38 +1020,44 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
950
1020
|
}),
|
|
951
1021
|
h('span', null, '启用该套餐')),
|
|
952
1022
|
providerEnabled
|
|
953
|
-
? h('span', { style: style.chip }, '套餐已启用')
|
|
1023
|
+
? h('span', { style: style.chip }, !account ? '待选择账号' : !auth.inference ? '待完成鉴权' : '套餐已启用')
|
|
954
1024
|
: h('span', { style: style.chip }, '已停用:不注册模型路由(账号选择与模型参数保留)')),
|
|
955
1025
|
h('div', { style: style.row },
|
|
956
1026
|
h('label', { style: style.label }, '使用账号'),
|
|
957
1027
|
h('select', {
|
|
958
1028
|
style: { ...style.input, width: 'auto', minWidth: 160 },
|
|
959
1029
|
value: activeId ?? '',
|
|
1030
|
+
'aria-label': `${PLAN_TITLES[plan]}使用账号`,
|
|
960
1031
|
disabled: disabled,
|
|
961
1032
|
onChange: (event) => onSelect(plan, event.target.value || null)
|
|
962
1033
|
},
|
|
963
1034
|
h('option', { value: '' }, '未选择'),
|
|
964
|
-
accounts.map((item) => h('option', { key: item.id, value: item.id }, `${item.label}(${item.id})`)))),
|
|
965
|
-
h('div', { style: style.row },
|
|
966
|
-
h('button', { type: 'button', style: style.btn, disabled: disabled || !activeId, onClick: () => onModels(plan) }, '拉取模型'),
|
|
967
|
-
h('button', { type: 'button', style: style.btn, disabled: disabled || !activeId, onClick: () => onQuota(plan) }, '刷新额度')),
|
|
1035
|
+
accounts.map((item) => h('option', { key: item.id, value: item.id }, `${accountName(item)}${item.label && item.label !== accountName(item) ? ` · 备注:${item.label}` : ''}(${item.id})`)))),
|
|
968
1036
|
h('div', { style: style.row },
|
|
969
|
-
h('
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1037
|
+
h('button', { type: 'button', style: style.btn, disabled: disabled || !canPullModels, onClick: () => onModels(plan) }, busy === `models:${plan}` ? '正在拉取模型…' : '拉取模型'),
|
|
1038
|
+
h('button', { type: 'button', style: style.btn, disabled: disabled || quotaBusy || !auth.quota, onClick: () => onQuota(plan) }, quotaBusy ? '正在刷新额度…' : quota?.state === 'error' ? '重试额度查询' : '刷新额度')),
|
|
1039
|
+
account ? h('div', { style: style.row },
|
|
1040
|
+
h('span', { style: style.chip }, `鉴权来源:${auth.oauth ? '官方网页登录(OAuth)' : '凭据引用'}`),
|
|
1041
|
+
h('span', { style: style.chip }, auth.oauth ? `套餐绑定:${auth.bound ? '已绑定' : '未绑定'}` : `推理凭据:${auth.inference ? '已配置' : '未配置'}`),
|
|
1042
|
+
h('span', { style: style.chip }, `额度鉴权:${auth.oauth ? (auth.quota ? 'OAuth 已就绪' : 'OAuth 未就绪') : auth.quota ? 'AK/SK 已配置' : '未配置'}`)) : null,
|
|
1043
|
+
!account ? h('p', { style: style.muted }, '该套餐尚未选择账号,请选择已登录的账号。') : null,
|
|
1044
|
+
account && auth.oauth && !auth.bound
|
|
1045
|
+
? h('p', { style: style.warn }, '此账号尚未绑定该套餐,暂不能拉取模型或查询额度。请先确认已订阅此个人套餐,再到上方账号区重新网页登录更新绑定。')
|
|
976
1046
|
: null,
|
|
977
|
-
account && !
|
|
978
|
-
? h('p', { style: style.
|
|
979
|
-
|
|
980
|
-
|
|
1047
|
+
account && !auth.oauth && !canPullModels
|
|
1048
|
+
? h('p', { style: style.muted }, '当前可使用本地模型快照;远端目录需要官方网页登录或该账号隔离目录内的 CLI Profile,配置前无法拉取。') : null,
|
|
1049
|
+
account && !auth.oauth && !auth.inference
|
|
1050
|
+
? h('p', { style: style.warn }, '该账号尚未配置此套餐的推理凭据,请在账号高级配置中填写引用名,或使用网页登录。')
|
|
981
1051
|
: null,
|
|
982
|
-
|
|
983
|
-
? h('p', { style: style.
|
|
984
|
-
:
|
|
1052
|
+
account && !auth.quota && (!auth.oauth || auth.bound)
|
|
1053
|
+
? h('p', { style: style.warn }, auth.oauth ? '该套餐的登录身份暂不可查询额度,请重新登录后重试。' : '该账号缺少 AK/SK 凭据引用,额度窗口无法查询。')
|
|
1054
|
+
: null,
|
|
1055
|
+
h('details', null,
|
|
1056
|
+
h('summary', { style: style.muted }, '套餐高级信息'),
|
|
1057
|
+
h('p', { style: style.muted }, PLAN_HINTS[plan]),
|
|
1058
|
+
account ? h('p', { style: style.muted }, `本地账号 ID:${account.id}${auth.oauth && auth.bound ? ` · 套餐 Profile:${account.oauthProfiles[plan]}` : ''}`) : null,
|
|
1059
|
+
route ? h('p', { style: style.muted }, `模型路由:${route}`) : null,
|
|
1060
|
+
catalog ? h('p', { style: style.muted }, `模型目录:${catalog.count} 个模型(来源 ${CATALOG_SOURCE_LABELS[catalog.source] ?? catalog.source}${catalog.updatedAt ? `,更新于 ${formatTime(catalog.updatedAt)}` : ''})。`) : null),
|
|
985
1061
|
catalog?.error ? h('p', { role: 'alert', style: style.error }, describeError(catalog.error)) : null,
|
|
986
1062
|
models.length
|
|
987
1063
|
? h('details', { open: modelsOpen },
|
|
@@ -996,7 +1072,7 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
996
1072
|
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8, marginTop: 8 } },
|
|
997
1073
|
models.map((model, index) => h(ModelRow, {
|
|
998
1074
|
key: model?.id ?? `model-${index}`,
|
|
999
|
-
model, disabled, editor, draftError,
|
|
1075
|
+
model, disabled, routingError: snapshot?.routingError, editor, draftError,
|
|
1000
1076
|
onToggle: (item, enabled) => onToggleModel(plan, activeId, item.id, enabled),
|
|
1001
1077
|
onOpenEditor: openEditor,
|
|
1002
1078
|
onCloseEditor: closeEditor,
|
|
@@ -1006,8 +1082,14 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
1006
1082
|
}))))
|
|
1007
1083
|
: h('p', { style: style.muted }, catalog
|
|
1008
1084
|
? '该目录暂无模型明细(旧缓存可能没有模型列表,重新拉取模型后可用)。'
|
|
1009
|
-
: '模型目录:尚未拉取。'),
|
|
1010
|
-
h(
|
|
1085
|
+
: !account ? '选择账号后显示该套餐的模型目录。' : '模型目录:尚未拉取。'),
|
|
1086
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 }, 'aria-busy': Boolean(quotaBusy) },
|
|
1087
|
+
h('h4', { style: { margin: 0, fontSize: 13 } }, '套餐额度'),
|
|
1088
|
+
quotaBusy ? h('p', { role: 'status', style: style.muted }, `正在查询${PLAN_TITLES[plan]}的额度…`) : null,
|
|
1089
|
+
quota?.updatedAt ? h('p', { style: style.muted }, `额度更新时间:${formatTime(quota.updatedAt)}`) : null,
|
|
1090
|
+
!account ? h('p', { style: style.muted }, '请先登录或添加账号,再为此套餐选择账号。')
|
|
1091
|
+
: !quota && !auth.quota ? h('p', { style: style.muted }, '完成此套餐的登录绑定或额度鉴权配置后,即可查询额度。')
|
|
1092
|
+
: h(QuotaWindows, { quota }))
|
|
1011
1093
|
);
|
|
1012
1094
|
}
|
|
1013
1095
|
|
|
@@ -1017,63 +1099,97 @@ function PlanCard({ plan, snapshot, rawQuota, busy, onSelect, onModels, onQuota,
|
|
|
1017
1099
|
* @param {object} props 组件属性
|
|
1018
1100
|
* @returns {object} 元素树
|
|
1019
1101
|
*/
|
|
1020
|
-
function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, busy, onNew, onEdit, onCancelEdit, onChangeDraft, onSave, onRequestDelete, onConfirmDelete, onCancelDelete, onRequestLogin, onConfirmLogin, onCancelLoginConfirm, onCancelLogin }) {
|
|
1102
|
+
function AccountPanel({ snapshot, editor, confirmDelete, loginConfirm, login, busy, onNew, onEdit, onCancelEdit, onChangeDraft, onSave, onRequestDelete, onConfirmDelete, onCancelDelete, onRequestLogin, onConfirmLogin, onCancelLoginConfirm, onCancelLogin, onUsePlan }) {
|
|
1021
1103
|
const accounts = Array.isArray(snapshot?.accounts) ? snapshot.accounts : [];
|
|
1022
1104
|
const disabled = busy !== null;
|
|
1023
1105
|
const loginActive = LOGIN_ACTIVE_STATES.includes(login.state);
|
|
1024
1106
|
const loginUrl = safeLoginUrl(login.url);
|
|
1025
1107
|
// 登录方式挂在账号上(OAuth 绑定 / 凭据引用名),不是整个设置的属性。
|
|
1026
1108
|
const loginAccount = accounts.find((item) => item?.id === login.accountId) ?? null;
|
|
1027
|
-
const authMode = loginAccount?.authMode ??
|
|
1109
|
+
const authMode = loginAccount?.authMode ?? login.authMode ?? null;
|
|
1028
1110
|
|
|
1029
1111
|
return h('section', { style: style.card },
|
|
1030
|
-
h('h3', { style: style.cardTitle }, '
|
|
1031
|
-
h('p', { style: style.muted }, '
|
|
1112
|
+
h('h3', { style: style.cardTitle }, '账号管理'),
|
|
1113
|
+
h('p', { style: style.muted }, '账号以官方登录身份区分,本地备注仅用于帮助识别。每个套餐可独立选择账号。'),
|
|
1032
1114
|
accounts.length
|
|
1033
1115
|
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
1034
1116
|
accounts.map((account) => h('div', { key: account.id, style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px', border: '1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.22))', borderRadius: 'var(--dsw-radius-sm, 6px)' } },
|
|
1035
1117
|
h('div', { style: style.row },
|
|
1036
|
-
h('strong', { style: { fontWeight: 600 } }, account
|
|
1037
|
-
h('span', { style: style.chip }, account.
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
h('
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
h('
|
|
1044
|
-
|
|
1045
|
-
|
|
1118
|
+
h('strong', { style: { fontWeight: 600 } }, accountName(account)),
|
|
1119
|
+
account.authMode ? h('span', { style: style.chip }, `凭据来源:${AUTH_MODE_LABELS[account.authMode] ?? account.authMode}`) : null),
|
|
1120
|
+
account.label ? h('p', { style: style.muted }, `本地备注:${account.label}`) : null,
|
|
1121
|
+
account.identity?.accountId ? h('p', { style: style.muted }, `官方账号 ID:${account.identity.accountId}`) : null,
|
|
1122
|
+
account.identity?.userId ? h('p', { style: style.muted }, `官方用户 ID:${account.identity.userId}`) : null,
|
|
1123
|
+
isOAuth(account) && !account.identity ? h('p', { style: style.muted }, '官方身份摘要暂不可用,完成网页登录后更新。') : null,
|
|
1124
|
+
account.loggedAt ? h('p', { style: style.muted }, `最近登录:${formatTime(account.loggedAt)}`) : null,
|
|
1125
|
+
account.credentialError ? h('p', { role: 'alert', style: style.error }, `凭据状态:${describeError(account.credentialError)}`) : null,
|
|
1126
|
+
h('div', { style: style.row }, PLANS.map((plan) => h('span', { key: plan, style: style.chip },
|
|
1127
|
+
`${plan === 'agent-plan' ? 'Agent' : '编程'}套餐:${snapshot?.active?.[plan] === account.id ? (providerEnabledOf(snapshot, plan) ? '当前使用' : '已选择 · 已停用') : '未选用'}${isOAuth(account) ? ` · ${account.oauthProfiles?.[plan] ? '已绑定' : '未绑定'}` : ''}`))),
|
|
1128
|
+
h('div', { style: style.row }, PLANS.map(plan => {
|
|
1129
|
+
const selected = snapshot?.active?.[plan] === account.id;
|
|
1130
|
+
if (!planAuth(account, plan).inference || (selected && providerEnabledOf(snapshot, plan))) return null;
|
|
1131
|
+
return h('button', { key: plan, type: 'button', style: style.primary, disabled: disabled || loginActive,
|
|
1132
|
+
onClick: () => onUsePlan(plan, account.id) }, `${selected ? '启用' : '用于'} ${plan === 'agent-plan' ? 'Agent' : '编程'}套餐`);
|
|
1133
|
+
})),
|
|
1134
|
+
h('details', null,
|
|
1135
|
+
h('summary', { style: style.muted }, '账号高级配置与标识'),
|
|
1136
|
+
h('p', { style: style.muted }, `本地账号 ID:${account.id}`),
|
|
1137
|
+
isOAuth(account)
|
|
1138
|
+
? PLANS.map((plan) => account.oauthProfiles?.[plan] ? h('p', { key: plan, style: style.muted }, `${plan === 'agent-plan' ? 'Agent' : '编程'}套餐 Profile:${account.oauthProfiles[plan]}`) : null)
|
|
1139
|
+
: h('div', null,
|
|
1140
|
+
h('p', { style: style.muted }, `Agent 套餐推理引用:${account.apiKeyRefs?.['agent-plan'] || '未配置'}`),
|
|
1141
|
+
h('p', { style: style.muted }, `编程套餐推理引用:${account.apiKeyRefs?.['coding-plan'] || '未配置'}`),
|
|
1142
|
+
h('p', { style: style.muted }, `AK 引用:${account.accessKeyRef || '未配置'} · SK 引用:${account.secretKeyRef || '未配置'}`)),
|
|
1143
|
+
account.cliProfile ? h('p', { style: style.muted }, `ArkCli Profile:${account.cliProfile}`) : null),
|
|
1046
1144
|
h('div', { style: style.row },
|
|
1047
1145
|
h('button', { type: 'button', style: style.btn, disabled: disabled || loginActive, onClick: () => onRequestLogin(account.id) }, loginActive ? '登录进行中…' : '网页登录'),
|
|
1048
|
-
h('button', { type: 'button', style: style.btn, disabled: disabled, onClick: () => onEdit(account) }, '编辑'),
|
|
1146
|
+
h('button', { type: 'button', style: style.btn, disabled: disabled || loginActive, onClick: () => onEdit(account) }, '编辑'),
|
|
1049
1147
|
confirmDelete === account.id
|
|
1050
|
-
? h('button', { type: 'button', style: style.danger, disabled: disabled, onClick: () => onConfirmDelete(account.id) }, '确认删除')
|
|
1051
|
-
: h('button', { type: 'button', style: style.btn, disabled: disabled, onClick: () => onRequestDelete(account.id) }, '删除'),
|
|
1148
|
+
? h('button', { type: 'button', style: style.danger, disabled: disabled || loginActive, onClick: () => onConfirmDelete(account.id) }, '确认删除')
|
|
1149
|
+
: h('button', { type: 'button', style: style.btn, disabled: disabled || loginActive, onClick: () => onRequestDelete(account.id) }, '删除'),
|
|
1052
1150
|
confirmDelete === account.id
|
|
1053
1151
|
? h('button', { type: 'button', style: style.btn, disabled: disabled, onClick: onCancelDelete }, '取消')
|
|
1054
1152
|
: null),
|
|
1055
1153
|
loginConfirm === account.id
|
|
1056
1154
|
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px', border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.3))', borderRadius: 'var(--dsw-radius-sm, 6px)' } },
|
|
1057
|
-
h('div', { style: { fontWeight: 600, fontSize: 13 } }, `开始网页登录:${account
|
|
1155
|
+
h('div', { style: { fontWeight: 600, fontSize: 13 } }, `开始网页登录:${accountName(account)}`),
|
|
1058
1156
|
h('ul', { style: { margin: 0, paddingLeft: 18, display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
1059
1157
|
LOGIN_CONFIRM_NOTES.map((note, index) => h('li', { key: index, style: style.muted }, note))),
|
|
1060
1158
|
h('div', { style: style.row },
|
|
1061
1159
|
h('button', { type: 'button', style: style.primary, disabled: disabled, onClick: () => onConfirmLogin(account.id) }, '确认并打开官方登录页'),
|
|
1062
1160
|
h('button', { type: 'button', style: style.btn, disabled: disabled, onClick: onCancelLoginConfirm }, '取消')))
|
|
1063
1161
|
: null)))
|
|
1064
|
-
: h('
|
|
1162
|
+
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
1163
|
+
h('p', { style: style.muted }, '还没有账号。可直接网页登录,确认后会自动创建本地账号,无需填写账号 ID 或密钥引用。'),
|
|
1164
|
+
h('div', { style: style.row },
|
|
1165
|
+
h('button', { type: 'button', style: style.primary, disabled: disabled || loginActive, onClick: () => onRequestLogin(NEW_LOGIN_ACCOUNT) }, '网页登录')),
|
|
1166
|
+
loginConfirm === NEW_LOGIN_ACCOUNT ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
1167
|
+
h('strong', null, '创建账号并开始网页登录'),
|
|
1168
|
+
h('ul', { style: { margin: 0, paddingLeft: 18 } },
|
|
1169
|
+
LOGIN_CONFIRM_NOTES.map((note, index) => h('li', { key: index, style: style.muted }, note))),
|
|
1170
|
+
h('div', { style: style.row },
|
|
1171
|
+
h('button', { type: 'button', style: style.primary, disabled: disabled || loginActive, onClick: () => onConfirmLogin(NEW_LOGIN_ACCOUNT) }, '确认并打开官方登录页'),
|
|
1172
|
+
h('button', { type: 'button', style: style.btn, disabled, onClick: onCancelLoginConfirm }, '取消'))) : null),
|
|
1065
1173
|
h('div', { style: style.row },
|
|
1066
|
-
h('button', { type: 'button', style: style.
|
|
1067
|
-
|
|
1174
|
+
accounts.length ? h('button', { type: 'button', style: style.primary, disabled: disabled || loginActive, onClick: () => onRequestLogin(NEW_LOGIN_ACCOUNT) }, '登录其他账号') : null,
|
|
1175
|
+
h('button', { type: 'button', style: style.btn, disabled: disabled || loginActive || editor !== null, onClick: onNew }, '新增账号')),
|
|
1176
|
+
accounts.length > 0 && loginConfirm === NEW_LOGIN_ACCOUNT ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
1177
|
+
h('strong', null, '创建独立账号并网页登录'),
|
|
1178
|
+
h('p', { style: style.muted }, '使用新的本地账号保存登录结果,不覆盖已有账号或更改当前套餐选择。请在普通浏览器的官方页面确认实际授权身份。'),
|
|
1179
|
+
h('ul', { style: { margin: 0, paddingLeft: 18 } }, LOGIN_CONFIRM_NOTES.map((note, index) => h('li', { key: index, style: style.muted }, note))),
|
|
1180
|
+
h('div', { style: style.row },
|
|
1181
|
+
h('button', { type: 'button', style: style.primary, disabled: disabled || loginActive, onClick: () => onConfirmLogin(NEW_LOGIN_ACCOUNT) }, '确认并打开官方登录页'),
|
|
1182
|
+
h('button', { type: 'button', style: style.btn, disabled, onClick: onCancelLoginConfirm }, '取消'))) : null,
|
|
1183
|
+
editor ? h(AccountForm, { editor, busy: busy ?? (loginActive ? 'login-active' : null), onChangeDraft, onSave, onCancel: onCancelEdit }) : null,
|
|
1068
1184
|
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 6, marginTop: 4 } },
|
|
1069
1185
|
h('div', { style: { fontWeight: 600, fontSize: 13 } }, '网页登录'),
|
|
1070
|
-
loginAccount ? h('p', { style: style.muted }, `当前登录账号:${loginAccount
|
|
1186
|
+
loginAccount ? h('p', { style: style.muted }, `当前登录账号:${accountName(loginAccount)}(${loginAccount.id})`) : null,
|
|
1071
1187
|
authMode ? h('p', { style: style.muted }, `凭据来源:${AUTH_MODE_LABELS[authMode] ?? authMode}`) : null,
|
|
1072
1188
|
h('p', { style: style.muted }, LOGIN_STATE_LABELS[login.state] ?? login.state),
|
|
1073
1189
|
login.message ? h('p', { style: style.muted }, login.message) : null,
|
|
1074
1190
|
loginUrl ? h('a', { href: loginUrl, target: '_blank', rel: 'noopener noreferrer', style: { fontSize: 12, color: 'var(--dsw-alias-link, inherit)' } }, '打开官方授权页面') : null,
|
|
1075
1191
|
loginActive
|
|
1076
|
-
? h('button', { type: 'button', style: style.btn, disabled: disabled || !login.jobId, onClick: onCancelLogin }, '取消登录')
|
|
1192
|
+
? h('button', { type: 'button', style: style.btn, disabled: disabled || !login.jobId, onClick: onCancelLogin }, login.jobId ? '取消登录' : '同步状态后可取消登录')
|
|
1077
1193
|
: null)
|
|
1078
1194
|
);
|
|
1079
1195
|
}
|
|
@@ -1107,8 +1223,12 @@ function AccountForm({ editor, busy, onChangeDraft, onSave, onCancel }) {
|
|
|
1107
1223
|
h('div', { style: { fontWeight: 600, fontSize: 13 } }, editor.mode === 'edit' ? `编辑账号:${editor.id}` : '新增账号'),
|
|
1108
1224
|
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 10 } },
|
|
1109
1225
|
field('账号 ID(小写字母开头)', 'id', 'default'),
|
|
1110
|
-
field('
|
|
1111
|
-
h('
|
|
1226
|
+
field('本地备注', 'label', '例如:个人账号')),
|
|
1227
|
+
h('p', { style: style.muted }, '保存后点击「网页登录」绑定官方账号;使用 OAuth 时无需填写下方的凭据引用。'),
|
|
1228
|
+
h('details', null,
|
|
1229
|
+
h('summary', { style: style.muted }, '高级配置:凭据引用与 CLI Profile'),
|
|
1230
|
+
isOAuth(editor) ? h('p', { style: style.warn }, '此账号当前使用 OAuth,编辑引用不会切换鉴权方式。模型调用与额度查询仍使用已绑定的套餐身份。') : null,
|
|
1231
|
+
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 10 } },
|
|
1112
1232
|
apiKeyField('agent-plan', 'Agent 套餐推理凭据引用名', '例如:ARKCLI_AGENT_PLAN_API_KEY'),
|
|
1113
1233
|
apiKeyField('coding-plan', '编程套餐推理凭据引用名', '例如:ARKCLI_CODING_PLAN_API_KEY')),
|
|
1114
1234
|
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 10 } },
|
|
@@ -1116,7 +1236,7 @@ function AccountForm({ editor, busy, onChangeDraft, onSave, onCancel }) {
|
|
|
1116
1236
|
field('SecretKey 引用名(可选)', 'secretKeyRef', '例如:VOLC_SECRETKEY')),
|
|
1117
1237
|
h('p', { style: style.muted }, 'AK/SK 引用名只用于查询管控面额度;用「网页登录」完成 OAuth 的账号不需要填写这两项。'),
|
|
1118
1238
|
h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 10 } },
|
|
1119
|
-
field('ArkCli Profile(可选)', 'cliProfile', '留空表示不使用')),
|
|
1239
|
+
field('ArkCli Profile(可选)', 'cliProfile', '留空表示不使用'))),
|
|
1120
1240
|
h('div', { style: style.row },
|
|
1121
1241
|
h('button', { type: 'button', style: style.primary, disabled: disabled, onClick: onSave }, busy === 'save' ? '保存中…' : '保存'),
|
|
1122
1242
|
h('button', { type: 'button', style: style.btn, disabled: disabled, onClick: onCancel }, '取消'))
|
|
@@ -1132,9 +1252,12 @@ function AccountForm({ editor, busy, onChangeDraft, onSave, onCancel }) {
|
|
|
1132
1252
|
function VolcengineProviderSection({ client }) {
|
|
1133
1253
|
const [snapshot, setSnapshot] = react.useState(null);
|
|
1134
1254
|
const [loadError, setLoadError] = react.useState(null);
|
|
1255
|
+
const [loading, setLoading] = react.useState(true);
|
|
1135
1256
|
const [busy, setBusy] = react.useState(null);
|
|
1136
1257
|
const [notice, setNotice] = react.useState(null);
|
|
1137
1258
|
const [quotas, setQuotas] = react.useState({});
|
|
1259
|
+
const [quotaBusy, setQuotaBusy] = react.useState({});
|
|
1260
|
+
const quotaPendingRef = react.useRef(new Map());
|
|
1138
1261
|
const [editor, setEditor] = react.useState(null);
|
|
1139
1262
|
const [confirmDelete, setConfirmDelete] = react.useState(null);
|
|
1140
1263
|
const [loginConfirm, setLoginConfirm] = react.useState(null);
|
|
@@ -1143,6 +1266,9 @@ function VolcengineProviderSection({ client }) {
|
|
|
1143
1266
|
const aliveRef = react.useRef(true);
|
|
1144
1267
|
const busyRef = react.useRef(null);
|
|
1145
1268
|
const handledLoginRef = react.useRef(null);
|
|
1269
|
+
const readSequenceRef = react.useRef(0);
|
|
1270
|
+
const quotaEpochRef = react.useRef(0);
|
|
1271
|
+
const accountFingerprintRef = react.useRef(null);
|
|
1146
1272
|
|
|
1147
1273
|
react.useEffect(() => {
|
|
1148
1274
|
aliveRef.current = true;
|
|
@@ -1152,23 +1278,41 @@ function VolcengineProviderSection({ client }) {
|
|
|
1152
1278
|
/** 把一次 read 返回的整份快照落到状态里。 */
|
|
1153
1279
|
const applySnapshot = react.useCallback((value) => {
|
|
1154
1280
|
if (!aliveRef.current || !value) return;
|
|
1281
|
+
// 写操作的新快照使更早发起的 read 失效,避免迟到响应覆盖新状态。
|
|
1282
|
+
readSequenceRef.current += 1;
|
|
1283
|
+
const fingerprint = JSON.stringify({ active: value.active, accounts: (value.accounts ?? []).map(account => ({
|
|
1284
|
+
id: account.id, authMode: account.authMode, loggedAt: account.loggedAt, identity: account.identity,
|
|
1285
|
+
profiles: account.oauthProfiles, apiKeyRefs: account.apiKeyRefs, accessKeyRef: account.accessKeyRef,
|
|
1286
|
+
secretKeyRef: account.secretKeyRef, hasApiKeys: account.hasApiKeys, hasQuotaAccess: account.hasQuotaAccess
|
|
1287
|
+
})) });
|
|
1288
|
+
if (accountFingerprintRef.current !== fingerprint) {
|
|
1289
|
+
accountFingerprintRef.current = fingerprint;
|
|
1290
|
+
quotaEpochRef.current += 1;
|
|
1291
|
+
setQuotaBusy({});
|
|
1292
|
+
setQuotas({});
|
|
1293
|
+
}
|
|
1155
1294
|
setSnapshot(value);
|
|
1295
|
+
setEditor(previous => previous?.mode === 'edit' && !(value.accounts ?? []).some(account => account.id === previous.id) ? null : previous);
|
|
1296
|
+
setLoading(false);
|
|
1156
1297
|
const incoming = value.login ? normalizeLogin(value.login) : null;
|
|
1157
|
-
if (incoming)
|
|
1158
|
-
setLogin((previous) => (previous.jobId === incoming.jobId ? previous : incoming));
|
|
1159
|
-
}
|
|
1298
|
+
if (incoming) setLogin(incoming);
|
|
1160
1299
|
}, []);
|
|
1161
1300
|
|
|
1162
1301
|
/** 重新读取全部状态。 */
|
|
1163
1302
|
const refresh = react.useCallback(async () => {
|
|
1303
|
+
const sequence = ++readSequenceRef.current;
|
|
1304
|
+
setLoading(true);
|
|
1305
|
+
setLoadError(null);
|
|
1164
1306
|
try {
|
|
1165
1307
|
const value = await client.invoke({ op: 'read' });
|
|
1166
|
-
if (!aliveRef.current) return;
|
|
1308
|
+
if (!aliveRef.current || sequence !== readSequenceRef.current) return;
|
|
1167
1309
|
applySnapshot(value);
|
|
1168
|
-
|
|
1310
|
+
setLoading(false);
|
|
1311
|
+
return value;
|
|
1169
1312
|
} catch (error) {
|
|
1170
|
-
if (!aliveRef.current) return;
|
|
1313
|
+
if (!aliveRef.current || sequence !== readSequenceRef.current) return;
|
|
1171
1314
|
setLoadError(describeError(error));
|
|
1315
|
+
setLoading(false);
|
|
1172
1316
|
}
|
|
1173
1317
|
}, [client, applySnapshot]);
|
|
1174
1318
|
|
|
@@ -1194,7 +1338,8 @@ function VolcengineProviderSection({ client }) {
|
|
|
1194
1338
|
await refresh();
|
|
1195
1339
|
return;
|
|
1196
1340
|
}
|
|
1197
|
-
setNotice({ ok: false, text: `${prefix}:${describeError(error)}
|
|
1341
|
+
setNotice({ ok: false, text: `${prefix}:${describeError(error)}。正在重新读取已保存状态,请核对实际生效账号。`, refresh: true });
|
|
1342
|
+
await refresh();
|
|
1198
1343
|
};
|
|
1199
1344
|
|
|
1200
1345
|
const selectAccount = (plan, accountId) => run(`select:${plan}`, async () => {
|
|
@@ -1202,12 +1347,30 @@ function VolcengineProviderSection({ client }) {
|
|
|
1202
1347
|
try {
|
|
1203
1348
|
const value = await client.invoke({ op: 'select', revision: snapshot.revision, plan, accountId });
|
|
1204
1349
|
applySnapshot(value);
|
|
1350
|
+
setQuotas((previous) => ({ ...previous, [plan]: null }));
|
|
1205
1351
|
setNotice({ ok: true, text: `已切换${PLAN_TITLES[plan]}的账号。` });
|
|
1206
1352
|
} catch (error) {
|
|
1207
1353
|
await reportSaveError(error, '切换账号失败');
|
|
1208
1354
|
}
|
|
1209
1355
|
});
|
|
1210
1356
|
|
|
1357
|
+
// Explicit onboarding action: use the verified account and enable only the requested plan.
|
|
1358
|
+
const usePlan = (plan, accountId) => run(`use:${plan}`, async () => {
|
|
1359
|
+
let current = snapshot;
|
|
1360
|
+
if (!current?.revision) return;
|
|
1361
|
+
try {
|
|
1362
|
+
if (current.active?.[plan] !== accountId) {
|
|
1363
|
+
current = await client.invoke({ op: 'select', revision: current.revision, plan, accountId });
|
|
1364
|
+
applySnapshot(current);
|
|
1365
|
+
}
|
|
1366
|
+
if (!providerEnabledOf(current, plan)) {
|
|
1367
|
+
current = await client.invoke({ op: 'setProviderEnabled', revision: current.revision, plan, enabled: true });
|
|
1368
|
+
applySnapshot(current);
|
|
1369
|
+
}
|
|
1370
|
+
setNotice({ ok: true, text: `已为${PLAN_TITLES[plan]}启用此账号,可在套餐卡片查看模型与额度。` });
|
|
1371
|
+
} catch (error) { await reportSaveError(error, '启用套餐失败'); }
|
|
1372
|
+
});
|
|
1373
|
+
|
|
1211
1374
|
const pullModels = (plan) => run(`models:${plan}`, async () => {
|
|
1212
1375
|
const accountId = snapshot?.active?.[plan] ?? null;
|
|
1213
1376
|
if (!snapshot?.revision || !accountId) return;
|
|
@@ -1220,18 +1383,26 @@ function VolcengineProviderSection({ client }) {
|
|
|
1220
1383
|
}
|
|
1221
1384
|
});
|
|
1222
1385
|
|
|
1223
|
-
const pullQuota =
|
|
1386
|
+
const pullQuota = async (plan) => {
|
|
1224
1387
|
const accountId = snapshot?.active?.[plan] ?? null;
|
|
1225
|
-
|
|
1388
|
+
const epoch = quotaEpochRef.current;
|
|
1389
|
+
if (!accountId || quotaPendingRef.current.get(plan) === epoch) return;
|
|
1390
|
+
quotaPendingRef.current.set(plan, epoch);
|
|
1391
|
+
setQuotaBusy(previous => ({ ...previous, [plan]: true }));
|
|
1226
1392
|
try {
|
|
1227
1393
|
const value = await client.invoke({ op: 'quota', plan, accountId, force: true });
|
|
1228
|
-
if (!aliveRef.current) return;
|
|
1394
|
+
if (!aliveRef.current || epoch !== quotaEpochRef.current) return;
|
|
1229
1395
|
setQuotas((previous) => ({ ...previous, [plan]: value }));
|
|
1230
1396
|
} catch (error) {
|
|
1231
|
-
if (!aliveRef.current) return;
|
|
1232
|
-
setQuotas((previous) => ({ ...previous, [plan]: { accountId, plan, state: 'error', windows: [], error: describeError(error) } }));
|
|
1397
|
+
if (!aliveRef.current || epoch !== quotaEpochRef.current) return;
|
|
1398
|
+
setQuotas((previous) => ({ ...previous, [plan]: { accountId, plan, state: 'error', windows: [], error: describeError(error), updatedAt: new Date().toISOString() } }));
|
|
1399
|
+
} finally {
|
|
1400
|
+
if (quotaPendingRef.current.get(plan) === epoch) {
|
|
1401
|
+
quotaPendingRef.current.delete(plan);
|
|
1402
|
+
if (aliveRef.current) setQuotaBusy(previous => ({ ...previous, [plan]: false }));
|
|
1403
|
+
}
|
|
1233
1404
|
}
|
|
1234
|
-
}
|
|
1405
|
+
};
|
|
1235
1406
|
|
|
1236
1407
|
// 套餐启停:只改启用状态,不动账号选择,也不动模型参数。
|
|
1237
1408
|
const toggleProvider = (plan, enabled) => run(`provider:${plan}`, async () => {
|
|
@@ -1275,7 +1446,7 @@ function VolcengineProviderSection({ client }) {
|
|
|
1275
1446
|
try {
|
|
1276
1447
|
const value = await client.invoke({ op: 'resetModelSettings', accountId, plan, modelId, revision: snapshot.revision });
|
|
1277
1448
|
applySnapshot(value);
|
|
1278
|
-
setNotice({ ok: true, text: `模型 ${modelId}
|
|
1449
|
+
setNotice({ ok: true, text: `模型 ${modelId} 的参数与启用状态已恢复目录默认。` });
|
|
1279
1450
|
} catch (error) {
|
|
1280
1451
|
await reportSaveError(error, `恢复模型 ${modelId} 的默认参数失败`);
|
|
1281
1452
|
}
|
|
@@ -1284,11 +1455,31 @@ function VolcengineProviderSection({ client }) {
|
|
|
1284
1455
|
const startLogin = (accountId) => run('login', async () => {
|
|
1285
1456
|
if (!snapshot?.revision) return;
|
|
1286
1457
|
try {
|
|
1287
|
-
|
|
1458
|
+
let revision = snapshot.revision;
|
|
1459
|
+
if (accountId === NEW_LOGIN_ACCOUNT) {
|
|
1460
|
+
const accounts = snapshot.accounts ?? [];
|
|
1461
|
+
let index = 1;
|
|
1462
|
+
while (accounts.some(account => account.id === `account-${index}`)) index++;
|
|
1463
|
+
accountId = `account-${index}`;
|
|
1464
|
+
const saved = await client.invoke({ op: 'saveAccount', revision, account: { id: accountId, label: '方舟账号', apiKeyRefs: {}, accessKeyRef: '', secretKeyRef: '' } });
|
|
1465
|
+
applySnapshot(saved);
|
|
1466
|
+
revision = saved.revision;
|
|
1467
|
+
setEditor(null);
|
|
1468
|
+
}
|
|
1469
|
+
const value = await client.invoke({ op: 'startLogin', revision, accountId });
|
|
1288
1470
|
if (aliveRef.current) setLogin(normalizeLogin(value));
|
|
1289
1471
|
} catch (error) {
|
|
1290
|
-
if (aliveRef.current)
|
|
1291
|
-
|
|
1472
|
+
if (!aliveRef.current) return;
|
|
1473
|
+
const latest = await refresh();
|
|
1474
|
+
if (!latest) {
|
|
1475
|
+
setLogin({ jobId: null, accountId, state: 'launching', message: '启动结果暂无法确认,正在自动同步登录状态;确认前请勿重复登录或修改账号。' });
|
|
1476
|
+
setNotice(null);
|
|
1477
|
+
} else if (LOGIN_ACTIVE_STATES.includes(latest?.login?.state)) {
|
|
1478
|
+
setNotice({ ok: true, text: '检测到登录仍在进行,已恢复进度;请继续官方授权或取消登录。' });
|
|
1479
|
+
} else if (isRevisionConflict(error)) {
|
|
1480
|
+
setNotice({ ok: false, text: '设置已在别处被改动,已刷新;请重新确认登录。', refresh: true });
|
|
1481
|
+
} else {
|
|
1482
|
+
setNotice({ ok: false, text: `启动登录失败:${describeError(error)}。已创建的本地账号会保留,可在该账号上重试。`, refresh: true });
|
|
1292
1483
|
}
|
|
1293
1484
|
}
|
|
1294
1485
|
});
|
|
@@ -1325,6 +1516,9 @@ function VolcengineProviderSection({ client }) {
|
|
|
1325
1516
|
try {
|
|
1326
1517
|
const value = await client.invoke({ op: 'saveAccount', revision: snapshot.revision, account: accountPayload(editor.draft) });
|
|
1327
1518
|
applySnapshot(value);
|
|
1519
|
+
quotaEpochRef.current += 1;
|
|
1520
|
+
setQuotaBusy({});
|
|
1521
|
+
setQuotas({});
|
|
1328
1522
|
setEditor(null);
|
|
1329
1523
|
setNotice({ ok: true, text: '账号已保存。' });
|
|
1330
1524
|
} catch (error) {
|
|
@@ -1336,8 +1530,10 @@ function VolcengineProviderSection({ client }) {
|
|
|
1336
1530
|
try {
|
|
1337
1531
|
const value = await client.invoke({ op: 'removeAccount', revision: snapshot.revision, accountId });
|
|
1338
1532
|
applySnapshot(value);
|
|
1533
|
+
setEditor(previous => previous?.id === accountId ? null : previous);
|
|
1534
|
+
setLoginConfirm(previous => previous === accountId ? null : previous);
|
|
1339
1535
|
setConfirmDelete(null);
|
|
1340
|
-
setNotice({ ok: true, text: '
|
|
1536
|
+
setNotice({ ok: true, text: '账号已删除;官方 CLI 凭据目录仍保留。' });
|
|
1341
1537
|
} catch (error) {
|
|
1342
1538
|
await reportSaveError(error, '删除账号失败');
|
|
1343
1539
|
}
|
|
@@ -1345,32 +1541,46 @@ function VolcengineProviderSection({ client }) {
|
|
|
1345
1541
|
|
|
1346
1542
|
// 登录进行中:每秒轮询一次状态;流程结束即停止轮询。
|
|
1347
1543
|
react.useEffect(() => {
|
|
1348
|
-
if (!LOGIN_ACTIVE_STATES.includes(login.state)
|
|
1544
|
+
if (!LOGIN_ACTIVE_STATES.includes(login.state)) return undefined;
|
|
1349
1545
|
let alive = true;
|
|
1350
1546
|
let timer = null;
|
|
1547
|
+
let failures = 0;
|
|
1351
1548
|
const poll = async () => {
|
|
1352
1549
|
try {
|
|
1353
|
-
|
|
1550
|
+
// If the start response was lost, recover the host job and account snapshot together.
|
|
1551
|
+
const value = await client.invoke({ op: login.jobId ? 'loginStatus' : 'read' });
|
|
1354
1552
|
if (!alive) return;
|
|
1355
|
-
const next = normalizeLogin(value);
|
|
1553
|
+
const next = normalizeLogin(login.jobId ? value : value.login);
|
|
1554
|
+
if (!login.jobId) {
|
|
1555
|
+
applySnapshot(value);
|
|
1556
|
+
if (next.state === 'idle') setNotice({ ok: false, text: '连接已恢复,未检测到进行中的登录,请重新发起。' });
|
|
1557
|
+
}
|
|
1558
|
+
failures = 0;
|
|
1356
1559
|
setLogin(next);
|
|
1357
1560
|
if (LOGIN_ACTIVE_STATES.includes(next.state)) timer = setTimeout(poll, LOGIN_POLL_MS);
|
|
1358
1561
|
} catch (error) {
|
|
1359
1562
|
if (!alive) return;
|
|
1360
|
-
|
|
1563
|
+
// A transport failure does not mean the host login stopped: retain cancellation and the write lock.
|
|
1564
|
+
setLogin((previous) => ({ ...previous, message: `暂时无法查询登录进度:${describeError(error)}。将自动重试,${previous.jobId ? '仍可取消登录' : '同步状态后可取消登录'}。` }));
|
|
1565
|
+
timer = setTimeout(poll, Math.min(10000, ++failures * 2000));
|
|
1361
1566
|
}
|
|
1362
1567
|
};
|
|
1363
1568
|
timer = setTimeout(poll, LOGIN_POLL_MS);
|
|
1364
1569
|
return () => { alive = false; if (timer) clearTimeout(timer); };
|
|
1365
|
-
}, [client, login.jobId, login.state]);
|
|
1570
|
+
}, [client, login.jobId, login.state, applySnapshot]);
|
|
1366
1571
|
|
|
1367
1572
|
// 登录成功后刷新一次整页状态。
|
|
1368
1573
|
react.useEffect(() => {
|
|
1369
1574
|
if (login.state !== 'success') return;
|
|
1370
|
-
|
|
1371
|
-
handledLoginRef.current
|
|
1575
|
+
const identity = `${login.accountId ?? ''}:${login.jobId ?? ''}`;
|
|
1576
|
+
if (handledLoginRef.current === identity) return;
|
|
1577
|
+
handledLoginRef.current = identity;
|
|
1578
|
+
// 同一账号重新登录也可能换了官方身份;失效所有额度及在途旧响应。
|
|
1579
|
+
quotaEpochRef.current += 1;
|
|
1580
|
+
setQuotaBusy({});
|
|
1581
|
+
setQuotas({});
|
|
1372
1582
|
void refresh();
|
|
1373
|
-
}, [login.state, login.jobId, refresh]);
|
|
1583
|
+
}, [login.state, login.accountId, login.jobId, refresh]);
|
|
1374
1584
|
|
|
1375
1585
|
const openNew = () => {
|
|
1376
1586
|
setEditor({ mode: 'new', id: null, draft: emptyDraft() });
|
|
@@ -1378,7 +1588,7 @@ function VolcengineProviderSection({ client }) {
|
|
|
1378
1588
|
};
|
|
1379
1589
|
|
|
1380
1590
|
const openEdit = (account) => {
|
|
1381
|
-
setEditor({ mode: 'edit', id: account.id, draft: draftFromAccount(account) });
|
|
1591
|
+
setEditor({ mode: 'edit', id: account.id, authMode: account.authMode, draft: draftFromAccount(account) });
|
|
1382
1592
|
setNotice(null);
|
|
1383
1593
|
};
|
|
1384
1594
|
|
|
@@ -1392,12 +1602,21 @@ function VolcengineProviderSection({ client }) {
|
|
|
1392
1602
|
};
|
|
1393
1603
|
|
|
1394
1604
|
const busyAccount = busy !== null;
|
|
1605
|
+
const loginActive = LOGIN_ACTIVE_STATES.includes(login.state);
|
|
1606
|
+
const planBusy = busy ?? (loginActive ? 'login-active' : null);
|
|
1395
1607
|
|
|
1396
1608
|
return h('div', { style: style.root },
|
|
1397
1609
|
h('header', null,
|
|
1398
|
-
h('
|
|
1399
|
-
|
|
1400
|
-
|
|
1610
|
+
h('div', { style: { ...style.row, justifyContent: 'space-between' } },
|
|
1611
|
+
h('h2', { style: style.title }, '火山方舟 Provider'),
|
|
1612
|
+
h('button', { type: 'button', style: style.btn, disabled: busyAccount || loading, onClick: () => { void refresh(); } }, loading ? '正在刷新状态…' : '刷新状态')),
|
|
1613
|
+
h('p', { style: style.muted }, '登录或添加账号,再为 Agent 套餐与编程套餐分别选择账号、管理模型并查看额度。')),
|
|
1614
|
+
loading && snapshot ? h('p', { role: 'status', style: style.muted }, '正在更新账号与套餐状态…') : null,
|
|
1615
|
+
busy ? h('p', { role: 'status', 'aria-live': 'polite', style: style.muted }, busyMessage(busy)) : null,
|
|
1616
|
+
loginActive ? h('p', { role: 'status', style: style.muted }, '登录期间暂不能修改账号与套餐,请完成登录或取消后继续。') : null,
|
|
1617
|
+
loadError ? h('div', null,
|
|
1618
|
+
h('p', { role: 'alert', style: style.error }, `读取状态失败:${loadError}`),
|
|
1619
|
+
h('button', { type: 'button', style: style.btn, disabled: busyAccount || loading, onClick: () => { void refresh(); } }, '重试读取状态')) : null,
|
|
1401
1620
|
snapshot?.routingError ? h('p', { role: 'alert', style: style.error }, describeError(snapshot.routingError)) : null,
|
|
1402
1621
|
notice
|
|
1403
1622
|
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
@@ -1407,20 +1626,8 @@ function VolcengineProviderSection({ client }) {
|
|
|
1407
1626
|
: null)
|
|
1408
1627
|
: null,
|
|
1409
1628
|
!snapshot
|
|
1410
|
-
? h('p', { style: style.muted }, '正在读取方舟账号状态…')
|
|
1629
|
+
? (loading ? h('p', { role: 'status', style: style.muted }, '正在读取方舟账号状态…') : null)
|
|
1411
1630
|
: h('div', { style: { display: 'flex', flexDirection: 'column', gap: 16 } },
|
|
1412
|
-
h(PlanCard, {
|
|
1413
|
-
plan: 'agent-plan', snapshot, rawQuota: quotas['agent-plan'], busy,
|
|
1414
|
-
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1415
|
-
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1416
|
-
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
1417
|
-
}),
|
|
1418
|
-
h(PlanCard, {
|
|
1419
|
-
plan: 'coding-plan', snapshot, rawQuota: quotas['coding-plan'], busy,
|
|
1420
|
-
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1421
|
-
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1422
|
-
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
1423
|
-
}),
|
|
1424
1631
|
h(AccountPanel, {
|
|
1425
1632
|
snapshot, editor, confirmDelete, loginConfirm, login, busy,
|
|
1426
1633
|
onNew: openNew, onEdit: openEdit, onCancelEdit: () => setEditor(null),
|
|
@@ -1429,9 +1636,22 @@ function VolcengineProviderSection({ client }) {
|
|
|
1429
1636
|
onConfirmDelete: (accountId) => { void removeAccount(accountId); },
|
|
1430
1637
|
onCancelDelete: () => setConfirmDelete(null),
|
|
1431
1638
|
onRequestLogin: requestLogin,
|
|
1639
|
+
onUsePlan: usePlan,
|
|
1432
1640
|
onConfirmLogin: confirmLogin,
|
|
1433
1641
|
onCancelLoginConfirm: () => setLoginConfirm(null),
|
|
1434
1642
|
onCancelLogin: () => { void cancelLogin(); }
|
|
1643
|
+
}),
|
|
1644
|
+
h(PlanCard, {
|
|
1645
|
+
plan: 'agent-plan', snapshot, rawQuota: quotas['agent-plan'], busy: planBusy, quotaBusy: Boolean(quotaBusy['agent-plan']),
|
|
1646
|
+
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1647
|
+
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1648
|
+
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
1649
|
+
}),
|
|
1650
|
+
h(PlanCard, {
|
|
1651
|
+
plan: 'coding-plan', snapshot, rawQuota: quotas['coding-plan'], busy: planBusy, quotaBusy: Boolean(quotaBusy['coding-plan']),
|
|
1652
|
+
onSelect: selectAccount, onModels: pullModels, onQuota: pullQuota,
|
|
1653
|
+
onToggleProvider: toggleProvider, onToggleModel: toggleModel,
|
|
1654
|
+
onSaveModelSettings: saveModelSettings, onResetModelSettings: resetModelSettings
|
|
1435
1655
|
})));
|
|
1436
1656
|
}
|
|
1437
1657
|
|
|
@@ -1556,5 +1776,5 @@ function apply(ctx) {
|
|
|
1556
1776
|
const name = 'dsh-volcengine-provider';
|
|
1557
1777
|
const inject = ['slots', 'remote'];
|
|
1558
1778
|
|
|
1559
|
-
|
|
1779
|
+
return {name,inject,apply};
|
|
1560
1780
|
}});
|