dsh-duet 0.3.0 → 0.3.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/assets/avatar/desktop/companion.mjs +3 -4
- package/assets/avatar/desktop/manifest.json +1 -1
- package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
- package/desktop/bin/darwin-arm64/manifest.json +3 -3
- package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
- package/desktop/bin/win32-x64/manifest.json +3 -3
- package/node_modules/dsh-duet-superagent/lib/duet.d.ts +19 -3
- package/node_modules/dsh-duet-superagent/lib/duet.js +156 -10
- package/node_modules/dsh-duet-superagent/lib/{feishu-rAGM9U9b.js → feishu-CwKBb-B_.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.js +1 -1
- package/node_modules/dsh-duet-superagent/lib/{github-pull-gSbjzypm.js → github-pull-DyfAy0yE.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/index.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/{poll-Dh7J1cdM.js → poll-BBkmV_GM.js} +4 -1
- package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts} +70 -61
- package/node_modules/dsh-duet-superagent/lib/{runtime-CbDPyQoo.js → runtime-Ow0S-7ZZ.js} +45 -5
- package/package.json +6 -2
- package/src/avatar/surface.mjs +6 -1
- package/src/client/agent-entry.mjs +27 -0
- package/src/client/agent-tasks.mjs +42 -10
- package/src/client/agent-tool-views.mjs +190 -0
- package/src/client/audio.mjs +1 -1
- package/src/client/avatar-surfaces.mjs +3 -3
- package/src/client/browser.mjs +35 -27
- package/src/client/composer-bridge.mjs +1 -1
- package/src/client/connection-hint.mjs +20 -5
- package/src/client/entry.js +10 -3
- package/src/client/feedback.mjs +1 -1
- package/src/client/identity.mjs +1 -1
- package/src/client/settings.html +84 -80
- package/src/client/tutorial-adapter.mjs +5 -5
- package/src/client/tutorial.mjs +1 -1
- package/src/client/work-mode.mjs +46 -9
- package/src/host/agent-connection.mjs +6 -1
- package/src/host/assets.mjs +2 -0
- package/src/host/plugin.mjs +4 -2
- package/src/shared/avatar-menu-ui.mjs +30 -12
- package/src/shared/avatar-menu.mjs +4 -1
- package/src/shared/avatar-surface.mjs +1 -0
- package/src/shared/avatar-ui.mjs +2 -0
- package/src/shared/state.mjs +1 -1
- package/src/shared/work-mode.mjs +64 -4
package/src/client/settings.html
CHANGED
|
@@ -5,63 +5,48 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>duet · DeepSeek Harness</title>
|
|
7
7
|
<style>
|
|
8
|
-
:root
|
|
9
|
-
[hidden]
|
|
10
|
-
body
|
|
11
|
-
main
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
.connection-detail,.muted { color:#93a79e;line-height:1.7 }
|
|
51
|
-
.cards { display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin:22px 0 28px }
|
|
52
|
-
.metric { border:1px solid #334239;border-radius:12px;padding:18px;background:#141a17 }
|
|
53
|
-
.metric small { color:#91a79e;display:block;margin-bottom:9px }
|
|
54
|
-
.metric strong { font-size:16px;font-weight:550 }
|
|
55
|
-
input,textarea,select { background:#111814;border-color:#3c4c42;color:#e5eeeb }
|
|
56
|
-
label { display:block;margin:18px 0 8px;font-size:13px;color:#b8c9bf }
|
|
57
|
-
button { background:#b3e9cb;color:#152a1e }
|
|
58
|
-
button.secondary { background:#2c3b33;color:#dcebe3 }
|
|
59
|
-
details { border-top:1px solid #303d36;margin-top:24px;padding-top:20px }
|
|
60
|
-
summary { cursor:pointer;color:#c2d6c9;font-size:13px;user-select:none }
|
|
61
|
-
#saveDuet { width:auto;min-width:150px;margin-top:12px }
|
|
62
|
-
.section-note { color:#92a69b;font-size:13px;line-height:1.8;margin:0 0 18px }
|
|
63
|
-
footer { font-size:12px;color:#71867a;display:flex;justify-content:space-between;margin-top:28px }
|
|
64
|
-
@media(max-width:600px) { main{padding:32px 18px}.cards{grid-template-columns:1fr}.panel{padding:20px}h1{font-size:42px} }
|
|
8
|
+
:root{color-scheme:dark;font-family:Inter,"PingFang SC",system-ui,sans-serif;--bg:#101614;--panel:#18201c;--input:#121a16;--line:#2c3c32;--text:#e5eee8;--muted:#a2b4a8;--accent:#b3e9cb}
|
|
9
|
+
*{box-sizing:border-box}[hidden]{display:none!important}
|
|
10
|
+
body{margin:0;background:radial-gradient(ellipse at 20% 0%,#1e332855,transparent 600px),var(--bg);color:var(--text);font-size:14px;line-height:1.6}
|
|
11
|
+
main{max-width:1110px;margin:auto;padding:48px 32px}
|
|
12
|
+
.eyebrow{font-size:10px;font-weight:650;letter-spacing:2.8px;color:var(--muted);margin-bottom:12px}
|
|
13
|
+
h1{margin:0;font-size:52px;font-weight:750;letter-spacing:-2px;line-height:1.05}
|
|
14
|
+
#duetMark{display:inline-block;width:9px;height:9px;margin-left:4px;border-radius:50%;font-size:0;background:currentColor}
|
|
15
|
+
.sub{margin:14px 0 30px;color:var(--muted);font-size:15px}
|
|
16
|
+
.settings-shell{display:grid;grid-template-columns:158px minmax(0,1fr);gap:32px;align-items:start}
|
|
17
|
+
.settings-nav{position:sticky;top:24px;display:grid;gap:4px;padding-top:8px}
|
|
18
|
+
.settings-nav a{color:var(--muted);text-decoration:none;padding:9px 12px;border-radius:9px;font-size:13px;transition:background .15s,color .15s}
|
|
19
|
+
.settings-nav a:hover,.settings-nav a[aria-current=true]{background:#b3e9cb10;color:var(--accent)}
|
|
20
|
+
.settings-nav small{color:#82998a;font-size:10px;letter-spacing:1.5px;padding:12px;margin-bottom:2px}
|
|
21
|
+
.settings-content{min-width:0}.panel{background:var(--panel);border:1px solid var(--line);border-radius:20px;padding:28px;scroll-margin-top:24px;box-shadow:0 4px 20px #00000008}
|
|
22
|
+
h2{margin:0 0 18px;font-size:17px;font-weight:650;letter-spacing:-.3px}h3{font-weight:600}
|
|
23
|
+
.section-note,.muted{color:var(--muted);font-size:12px;line-height:1.75}.section-note{margin:8px 0 18px}
|
|
24
|
+
input,textarea,select,button{font:inherit;max-width:100%}
|
|
25
|
+
input,textarea,select{width:100%;color:var(--text);background:var(--input);border:1px solid #3a4c40;border-radius:10px;padding:10px 12px;outline:none}
|
|
26
|
+
input:hover,textarea:hover,select:hover{border-color:#647e6d}
|
|
27
|
+
input:focus,textarea:focus,select:focus{border-color:var(--accent);box-shadow:0 0 0 3px #b3e9cb14}
|
|
28
|
+
label{display:block;font-size:13px;color:#c2d0c7;margin:16px 0 8px}
|
|
29
|
+
textarea{min-height:130px;resize:vertical}.compact{min-height:92px}
|
|
30
|
+
button{width:auto;min-height:38px;border:1px solid transparent;border-radius:10px;padding:8px 16px;color:#12281b;background:var(--accent);font-weight:600;font-size:13px;cursor:pointer;transition:filter .15s}
|
|
31
|
+
button:hover:not(:disabled){filter:brightness(1.09)}button:disabled{opacity:.5;cursor:default}
|
|
32
|
+
button.secondary{color:var(--text);background:#25362c;border-color:#3b4e41}
|
|
33
|
+
:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
|
|
34
|
+
input[type=checkbox]{width:34px!important;height:20px;appearance:none;display:inline-block;vertical-align:middle;margin:0 10px 0 0;padding:0;background:#415047;border:1px solid #4e6054;border-radius:20px;cursor:pointer;position:relative}
|
|
35
|
+
input[type=checkbox]::after{content:'';position:absolute;width:14px;height:14px;top:2px;left:2px;border-radius:50%;background:#e5eee8;transition:transform .15s}
|
|
36
|
+
input[type=checkbox]:checked{background:#80b294;border-color:#80b294}input[type=checkbox]:checked::after{transform:translateX(14px)}
|
|
37
|
+
.row{display:flex;gap:10px;margin-top:10px;align-items:center}.row input{flex:1;min-width:0}.row button{flex-shrink:0}
|
|
38
|
+
.connection{display:flex;align-items:center;gap:10px;margin:0 0 18px;padding:14px 18px;border:1px solid var(--line);border-radius:14px;background:#142119}
|
|
39
|
+
.connection-title{font-size:13px;font-weight:600}.connection-detail{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
|
|
40
|
+
.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px 24px;margin:16px 0 20px}
|
|
41
|
+
.metric{min-width:0}.metric small{display:block;color:var(--muted);font-size:11px;margin-bottom:5px}.metric strong{font-size:14px!important;font-weight:550;overflow-wrap:anywhere}
|
|
42
|
+
details{border-top:1px solid var(--line);padding-top:16px;margin-top:22px}
|
|
43
|
+
summary{cursor:pointer;color:#c2d6c9;font-size:13px;user-select:none}details[open]>summary{margin-bottom:14px}
|
|
44
|
+
[role=status]{font-size:12px;overflow-wrap:anywhere}[role=status]:empty{display:none}
|
|
45
|
+
#assistantNickname{max-width:360px}#submitFeedback{margin-top:12px}#saveDuet{margin-top:0}
|
|
46
|
+
footer{font-size:11px;color:#82998a;margin:28px 0 0}
|
|
47
|
+
.layout{display:grid;grid-template-columns:310px 1fr;gap:18px}.session{border:1px solid var(--line);padding:12px;margin:8px 0;border-radius:10px}.session.active{background:#243e2e}.session strong{display:block}.session-main{cursor:pointer}.session-actions{display:flex;gap:6px;margin-top:9px}.session-actions button{font-size:12px;padding:5px}.job{border-top:1px solid var(--line);padding:12px 0}.status{font-size:12px;padding:3px 8px;border-radius:20px;background:#344339}.status.failed{color:#ffb3bf}.status.succeeded{color:#9bf0c9}.task,.result{white-space:pre-wrap;overflow-wrap:anywhere}.result{background:var(--input);padding:10px;border-radius:8px}
|
|
48
|
+
@media(max-width:760px){main{padding:30px 18px}.settings-shell{grid-template-columns:1fr;gap:20px}.settings-nav{position:static;display:flex;flex-wrap:wrap;gap:4px;padding:0}.settings-nav small{display:none}.settings-nav a{padding:7px 10px}.panel{padding:22px}.layout{grid-template-columns:1fr}}
|
|
49
|
+
@media(max-width:440px){main{padding:24px 12px}.panel{padding:18px;border-radius:16px}.cards{grid-template-columns:repeat(2,minmax(0,1fr))}h1{font-size:44px}}
|
|
65
50
|
</style>
|
|
66
51
|
</head>
|
|
67
52
|
<body>
|
|
@@ -69,12 +54,23 @@
|
|
|
69
54
|
<div class="eyebrow">DEEPSEEK HARNESS</div>
|
|
70
55
|
<h1>duet<span id="duetMark" style="color:#ed9b35">.</span></h1>
|
|
71
56
|
<div class="sub">用声音控制dsh,让工作变得更自由。</div>
|
|
57
|
+
<div class="settings-shell">
|
|
58
|
+
<nav class="settings-nav" aria-label="设置分组">
|
|
59
|
+
<small>偏好设置</small>
|
|
60
|
+
<a href="#work-settings">工作方式</a><a href="#nickname-settings">助手昵称</a><a href="#voice-settings">音色</a><a href="#avatar-settings">3D 形象</a><a href="#microphone-settings">麦克风</a><a href="#shortcut-settings">快捷键</a>
|
|
61
|
+
<small>服务与帮助</small>
|
|
62
|
+
<a href="#tutorial-settings">使用教学</a><a href="#feedback-settings">意见反馈</a>
|
|
63
|
+
</nav>
|
|
64
|
+
<div class="settings-content">
|
|
72
65
|
<div class="connection" id="connectionStatus">
|
|
73
66
|
<div><div class="connection-title" id="connectionTitle">正在读取连接状态</div><div class="connection-detail" id="connectionDetail"></div></div>
|
|
74
67
|
</div>
|
|
75
|
-
<section class="panel" style="margin-bottom:18px">
|
|
76
|
-
<h2
|
|
77
|
-
<
|
|
68
|
+
<section class="panel" id="news-settings" style="margin-bottom:18px" hidden>
|
|
69
|
+
<h2>服务动态</h2>
|
|
70
|
+
<div id="announcements" aria-live="polite" class="muted"></div>
|
|
71
|
+
</section>
|
|
72
|
+
<section class="panel" id="connection-settings" style="margin-bottom:18px">
|
|
73
|
+
<h2>连接与版本</h2>
|
|
78
74
|
<div class="cards">
|
|
79
75
|
<div class="metric"><small>当前模式</small><strong id="duetConnection">读取中</strong></div>
|
|
80
76
|
<div class="metric"><small>服务配置</small><strong id="authState">检查中</strong></div>
|
|
@@ -89,13 +85,13 @@
|
|
|
89
85
|
<div id="settingsMessage" role="status" style="margin-top:10px"></div>
|
|
90
86
|
</details>
|
|
91
87
|
</section>
|
|
92
|
-
<section class="panel" style="margin-bottom:18px">
|
|
93
|
-
<div style="
|
|
88
|
+
<section class="panel" id="work-settings" style="margin-bottom:18px">
|
|
89
|
+
<div style="margin-bottom:18px">
|
|
94
90
|
<h2 style="margin:0">工作方式</h2>
|
|
95
91
|
</div>
|
|
96
92
|
<div id="workModeSettings">正在读取工作方式…</div>
|
|
97
93
|
</section>
|
|
98
|
-
<section class="panel" style="margin-bottom:18px">
|
|
94
|
+
<section class="panel" id="nickname-settings" style="margin-bottom:18px">
|
|
99
95
|
<h2>助手昵称</h2>
|
|
100
96
|
<label for="assistantNickname">给助手起个名字</label>
|
|
101
97
|
<input id="assistantNickname" type="text" placeholder="duet" autocomplete="off">
|
|
@@ -103,7 +99,7 @@
|
|
|
103
99
|
<button id="saveNickname" type="button" disabled>保存昵称</button>
|
|
104
100
|
<p id="nicknameStatus" class="muted" role="status" aria-live="polite"></p>
|
|
105
101
|
</section>
|
|
106
|
-
<section class="panel" style="margin-bottom:18px">
|
|
102
|
+
<section class="panel" id="voice-settings" style="margin-bottom:18px">
|
|
107
103
|
<h2>音色</h2>
|
|
108
104
|
<div id="duetVoices">
|
|
109
105
|
<p data-availability role="status" hidden></p>
|
|
@@ -145,7 +141,7 @@
|
|
|
145
141
|
<p data-status role="status" aria-live="polite"></p>
|
|
146
142
|
</div>
|
|
147
143
|
</section>
|
|
148
|
-
<section class="panel" style="margin-bottom:18px">
|
|
144
|
+
<section class="panel" id="avatar-settings" style="margin-bottom:18px">
|
|
149
145
|
<h2>3D 形象</h2>
|
|
150
146
|
<label><input id="avatarEnabled" type="checkbox" style="width:auto"> 打开3D形象(实验)</label>
|
|
151
147
|
<label><input id="avatarWebOnly" type="checkbox" style="width:auto"> 仅在网页端显示(适用于dsh装在服务器)</label>
|
|
@@ -156,14 +152,14 @@
|
|
|
156
152
|
<button id="avatarRetryDesktop" type="button" hidden>重试桌面显示</button>
|
|
157
153
|
<p id="avatarSettingsStatus" class="muted" role="status"></p>
|
|
158
154
|
</section>
|
|
159
|
-
<section class="panel" style="margin-bottom:18px">
|
|
155
|
+
<section class="panel" id="microphone-settings" style="margin-bottom:18px">
|
|
160
156
|
<h2>麦克风</h2>
|
|
161
157
|
<label for="microphoneDevice">交互模式使用的设备</label>
|
|
162
158
|
<select id="microphoneDevice" disabled><option value="">系统默认麦克风</option></select>
|
|
163
159
|
<div class="row"><button id="refreshMicrophones" class="secondary" type="button" style="width:auto">刷新设备</button></div>
|
|
164
160
|
<p id="microphoneStatus" class="muted" role="status" aria-live="polite"></p>
|
|
165
161
|
</section>
|
|
166
|
-
<section class="panel" style="margin-bottom:18px">
|
|
162
|
+
<section class="panel" id="shortcut-settings" style="margin-bottom:18px">
|
|
167
163
|
<h2>快捷键</h2>
|
|
168
164
|
<p class="section-note">在 DSH 页面中切换语音模式。留空则不启用,建议避开浏览器已有的快捷键。</p>
|
|
169
165
|
<label for="speakerShortcut">播报模式</label>
|
|
@@ -172,16 +168,12 @@
|
|
|
172
168
|
<div class="row"><input id="micShortcut" readonly placeholder="点击后按下组合键" autocomplete="off"><button id="clearMicShortcut" type="button" class="secondary" style="width:auto">清除</button></div>
|
|
173
169
|
<p id="shortcutStatus" class="muted" role="status" aria-live="polite"></p>
|
|
174
170
|
</section>
|
|
175
|
-
<section class="panel" style="margin-bottom:18px">
|
|
176
|
-
<h2>服务动态</h2>
|
|
177
|
-
<div id="announcements" aria-live="polite" class="muted">正在获取服务通知……</div>
|
|
178
|
-
</section>
|
|
179
|
-
<section class="panel" style="margin-bottom:18px">
|
|
171
|
+
<section class="panel" id="tutorial-settings" style="margin-bottom:18px">
|
|
180
172
|
<h2>使用教学</h2><p class="section-note">跟着语音演示,了解播报、输入、修改和切换会话。</p>
|
|
181
173
|
<button id="openTutorial" type="button">打开教学</button>
|
|
182
174
|
<p id="tutorialStatus" role="status" aria-live="polite" class="muted"></p>
|
|
183
175
|
</section>
|
|
184
|
-
<section class="panel" style="margin-bottom:18px">
|
|
176
|
+
<section class="panel" id="feedback-settings" style="margin-bottom:18px">
|
|
185
177
|
<h2>意见反馈</h2><p class="section-note">告诉我们哪里不好用,或你希望增加什么功能。请勿填写密码、密钥等敏感信息。</p>
|
|
186
178
|
<label for="feedbackText">你的反馈</label>
|
|
187
179
|
<textarea id="feedbackText" maxlength="5000" placeholder="描述你的体验或建议……"></textarea>
|
|
@@ -217,8 +209,18 @@
|
|
|
217
209
|
</section>
|
|
218
210
|
</div>
|
|
219
211
|
<footer><span>duet / DeepSeek Harness</span></footer>
|
|
212
|
+
</div></div>
|
|
220
213
|
</main>
|
|
221
214
|
<script type="module">
|
|
215
|
+
const navLinks=[...document.querySelectorAll('.settings-nav a')];
|
|
216
|
+
const highlightSection=()=>{
|
|
217
|
+
const sections=navLinks.map(link=>document.querySelector(link.hash)).filter(Boolean).sort((a,b)=>a.offsetTop-b.offsetTop);
|
|
218
|
+
const active=sections.filter(section=>section.getBoundingClientRect().top<=100).at(-1)||sections[0];
|
|
219
|
+
for(const link of navLinks)link.setAttribute('aria-current',String(link.hash==='#'+active?.id));
|
|
220
|
+
};
|
|
221
|
+
let navFrame=0;
|
|
222
|
+
window.addEventListener('scroll',()=>{if(!navFrame)navFrame=requestAnimationFrame(()=>{navFrame=0;highlightSection();});},{passive:true});
|
|
223
|
+
highlightSection();
|
|
222
224
|
import { AVATAR_KEY, AVATAR_PRESENTATION_LABELS, avatarPreferences, saveAvatarPreferences } from '/duet/assets/shared/avatar.mjs';
|
|
223
225
|
import { sizeButton, nextAvatarSize, avatarCloseConfirmation } from '/duet/assets/shared/avatar-ui.mjs';
|
|
224
226
|
const avatarConfirm=avatarCloseConfirmation();
|
|
@@ -250,7 +252,7 @@
|
|
|
250
252
|
if(enabled||await avatarConfirm.ask())avatarSave({enabled});
|
|
251
253
|
};
|
|
252
254
|
window.addEventListener('pagehide',()=>{avatarConfirm.dispose();avatarChannel?.close();window.removeEventListener('storage',avatarStorage);},{once:true});
|
|
253
|
-
import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.3.
|
|
255
|
+
import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.3.2';
|
|
254
256
|
import { mountWorkMode, workModeOnboarding } from '/duet/assets/client/work-mode.mjs';
|
|
255
257
|
const modePreview=workModeOnboarding(undefined,{preview:true});
|
|
256
258
|
let previewRequested=new URL(location.href).searchParams.get('preview')==='work-mode';
|
|
@@ -474,11 +476,12 @@
|
|
|
474
476
|
};
|
|
475
477
|
async function loadNotices() {
|
|
476
478
|
const target = $('announcements');
|
|
479
|
+
const panel = $('news-settings');
|
|
477
480
|
try {
|
|
478
481
|
const result = await api('/announcements');
|
|
479
482
|
target.replaceChildren();
|
|
480
|
-
|
|
481
|
-
if (!result.items
|
|
483
|
+
panel.hidden=true;
|
|
484
|
+
if (result.status !== 'ok' || !Array.isArray(result.items) || !result.items.length) return;
|
|
482
485
|
for (const item of result.items) {
|
|
483
486
|
const article = document.createElement('article'); article.className = 'job';
|
|
484
487
|
const title = document.createElement('strong'); title.textContent = item.title;
|
|
@@ -486,7 +489,8 @@
|
|
|
486
489
|
const body = document.createElement('div'); body.textContent = item.body; body.className = 'result';
|
|
487
490
|
article.append(title, time, body); target.append(article);
|
|
488
491
|
}
|
|
489
|
-
|
|
492
|
+
panel.hidden=false;
|
|
493
|
+
} catch { panel.hidden=true;target.replaceChildren(); }
|
|
490
494
|
}
|
|
491
495
|
async function initialize() {
|
|
492
496
|
await loadDuetConfig(true);
|
|
@@ -498,7 +502,7 @@
|
|
|
498
502
|
}
|
|
499
503
|
$('openTutorial').onclick = async () => {
|
|
500
504
|
try {
|
|
501
|
-
const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.3.
|
|
505
|
+
const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.3.2');
|
|
502
506
|
requestTutorial(localStorage);
|
|
503
507
|
$('tutorialStatus').textContent = '请回到 DSH 页面继续教学。';
|
|
504
508
|
} catch { $('tutorialStatus').textContent = '暂时无法打开教学,请允许浏览器存储后重试。'; }
|
|
@@ -507,11 +511,11 @@
|
|
|
507
511
|
setInterval(() => { loadDuetConfig().catch(showConnectionUnavailable); }, 2000);
|
|
508
512
|
void loadNotices();
|
|
509
513
|
setInterval(loadNotices, 60000);
|
|
510
|
-
import('/duet/assets/client/shortcuts.mjs?v=0.3.
|
|
514
|
+
import('/duet/assets/client/shortcuts.mjs?v=0.3.2').then(({mountShortcutSettings}) => {
|
|
511
515
|
const dispose = mountShortcutSettings({speaker:$('speakerShortcut'),mic:$('micShortcut'),clearSpeaker:$('clearSpeakerShortcut'),clearMic:$('clearMicShortcut'),status:$('shortcutStatus')});
|
|
512
516
|
window.addEventListener('pagehide', e => {if(!e.persisted)dispose()}, {once:true});
|
|
513
517
|
}).catch(() => { $('shortcutStatus').textContent = '暂时无法加载快捷键设置,请刷新重试。'; });
|
|
514
|
-
import('/duet/assets/client/microphone.mjs?v=0.3.
|
|
518
|
+
import('/duet/assets/client/microphone.mjs?v=0.3.2').then(({mountMicrophoneSettings}) => {
|
|
515
519
|
const dispose = mountMicrophoneSettings({select:$('microphoneDevice'),refresh:$('refreshMicrophones'),status:$('microphoneStatus')});
|
|
516
520
|
window.addEventListener('pagehide', dispose, {once:true});
|
|
517
521
|
}).catch(() => { $('microphoneStatus').textContent = '暂时无法加载麦克风设置,请刷新重试。'; });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** DSH browser services plus existing voice connection; never opens a microphone. */
|
|
2
|
-
import { PLUGIN_VERSION } from '../shared/state.mjs?v=0.3.
|
|
3
|
-
import { focusedSession } from './composer.mjs?v=0.3.
|
|
4
|
-
import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.3.
|
|
5
|
-
import { startComposerBridge } from './composer-bridge.mjs?v=0.3.
|
|
6
|
-
import { identityFetch } from './identity.mjs?v=0.3.
|
|
2
|
+
import { PLUGIN_VERSION } from '../shared/state.mjs?v=0.3.2'
|
|
3
|
+
import { focusedSession } from './composer.mjs?v=0.3.2'
|
|
4
|
+
import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.3.2'
|
|
5
|
+
import { startComposerBridge } from './composer-bridge.mjs?v=0.3.2'
|
|
6
|
+
import { identityFetch } from './identity.mjs?v=0.3.2'
|
|
7
7
|
export function tutorialAdapter(ctx, state, audio, pollReady, startBridge = startComposerBridge) {
|
|
8
8
|
let narration
|
|
9
9
|
const completed = new Map()
|
package/src/client/tutorial.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Opt-in walkthrough. All writes are limited to sessions created by this run. */
|
|
2
|
-
import {consumeTutorialRequest} from './tutorial-request.mjs?v=0.3.
|
|
2
|
+
import {consumeTutorialRequest} from './tutorial-request.mjs?v=0.3.2'
|
|
3
3
|
export const TUTORIAL_KEY = 'dsh-duplex-tutorial-v1'
|
|
4
4
|
export const QUESTION = '什么是语音交互?请用一句话简单解释,不使用工具。'
|
|
5
5
|
export const INPUT = '用一句话介绍语音助手。'
|
package/src/client/work-mode.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WORK_MODES, AGENT_PERMISSION_TEXT, workModeIssue, TASK_STATES,
|
|
2
|
-
import { identityFetch } from './identity.mjs?v=0.3.
|
|
1
|
+
import { WORK_MODES, AGENT_PERMISSION_TEXT, AGENT_WORKSPACE_NOTICE, workModeIssue, TASK_STATES, taskModelLabel } from '../shared/work-mode.mjs'
|
|
2
|
+
import { identityFetch } from './identity.mjs?v=0.3.2'
|
|
3
3
|
|
|
4
4
|
const styles = `
|
|
5
5
|
.dt-work{--ink:light-dark(#20392d,#e3eee7);--muted:light-dark(#53695c,#a7b9ae);--edge:light-dark(#cbd7cf,#3b4a40);--surface:light-dark(#fff,#191f1d);--tint:light-dark(#eef7f0,#203329);--accent:light-dark(#236548,#b3e9cb);color:var(--ink);font:normal 14px/1.5 system-ui,sans-serif;text-align:start;display:grid;gap:16px;container-type:inline-size}
|
|
@@ -23,6 +23,20 @@ const styles = `
|
|
|
23
23
|
.dt-work button{width:auto;margin:0;border:1px solid var(--edge);border-radius:9px;padding:8px 14px;color:var(--ink);background:transparent;font:600 13px/1.4 system-ui;cursor:pointer}
|
|
24
24
|
.dt-work button:disabled{opacity:.5;cursor:default}.dt-work :focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
25
25
|
.dt-work [role=status]:empty{display:none}.dt-work [role=status]{font-size:13px}
|
|
26
|
+
.dt-work button.choice{position:relative;padding:18px 40px 18px 18px;gap:8px;border-radius:16px;transition:background .15s,border-color .15s}
|
|
27
|
+
.dt-work button.choice::after{content:'';position:absolute;right:16px;top:20px;width:14px;height:14px;border:1.5px solid var(--edge);border-radius:50%}
|
|
28
|
+
.dt-work button.choice[aria-pressed=true]::after{border:4px solid var(--accent);background:var(--surface)}
|
|
29
|
+
.dt-work .choice strong{font-size:16px}.dt-work .choice small{line-height:1.65}
|
|
30
|
+
.dt-work .agent-options{padding:18px;border:1px solid var(--edge);border-radius:16px;gap:18px;background:color-mix(in srgb,var(--surface) 94%,var(--accent))}
|
|
31
|
+
.dt-work .workspace-row{justify-content:flex-start;gap:10px}.dt-work .workspace-row select{flex:1;min-width:160px;max-width:360px}
|
|
32
|
+
.dt-work .fields{gap:16px}.dt-work label.field{gap:8px}.dt-work select{height:42px;border-radius:10px;padding:0 12px}
|
|
33
|
+
.dt-work .auto-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--edge)}
|
|
34
|
+
.dt-work .auto-row label{cursor:pointer;color:var(--ink);font-size:14px}
|
|
35
|
+
.dt-work button.auto-toggle{position:relative;flex:0 0 40px;width:40px;height:24px;min-height:24px;padding:0;border:1px solid var(--edge);border-radius:20px;background:var(--edge)}
|
|
36
|
+
.dt-work button.auto-toggle::after{content:'';position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:var(--surface);box-shadow:0 1px 3px #0003;transition:transform .16s}
|
|
37
|
+
.dt-work button.auto-toggle[aria-checked=true]{background:var(--accent);border-color:var(--accent)}
|
|
38
|
+
.dt-work button.auto-toggle[aria-checked=true]::after{transform:translateX(16px)}
|
|
39
|
+
.dt-work .auto-row small{color:var(--muted);font-size:12px}.dt-work .auto-copy{display:grid;gap:3px}
|
|
26
40
|
@container(max-width:390px){.dt-work .choices,.dt-work .fields{grid-template-columns:1fr}}
|
|
27
41
|
`
|
|
28
42
|
|
|
@@ -65,7 +79,13 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
65
79
|
const title=document.createElement('strong'),detail=document.createElement('small')
|
|
66
80
|
title.textContent=item.name;detail.textContent=item.description
|
|
67
81
|
if(value==='agent'&&(!config.work_mode_policy||config.work_mode_policy==='recommend_agent')){const badge=document.createElement('span');badge.className='badge';badge.textContent='推荐';title.append(badge)}
|
|
68
|
-
label.append(title,detail)
|
|
82
|
+
label.append(title,detail)
|
|
83
|
+
if(value==='agent'){
|
|
84
|
+
const warning=document.createElement('small'),emphasis=document.createElement('b')
|
|
85
|
+
const [before,after]=AGENT_WORKSPACE_NOTICE.split('只能');emphasis.textContent='只能'
|
|
86
|
+
warning.append(before,emphasis,after);label.append(warning,grant)
|
|
87
|
+
}
|
|
88
|
+
choices.append(label);cards[value]=label
|
|
69
89
|
}
|
|
70
90
|
const agent=document.createElement('div');agent.className='agent-options'
|
|
71
91
|
const permission=document.createElement('small');permission.className='permission';permission.id='dt-permission-'+crypto.randomUUID()
|
|
@@ -111,6 +131,15 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
111
131
|
}
|
|
112
132
|
const executor=modelSelect('任务模型','跟随 DSH 默认模型',config.agent_options?.executor_model)
|
|
113
133
|
fields.append(executor.label,executor.effort.label)
|
|
134
|
+
const autoRow=document.createElement('div');autoRow.className='auto-row'
|
|
135
|
+
const autoLabel=document.createElement('label');autoLabel.textContent='自动跳转会话'
|
|
136
|
+
const autoSwitch=document.createElement('button');autoSwitch.type='button';autoSwitch.setAttribute('role','switch');autoSwitch.setAttribute('aria-label','自动跳转会话')
|
|
137
|
+
autoSwitch.className='auto-toggle';autoSwitch.id='dt-auto-'+crypto.randomUUID();autoLabel.htmlFor=autoSwitch.id
|
|
138
|
+
const autoCopy=document.createElement('div');autoCopy.className='auto-copy'
|
|
139
|
+
const autoHelp=document.createElement('small');autoHelp.textContent='跟随任务,打开正在处理或刚完成的会话';autoCopy.append(autoLabel,autoHelp)
|
|
140
|
+
let autoEnabled=config.agent_options?.auto_switch_session!==false
|
|
141
|
+
const drawAuto=()=>{autoSwitch.setAttribute('aria-checked',String(autoEnabled));autoSwitch.title=autoEnabled?'关闭自动跳转':'开启自动跳转'}
|
|
142
|
+
drawAuto();autoRow.append(autoSwitch,autoCopy);agent.append(autoRow)
|
|
114
143
|
const advanced=document.createElement('details'),summary=document.createElement('summary');summary.textContent='高级设置 · 任务管理模型'
|
|
115
144
|
const manager=modelSelect('任务管理模型','与任务模型相同',config.agent_options?.manager_model)
|
|
116
145
|
const extra=document.createElement('div');extra.className='fields';extra.append(manager.label,manager.effort.label)
|
|
@@ -118,16 +147,22 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
118
147
|
const tasks=document.createElement('details')
|
|
119
148
|
if(!cancel&&!preview){
|
|
120
149
|
const title=document.createElement('summary'),list=document.createElement('ul'),refresh=document.createElement('button')
|
|
121
|
-
title.textContent='
|
|
150
|
+
title.textContent='会话与模型';refresh.type='button';refresh.textContent='刷新'
|
|
122
151
|
const load=async()=>{
|
|
123
152
|
refresh.disabled=true
|
|
124
153
|
try{
|
|
125
|
-
const rows=
|
|
154
|
+
const {rows=[],main}=await api('agent-tasks')
|
|
126
155
|
list.replaceChildren()
|
|
156
|
+
const append=(name,info)=>{
|
|
157
|
+
const li=document.createElement('li'),label=document.createElement('strong'),model=document.createElement('small')
|
|
158
|
+
label.textContent=name;model.textContent=taskModelLabel(info);model.style.cssText='display:block;overflow-wrap:anywhere;color:var(--muted)'
|
|
159
|
+
li.style.cssText='margin:10px 0;list-style:none';li.append(label,model);list.append(li)
|
|
160
|
+
}
|
|
161
|
+
if(main)append('dsh-duet 主会话',main.model_info)
|
|
127
162
|
for(const row of rows){
|
|
128
|
-
|
|
163
|
+
append((row.name||'未命名任务')+' · '+(TASK_STATES[row.state]||'状态待确认'),row.model_info)
|
|
129
164
|
}
|
|
130
|
-
if(!rows.length)list.textContent='还没有任务'
|
|
165
|
+
if(!rows.length&&!main)list.textContent='还没有任务'
|
|
131
166
|
}catch{list.textContent='暂时无法读取任务状态'}
|
|
132
167
|
finally{refresh.disabled=false}
|
|
133
168
|
}
|
|
@@ -151,6 +186,7 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
151
186
|
tasks.hidden=!activeAgent
|
|
152
187
|
agent.hidden=onboarding?draft!=='agent':!activeAgent&&!choosingAgent
|
|
153
188
|
fields.hidden=executor.label.hidden=advanced.hidden=!activeAgent
|
|
189
|
+
autoRow.hidden=!activeAgent
|
|
154
190
|
if(!activeAgent)executor.effort.label.hidden=true
|
|
155
191
|
workspace.input.options[0].disabled=activeAgent
|
|
156
192
|
permission.hidden=grant.hidden=activeAgent
|
|
@@ -162,7 +198,7 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
162
198
|
confirm.disabled=busy||!draft||(draft==='agent'&&!dedicated&&!workspace.input.value)
|
|
163
199
|
}
|
|
164
200
|
}
|
|
165
|
-
const restoreFields=()=>{const opts=config.agent_options;dedicated=!!dedicatedId&&dedicatedId===opts?.workspace_id;workspace.input.value=dedicated?'':opts?.workspace_id||'';executor.restore(opts?.executor_model);manager.restore(opts?.manager_model)}
|
|
201
|
+
const restoreFields=()=>{const opts=config.agent_options;dedicated=!!dedicatedId&&dedicatedId===opts?.workspace_id;workspace.input.value=dedicated?'':opts?.workspace_id||'';executor.restore(opts?.executor_model);manager.restore(opts?.manager_model);autoEnabled=opts?.auto_switch_session!==false;drawAuto()}
|
|
166
202
|
const persist=async(mode)=>{
|
|
167
203
|
if(busy||disposed)return
|
|
168
204
|
status.textContent=''
|
|
@@ -181,7 +217,7 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
181
217
|
if(disposed)return
|
|
182
218
|
const result=await api('config',{backend_url:current.backend_url,revision:current.revision,work_mode:mode,
|
|
183
219
|
agent_permission:mode==='agent',agent_options:mode==='agent'?{workspace_id:dedicated?dedicatedId:workspace.input.value,
|
|
184
|
-
executor_model:executor.value(),manager_model:manager.value()}:current.agent_options})
|
|
220
|
+
executor_model:executor.value(),manager_model:manager.value(),auto_switch_session:autoEnabled}:current.agent_options})
|
|
185
221
|
Object.assign(config,result);choosingAgent=false;restoreFields()
|
|
186
222
|
if(!disposed)saved(result)
|
|
187
223
|
}catch(error){if(!disposed){if(!onboarding){choosingAgent=false;restoreFields()}status.textContent=error.message}}
|
|
@@ -197,6 +233,7 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
|
|
|
197
233
|
dedicatedId=row.id;legacyTitle=false
|
|
198
234
|
}
|
|
199
235
|
confirm.onclick=()=>{if(!confirm.disabled)void persist(draft)}
|
|
236
|
+
autoSwitch.onclick=()=>{if(busy)return;autoEnabled=!autoEnabled;drawAuto();if(!onboarding)void persist('agent')}
|
|
200
237
|
create.onclick=async()=>{
|
|
201
238
|
if(busy||disposed)return
|
|
202
239
|
status.textContent=''
|
|
@@ -71,7 +71,11 @@ export class AgentConnection {
|
|
|
71
71
|
if(!this.present||this.closed||!this.source?.taskRows)return
|
|
72
72
|
// Presentation failure must never affect voice delivery.
|
|
73
73
|
try{
|
|
74
|
-
const rows=this.source.taskRows()
|
|
74
|
+
const rows=this.source.taskRows().map(row=>{
|
|
75
|
+
// Local notification identity; never send native ticket metadata upstream.
|
|
76
|
+
const ticket=this.source.runtime?.store?.tickets?.get?.(row.session_id?.replace(/^worker-/,''))
|
|
77
|
+
return ticket?.attention?.id?{...row,attention_id:ticket.attention.id}:row
|
|
78
|
+
})
|
|
75
79
|
const key=r=>r.task_id+':'+r.run_id
|
|
76
80
|
for(const r of rows)if(r.run_id && !r.finished_at && this.previousFinished?.has(key(r)))
|
|
77
81
|
this.focusedResults.delete(key(r))
|
|
@@ -91,6 +95,7 @@ export class AgentConnection {
|
|
|
91
95
|
if(serialized!==this.lastRows||focus){
|
|
92
96
|
if(focus)this.traceLab('view.focus_requested',{session_id:focus,reason:completed?'result':'acknowledgement'})
|
|
93
97
|
this.present({type:'duet.local.tasks',rows,focus:focus||null,
|
|
98
|
+
main_session_id:this.source.runtime?.masterId||null,
|
|
94
99
|
...(completed?{focus_reason:'result'}:{})});this.lastRows=serialized
|
|
95
100
|
}
|
|
96
101
|
}catch{/* Optional local view. */}
|
package/src/host/assets.mjs
CHANGED
|
@@ -26,6 +26,8 @@ const modules = {
|
|
|
26
26
|
avatar_menu: 'shared/avatar-menu', avatar_menu_ui: 'shared/avatar-menu-ui',
|
|
27
27
|
avatar_tasks: 'client/avatar-tasks',
|
|
28
28
|
agent_tasks: 'client/agent-tasks',
|
|
29
|
+
agent_entry: 'client/agent-entry',
|
|
30
|
+
agent_tool_views: 'client/agent-tool-views',
|
|
29
31
|
avatar_surface: 'shared/avatar-surface', avatar_surfaces: 'client/avatar-surfaces',
|
|
30
32
|
input_effect: 'client/input-effect',
|
|
31
33
|
}
|
package/src/host/plugin.mjs
CHANGED
|
@@ -676,8 +676,10 @@ export function apply(ctx, options = {}) {
|
|
|
676
676
|
const policy=effectiveWorkPolicy(settings.public(),await workPolicy.get())
|
|
677
677
|
if(policy.work_mode!=='agent'||policy.agent_permission_version!==1){sendJson(res,200,{rows:[]});return}
|
|
678
678
|
try{
|
|
679
|
-
const
|
|
680
|
-
|
|
679
|
+
const service=ctx.get('duetAgent'),workspace=policy.agent_options.workspace_id
|
|
680
|
+
const rows=await service.taskRows(workspace)
|
|
681
|
+
const main=await service.mainRow?.(workspace)??null
|
|
682
|
+
sendJson(res,200,{main,rows:rows.map(({name,state,session_id,finished_at,model_info})=>({name,state,model_info,
|
|
681
683
|
...(/^worker-[a-f0-9]{32}$/.test(session_id)?{session_id,finished_at}:{} )}))})
|
|
682
684
|
}catch{sendError(res,503,'任务状态暂不可用')}
|
|
683
685
|
return
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {avatarLocalState,avatarMenuAction,avatarMenuResult} from './avatar-menu.mjs'
|
|
2
|
-
import {sizeButton,nextAvatarSize} from './avatar-ui.mjs'
|
|
1
|
+
import {avatarLocalState,avatarMenuAction,avatarMenuResult,COMPLETION_NOTICE_MS} from './avatar-menu.mjs'
|
|
2
|
+
import {sizeButton,nextAvatarSize,taskBubbleCardStyle} from './avatar-ui.mjs'
|
|
3
3
|
const labels={completed:'本轮已完成',failed:'执行失败',stopped:'已停止',approval:'等待授权',question:'等待回答',plan_review:'等待方案确认'}
|
|
4
4
|
const names={small:'紧凑',medium:'标准',large:'宽松'}
|
|
5
|
-
export const noticeBadgeStyle='border:0;border-radius:12px;background:#dcefff;color:#185a89;font:12px system-ui;padding:4px 7px;cursor:pointer;pointer-events:auto'
|
|
6
5
|
const paths={open:'M14 3h7v7m0-7L10 14M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5',pending:'M8 4h8m-9 0H5v17h14V4h-2M8 3h8v4H8zM8 12h8m-8 4h5',bubble:'M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 3v-3H3V6a2 2 0 0 1 2-2zM7 9h10m-10 4h6',tutorial:'m9 5 10 7-10 7z',settings:'M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8M9 3h6l1 3 3 1 2 5-2 5-3 1-1 3H9l-1-3-3-1-2-5 2-5 3-1z',hide:'m4 4 16 16M9 5a11 11 0 0 1 12 7l-3 4M6 6a13 13 0 0 0-5 6s4 7 11 7l3-1M10 10a3 3 0 0 0 4 4',back:'m14 5-7 7 7 7'}
|
|
7
6
|
const icon=name=>{const s=document.createElementNS('http://www.w3.org/2000/svg','svg');s.setAttribute('viewBox','0 0 24 24');s.setAttribute('aria-hidden','true');s.innerHTML=`<path d="${paths[name]||paths.pending}"/>`;return s}
|
|
8
7
|
export function mountAvatarMenu({anchor,viewport=()=>[0,0,innerWidth,innerHeight],send,changed=()=>{}}){
|
|
9
|
-
let state={items:[],running:0,enabled:true,size:'large',bubble:'medium'},root,toast,
|
|
8
|
+
let state={items:[],running:0,enabled:true,size:'large',bubble:'medium'},root,toast,section='main',timer,dead=false,point,previous,toastId,ackTimer
|
|
10
9
|
const style=document.createElement('style');style.textContent=`
|
|
11
10
|
.duet-pet-menu{position:fixed;z-index:2147483601;box-sizing:border-box;width:264px;max-width:calc(100vw - 24px);padding:9px;border:1px solid #a7c5dc30;border-radius:18px;background:#142330f7;color:#eaf2f8;font:13px/1.5 Inter,"PingFang SC",sans-serif;box-shadow:0 16px 48px #0004,0 2px 8px #0002;backdrop-filter:blur(20px);pointer-events:auto;overflow:auto}
|
|
12
11
|
.duet-pet-menu button{position:relative;display:flex;align-items:center;justify-content:flex-start;gap:10px;box-sizing:border-box;width:100%;min-height:39px;margin:0;border:0;border-radius:10px;padding:8px 11px;background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer;height:auto;flex-shrink:0;letter-spacing:normal}
|
|
13
12
|
.duet-pet-menu button>[data-label]{min-width:0;flex:1;overflow-wrap:anywhere}
|
|
14
13
|
.duet-pet-menu button>svg,.duet-pet-menu [data-size-icon]{display:flex;align-items:center;justify-content:center;width:20px;height:20px;flex:0 0 20px}
|
|
15
|
-
[data-duet-notice-badge][hidden]{display:none!important}
|
|
16
14
|
.duet-pet-menu button:hover,.duet-pet-menu button:focus-visible{background:#b3daff16;outline:none}
|
|
17
15
|
.duet-pet-menu svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0;color:#a7bdd0}
|
|
18
16
|
.duet-pet-menu [data-wordmark]{font:700 28px/1.1 Inter,"PingFang SC",sans-serif;letter-spacing:-1.1px;padding:11px 12px 15px}
|
|
@@ -34,8 +32,7 @@ export function mountAvatarMenu({anchor,viewport=()=>[0,0,innerWidth,innerHeight
|
|
|
34
32
|
if(paths[iconName])b.append(icon(iconName));const t=document.createElement('span');t.dataset.label='';t.textContent=label;b.append(t)
|
|
35
33
|
b.onclick=()=>{if(['pending','bubble_panel','back'].includes(action)){section=action==='back'?'main':action;render();return}close();command(action,undefined,id)};return b
|
|
36
34
|
}
|
|
37
|
-
const
|
|
38
|
-
const countLabel=()=>{const n=unreadCount();return '待处理事项与通知'+(n?`(${n})`:'')}
|
|
35
|
+
const countLabel=()=> '待处理事项与通知'
|
|
39
36
|
const valueSpan=b=>{const v=document.createElement('span');v.dataset.value='';b.append(v);return v}
|
|
40
37
|
const refreshControls=()=>{
|
|
41
38
|
if(!root)return
|
|
@@ -74,14 +71,35 @@ export function mountAvatarMenu({anchor,viewport=()=>[0,0,innerWidth,innerHeight
|
|
|
74
71
|
const keys=e=>{if(!root)return;if(e.key==='Escape'){e.preventDefault();e.stopImmediatePropagation();close();return}const buttons=[...root.querySelectorAll('button')],index=buttons.indexOf(document.activeElement);if(['ArrowDown','ArrowUp','Home','End','Tab'].includes(e.key)){e.preventDefault();buttons[e.key==='Home'?0:e.key==='End'?buttons.length-1:(index+(e.key==='ArrowUp'||e.key==='Tab'&&e.shiftKey?-1:1)+buttons.length)%buttons.length]?.focus()}}
|
|
75
72
|
const decorate=(node,label)=>{node.className='duet-pet-menu';node.setAttribute('aria-label',label)}
|
|
76
73
|
const update=value=>{
|
|
77
|
-
state=avatarLocalState(value)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
state=avatarLocalState(value)
|
|
75
|
+
if(toastId!==state.toast){
|
|
76
|
+
clearTimeout(timer);clearTimeout(ackTimer);toast?.remove();toast=null;toastId=state.toast
|
|
77
|
+
const item=state.items.find(i=>i.id===state.toast)
|
|
78
|
+
if(item){
|
|
79
|
+
toast=document.createElement('section');toast.dataset.duetLocalNotice=''
|
|
80
|
+
if(item.status==='completed'){
|
|
81
|
+
toast.setAttribute('aria-label','DSH 任务通知');toast.setAttribute('role','status')
|
|
82
|
+
toast.style.cssText='position:fixed;z-index:2147483600;width:264px;max-width:calc(100vw - 24px);pointer-events:auto'
|
|
83
|
+
const card=document.createElement('button');card.type='button';card.dataset.completionCard='';card.style.cssText=taskBubbleCardStyle
|
|
84
|
+
const check=document.createElement('span');check.textContent='✓';check.setAttribute('aria-hidden','true')
|
|
85
|
+
check.style.cssText='flex:0 0 18px;width:18px;height:18px;border-radius:50%;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui'
|
|
86
|
+
const copy=document.createElement('span'),name=document.createElement('strong'),status=document.createElement('small')
|
|
87
|
+
copy.style.cssText='min-width:0;overflow-wrap:anywhere';name.textContent=item.name||'未命名会话';name.style.cssText='display:block;font-size:13px;font-weight:550'
|
|
88
|
+
status.textContent='已完成';status.style.cssText='display:block;font-size:11px;opacity:.7'
|
|
89
|
+
copy.append(name,status);card.append(check,copy);card.setAttribute('aria-label',`${name.textContent} · 已完成,查看会话`)
|
|
90
|
+
card.onclick=()=>command('view',undefined,item.id);toast.append(card)
|
|
91
|
+
}else{
|
|
92
|
+
decorate(toast,'DSH 任务通知');const p=document.createElement('div');p.dataset.noticeTitle='';p.textContent=`${item.name||'未命名会话'} · ${labels[item.status]}`
|
|
93
|
+
toast.append(p,row(item.pending?'去处理':'查看','view','open',item.id),row('收起','dismiss','hide',item.id))
|
|
94
|
+
}
|
|
95
|
+
document.body.append(toast);place(toast)
|
|
96
|
+
if(!item.pending)timer=setTimeout(()=>{toast?.remove();toast=null;changed()},item.status==='completed'?COMPLETION_NOTICE_MS:8000)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
81
99
|
refreshControls();changed()
|
|
82
100
|
}
|
|
83
101
|
const result=value=>{const r=avatarMenuResult(value);if(!r.message)return;clearTimeout(ackTimer);toast?.remove();toast=document.createElement('section');decorate(toast,'操作提示');toast.textContent=r.message;document.body.append(toast);place(toast);changed();ackTimer=setTimeout(()=>{toast?.remove();toast=null;changed()},4000)}
|
|
84
102
|
const reposition=()=>{if(root)place(root);if(toast)place(toast)}
|
|
85
103
|
document.addEventListener('pointerdown',outside,true);document.addEventListener('keydown',keys,true);window.addEventListener('resize',reposition);window.addEventListener('blur',close)
|
|
86
|
-
return{open,close,update,result,get active(){return Boolean(root)},regions(){return[root,toast
|
|
104
|
+
return{open,close,update,result,get active(){return Boolean(root)},regions(){return[root,toast].filter(n=>n?.isConnected&&!n.hidden).map(n=>{const r=n.getBoundingClientRect();return[r.x,r.y,r.width,r.height]})},dispose(){dead=true;close();style.remove();clearTimeout(timer);clearTimeout(ackTimer);toast?.remove();document.removeEventListener('pointerdown',outside,true);document.removeEventListener('keydown',keys,true);window.removeEventListener('resize',reposition);window.removeEventListener('blur',close)}}
|
|
87
105
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Local-only presentation protocol. No remote URLs, credentials or executable payloads. */
|
|
2
2
|
export const AVATAR_LOCAL_PROTOCOL='avatar_local_v1'
|
|
3
3
|
export const NOTICE_KEY='dsh.duet.avatar.notices.v1'
|
|
4
|
+
export const COMPLETION_NOTICE_MS=3000
|
|
4
5
|
export const MENU_ACTIONS=['open_dsh','pending','settings','tutorial','hide','notifications','size','bubble','view','dismiss']
|
|
5
6
|
const sizes=['small','medium','large'], statuses=['completed','failed','stopped','approval','question','plan_review']
|
|
6
7
|
export function noticePreferences(storage=globalThis.localStorage){
|
|
@@ -62,7 +63,8 @@ export class AvatarNotices {
|
|
|
62
63
|
const status=job.turn_end_reason==='aborted'?'stopped':job.status==='failed'?'failed':job.status==='succeeded'&&job.turn_end_reason==='completed'?'completed':null
|
|
63
64
|
if(!status)continue
|
|
64
65
|
const row=allowed.get(job.session_id)
|
|
65
|
-
this.items.set(id,{id,order:++this.order,session_id:job.session_id,name:row.label,status,summary:status==='failed'?text(job.error,240):'',pending:false,unread:
|
|
66
|
+
this.items.set(id,{id,order:++this.order,session_id:job.session_id,name:row.label,status,summary:status==='failed'?text(job.error,240):'',pending:false,unread:status!=='completed',
|
|
67
|
+
...(status==='completed'?{expiresAt:Date.now()+COMPLETION_NOTICE_MS}:{})})
|
|
66
68
|
this.toast=id;this.toastAt=Date.now()
|
|
67
69
|
}
|
|
68
70
|
while(this.seen.size>1024)this.seen.delete(this.seen.values().next().value)
|
|
@@ -78,6 +80,7 @@ export class AvatarNotices {
|
|
|
78
80
|
}
|
|
79
81
|
dismiss(id){if(this.items.has(id))this.dismissed.add(id);if(this.toast===id)this.toast=null;this.revision++}
|
|
80
82
|
state(prefs,size,available=true){
|
|
83
|
+
for(const [id,item]of this.items)if(item.expiresAt && Date.now()>=item.expiresAt){this.items.delete(id);if(this.toast===id)this.toast=null}
|
|
81
84
|
const pending=[...this.items.values()].find(i=>i.pending&&i.unread&&!this.dismissed.has(i.id))
|
|
82
85
|
const toast=pending?.id??(Date.now()-this.toastAt<=8000?this.toast:null)
|
|
83
86
|
return avatarLocalState({type:'local_state',protocol:AVATAR_LOCAL_PROTOCOL,revision:this.revision,items:[...this.items.values()],
|
|
@@ -11,6 +11,7 @@ export function avatarSurface(value) {
|
|
|
11
11
|
length+=n.text.length;if(length>10000)throw Error('invalid_surface')
|
|
12
12
|
const node={kind:n.kind,text:n.text}
|
|
13
13
|
if(['running','completed','waiting','failed','stopped'].includes(n.taskState))node.taskState=n.taskState
|
|
14
|
+
if(n.kind==='button'&&n.taskState==='completed'&&Number.isInteger(n.countdown)&&n.countdown>=0&&n.countdown<=10)node.countdown=n.countdown
|
|
14
15
|
if(n.kind==='button'||n.kind==='checkbox') {
|
|
15
16
|
if(!/^a\d+$/.test(n.action))throw Error('invalid_surface')
|
|
16
17
|
Object.assign(node,{action:n.action,disabled:n.disabled===true,checked:n.checked===true,gesture:n.gesture===true,label:String(n.label||'').slice(0,100)})
|