dsh-duet 0.1.10 → 0.2.1

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.
Files changed (66) hide show
  1. package/README.md +19 -1
  2. package/assets/avatar/THREE-LICENSE.txt +21 -0
  3. package/assets/avatar/character.glb +0 -0
  4. package/assets/avatar/desktop/character.glb +0 -0
  5. package/assets/avatar/desktop/companion.mjs +18 -0
  6. package/assets/avatar/desktop/index.html +33 -0
  7. package/assets/avatar/desktop/manifest.json +10 -0
  8. package/assets/avatar/desktop/portrait.png +0 -0
  9. package/assets/avatar/desktop/renderer.mjs +4230 -0
  10. package/assets/avatar/portrait.png +0 -0
  11. package/assets/avatar/renderer.mjs +4230 -0
  12. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/Info.plist +36 -0
  13. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
  14. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/Resources/duet companion.icns +0 -0
  15. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/_CodeSignature/CodeResources +128 -0
  16. package/desktop/bin/darwin-arm64/manifest.json +14 -0
  17. package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
  18. package/desktop/bin/win32-x64/manifest.json +11 -0
  19. package/package.json +17 -5
  20. package/src/avatar/companion.html +33 -0
  21. package/src/avatar/companion.mjs +210 -0
  22. package/src/avatar/idle.mjs +9 -0
  23. package/src/avatar/lipsync.mjs +13 -0
  24. package/src/avatar/motion.mjs +93 -0
  25. package/src/avatar/renderer.mjs +90 -0
  26. package/src/avatar/surface.mjs +45 -0
  27. package/src/avatar/toolbar.mjs +49 -0
  28. package/src/client/audio.mjs +68 -3
  29. package/src/client/avatar-surfaces.mjs +83 -0
  30. package/src/client/avatar-tasks.mjs +68 -0
  31. package/src/client/avatar.mjs +218 -0
  32. package/src/client/browser.mjs +83 -35
  33. package/src/client/composer-bridge.mjs +5 -2
  34. package/src/client/connection-hint.mjs +2 -1
  35. package/src/client/consent.mjs +3 -1
  36. package/src/client/controls-layout.mjs +21 -9
  37. package/src/client/entry.js +26 -3
  38. package/src/client/feedback.mjs +19 -4
  39. package/src/client/identity.mjs +2 -2
  40. package/src/client/input-effect.mjs +51 -0
  41. package/src/client/notice.mjs +20 -4
  42. package/src/client/rpc.mjs +2 -1
  43. package/src/client/settings.html +124 -4
  44. package/src/client/transport.mjs +2 -2
  45. package/src/client/tutorial-adapter.mjs +4 -4
  46. package/src/client/tutorial.mjs +5 -3
  47. package/src/client/voices.mjs +137 -0
  48. package/src/host/assets.mjs +13 -0
  49. package/src/host/avatar-activity.mjs +24 -0
  50. package/src/host/avatar-assets.mjs +18 -0
  51. package/src/host/avatar.mjs +130 -0
  52. package/src/host/diagnostics.mjs +111 -7
  53. package/src/host/feedback-files.mjs +5 -1
  54. package/src/host/plugin.mjs +59 -4
  55. package/src/host/proxy.mjs +41 -6
  56. package/src/host/settings-migration.mjs +2 -1
  57. package/src/host/settings.mjs +19 -4
  58. package/src/host/voices.mjs +205 -0
  59. package/src/shared/avatar-activity.mjs +33 -0
  60. package/src/shared/avatar-menu-ui.mjs +85 -0
  61. package/src/shared/avatar-menu.mjs +83 -0
  62. package/src/shared/avatar-surface.mjs +24 -0
  63. package/src/shared/avatar-ui.mjs +91 -0
  64. package/src/shared/avatar.mjs +125 -0
  65. package/src/shared/nickname.mjs +13 -0
  66. package/src/shared/state.mjs +15 -4
@@ -1,9 +1,12 @@
1
1
  /** Optional, explicit rating; never opens voice or submits without a user click. */
2
- import { identityFetch } from './identity.mjs?v=0.1.10'
2
+ import { identityFetch } from './identity.mjs?v=0.2.1'
3
3
 
