@ai-wendao/ant 0.4.6 → 0.4.7
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 +71 -32
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -377,14 +377,16 @@ window.__ModuleLoader__.load({
|
|
|
377
377
|
link ? h('a', { href: link, target: '_blank', rel: 'noopener noreferrer', style: { color: 'var(--dsw-alias-link)', fontSize: 13 } }, '打开团队管理 ↗') : null))
|
|
378
378
|
return h('section', { style: { display: 'grid', gap: 16, width: '100%', maxWidth: 1120 } },
|
|
379
379
|
h('div', { style: { display: 'grid', gap: 4 } },
|
|
380
|
-
h('h2', { style: { margin: 0, fontSize: 20, fontWeight: 650, lineHeight: 1.35 } }, '
|
|
381
|
-
h('p', { style: mutedTextStyle }, '
|
|
380
|
+
h('h2', { style: { margin: 0, fontSize: 20, fontWeight: 650, lineHeight: 1.35 } }, '团队与协作'),
|
|
381
|
+
h('p', { style: mutedTextStyle }, '管理团队连接、机器人聊天入口和本机任务授权。日常聊天保持自然;执行能力按你开放的范围核验。')),
|
|
382
382
|
h('div', { role: 'status', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
383
383
|
flexWrap: 'wrap', gap: 10, padding: '10px 12px', borderRadius: 8,
|
|
384
384
|
backgroundColor: bindingReadyForSummary ? 'var(--dsw-alias-state-success-tertiary)' : 'var(--dsw-alias-bg-layer-2)' } },
|
|
385
385
|
h('span', null, bindingSummary),
|
|
386
386
|
!bindingReadyForSummary ? h('button', { type: 'button', onClick: () => selectSettingsTab('connection'),
|
|
387
|
-
style: secondaryButtonStyle }, binding.state === 'error' ? '检查连接' : '查看连接设置')
|
|
387
|
+
style: secondaryButtonStyle }, binding.state === 'error' ? '检查连接' : '查看连接设置')
|
|
388
|
+
: activeTab === 'connection' ? h('button', { type: 'button', onClick: () => selectSettingsTab('bot-chat'),
|
|
389
|
+
style: secondaryButtonStyle }, '设置或管理机器人') : null),
|
|
388
390
|
h('div', { style: { position: 'sticky', top: 0, zIndex: 8, display: 'grid', gap: 8, padding: '6px 0',
|
|
389
391
|
backgroundColor: 'var(--dsw-alias-bg-module-platform)' } },
|
|
390
392
|
pluginAlerts.length ? h('section', { role: 'alert', style: { ...panelStyle,
|
|
@@ -407,7 +409,12 @@ window.__ModuleLoader__.load({
|
|
|
407
409
|
? `有新版 ANT:${updateSummary.currentVersion || '当前版本未知'} → ${updateSummary.version}`
|
|
408
410
|
: updateSummary.state === 'done' ? `ANT ${updateSummary.version} 已安装,需重启 DSH`
|
|
409
411
|
: updateSummary.state === 'revoked' ? '当前 ANT 安装包已撤回' : 'ANT 更新需要处理'),
|
|
410
|
-
h('span', { style: mutedTextStyle }, updateSummary.
|
|
412
|
+
h('span', { style: mutedTextStyle }, updateSummary.state === 'available'
|
|
413
|
+
? '查看“关于”中的更新说明与兼容要求;安装后需重启 DSH。'
|
|
414
|
+
: updateSummary.state === 'done' ? '请完全退出并重新启动 DSH 后生效。'
|
|
415
|
+
: updateSummary.state === 'revoked' ? '打开“关于”查看安全处置方式。'
|
|
416
|
+
: updateSummary.state === 'artifact-missing' ? '新版安装包尚未审核,请联系管理员。'
|
|
417
|
+
: '打开“关于”查看处理方式。')),
|
|
411
418
|
h('button', { type: 'button', onClick: () => selectSettingsTab('updates'), style: primaryButtonStyle },
|
|
412
419
|
updateSummary.state === 'available' ? '查看并更新' : '查看处理方式')) : null,
|
|
413
420
|
h('nav', { role: 'tablist', 'aria-label': 'ANT 插件设置', style: {
|
|
@@ -715,23 +722,46 @@ window.__ModuleLoader__.load({
|
|
|
715
722
|
} catch (error) { setMessage(error.message) }
|
|
716
723
|
finally { setBusy(false) }
|
|
717
724
|
}
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
}
|
|
734
|
-
|
|
725
|
+
const focusAfterTabChange = (tab, elementId) => {
|
|
726
|
+
onSelectTab(tab)
|
|
727
|
+
window.requestAnimationFrame?.(() => {
|
|
728
|
+
const target = window.document?.getElementById(elementId)
|
|
729
|
+
target?.scrollIntoView?.({ behavior: 'smooth', block: 'start' })
|
|
730
|
+
target?.focus?.({ preventScroll: true })
|
|
731
|
+
})
|
|
732
|
+
}
|
|
733
|
+
const goToSetupStep = (index) => {
|
|
734
|
+
if (index === 0) return focusAfterTabChange('bot-chat', selectedBot ? 'ant-bot-selector' : 'ant-chat-entry')
|
|
735
|
+
if (index === 1) return focusAfterTabChange('bot-chat', 'ant-chat-scope-panel')
|
|
736
|
+
if (authorizationLoadError || selectedTaskCount > 0) return focusAfterTabChange('capability', 'ant-capability-list')
|
|
737
|
+
setCreateOpen(true)
|
|
738
|
+
focusAfterTabChange('capability', index === 2 ? 'ant-new-task-summary' : 'ant-authorization-review')
|
|
739
|
+
}
|
|
740
|
+
const setupStepper = h('section', { 'aria-label': '首次设置引导', style: { display: 'grid', gap: 6 } },
|
|
741
|
+
h('p', { style: mutedTextStyle }, '首次设置可按顺序完成;你也可以直接切换页面。普通聊天不需要先开放任务。'),
|
|
742
|
+
h('ol', { 'aria-label': '设置步骤', style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 150px), 1fr))',
|
|
743
|
+
gap: 8, padding: 0, margin: 0, listStyle: 'none' } },
|
|
744
|
+
...[
|
|
745
|
+
{ label: '机器人和设备', detail: !selectedBot ? '选择已连接的机器人' : !botConnected ? '检查 DSH-IM 连接' : selectedEnrollmentBound ? '已绑定到这台 DSH' : '绑定到这台 DSH' },
|
|
746
|
+
{ label: '聊天入口', detail: !selectedBot || !selectedEnrollmentBound ? '绑定设备后设置私聊和群聊' : groupChatLoadFailed ? '群列表暂不可用,可手动输入群 ID' : `${dmChatEnabled ? '私聊可用' : '私聊已关闭'} · ${availableGroups.length} 个已发现群` },
|
|
747
|
+
{ label: '开放能力', detail: !botConnected || !selectedEnrollmentBound ? '完成机器人绑定后再开放' : authorizationLoadError ? '授权列表暂不可读,请刷新状态' : selectedTaskCount ? `${selectedTaskCount} 项已开放,可查看或停止` : '按需要创建任务' },
|
|
748
|
+
{ label: '复核授权', detail: authorizationLoadError ? '先确认已保存授权' : createOpen ? '检查请求范围后确认' : selectedTaskCount ? '查看已开放范围' : '请求人、执行方和期限' },
|
|
749
|
+
].map((step, index) => {
|
|
750
|
+
const currentStep = !botConnected || !selectedEnrollmentBound ? 0 : createOpen ? 3 : selectedTaskCount ? 4 : 2
|
|
751
|
+
const state = index < currentStep ? '完成' : index === currentStep ? '当前' : '待完成'
|
|
752
|
+
return h('li', { key: step.label, style: { minWidth: 0 } },
|
|
753
|
+
h('button', { type: 'button', 'aria-current': state === '当前' ? 'step' : undefined,
|
|
754
|
+
onClick: () => goToSetupStep(index), style: { width: '100%', minHeight: 70, display: 'grid', gap: 3,
|
|
755
|
+
padding: '8px 10px', textAlign: 'left', color: mutedTextStyle.color,
|
|
756
|
+
backgroundColor: 'var(--dsw-alias-bg-module-platform)', cursor: 'pointer',
|
|
757
|
+
border: '0', borderTop: `2px solid ${state === '完成' ? 'var(--dsw-alias-state-success-primary)' : state === '当前' ? 'var(--dsw-alias-state-business-primary)' : 'var(--dsw-alias-border-l2)'}`,
|
|
758
|
+
borderRadius: 0 } },
|
|
759
|
+
h('span', { style: { display: 'flex', justifyContent: 'space-between', gap: 6, alignItems: 'center' } },
|
|
760
|
+
h('strong', { style: { fontSize: 13, fontWeight: 600 } }, step.label),
|
|
761
|
+
h('span', { style: { fontSize: 12, color: mutedTextStyle.color } }, state)),
|
|
762
|
+
h('span', { style: mutedTextStyle }, step.detail)))
|
|
763
|
+
})))
|
|
764
|
+
const chatScopePanel = h('div', { id: 'ant-chat-scope-panel', tabIndex: -1, style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8, padding: 12,
|
|
735
765
|
display: 'grid', gap: 8 } },
|
|
736
766
|
h('strong', null, '机器人和聊天范围'),
|
|
737
767
|
h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 240px), 1fr))', gap: 8 } },
|
|
@@ -906,10 +936,11 @@ window.__ModuleLoader__.load({
|
|
|
906
936
|
display: ['bot-chat', 'capability', 'local'].includes(activeTab) ? 'grid' : 'none' },
|
|
907
937
|
'aria-label': '协作机器人与开放能力' },
|
|
908
938
|
message ? h('p', { role: 'status', style: mutedTextStyle }, message) : null,
|
|
909
|
-
h('div', {
|
|
910
|
-
|
|
939
|
+
h('div', { id: 'ant-chat-entry', role: 'region', 'aria-label': '聊天入口和机器人状态', tabIndex: -1,
|
|
940
|
+
style: { display: activeTab === 'bot-chat' ? 'grid' : 'none', gap: 14 } },
|
|
941
|
+
h('h3', { style: sectionTitleStyle }, '聊天入口'),
|
|
911
942
|
h('p', { style: mutedTextStyle }, '在所有者开启的私聊或群聊中,同事可以像平常一样和机器人聊天。DSH 负责理解与回答;只有准备执行你开放的能力时,ANT 才核对请求人、群、参数和权限。群里的任务结果会回复原群。'),
|
|
912
|
-
h('p', { role: 'status', style: mutedTextStyle }, '
|
|
943
|
+
h('p', { role: 'status', style: mutedTextStyle }, '私聊与群聊可同时开启;每项能力一次只授权给一个私聊或一个群。普通对话不会自动获得读取电脑、调用工具或访问其他群的权限。'),
|
|
913
944
|
loadFailures.length ? h('p', { role: 'status', style: mutedTextStyle },
|
|
914
945
|
`部分协作信息暂时无法读取:${loadFailures.map((path) => loadNames[path]).join('、')}。已读取的信息仍显示,请稍后刷新状态。`) : null,
|
|
915
946
|
h('span', { role: 'status', style: mutedTextStyle }, loading ? '正在读取机器人与任务状态…'
|
|
@@ -928,7 +959,7 @@ window.__ModuleLoader__.load({
|
|
|
928
959
|
: !dmChatEnabled ? `“${selectedBot.name}”已启用协作;私聊已关闭,群聊仍按各自设置工作。`
|
|
929
960
|
: selectedTaskCount === 0 ? `“${selectedBot.name}”已启用协作;下一步开放一项能力。你也可以先私聊自测普通聊天。`
|
|
930
961
|
: `“${selectedBot.name}”已启用协作 · ${selectedTaskCount} 项能力已开放。可以私聊自测。`),
|
|
931
|
-
bots.length ? h('label', null, '我的机器人', h('select', { value: botId,
|
|
962
|
+
bots.length ? h('label', null, '我的机器人', h('select', { id: 'ant-bot-selector', value: botId,
|
|
932
963
|
onChange: (event) => { setBotId(event.target.value); setGroupId(''); setChatGroupId(''); setBindingCode('');
|
|
933
964
|
setTrustedOrigin(enrolled.find((bot) => bot.bot_id === event.target.value)?.gitea_origin || '') }, style: inputStyle },
|
|
934
965
|
h('option', { value: '' }, '请选择机器人'),
|
|
@@ -1002,7 +1033,8 @@ window.__ModuleLoader__.load({
|
|
|
1002
1033
|
h('button', { type: 'button', onClick: () => { preparePrExample(); onSelectTab('capability') }, style: secondaryButtonStyle }, '使用 PR 差异审查示例'),
|
|
1003
1034
|
h('button', { type: 'button', onClick: () => void load().catch((error) => setMessage(error.message)),
|
|
1004
1035
|
style: secondaryButtonStyle }, '刷新状态'))),
|
|
1005
|
-
h('div', { role: 'region', 'aria-label': '已开放能力列表',
|
|
1036
|
+
h('div', { id: 'ant-capability-list', role: 'region', 'aria-label': '已开放能力列表', tabIndex: -1,
|
|
1037
|
+
style: { display: activeTab === 'capability' ? 'grid' : 'none', gap: 12 } },
|
|
1006
1038
|
h('h4', { style: sectionTitleStyle }, `我开放的能力 · ${authorizationLoadError ? '暂未读取' : activeCards.length}`),
|
|
1007
1039
|
h('p', { style: mutedTextStyle }, '当前一项能力只能绑定一个范围:私聊,或某一个群。若要给其他群或私聊开放相同任务,目前需分别建立能力卡;它们的请求人和有效期独立。'),
|
|
1008
1040
|
...activeCards.map((card) => {
|
|
@@ -1047,9 +1079,13 @@ window.__ModuleLoader__.load({
|
|
|
1047
1079
|
h('button', { type: 'button', disabled: busy, onClick: () => copyCardToDraft(card), style: secondaryButtonStyle }, '复制'),
|
|
1048
1080
|
h('button', { type: 'button', disabled: busy, onClick: () => void revokeCard(card), style: secondaryButtonStyle }, '停止')))
|
|
1049
1081
|
}),
|
|
1050
|
-
activeCards.length === 0 ? h('
|
|
1051
|
-
|
|
1052
|
-
|
|
1082
|
+
activeCards.length === 0 ? h('div', { style: { display: 'grid', justifyItems: 'start', gap: 8 } },
|
|
1083
|
+
h('p', { style: mutedTextStyle }, authorizationLoadError
|
|
1084
|
+
? '暂时无法确认已开放的能力。刷新授权状态后再试;列表未核实前请勿重复创建。'
|
|
1085
|
+
: '还没有开放能力。先选机器人,再开放一项能力;PR 审查只是可选示例。'),
|
|
1086
|
+
authorizationLoadError ? h('button', { type: 'button', disabled: loading,
|
|
1087
|
+
onClick: () => void load().catch((error) => setMessage(error.message)), style: secondaryButtonStyle },
|
|
1088
|
+
loading ? '正在刷新…' : '刷新授权状态') : null) : null),
|
|
1053
1089
|
h('div', { role: 'region', 'aria-label': '最近任务', style: { display: activeTab === 'local' ? 'grid' : 'none', gap: 12 } },
|
|
1054
1090
|
h('h4', { style: sectionTitleStyle }, '最近任务'),
|
|
1055
1091
|
...(tasks.filter((task) => task.task_id).length ? tasks.filter((task) => task.task_id)
|
|
@@ -1075,7 +1111,7 @@ window.__ModuleLoader__.load({
|
|
|
1075
1111
|
h('details', { id: 'ant-new-task', open: createOpen,
|
|
1076
1112
|
onToggle: (event) => setCreateOpen(event.currentTarget.open),
|
|
1077
1113
|
style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8, padding: 12 } },
|
|
1078
|
-
h('summary', { style: { cursor: 'pointer', fontWeight: 600 } }, '开放一项能力'),
|
|
1114
|
+
h('summary', { id: 'ant-new-task-summary', style: { cursor: 'pointer', fontWeight: 600 } }, '开放一项能力'),
|
|
1079
1115
|
h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 320px), 1fr))',
|
|
1080
1116
|
gap: 16, alignItems: 'start', marginTop: 12 } },
|
|
1081
1117
|
h('form', { id: 'ant-capability-create-form', onSubmit: createCard, style: { display: 'grid', gap: 9, minWidth: 0 } },
|
|
@@ -1170,7 +1206,8 @@ window.__ModuleLoader__.load({
|
|
|
1170
1206
|
h('label', null, '有效期', h('select', { value: days, onChange: (event) => setDays(Number(event.target.value)), style: inputStyle },
|
|
1171
1207
|
h('option', { value: 1 }, '1 天'), h('option', { value: 7 }, '7 天'), h('option', { value: 30 }, '30 天')))),
|
|
1172
1208
|
),
|
|
1173
|
-
h('aside', { role: 'region', 'aria-label': '开放前复核',
|
|
1209
|
+
h('aside', { id: 'ant-authorization-review', role: 'region', 'aria-label': '开放前复核', tabIndex: -1,
|
|
1210
|
+
style: { ...panelStyle, padding: 14, gap: 10,
|
|
1174
1211
|
position: 'sticky', top: 12, alignSelf: 'start' } },
|
|
1175
1212
|
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8 } },
|
|
1176
1213
|
h('h4', { style: sectionTitleStyle }, '开放前复核'),
|
|
@@ -2324,7 +2361,9 @@ window.__ModuleLoader__.load({
|
|
|
2324
2361
|
installing: '正在安装', done: '需重启 DSH', current: '已是最新', checking: '正在检查', none: '尚未发布',
|
|
2325
2362
|
}
|
|
2326
2363
|
const updateStatusNeedsDetails = ['artifact-missing', 'revoked', 'migration-required', 'unknown', 'failed', 'installing', 'done']
|
|
2327
|
-
const updateVersionSummary = bundleUpdate.
|
|
2364
|
+
const updateVersionSummary = bundleUpdate.state === 'available'
|
|
2365
|
+
? `可更新至 ${bundleRelease?.version || '最新版本'}`
|
|
2366
|
+
: updateStatusNeedsDetails.includes(bundleUpdate.state) ? '' : bundleUpdate.currentVersion && bundleRelease?.version
|
|
2328
2367
|
? bundleUpdate.currentVersion === bundleRelease.version
|
|
2329
2368
|
? `当前版本 ${bundleUpdate.currentVersion} · 已是最新`
|
|
2330
2369
|
: `当前版本 ${bundleUpdate.currentVersion} · 最新版本 ${bundleRelease.version}`
|