4
- export function mountRating(anchor, sessionTicket) {
4
+ export function mountRating(anchor, sessionTicket, {origin='page'} = {}) {
5
5
  if(!sessionTicket)return null
6
6
  const panel=document.createElement('section')
7
+ // Page ratings are never eligible for avatar projection, including older bridges.
8
+ if(origin==='avatar')panel.dataset.duetAvatarSurface='60'
9
+ panel.dataset.duetSurfaceOrigin=origin
7
10
  panel.setAttribute('role','region');panel.setAttribute('aria-label','本次语音体验评分')
8
11
  panel.style.cssText='position:fixed;z-index:100020;width:min(300px,calc(100vw - 24px));box-sizing:border-box;background:#17212f;color:#edf3ff;border:1px solid #52647d;border-radius:16px;padding:16px;box-shadow:0 12px 40px #0006;font:14px/1.6 system-ui'
9
12
  const title=document.createElement('h3');title.textContent='这次语音体验怎么样?';title.style.margin='0 0 10px';panel.append(title)
@@ -19,10 +22,22 @@ export function mountRating(anchor, sessionTicket) {
19
22
  const submit=document.createElement('button');submit.type='button';submit.textContent='提交评分';submit.disabled=true
20
23
  submit.style.cssText='border:0;border-radius:8px;background:#b3e9cb;color:#152a1e;padding:8px 14px;cursor:pointer'
21
24
  const skip=document.createElement('button');skip.type='button';skip.textContent='暂不评价(10s)';skip.style.cssText='border:0;background:transparent;color:#b9c9dc;padding:8px 14px;cursor:pointer'
25
+ skip.dataset.duetLiveText='';skip.setAttribute('aria-label','暂不评价')
22
26
  const position=()=>{
23
27
  const rect=anchor.getBoundingClientRect(),box=panel.getBoundingClientRect()
24
- panel.style.left=Math.max(12,Math.min(rect.left,innerWidth-box.width-12))+'px'
25
- panel.style.top=(rect.top>=box.height+20?rect.top-box.height-12:rect.bottom+12)+'px'
28
+ let left=Math.max(12,Math.min(rect.left,innerWidth-box.width-12))
29
+ let top=rect.top>=box.height+20?rect.top-box.height-12:rect.bottom+12
30
+ const avatar=origin==='page'?document.querySelector('[data-duet-avatar]:not([hidden])'):null
31
+ if(avatar){
32
+ const a=avatar.getBoundingClientRect()
33
+ if(left<a.right&&left+box.width>a.left&&top<a.bottom&&top+box.height>a.top){
34
+ if(Math.max(rect.right,a.right)+12+box.width<=innerWidth-12)left=Math.max(rect.right,a.right)+12
35
+ else if(Math.min(rect.left,a.left)-box.width-12>=12)left=Math.min(rect.left,a.left)-box.width-12
36
+ else top=a.top>=box.height+24?a.top-box.height-12:a.bottom+12
37
+ }
38
+ }
39
+ panel.style.left=left+'px'
40
+ panel.style.top=Math.max(12,Math.min(top,innerHeight-box.height-12))+'px'
26
41
  }
27
42
  let countdown,timeout
28
43
  const dispose=()=>{disposed=true;clearInterval(countdown);clearTimeout(timeout);clearTimeout(requestTimeout);requestController?.abort();panel.remove();document.removeEventListener('keydown',onKey);window.removeEventListener('resize',position);window.removeEventListener('scroll',position,true)}
@@ -1,5 +1,5 @@
1
1
  import { IDENTITY_HEADER, IDENTITY_TRANSPORT_HEADER, IDENTITY_TRANSPORT, IDENTITY_STORAGE,
2
- VOICE_PROTOCOL, IDENTITY_PROTOCOL_PREFIX, validIdentityToken } from '../shared/identity.mjs?v=0.1.10'
2
+ VOICE_PROTOCOL, IDENTITY_PROTOCOL_PREFIX, validIdentityToken } from '../shared/identity.mjs?v=0.2.1'
3
3
 
4
4
  /** Desktop strips plugin cookies. Keep the Host-signed value in its origin storage. */
5
5
  export function createIdentityClient(globals = globalThis) {
@@ -10,7 +10,7 @@ export function createIdentityClient(globals = globalThis) {
10
10
  }
11
11
  async function fetchIdentity(path, options = {}) {
12
12
  if (!desktop()) return globals.fetch(path, options)
13
- if (!['/duplex-control/api/voice/config', '/duplex-control/api/feedback'].includes(path)) {
13
+ if (!['/duplex-control/api/voice/config', '/duplex-control/api/voices', '/duplex-control/api/feedback', '/duplex-control/api/duet/nickname', '/duplex-control/api/avatar/activity'].includes(path)) {
14
14
  return globals.fetch(path, options)
15
15
  }
16
16
  const config = path.endsWith('/voice/config') && (!options.method || options.method === 'GET')
@@ -0,0 +1,51 @@
1
+ /** Local, post-commit feedback only. Never delays a write or submits a draft. */
2
+ export function mountInputEffect({anchor, isCurrent, target = composerTarget}) {
3
+ let current, disposed=false
4
+ const clear=()=>{
5
+ const item=current;current=null
6
+ if(!item)return
7
+ clearTimeout(item.timer);clearInterval(item.watch);item.animation?.cancel();item.node.remove()
8
+ }
9
+ const show=(text,sessionId)=>{
10
+ clear()
11
+ if(disposed || !text || !isCurrent(sessionId) || document.hidden)return
12
+ const source=anchor()?.getBoundingClientRect()
13
+ if(!source || !source.width || !source.height)return
14
+ const node=document.createElement('div');node.dataset.duetInputEffect='';node.dataset.phase='preview'
15
+ node.setAttribute('role','status');node.setAttribute('aria-label','已写入输入框')
16
+ node.style.cssText='position:fixed;z-index:100020;pointer-events:none;box-sizing:border-box;width:260px;max-width:calc(100vw - 16px);padding:11px 13px;border:1px solid #7cb8e566;border-radius:15px;background:light-dark(#eef8ff,#172d40);color:light-dark(#194a6a,#e0f2ff);color-scheme:light dark;box-shadow:0 8px 26px #0002;display:flex;gap:9px;align-items:flex-start;font:13px/1.6 system-ui;transform-origin:center'
17
+ const icon=document.createElement('span')
18
+ icon.innerHTML='<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="5" width="20" height="14" rx="3"/><path d="M6 9h.01M10 9h.01M14 9h.01M18 9h.01M6 12h.01M10 12h.01M14 12h.01M18 12h.01M7 15h10"/></svg>'
19
+ const words=document.createElement('span');words.dataset.duetInputText=''
20
+ words.style.cssText='min-width:0;max-height:126px;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere'
21
+ words.textContent=text.length>600?text.slice(0,600)+'…':text
22
+ node.append(icon,words);document.body.append(node)
23
+ node.style.left=`${Math.max(8,Math.min(source.left,innerWidth-node.offsetWidth-8))}px`
24
+ node.style.top=`${Math.max(8,Math.min(source.top-node.offsetHeight-10,innerHeight-node.offsetHeight-8))}px`
25
+ const item=current={node,animation:null}
26
+ item.watch=setInterval(()=>{if(!isCurrent(sessionId)||document.hidden)clear()},100)
27
+ item.timer=setTimeout(()=>{
28
+ if(current!==item || !isCurrent(sessionId)){clear();return}
29
+ const destination=target(),to=destination?.getBoundingClientRect(),from=node.getBoundingClientRect()
30
+ const visible=to&&to.width>0&&to.height>0&&to.bottom>0&&to.top<innerHeight&&to.right>0&&to.left<innerWidth
31
+ const dx=visible?to.left+to.width/2-from.left-from.width/2:0
32
+ const dy=visible?to.top+to.height/2-from.top-from.height/2:-10
33
+ node.dataset.phase=visible?'flying':'fading'
34
+ item.animation=node.animate([
35
+ {transform:'translate(0,0) scale(1)',opacity:1},
36
+ {transform:`translate(${dx}px,${dy}px) scale(${visible?.12:.98})`,opacity:0},
37
+ ],{duration:visible?520:220,easing:'cubic-bezier(.4,0,.3,1)',fill:'forwards'})
38
+ item.animation.finished.then(()=>{if(current===item)clear()},()=>{})
39
+ },900)
40
+ }
41
+ return {show,clear,dispose(){disposed=true;clear()}}
42
+ }
43
+
44
+ /** Only known DSH composer surfaces; never select a search/settings field. */
45
+ export function composerTarget() {
46
+ const nodes=[...document.querySelectorAll('[data-composer-input]')].filter(node=>{
47
+ const r=node.getBoundingClientRect(),s=getComputedStyle(node)
48
+ return r.width>0&&r.height>0&&r.bottom>0&&r.top<innerHeight&&s.visibility!=='hidden'&&s.display!=='none'
49
+ })
50
+ return nodes.find(node=>node===document.activeElement||node.contains(document.activeElement)) || (nodes.length===1?nodes[0]:null)
51
+ }
@@ -2,10 +2,11 @@
2
2
  export function mountNotice(anchor) {
3
3
  const panel = document.createElement('div')
4
4
  panel.dataset.duetNotice = ''
5
+ panel.dataset.duetAvatarSurface = '70'
5
6
  panel.setAttribute('role', 'status')
6
7
  panel.setAttribute('aria-live', 'polite')
7
8
  panel.hidden = true
8
- panel.style.cssText = 'position:fixed;z-index:100021;box-sizing:border-box;width:280px;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);overflow:auto;background:#252c38;color:white;padding:14px;border:1px solid #52647d;border-radius:12px;font:13px/1.6 system-ui;box-shadow:0 8px 28px #0005;overflow-wrap:anywhere'
9
+ panel.style.cssText = 'position:fixed;z-index:100021;box-sizing:border-box;width:320px;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);overflow:auto;background:#eff9ff;color:#163c56;padding:16px;border:1px solid #a5d8f4;border-radius:12px;font:13px/1.65 system-ui,sans-serif;box-shadow:0 8px 28px #153e6524;overflow-wrap:anywhere'
9
10
  document.body.append(panel)
10
11
  let timer, disposed = false
11
12
  const hide = () => { panel.hidden = true; clearTimeout(timer) }
@@ -25,20 +26,35 @@ export function mountNotice(anchor) {
25
26
  const observer = new ResizeObserver(position)
26
27
  observer.observe(panel)
27
28
  return {
28
- show(text, {upgrade = false} = {}) {
29
+ show(text, {upgrade = false, releaseNotes} = {}) {
29
30
  if (disposed) return
30
31
  clearTimeout(timer); panel.textContent = text; panel.hidden = false
31
32
  if (upgrade) {
33
+ panel.textContent = ''
34
+ const heading=document.createElement('strong');heading.textContent='更新 duet';heading.style.cssText='display:block;font-size:15px;margin-bottom:6px'
35
+ const message=document.createElement('p');message.textContent=text;message.style.cssText='margin:0 0 12px'
36
+ panel.append(heading,message)
37
+ if(typeof releaseNotes==='string' && releaseNotes.trim()){
38
+ const label=document.createElement('strong');label.textContent='更新内容';label.style.fontSize='12px'
39
+ const notes=document.createElement('p');notes.dataset.duetReleaseNotes='';notes.textContent=releaseNotes.slice(0,1000).trim()
40
+ notes.style.cssText='white-space:pre-wrap;margin:6px 0 14px;padding:10px 12px;border-radius:8px;background:#ffffffa8'
41
+ panel.append(label,notes)
42
+ }
32
43
  const help = document.createElement('details'), title = document.createElement('summary')
44
+ help.style.cssText='border-top:1px solid #a5d8f4;padding-top:10px'
45
+ title.style.cssText='cursor:pointer;font-weight:600'
33
46
  title.textContent = '如何升级'; help.append(title)
34
47
  const before = document.createElement('p'), command = document.createElement('code'), after = document.createElement('p')
35
48
  before.textContent = '通过 npm 安装的用户,可在终端运行:'
36
49
  command.textContent = 'dsh plugin --profile web add dsh-duet@latest'
37
- command.style.cssText = 'display:block;white-space:normal;margin:8px 0'
50
+ command.style.cssText = 'display:block;white-space:normal;margin:8px 0;padding:10px;border-radius:8px;background:#ffffffa8;user-select:text;font:12px/1.6 monospace'
38
51
  after.textContent = '其他安装方式请从原来源更新。完成后重启 DSH 并刷新页面,再手动开启语音。'
39
52
  help.append(before, command, after); panel.append(help)
40
53
  help.addEventListener('toggle', position)
41
- const close = document.createElement('button'); close.type = 'button'; close.textContent = '知道了'; close.onclick = hide; panel.append(close)
54
+ const actions=document.createElement('div');actions.style.cssText='display:flex;justify-content:flex-end;margin-top:14px'
55
+ const close = document.createElement('button'); close.type = 'button'; close.textContent = '知道了'; close.onclick = hide
56
+ close.style.cssText='font:inherit;padding:7px 15px;border-radius:8px;border:1px solid #a5d8f4;background:#dcefff;color:#185a89;cursor:pointer'
57
+ actions.append(close);panel.append(actions)
42
58
  } else timer = setTimeout(hide, 8000)
43
59
  position()
44
60
  },
@@ -4,7 +4,7 @@ const MAX_BYTES = 2_000_000
4
4
  // Only colons may be escaped in a session segment: never decode arbitrary paths.
5
5
  const SESSION = '(?:[A-Za-z0-9_:-]|%3[Aa]){1,256}'
6
6
  const READ = new RegExp(`^/api/(?:health|sessions|jobs|results|interactions|composer/focused|sessions/${SESSION}/(?:composer|execution))$`)
7
- const WRITE = new RegExp(`^/api/(?:sessions|sessions/${SESSION}/(?:composer/submit|activate|rename|fork|cancel)|interactions/(?:(?:question|approval)(?::|%3[Aa])(?:[A-Za-z0-9_:-]|%3[Aa]){1,1024}|[A-Za-z0-9_-]{1,256})/respond)$`)
7
+ const WRITE = new RegExp(`^/api/(?:duet/nickname|sessions|sessions/${SESSION}/(?:composer/submit|activate|rename|fork|cancel)|interactions/(?:(?:question|approval)(?::|%3[Aa])(?:[A-Za-z0-9_:-]|%3[Aa]){1,1024}|[A-Za-z0-9_-]{1,256})/respond)$`)
8
8
  const sessionRoute = (path, suffix) => new RegExp(`^/api/sessions/${SESSION}/${suffix}$`).test(path)
9
9
 
10
10
  // Navigate only the connection-owning page after a successful mutation.
@@ -121,6 +121,7 @@ export class HarnessRPCExecutor {
121
121
  this.stopSupported = body.duet_rpc_capabilities?.includes('stop_task_v1') === true
122
122
  && typeof this.binding.focused === 'function'
123
123
  body.duet_rpc_capabilities = ['create_session_v1',
124
+ ...(body.duet_rpc_capabilities?.includes('rename_duet_v1') ? ['rename_duet_v1'] : []),
124
125
  ...(this.stopSupported ? ['stop_task_v1'] : []),
125
126
  ...(this.binding.syncSupported?.() === false ? [] : ['harness_sync_v1'])]
126
127
  // Both startup prompt and nth_N resolution read this same browser-local
@@ -89,6 +89,67 @@
89
89
  <div id="settingsMessage" role="status" style="margin-top:10px"></div>
90
90
  </details>
91
91
  </section>
92
+ <section class="panel" style="margin-bottom:18px">
93
+ <h2>助手昵称</h2>
94
+ <label for="assistantNickname">给助手起个名字</label>
95
+ <input id="assistantNickname" type="text" placeholder="duet" autocomplete="off">
96
+ <p class="section-note">最多 5 个汉字或 2 个英文单词;中英文混用时最多 5 个字符。</p>
97
+ <button id="saveNickname" type="button" disabled>保存昵称</button>
98
+ <p id="nicknameStatus" class="muted" role="status" aria-live="polite"></p>
99
+ </section>
100
+ <section class="panel" style="margin-bottom:18px">
101
+ <h2>音色</h2>
102
+ <div id="duetVoices">
103
+ <p data-availability role="status" hidden></p>
104
+ <label for="duetVoiceChoice">选择音色</label>
105
+ <select id="duetVoiceChoice" data-choice disabled><option value="default">默认音色</option></select>
106
+ <p class="section-note">选择后,下次开启语音时生效。最多添加 5 个自定义音色。</p>
107
+ <button data-remove type="button" class="secondary" hidden>移除此音色</button>
108
+ <div data-recovery hidden>
109
+ <p data-voice-issue role="status"></p>
110
+ <div data-reupload-fields hidden>
111
+ <p class="muted">可使用本机保存的原音频重新上传;如果本机文件也已丢失,请重新选择最初上传的同一份文件。恢复不会重新识别或更改你修正过的文字。</p>
112
+ <input data-reupload-file type="file" accept="audio/wav,audio/mpeg,audio/mp4,.m4a">
113
+ <button data-reupload type="button">重新上传并恢复音色</button>
114
+ </div>
115
+ <button data-recovery-back type="button" class="secondary">返回</button>
116
+ <button data-recovery-remove type="button" class="secondary">移除此音色</button>
117
+ </div>
118
+ <div data-create hidden style="margin-top:16px;padding-top:16px;border-top:1px solid #334266">
119
+ <h3 style="margin-top:0;font-size:14px">新增音色</h3>
120
+ <div data-upload-fields>
121
+ <p class="section-note">上传一段 3–15 秒、清晰无背景音乐的 WAV、MP3 或 M4A,不超过 10 MB。</p>
122
+ <label>音色名称<input data-name maxlength="40" placeholder="例如:我的声音"></label>
123
+ <label>参考音频<input data-file type="file" accept="audio/wav,audio/mpeg,audio/mp4,.wav,.mp3,.m4a"></label>
124
+ <label><input data-consent type="checkbox" style="width:auto"> 我有权使用该音频,并同意上传用于识别和音色合成。</label>
125
+ <button data-upload type="button">上传并自动识别</button>
126
+ </div>
127
+ <div data-editor hidden>
128
+ <p data-uploaded-name></p>
129
+ <label for="duetVoiceTranscript">音频中说的话</label>
130
+ <p id="duetVoiceTextHelp" class="section-note">上传的音频中说了什么文本,如果自动识别有误请修改准确,否则影响合成效果。</p>
131
+ <textarea id="duetVoiceTranscript" data-text maxlength="400" rows="3" aria-describedby="duetVoiceTextHelp" placeholder="请填写上传音频中说的完整原话"></textarea>
132
+ <p data-recognition role="status" aria-live="polite" class="muted"></p>
133
+ <button data-refresh type="button" class="secondary" hidden>刷新识别结果</button>
134
+ <button data-save type="button">保存并使用此音色</button>
135
+ <button data-remove-draft type="button" class="secondary" style="margin-top:8px">移除此音色</button>
136
+ </div>
137
+ <button data-cancel type="button" class="secondary" style="margin-top:8px">取消</button>
138
+ </div>
139
+ <p data-status role="status" aria-live="polite"></p>
140
+ </div>
141
+ </section>
142
+ <section class="panel" style="margin-bottom:18px">
143
+ <h2>3D 形象</h2>
144
+ <label><input id="avatarEnabled" type="checkbox" style="width:auto"> 打开3D形象(实验)</label>
145
+ <label><input id="avatarWebOnly" type="checkbox" style="width:auto"> 仅在网页端显示(适用于dsh装在服务器)</label>
146
+ <label for="avatarSize">形象大小</label>
147
+ <button id="avatarSize" type="button" style="display:inline-flex;align-items:center;gap:10px;width:auto"></button>
148
+ <p class="section-note">形象可以陪伴在桌面上,也可以显示在 duet 栏上方。打开形象不会开启语音。</p>
149
+ <p id="avatarPresentationStatus" class="muted" role="status">当前显示:等待 DSH 页面连接</p>
150
+ <button id="avatarRetryDesktop" type="button" hidden>重试桌面显示</button>
151
+ <p id="avatarSettingsStatus" class="muted" role="status"></p>
152
+ </section>
92
153
  <section class="panel" style="margin-bottom:18px">
93
154
  <h2>麦克风</h2>
94
155
  <label for="microphoneDevice">交互模式使用的设备</label>
@@ -152,13 +213,50 @@
152
213
  <footer><span>duet / DeepSeek Harness</span></footer>
153
214
  </main>
154
215
  <script type="module">
155
- import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.1.10';
216
+ import { AVATAR_KEY, AVATAR_PRESENTATION_LABELS, avatarPreferences, saveAvatarPreferences } from '/duet/assets/shared/avatar.mjs';
217
+ import { sizeButton, nextAvatarSize, avatarCloseConfirmation } from '/duet/assets/shared/avatar-ui.mjs';
218
+ const avatarConfirm=avatarCloseConfirmation();
219
+ const avatarChannel = typeof BroadcastChannel==='undefined'?null:new BroadcastChannel(AVATAR_KEY);
220
+ const avatarRead = () => {const p=avatarPreferences();document.getElementById('avatarEnabled').checked=p.enabled;document.getElementById('avatarWebOnly').checked=p.webOnly;sizeButton(document.getElementById('avatarSize'),p.size,{label:true});};
221
+ avatarRead();
222
+ const avatarStorage=e=>{if(e.key===AVATAR_KEY)avatarRead();};
223
+ window.addEventListener('storage',avatarStorage);
224
+ if(avatarChannel){
225
+ avatarChannel.onmessage=e=>{
226
+ avatarRead()
227
+ const mode=e.data?.type==='presentation'?e.data.mode:null
228
+ if(Object.hasOwn(AVATAR_PRESENTATION_LABELS,mode)){
229
+ document.getElementById('avatarPresentationStatus').textContent=AVATAR_PRESENTATION_LABELS[mode]
230
+ document.getElementById('avatarRetryDesktop').hidden=!['recovering','fallback','unavailable'].includes(mode)
231
+ }
232
+ }
233
+ avatarChannel.postMessage({type:'presentation_request'})
234
+ }
235
+ document.getElementById('avatarRetryDesktop').onclick=()=>avatarChannel?.postMessage({type:'retry_desktop'});
236
+ const avatarSave=patch=>{
237
+ try {saveAvatarPreferences({...avatarPreferences(),...patch});avatarRead();avatarChannel?.postMessage('changed');document.getElementById('avatarSettingsStatus').textContent='已保存';}
238
+ catch {document.getElementById('avatarSettingsStatus').textContent='设置未保存,请检查浏览器存储权限。';avatarRead();}
239
+ };
240
+ document.getElementById('avatarSize').onclick=()=>avatarSave({size:nextAvatarSize(avatarPreferences().size)});
241
+ document.getElementById('avatarWebOnly').onchange=e=>avatarSave({webOnly:e.target.checked});
242
+ document.getElementById('avatarEnabled').onchange=async e=>{
243
+ const enabled=e.target.checked;avatarRead();
244
+ if(enabled||await avatarConfirm.ask())avatarSave({enabled});
245
+ };
246
+ window.addEventListener('pagehide',()=>{avatarConfirm.dispose();avatarChannel?.close();window.removeEventListener('storage',avatarStorage);},{once:true});
247
+ import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.2.1';
248
+ import('/duet/assets/client/voices.mjs').then(({mountVoices})=>{
249
+ const disposeVoices=mountVoices(document.getElementById('duetVoices'));
250
+ window.addEventListener('pagehide',disposeVoices,{once:true});
251
+ }).catch(()=>{document.querySelector('#duetVoices [data-status]').textContent='音色设置暂不可用,请刷新后重试。';});
156
252
  const base = "/duplex-control/api";
157
253
  let debugEnabled = false, settingsRevision = null, feedbackSubmitting = false;
254
+ let nicknameDirty = false, nicknameRevision = null;
158
255
  const composerChannel = typeof BroadcastChannel === "undefined" ? null : new BroadcastChannel("dsh-duplex-control-v1");
159
256
  const composerPending = new Map();
160
257
  const sessionLabels = new Map();
161
258
  const $ = id => document.getElementById(id);
259
+ $('assistantNickname').oninput = () => { nicknameDirty = true; };
162
260
  const escapeHtml = value => String(value ?? "").replace(/[&<>"']/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
163
261
  async function api(path, options = {}) {
164
262
  const response = await identityFetch(base + path, {headers:{"Content-Type":"application/json"}, ...options});
@@ -291,6 +389,8 @@
291
389
  async function refresh() { try { await Promise.all([loadSessions(), loadJobs()]); } catch (error) { showMessage(error.message, true); } }
292
390
  async function loadDuetConfig(fill = false) {
293
391
  const config = await api('/voice/config');
392
+ $('avatarWebOnly').disabled = config.avatar?.web_only === true;
393
+ if (config.avatar?.web_only) $('avatarWebOnly').checked = true;
294
394
  showConnectionStatus(config);
295
395
  const c = config.connection || {};
296
396
  $('duetMark').style.color = c.online || c.tts_only ? '#7fd6a6' : '#ed9b35';
@@ -304,9 +404,15 @@
304
404
  settingsRevision = config.revision;
305
405
  $('backendUrl').value = config.backend_url || '';
306
406
  }
407
+ if (fill || !nicknameDirty) {
408
+ nicknameRevision = config.revision;
409
+ $('assistantNickname').value = config.nickname || '';
410
+ nicknameDirty = false;
411
+ }
307
412
  $('authState').textContent = config.backend_url ? '已配置' : '待配置';
308
413
  $('pluginVersion').textContent = config.plugin_version || '—';
309
414
  $('saveDuet').disabled = false;
415
+ $('saveNickname').disabled = false;
310
416
  $('submitFeedback').disabled = feedbackSubmitting || config.feedback_enabled !== true;
311
417
  if(config.feedback_enabled !== true)$('feedbackStatus').textContent = '反馈暂时不可用,请稍后再试。';
312
418
  else if($('feedbackStatus').textContent.startsWith('正在检查') || $('feedbackStatus').textContent.startsWith('反馈暂时'))$('feedbackStatus').textContent = '';
@@ -337,6 +443,20 @@
337
443
  } catch (error) { $('settingsMessage').textContent = debugEnabled ? `保存失败:${error.message}` : '保存失败,请稍后重试。'; }
338
444
  finally { $('saveDuet').disabled = false; }
339
445
  };
446
+ $('saveNickname').onclick = async () => {
447
+ $('saveNickname').disabled = true;
448
+ try {
449
+ const result = await api('/duet/nickname', {method:'POST',
450
+ headers:{'Content-Type':'application/json','X-Duplex-Settings':'1'},
451
+ body:JSON.stringify({nickname:$('assistantNickname').value, revision:nicknameRevision})});
452
+ if (!result.ok) { $('nicknameStatus').textContent = result.reason || '昵称保存失败,请重试'; return; }
453
+ settingsRevision = result.revision;
454
+ nicknameRevision = result.revision; nicknameDirty = false;
455
+ $('assistantNickname').value = result.nickname;
456
+ $('nicknameStatus').textContent = '已保存,下次开启语音时使用这个昵称。';
457
+ } catch { $('nicknameStatus').textContent = '昵称保存失败,请重试'; }
458
+ finally { $('saveNickname').disabled = false; }
459
+ };
340
460
  async function loadNotices() {
341
461
  const target = $('announcements');
342
462
  try {
@@ -363,7 +483,7 @@
363
483
  }
364
484
  $('openTutorial').onclick = async () => {
365
485
  try {
366
- const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.1.10');
486
+ const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.2.1');
367
487
  requestTutorial(localStorage);
368
488
  $('tutorialStatus').textContent = '请回到 DSH 页面继续教学。';
369
489
  } catch { $('tutorialStatus').textContent = '暂时无法打开教学,请允许浏览器存储后重试。'; }
@@ -372,11 +492,11 @@
372
492
  setInterval(() => { loadDuetConfig().catch(showConnectionUnavailable); }, 2000);
373
493
  void loadNotices();
374
494
  setInterval(loadNotices, 60000);
375
- import('/duet/assets/client/shortcuts.mjs?v=0.1.10').then(({mountShortcutSettings}) => {
495
+ import('/duet/assets/client/shortcuts.mjs?v=0.2.1').then(({mountShortcutSettings}) => {
376
496
  const dispose = mountShortcutSettings({speaker:$('speakerShortcut'),mic:$('micShortcut'),clearSpeaker:$('clearSpeakerShortcut'),clearMic:$('clearMicShortcut'),status:$('shortcutStatus')});
377
497
  window.addEventListener('pagehide', e => {if(!e.persisted)dispose()}, {once:true});
378
498
  }).catch(() => { $('shortcutStatus').textContent = '暂时无法加载快捷键设置,请刷新重试。'; });
379
- import('/duet/assets/client/microphone.mjs?v=0.1.10').then(({mountMicrophoneSettings}) => {
499
+ import('/duet/assets/client/microphone.mjs?v=0.2.1').then(({mountMicrophoneSettings}) => {
380
500
  const dispose = mountMicrophoneSettings({select:$('microphoneDevice'),refresh:$('refreshMicrophones'),status:$('microphoneStatus')});
381
501
  window.addEventListener('pagehide', dispose, {once:true});
382
502
  }).catch(() => { $('microphoneStatus').textContent = '暂时无法加载麦克风设置,请刷新重试。'; });
@@ -12,8 +12,8 @@ export function voiceSocketUrl(params, globals = globalThis, path = 'duplex-cont
12
12
  }
13
13
 
14
14
  /** Desktop refuses custom-protocol popups; keep settings in the owned window. */
15
- export function bindSettingsLink(link, globals = globalThis) {
16
- if (globals.location.protocol !== 'dsh-app:') return () => {}
15
+ export function bindSettingsLink(link, globals = globalThis, {embedded=false} = {}) {
16
+ if (!embedded && globals.location.protocol !== 'dsh-app:') return () => {}
17
17
  let dialog
18
18
  const close = () => { dialog?.close(); dialog?.remove(); dialog = null }
19
19
  const open = event => {
@@ -1,8 +1,8 @@
1
1
  /** DSH browser services plus existing voice connection; never opens a microphone. */
2
- import { PLUGIN_VERSION } from '../shared/state.mjs?v=0.1.10'
3
- import { focusedSession } from './composer.mjs?v=0.1.10'
4
- import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.1.10'
5
- import { startComposerBridge } from './composer-bridge.mjs?v=0.1.10'
2
+ import { PLUGIN_VERSION } from '../shared/state.mjs?v=0.2.1'
3
+ import { focusedSession } from './composer.mjs?v=0.2.1'
4
+ import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.2.1'
5
+ import { startComposerBridge } from './composer-bridge.mjs?v=0.2.1'
6
6
  export function tutorialAdapter(ctx, state, audio, pollReady, startBridge = startComposerBridge) {
7
7
  let narration
8
8
  const completed = new Map()
@@ -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.1.10'
2
+ import {consumeTutorialRequest} from './tutorial-request.mjs?v=0.2.1'
3
3
  export const TUTORIAL_KEY = 'dsh-duplex-tutorial-v1'
4
4
  export const QUESTION = '什么是语音交互?请用一句话简单解释,不使用工具。'
5
5
  export const INPUT = '用一句话介绍语音助手。'
@@ -113,7 +113,7 @@ export class TutorialRun {
113
113
  }
114
114
  }
115
115
 
116
- export function mountTutorial({ controls, adapter }) {
116
+ export function mountTutorial({ controls, adapter, origin='page' }) {
117
117
  const element = (tag, text, parent) => { const n = document.createElement(tag); if (text) n.textContent = text; parent?.append(n); return n }
118
118
  let run, closed = false, panel, highlight, pointer, lockRelease, active = false
119
119
  const get = (store, key) => { try { return store.getItem(key) } catch { return null } }
@@ -166,6 +166,7 @@ export function mountTutorial({ controls, adapter }) {
166
166
  document.body.append(pointer)
167
167
  }
168
168
  panel=element('section',null,document.body); panel.className='duet-tutorial'; panel.setAttribute('role','region'); panel.setAttribute('aria-label','duet 使用教学')
169
+ panel.dataset.duetAvatarSurface='80';panel.dataset.duetSurfaceOrigin=origin;panel.dataset.duetSurfaceTarget=selector?.includes('speaker')?'tts_only':selector?.includes('mic')?'online':''
169
170
  element('small', finished?'duet':active ? 'duet / GUIDED TOUR · 可随时退出' : 'WELCOME TO duet',panel)
170
171
  element('h3',title,panel); element('p',text,panel)
171
172
  const footer=element('footer',null,panel)
@@ -260,9 +261,10 @@ export function mountTutorial({ controls, adapter }) {
260
261
  void adapter.unlock().then(()=>{if(!closed&&view.panel.isConnected)return start(consent)}).catch(fail)
261
262
  },true)
262
263
  b.disabled=true;sound.onchange=chat.onchange=()=>{b.disabled=!(sound.checked&&chat.checked)}
264
+ b.dataset.duetUserGesture=''
263
265
  position()
264
266
  }
265
- const open = () => { if(!active)welcome() }
267
+ const open = (options={}) => { if(!active){origin=options.origin==='avatar'?'avatar':'page';welcome()} }
266
268
  const onKey=e=>{if(e.key==='Escape'&&panel)void dismiss()}
267
269
  window.addEventListener('resize',position);window.addEventListener('scroll',position,true);window.addEventListener('keydown',onKey)
268
270
  const layoutTimer=setInterval(position,300)
@@ -0,0 +1,137 @@
1
+ import {identityFetch} from './identity.mjs'
2
+ const messages={local_voice_limit:'最多保留 5 个自定义音色。',ip_voice_limit:'当前网络已授权 5 个音色,请先移除一个。',
3
+ challenge_daily_limit:'今天的音色验证次数已用完,请明天再试。',upload_daily_limit:'今天的音频上传次数已用完。',
4
+ voice_proof_invalid:'原音频验证未通过,请检查本地原文件。',voice_original_unavailable:'找不到本地原音频。',
5
+ audio_duration_must_be_3_to_15_seconds:'请选择 3–15 秒的音频。',voice_service_unavailable:'音色服务暂不可用,请稍后重试。'}
6
+ const pending=v=>['queued','recognizing'].includes(v.status)
7
+ messages.custom_voice_disabled='自定义音色暂不可用,已切换为默认音色。'
8
+ Object.assign(messages,{voice_disabled:'此音色已被服务端停用,不能使用或通过重新上传恢复。请选择其他音色。',
9
+ voice_audio_missing:'服务端的参考音频已丢失,请重新上传原音频恢复。',
10
+ voice_not_found:'服务端已没有这份音色记录,请移除后重新新增音色。',
11
+ voice_original_mismatch:'请选择最初上传的同一份音频文件,不能用其他音频替换。'})
12
+ const ADD='__add__'
13
+ export function mountVoices(root){
14
+ let state={selected:'default',voices:[]},busy=false,loaded=false,stopped=false,timer,featureTimer,adding=false,editing=null,draft=null,recovering=null
15
+ const attempts=new Map(),failed=new Set(),get=s=>root.querySelector(s)
16
+ const choice=get('[data-choice]'),status=get('[data-status]'),text=get('[data-text]')
17
+ const api=async body=>{
18
+ const r=await identityFetch('/duplex-control/api/voices',body?{method:'POST',headers:{'Content-Type':'application/json','X-Duplex-Settings':'1'},body:JSON.stringify(body)}:{})
19
+ const v=await r.json();if(!r.ok)throw Error(v.detail||'voice_service_unavailable');return v
20
+ }
21
+ const fail=e=>{status.textContent=messages[e.message]||'音色操作未成功,请稍后重试。'}
22
+ const close=()=>{adding=false;editing=null;draft=null;recovering=null;get('[data-name]').value='';get('[data-file]').value='';get('[data-consent]').checked=false;get('[data-reupload-file]').value=''}
23
+ const draw=()=>{
24
+ if(stopped)return
25
+ const disabled=state.custom_voice_enabled===false
26
+ if(disabled){close();state.selected='default'}
27
+ if(recovering&&!state.voices.some(v=>v.voice_id===recovering&&v.issue))recovering=null
28
+ get('[data-availability]').hidden=!disabled
29
+ get('[data-availability]').textContent=disabled?messages.custom_voice_disabled:''
30
+ choice.replaceChildren(new Option('默认音色','default'))
31
+ for(const v of state.voices){const option=new Option(v.name+(v.issue==='voice_disabled'?'(已停用)':v.issue?'(需恢复)':v.status==='ready'?'':'(待完成)'),v.voice_id);option.disabled=disabled;choice.add(option)}
32
+ const add=new Option('+ 新增音色',ADD);add.disabled=disabled||state.voices.length>=5;choice.add(add)
33
+ choice.value=recovering||(adding?(editing||ADD):state.selected);choice.disabled=busy||!loaded
34
+ const recovery=state.voices.find(v=>v.voice_id===recovering)
35
+ get('[data-recovery]').hidden=!recovery
36
+ get('[data-voice-issue]').textContent=recovery?(messages[recovery.issue]||'') : ''
37
+ get('[data-reupload-fields]').hidden=recovery?.issue!=='voice_audio_missing'
38
+ for(const el of root.querySelectorAll('[data-recovery] input,[data-recovery] button'))el.disabled=busy||!loaded
39
+ get('[data-create]').hidden=!adding;get('[data-upload-fields]').hidden=!!editing;get('[data-editor]').hidden=!editing
40
+ get('[data-remove]').hidden=state.selected==='default'||adding||!!recovering
41
+ get('[data-cancel]').textContent=editing?'返回选择音色':'取消'
42
+ for(const el of root.querySelectorAll('[data-create] input,[data-create] button,[data-remove]'))el.disabled=busy||!loaded
43
+ text.disabled=busy
44
+ const voice=state.voices.find(v=>v.voice_id===editing)
45
+ if(voice){
46
+ get('[data-uploaded-name]').textContent=voice.name
47
+ const value=draft??voice.ref_text??'';if(text.value!==value)text.value=value
48
+ get('[data-refresh]').hidden=!(failed.has(editing)||(!pending(voice)&&voice.status!=='ready'))
49
+ get('[data-recognition]').textContent=failed.has(editing)?'暂时未获取到识别结果,可以刷新结果,也可以直接填写音频中的原话。':
50
+ pending(voice)?'正在自动识别,请稍候…':voice.status==='ready'?'请核对上方文字与音频一致。':'未能自动识别,请填写音频中的原话。'
51
+ get('[data-save]').disabled=busy||!text.value.trim()
52
+ }
53
+ }
54
+ const schedule=()=>{clearTimeout(timer);if(!stopped&&state.custom_voice_enabled!==false&&state.voices.some(v=>pending(v)&&!failed.has(v.voice_id)))timer=setTimeout(poll,3000)}
55
+ async function run(work){
56
+ if(busy||stopped||!loaded)return false
57
+ busy=true;draw()
58
+ try{await work();return true}catch(e){if(!stopped)fail(e);return false}
59
+ finally{busy=false;draw();schedule()}
60
+ }
61
+ // Refresh reads the existing ASR result; it never starts another recognition.
62
+ async function refresh(id){
63
+ try{state=await api({op:'refresh',voice_id:id});failed.delete(id)}
64
+ catch(e){failed.add(id);throw e}
65
+ }
66
+ async function poll(){
67
+ if(stopped)return
68
+ if(busy){schedule();return}
69
+ await run(async()=>{
70
+ for(const v of state.voices.filter(v=>pending(v)&&!failed.has(v.voice_id))){
71
+ if(stopped)return
72
+ const count=attempts.get(v.voice_id)||0
73
+ if(count>=30){failed.add(v.voice_id);continue}
74
+ attempts.set(v.voice_id,count+1)
75
+ try{await refresh(v.voice_id)}catch{/* Keep retry scoped to this draft. */}
76
+ }
77
+ })
78
+ }
79
+ choice.onchange=()=>{
80
+ const id=choice.value
81
+ if(id===ADD){close();adding=true;status.textContent='';draw();get('[data-name]').focus();return}
82
+ const voice=state.voices.find(v=>v.voice_id===id)
83
+ if(voice?.issue){close();recovering=id;status.textContent='';draw();return}
84
+ if(voice&&voice.status!=='ready'){close();adding=true;editing=id;status.textContent='';draw();schedule();return}
85
+ void run(async()=>{state=await api({op:'select',voice_id:id});close();status.textContent='已选择,下次语音连接生效。'})
86
+ }
87
+ text.oninput=()=>{draft=text.value;get('[data-save]').disabled=busy||!text.value.trim()}
88
+ get('[data-cancel]').onclick=()=>{if(busy)return;close();status.textContent='';draw()}
89
+ get('[data-recovery-back]').onclick=()=>{if(busy)return;close();status.textContent='';draw()}
90
+ get('[data-recovery-remove]').onclick=()=>void run(async()=>{state=await api({op:'remove',voice_id:recovering});close()})
91
+ get('[data-reupload]').onclick=()=>void run(async()=>{
92
+ const file=get('[data-reupload-file]').files[0];let audio
93
+ if(file){
94
+ if(file.size>10*1024*1024)throw Error('invalid_audio_size')
95
+ const bytes=new Uint8Array(await file.arrayBuffer());let raw=''
96
+ for(let i=0;i<bytes.length;i+=8192)raw+=String.fromCharCode(...bytes.subarray(i,i+8192))
97
+ audio=btoa(raw)
98
+ }
99
+ const id=recovering
100
+ try{state=await api({op:'restore',voice_id:id,...(audio?{audio}:{})});close();status.textContent='音色已恢复,下次语音连接生效。'}
101
+ catch(e){state=await api();recovering=id;throw e}
102
+ })
103
+ get('[data-remove]').onclick=()=>void run(async()=>{state=await api({op:'remove',voice_id:state.selected});status.textContent='已移除,恢复默认音色。'})
104
+ get('[data-remove-draft]').onclick=()=>void run(async()=>{
105
+ state=await api({op:'remove',voice_id:editing});close();status.textContent='已移除此音色。'
106
+ })
107
+ get('[data-refresh]').onclick=()=>void run(async()=>{attempts.delete(editing);await refresh(editing)})
108
+ get('[data-save]').onclick=()=>void run(async()=>{
109
+ const index=state.voices.findIndex(v=>v.voice_id===editing),value=text.value.trim()
110
+ if(index<0||!value)return
111
+ if(value!==state.voices[index].ref_text){state=await api({op:'text',voice_id:editing,ref_text:value});editing=state.voices[index].voice_id;draft=value}
112
+ state=await api({op:'select',voice_id:editing});close();status.textContent='音色已保存并选择,下次语音连接生效。'
113
+ })
114
+ get('[data-upload]').onclick=()=>void run(async()=>{
115
+ const file=get('[data-file]').files[0],name=get('[data-name]').value.trim()
116
+ if(!get('[data-consent]').checked){status.textContent='请先确认你有权使用这段参考音频。';return}
117
+ if(!file||file.size>10*1024*1024||!name){status.textContent='请填写音色名称,并选择不超过 10 MB 的参考音频。';return}
118
+ status.textContent='正在上传…'
119
+ const bytes=new Uint8Array(await file.arrayBuffer());let raw=''
120
+ for(let i=0;i<bytes.length;i+=8192)raw+=String.fromCharCode(...bytes.subarray(i,i+8192))
121
+ if(stopped)return
122
+ const count=state.voices.length;state=await api({op:'upload',name,audio:btoa(raw)})
123
+ editing=state.voices[count].voice_id;draft=null;status.textContent=''
124
+ })
125
+ api().then(v=>{if(stopped)return;state=v;loaded=true;draw();schedule()}).catch(e=>{if(!stopped)fail(e)})
126
+ async function refreshFeature(){
127
+ if(stopped)return
128
+ if(!busy&&loaded){
129
+ busy=true
130
+ try{state=await api();draw();schedule()}catch{/* Keep the last known policy. */}
131
+ finally{busy=false;draw()}
132
+ }
133
+ if(!stopped)featureTimer=setTimeout(refreshFeature,15000)
134
+ }
135
+ featureTimer=setTimeout(refreshFeature,15000)
136
+ return()=>{stopped=true;clearTimeout(timer);clearTimeout(featureTimer)}
137
+ }
@@ -15,9 +15,17 @@ const modules = {
15
15
  connection_hint: 'client/connection-hint',
16
16
  controls_layout: 'client/controls-layout',
17
17
  notice: 'client/notice',
18
+ voices: 'client/voices',
18
19
  workspaces: 'client/workspaces',
19
20
  transport: 'client/transport',
20
21
  identity: 'client/identity', identity_protocol: 'shared/identity',
22
+ avatar: 'client/avatar', avatar_protocol: 'shared/avatar',
23
+ avatar_activity: 'shared/avatar-activity',
24
+ avatar_ui: 'shared/avatar-ui',
25
+ avatar_menu: 'shared/avatar-menu', avatar_menu_ui: 'shared/avatar-menu-ui',
26
+ avatar_tasks: 'client/avatar-tasks',
27
+ avatar_surface: 'shared/avatar-surface', avatar_surfaces: 'client/avatar-surfaces',
28
+ input_effect: 'client/input-effect',
21
29
  }
22
30
  const aliases = {
23
31
  state: 'DuetState as VoiceState', audio: 'DuetAudio as VoiceAudio',
@@ -26,6 +34,11 @@ const aliases = {
26
34
  const publicModules = new Set(Object.values(modules))
27
35
 
28
36
  export function publicAsset(pathname) {
37
+ const avatar = { '/duet/avatar/renderer.mjs':['renderer.mjs','text/javascript; charset=utf-8'],
38
+ '/duet/avatar/character.glb':['character.glb','model/gltf-binary'],
39
+ '/duet/avatar/portrait.png':['portrait.png','image/png'] }[pathname]
40
+ if (avatar) return {url:new URL(`../../assets/avatar/${avatar[0]}`,import.meta.url),contentType:avatar[1],
41
+ cacheControl:avatar[0].endsWith('.mjs')?'no-store':'private, max-age=3600'}
29
42
  const modern = pathname.match(/^\/duet\/assets\/(client|shared)\/([a-z-]+)\.mjs$/)
30
43
  if (modern && publicModules.has(`${modern[1]}/${modern[2]}`)) {
31
44
  return { url: new URL(`../${modern[1]}/${modern[2]}.mjs`, import.meta.url) }