dsh-duet 0.3.1 → 0.3.3

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 (52) hide show
  1. package/README.md +2 -0
  2. package/assets/avatar/desktop/companion.mjs +3 -4
  3. package/assets/avatar/desktop/manifest.json +1 -1
  4. package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
  5. package/desktop/bin/darwin-arm64/manifest.json +3 -3
  6. package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
  7. package/desktop/bin/win32-x64/manifest.json +3 -3
  8. package/node_modules/dsh-duet-superagent/lib/duet.d.ts +17 -2
  9. package/node_modules/dsh-duet-superagent/lib/duet.js +99 -4
  10. package/node_modules/dsh-duet-superagent/lib/{feishu-rAGM9U9b.js → feishu-CwKBb-B_.js} +1 -1
  11. package/node_modules/dsh-duet-superagent/lib/feishu-watch.d.ts +1 -1
  12. package/node_modules/dsh-duet-superagent/lib/feishu-watch.js +1 -1
  13. package/node_modules/dsh-duet-superagent/lib/{github-pull-gSbjzypm.js → github-pull-DyfAy0yE.js} +1 -1
  14. package/node_modules/dsh-duet-superagent/lib/github-watch.d.ts +1 -1
  15. package/node_modules/dsh-duet-superagent/lib/github-watch.js +2 -2
  16. package/node_modules/dsh-duet-superagent/lib/index.js +2 -2
  17. package/node_modules/dsh-duet-superagent/lib/{poll-Dh7J1cdM.js → poll-BBkmV_GM.js} +4 -1
  18. package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts} +70 -61
  19. package/node_modules/dsh-duet-superagent/lib/{runtime-mbw1-2iK.js → runtime-Ow0S-7ZZ.js} +44 -4
  20. package/package.json +2 -2
  21. package/src/avatar/companion.mjs +5 -3
  22. package/src/avatar/surface.mjs +6 -1
  23. package/src/client/agent-tasks.mjs +144 -17
  24. package/src/client/audio.mjs +1 -1
  25. package/src/client/avatar-surfaces.mjs +3 -3
  26. package/src/client/avatar.mjs +15 -2
  27. package/src/client/browser.mjs +24 -24
  28. package/src/client/composer-bridge.mjs +1 -1
  29. package/src/client/connection-hint.mjs +1 -1
  30. package/src/client/entry.js +2 -2
  31. package/src/client/feedback.mjs +1 -1
  32. package/src/client/identity.mjs +1 -1
  33. package/src/client/interactions.mjs +5 -4
  34. package/src/client/notice.mjs +30 -9
  35. package/src/client/settings.html +5 -4
  36. package/src/client/sidebar-layout.mjs +26 -0
  37. package/src/client/tutorial-adapter.mjs +5 -5
  38. package/src/client/tutorial.mjs +1 -1
  39. package/src/client/work-mode.mjs +12 -6
  40. package/src/host/agent-connection.mjs +6 -1
  41. package/src/host/assets.mjs +1 -0
  42. package/src/host/auth.mjs +13 -0
  43. package/src/host/avatar.mjs +32 -13
  44. package/src/host/plugin.mjs +22 -17
  45. package/src/host/proxy.mjs +3 -2
  46. package/src/host/sync-feed.mjs +3 -2
  47. package/src/shared/avatar-menu-ui.mjs +30 -12
  48. package/src/shared/avatar-menu.mjs +4 -1
  49. package/src/shared/avatar-surface.mjs +1 -0
  50. package/src/shared/avatar-ui.mjs +2 -0
  51. package/src/shared/state.mjs +29 -4
  52. package/src/shared/work-mode.mjs +20 -0
@@ -7,6 +7,7 @@ import { avatarCloseConfirmation } from '../shared/avatar-ui.mjs'
7
7
  import {mountAvatarMenu} from '../shared/avatar-menu-ui.mjs'
8
8
  import {avatarLocalState,avatarMenuResult,noticePreferences} from '../shared/avatar-menu.mjs'
9
9
  import {AvatarActivityClock,avatarGeometry} from '../shared/avatar-activity.mjs'
10
+ import {sidebarBounds} from './sidebar-layout.mjs'
10
11
 
11
12
  /** Page-bound presentation. The native helper cannot acquire its own voice session. */
12
13
  export function mountAvatar({controls, audio, state, notice, requestMode, onSurfaceAction=()=>{}, onMenuAction=()=>{}, focusedSession=()=>null}) {
@@ -16,6 +17,7 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
16
17
  let forceWebOnly=false,configLoaded=false
17
18
  let menu,localState,lastNotice,retryTimer,connectTimer,reconnect,retryCount=0,presentationMode='off'
18
19
  let desktopPosition=null,activityStartTimer
20
+ let taskCards=false
19
21
  const activity=new AvatarActivityClock({snapshot:()=>{
20
22
  const p=noticePreferences(),r=root?.getBoundingClientRect(),screen=window.screen
21
23
  const position=native?desktopPosition:r?avatarGeometry({space:'viewport_css',total_resolution:{width:screen.width,height:screen.height},viewport_resolution:{width:innerWidth,height:innerHeight},avatar_position:{x:r.x,y:r.y,width:r.width,height:r.height}}):null
@@ -47,6 +49,8 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
47
49
  }
48
50
  const place=()=>{
49
51
  if(!root)return
52
+ const taskLayout=taskCards&&location.protocol!=='dsh-app:'&&!native
53
+ root.toggleAttribute('data-duet-task-layout',taskLayout)
50
54
  const c=controls(),r=c?.getBoundingClientRect()
51
55
  root.hidden=!r||c.dataset.compact==='true'
52
56
  // Insert a sibling between DSH's scrollable workspace region and its footer.
@@ -61,7 +65,9 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
61
65
  const scale=Math.min(avatarScale(prefs.size),width/180,innerHeight*.32/210)
62
66
  root.dataset.size=prefs.size
63
67
  root.style.cssText='position:relative;flex:0 0 auto;align-self:stretch;min-width:0;display:flex;flex-direction:column;align-items:center;pointer-events:none'
64
- stage.style.cssText=`position:relative;width:${width}px;max-width:100%;height:${210*scale}px`
68
+ if(taskLayout)root.style.alignItems='flex-start'
69
+ // Move the unchanged viewport, not its camera/aspect or selected size.
70
+ stage.style.cssText=`position:relative;width:${width}px;max-width:100%;height:${210*scale}px;transform:translateX(${taskLayout?-width*.22:0}px)`
65
71
  caption.style.position='relative';caption.style.bottom='auto';caption.style.left='auto';caption.style.right='auto'
66
72
  caption.style.width='calc(100% - 16px)';caption.style.maxHeight=`min(${{small:90,medium:180,large:260}[noticePreferences().bubble]}px,16vh)`
67
73
  caption.style.order='-1';if(!caption.hidden)caption.scrollTop=caption.scrollHeight
@@ -74,6 +80,12 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
74
80
  root.dataset.size=prefs.size;root.style.width=`${width}px`;root.style.height=`${height}px`
75
81
  root.style.left=`${Math.max(8,Math.min(innerWidth-width-8,r.left))}px`;root.style.top=`${top}px`
76
82
  stage.style.width=`${base}px`;stage.style.transform=`scale(${scale})`
83
+ stage.style.height='210px'
84
+ if(taskLayout){
85
+ const side=sidebarBounds(c)
86
+ if(side)root.style.left=`${side.left+8}px`
87
+ stage.style.transform=`translateX(${-width*.22}px) scale(${scale})`
88
+ }
77
89
  const bubbleWidth=Math.min(base-8,innerWidth-16),left=parseFloat(root.style.left)
78
90
  caption.style.width=`${bubbleWidth}px`;caption.style.left=`${Math.max(8,Math.min(innerWidth-bubbleWidth-8,left+width/2-bubbleWidth/2))-left}px`
79
91
  caption.style.maxHeight=`${Math.max(30,Math.min({small:90,medium:180,large:260}[noticePreferences().bubble],top-18))}px`
@@ -214,7 +226,8 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
214
226
  .then(r=>r.ok?r.json():{}).then(config=>{forceWebOnly=config.avatar?.web_only===true})
215
227
  .catch(()=>{}).finally(()=>{clearTimeout(configTimeout);configLoaded=true;if(!dead)start()})
216
228
  return {
217
- presentation(){return {native,mode:presentationMode,anchor:root&&!root.hidden?root:null}},
229
+ presentation(){return {native,mode:presentationMode,anchor:root&&!root.hidden?root:null,
230
+ taskLayout(value){const next=value===true&&location.protocol!=='dsh-app:'&&!native;if(next!==taskCards){taskCards=next;place()}}}},
218
231
  surface(value){return native&&send(value)},
219
232
  syncToggle,
220
233
  setSize,
@@ -1,29 +1,29 @@
1
- import { DuetState, PLUGIN_VERSION } from '../shared/state.mjs?v=0.3.1'
2
- import { DuetAudio, AUDIO_STOP_PROTOCOL } from './audio.mjs?v=0.3.1'
3
- import { HarnessRPCExecutor, rpcNavigationSession } from './rpc.mjs?v=0.3.1'
4
- import { composerAccess, observeComposer, focusedSession, openLocalSession } from './composer.mjs?v=0.3.1'
5
- import { startComposerBridge } from './composer-bridge.mjs?v=0.3.1'
6
- import { mountTutorial } from './tutorial.mjs?v=0.3.1'
1
+ import { DuetState, PLUGIN_VERSION } from '../shared/state.mjs?v=0.3.3'
2
+ import { DuetAudio, AUDIO_STOP_PROTOCOL } from './audio.mjs?v=0.3.3'
3
+ import { HarnessRPCExecutor, rpcNavigationSession } from './rpc.mjs?v=0.3.3'
4
+ import { composerAccess, observeComposer, focusedSession, openLocalSession } from './composer.mjs?v=0.3.3'
5
+ import { startComposerBridge } from './composer-bridge.mjs?v=0.3.3'
6
+ import { mountTutorial } from './tutorial.mjs?v=0.3.3'
7
7
  import { mountAvatarTasks } from './avatar-tasks.mjs'
8
- import { tutorialAdapter } from './tutorial-adapter.mjs?v=0.3.1'
9
- import { mountRating } from './feedback.mjs?v=0.3.1'
10
- import { createAudioUploadConsent } from './consent.mjs?v=0.3.1'
11
- import { bindDuetShortcuts } from './shortcuts.mjs?v=0.3.1'
12
- import { nativeInteractions } from './interactions.mjs?v=0.3.1'
13
- import { mountConnectionHint } from './connection-hint.mjs?v=0.3.1'
14
- import { mountControlsLayout } from './controls-layout.mjs?v=0.3.1'
15
- import { mountNotice } from './notice.mjs?v=0.3.1'
16
- import { browserSessionCatalog, sessionCreationPayload } from './workspaces.mjs?v=0.3.1'
8
+ import { tutorialAdapter } from './tutorial-adapter.mjs?v=0.3.3'
9
+ import { mountRating } from './feedback.mjs?v=0.3.3'
10
+ import { createAudioUploadConsent } from './consent.mjs?v=0.3.3'
11
+ import { bindDuetShortcuts } from './shortcuts.mjs?v=0.3.3'
12
+ import { nativeInteractions } from './interactions.mjs?v=0.3.3'
13
+ import { mountConnectionHint } from './connection-hint.mjs?v=0.3.3'
14
+ import { mountControlsLayout } from './controls-layout.mjs?v=0.3.3'
15
+ import { mountNotice } from './notice.mjs?v=0.3.3'
16
+ import { browserSessionCatalog, sessionCreationPayload } from './workspaces.mjs?v=0.3.3'
17
17
  import { workModeOnboarding } from './work-mode.mjs'
18
18
  import { agentEntryNavigation } from './agent-entry.mjs'
19
19
  import { workModeIssue, noteTaskVisit } from '../shared/work-mode.mjs'
20
- import { voiceSocketUrl, bindSettingsLink } from './transport.mjs?v=0.3.1'
21
- import { identityFetch, identityVoiceProtocols } from './identity.mjs?v=0.3.1'
22
- import { sessionLabel } from '../shared/catalog.mjs?v=0.3.1'
23
- import { resultNotification } from '../shared/result-notification.mjs?v=0.3.1'
24
- import { HarnessSync } from './harness-sync.mjs?v=0.3.1'
25
- import { LocalSync } from './local-sync.mjs?v=0.3.1'
26
- import { diagnosticPayload } from '../shared/diagnostics.mjs?v=0.3.1'
20
+ import { voiceSocketUrl, bindSettingsLink } from './transport.mjs?v=0.3.3'
21
+ import { identityFetch, identityVoiceProtocols } from './identity.mjs?v=0.3.3'
22
+ import { sessionLabel } from '../shared/catalog.mjs?v=0.3.3'
23
+ import { resultNotification } from '../shared/result-notification.mjs?v=0.3.3'
24
+ import { HarnessSync } from './harness-sync.mjs?v=0.3.3'
25
+ import { LocalSync } from './local-sync.mjs?v=0.3.3'
26
+ import { diagnosticPayload } from '../shared/diagnostics.mjs?v=0.3.3'
27
27
  import { mountAvatar } from './avatar.mjs'
28
28
  import { mountAvatarSurfaces } from './avatar-surfaces.mjs'
29
29
  import { audioUnlockPanel } from '../shared/avatar-ui.mjs'
@@ -59,10 +59,10 @@ export function mountDuet(ctx) {
59
59
  const pageError = event => diagnostic({ event: 'browser.error', message: String(event.message || event.reason?.message || event.reason), stack: event.error?.stack || event.reason?.stack })
60
60
  window.addEventListener('error', pageError)
61
61
  window.addEventListener('unhandledrejection', pageError)
62
- const notice = (text, { upgrade = false, releaseNotes } = {}) => {
62
+ const notice = (text, { upgrade = false, ...details } = {}) => {
63
63
  connectionHint?.dismiss()
64
64
  if (upgrade) { ratingPanel?.dispose(); ratingPanel = null }
65
- notices.show(text, { upgrade, releaseNotes })
65
+ notices.show(text, { upgrade, ...details })
66
66
  }
67
67
  const draw = state => {
68
68
  if (pollGeneration !== state.generation) {
@@ -1,5 +1,5 @@
1
1
  /** Composer requests belong to one explicit voice/tutorial connection, never all tabs. */
2
- import { focusedSession as currentSession } from './composer.mjs?v=0.3.1'
2
+ import { focusedSession as currentSession } from './composer.mjs?v=0.3.3'
3
3
 
4
4
  export function startComposerBridge(ctx, clientId, fetchImpl = fetch, feed = null, onWrite = () => {}) {
5
5
  const focusedSession = () => currentSession(ctx)
@@ -1,5 +1,5 @@
1
1
  /** A brief, non-modal invitation after the microphone is actually ready. */
2
- import {normalizeGuidance} from '../shared/connection-guidance.mjs?v=0.3.1'
2
+ import {normalizeGuidance} from '../shared/connection-guidance.mjs?v=0.3.3'
3
3
  import {AGENT_WORKSPACE_NOTICE,agentEntryReminder} from '../shared/work-mode.mjs'
4
4
  export function mountConnectionHint(controls, { duration = 8000, onShown = ()=>{}, onSettings = ()=>{} } = {}) {
5
5
  const hint = document.createElement('div')
@@ -10,7 +10,7 @@ window.__ModuleLoader__.load({
10
10
  function apply(ctx) {
11
11
  ctx.effect(() => {
12
12
  let active=true,dispose
13
- import('/duet/assets/client/agent-tool-views.mjs?v=0.3.1').then(module=>{
13
+ import('/duet/assets/client/agent-tool-views.mjs?v=0.3.3').then(module=>{
14
14
  if(active&&ctx.slots&&typeof require==='function')dispose=module.mountAgentToolViews(ctx,require('react'))
15
15
  }).catch(error=>console.warn('duet task cards could not load:',error))
16
16
  return ()=>{active=false;dispose?.()}
@@ -20,7 +20,7 @@ window.__ModuleLoader__.load({
20
20
  ctx.effect(() => {
21
21
  let active = true
22
22
  let dispose
23
- import('/duet/assets/client/browser.mjs?v=0.3.1').then(module => {
23
+ import('/duet/assets/client/browser.mjs?v=0.3.3').then(module => {
24
24
  if (active) dispose = module.mountDuet(ctx)
25
25
  }).catch(error => {
26
26
  console.warn('duet controls could not load:', error)
@@ -1,5 +1,5 @@
1
1
  /** Optional, explicit rating; never opens voice or submits without a user click. */
2
- import { identityFetch } from './identity.mjs?v=0.3.1'
2
+ import { identityFetch } from './identity.mjs?v=0.3.3'
3
3
 
4
4
  export function mountRating(anchor, sessionTicket, {origin='page'} = {}) {
5
5
  if(!sessionTicket)return null
@@ -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.3.1'
2
+ VOICE_PROTOCOL, IDENTITY_PROTOCOL_PREFIX, validIdentityToken } from '../shared/identity.mjs?v=0.3.3'
3
3
 
4
4
  /** Desktop strips plugin cookies. Keep the Host-signed value in its origin storage. */
5
5
  export function createIdentityClient(globals = globalThis) {
@@ -1,9 +1,11 @@
1
1
  /** Use the same pending objects as DSH's clickable question/approval cards. */
2
2
  export function nativeInteractions(ctx) {
3
3
  const firstSeen = new Map()
4
- const pending = () => ctx.uiSession.sessionStatus
5
- ? [...ctx.uiSession.sessionStatus.getSnapshot().values()].map(row => row.pendingInteraction).filter(Boolean)
6
- : [...ctx.uiSession.pendingInteractions.getSnapshot().values()]
4
+ const pendingStore = ctx.uiSession.pendingInteractions
5
+ const store = pendingStore ?? ctx.uiSession.sessionStatus
6
+ const pending = () => pendingStore
7
+ ? [...store.getSnapshot().values()]
8
+ : [...store.getSnapshot().values()].map(row => row.pendingInteraction).filter(Boolean)
7
9
  const publicValue = value => {
8
10
  if (!firstSeen.has(value.key)) firstSeen.set(value.key, Date.now() / 1000)
9
11
  if (firstSeen.size > 512) firstSeen.delete(firstSeen.keys().next().value)
@@ -38,7 +40,6 @@ export function nativeInteractions(ctx) {
38
40
  return { ok: true, interaction_id: value.key }
39
41
  }
40
42
  execute.snapshot = snapshot
41
- const store = ctx.uiSession.sessionStatus ?? ctx.uiSession.pendingInteractions
42
43
  execute.supportsSync = typeof store.subscribe === 'function'
43
44
  execute.subscribe = fn => store.subscribe?.(fn) ?? (() => {})
44
45
  return execute
@@ -26,30 +26,51 @@ export function mountNotice(anchor) {
26
26
  const observer = new ResizeObserver(position)
27
27
  observer.observe(panel)
28
28
  return {
29
- show(text, {upgrade = false, releaseNotes} = {}) {
29
+ show(text, {upgrade = false, releaseNotes, releases = [], currentVersion, targetVersion} = {}) {
30
30
  if (disposed) return
31
31
  clearTimeout(timer); panel.textContent = text; panel.hidden = false
32
32
  if (upgrade) {
33
33
  panel.textContent = ''
34
- const heading=document.createElement('strong');heading.textContent='更新 duet';heading.style.cssText='display:block;font-size:15px;margin-bottom:6px'
34
+ const heading=document.createElement('strong');heading.textContent='duet 有新版本';heading.style.cssText='display:block;font-size:16px;margin-bottom:8px'
35
35
  const message=document.createElement('p');message.textContent=text;message.style.cssText='margin:0 0 12px'
36
36
  panel.append(heading,message)
37
- if(typeof releaseNotes==='string' && releaseNotes.trim()){
37
+ if(currentVersion&&targetVersion){
38
+ const range=document.createElement('div');range.dataset.duetVersionRange=''
39
+ range.style.cssText='display:flex;align-items:center;gap:10px;margin:0 0 14px;font-size:12px'
40
+ for(const [index,text] of [`v${currentVersion}`,'→',`v${targetVersion}`].entries()){
41
+ const badge=document.createElement('span');badge.textContent=text
42
+ if(index!==1)badge.style.cssText=`padding:3px 10px;border-radius:20px;background:${index===2?'#d1eaff':'#ffffffa8'};font-weight:${index===2?600:400}`
43
+ range.append(badge)
44
+ }
45
+ panel.append(range)
46
+ }
47
+ if(releases.length){
48
+ const label=document.createElement('strong');label.textContent=`更新内容 · ${currentVersion} → ${targetVersion}`;label.style.fontSize='12px'
49
+ const list=document.createElement('div');list.dataset.duetReleaseHistory=''
50
+ for(const release of releases){
51
+ const section=document.createElement('section'),version=document.createElement('strong'),notes=document.createElement('p')
52
+ version.textContent=`v${release.version}`;notes.textContent=release.notes
53
+ notes.style.cssText='white-space:pre-wrap;margin:4px 0 0'
54
+ section.style.cssText='margin:8px 0;padding:10px 12px;border-radius:8px;background:#ffffffa8'
55
+ section.append(version,notes);list.append(section)
56
+ }
57
+ panel.append(label,list)
58
+ }else if(typeof releaseNotes==='string' && releaseNotes.trim()){
38
59
  const label=document.createElement('strong');label.textContent='更新内容';label.style.fontSize='12px'
39
60
  const notes=document.createElement('p');notes.dataset.duetReleaseNotes='';notes.textContent=releaseNotes.slice(0,1000).trim()
40
61
  notes.style.cssText='white-space:pre-wrap;margin:6px 0 14px;padding:10px 12px;border-radius:8px;background:#ffffffa8'
41
62
  panel.append(label,notes)
42
63
  }
43
64
  const help = document.createElement('details'), title = document.createElement('summary')
65
+ help.open=true
44
66
  help.style.cssText='border-top:1px solid #a5d8f4;padding-top:10px'
45
67
  title.style.cssText='cursor:pointer;font-weight:600'
46
68
  title.textContent = '如何升级'; help.append(title)
47
- const before = document.createElement('p'), command = document.createElement('code'), after = document.createElement('p')
48
- before.textContent = '通过 npm 安装的用户,可在终端运行:'
49
- command.textContent = 'dsh plugin --profile web add dsh-duet@latest'
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'
51
- after.textContent = '其他安装方式请从原来源更新。完成后重启 DSH 并刷新页面,再手动开启语音。'
52
- help.append(before, command, after); panel.append(help)
69
+ const steps=document.createElement('ol');steps.style.cssText='margin:10px 0;padding-left:20px'
70
+ for(const text of ['在 DSH 的「插件」页面卸载 duet。','点击「添加插件」,输入 dsh-duet 并安装。','安装完成后,如果插件不可用,可能需要重启 DSH 哦']){
71
+ const step=document.createElement('li');step.textContent=text;step.style.margin='6px 0';steps.append(step)
72
+ }
73
+ help.append(steps); panel.append(help)
53
74
  help.addEventListener('toggle', position)
54
75
  const actions=document.createElement('div');actions.style.cssText='display:flex;justify-content:flex-end;margin-top:14px'
55
76
  const close = document.createElement('button'); close.type = 'button'; close.textContent = '知道了'; close.onclick = hide
@@ -35,6 +35,7 @@
35
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
36
  input[type=checkbox]:checked{background:#80b294;border-color:#80b294}input[type=checkbox]:checked::after{transform:translateX(14px)}
37
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
+ #debugTools .row{flex-wrap:wrap}
38
39
  .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
40
  .connection-title{font-size:13px;font-weight:600}.connection-detail{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
40
41
  .cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px 24px;margin:16px 0 20px}
@@ -252,7 +253,7 @@
252
253
  if(enabled||await avatarConfirm.ask())avatarSave({enabled});
253
254
  };
254
255
  window.addEventListener('pagehide',()=>{avatarConfirm.dispose();avatarChannel?.close();window.removeEventListener('storage',avatarStorage);},{once:true});
255
- import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.3.1';
256
+ import { identityFetch } from '/duet/assets/client/identity.mjs?v=0.3.3';
256
257
  import { mountWorkMode, workModeOnboarding } from '/duet/assets/client/work-mode.mjs';
257
258
  const modePreview=workModeOnboarding(undefined,{preview:true});
258
259
  let previewRequested=new URL(location.href).searchParams.get('preview')==='work-mode';
@@ -502,7 +503,7 @@
502
503
  }
503
504
  $('openTutorial').onclick = async () => {
504
505
  try {
505
- const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.3.1');
506
+ const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.3.3');
506
507
  requestTutorial(localStorage);
507
508
  $('tutorialStatus').textContent = '请回到 DSH 页面继续教学。';
508
509
  } catch { $('tutorialStatus').textContent = '暂时无法打开教学,请允许浏览器存储后重试。'; }
@@ -511,11 +512,11 @@
511
512
  setInterval(() => { loadDuetConfig().catch(showConnectionUnavailable); }, 2000);
512
513
  void loadNotices();
513
514
  setInterval(loadNotices, 60000);
514
- import('/duet/assets/client/shortcuts.mjs?v=0.3.1').then(({mountShortcutSettings}) => {
515
+ import('/duet/assets/client/shortcuts.mjs?v=0.3.3').then(({mountShortcutSettings}) => {
515
516
  const dispose = mountShortcutSettings({speaker:$('speakerShortcut'),mic:$('micShortcut'),clearSpeaker:$('clearSpeakerShortcut'),clearMic:$('clearMicShortcut'),status:$('shortcutStatus')});
516
517
  window.addEventListener('pagehide', e => {if(!e.persisted)dispose()}, {once:true});
517
518
  }).catch(() => { $('shortcutStatus').textContent = '暂时无法加载快捷键设置,请刷新重试。'; });
518
- import('/duet/assets/client/microphone.mjs?v=0.3.1').then(({mountMicrophoneSettings}) => {
519
+ import('/duet/assets/client/microphone.mjs?v=0.3.3').then(({mountMicrophoneSettings}) => {
519
520
  const dispose = mountMicrophoneSettings({select:$('microphoneDevice'),refresh:$('refreshMicrophones'),status:$('microphoneStatus')});
520
521
  window.addEventListener('pagehide', dispose, {once:true});
521
522
  }).catch(() => { $('microphoneStatus').textContent = '暂时无法加载麦克风设置,请刷新重试。'; });
@@ -0,0 +1,26 @@
1
+ /** Resolve the sidebar without depending on DSH's generated CSS class names. */
2
+ export function sidebarElement(controls) {
3
+ if (!controls?.isConnected) return null
4
+ let fallback=null
5
+ for(let node=controls;node&&node!==document.body;node=node.parentElement){
6
+ const r=node.getBoundingClientRect()
7
+ if(!r.width||!r.height||r.width>Math.min(600,innerWidth*.75))continue
8
+ fallback=node
9
+ if(node.matches('aside,[role="complementary"]')||node.querySelector('[data-slot="sidebar.workspaces"]'))return node
10
+ }
11
+ return fallback
12
+ }
13
+ export const sidebarBounds=controls=>sidebarElement(controls)?.getBoundingClientRect()??null
14
+
15
+ /** A mask fades pixels; clipping also prevents the hidden area from taking clicks. */
16
+ export function clipToSidebar(node,bounds){
17
+ node.style.clipPath='';node.style.maskImage='';node.style.webkitMaskImage=''
18
+ if(!bounds)return
19
+ const r=node.getBoundingClientRect(),right=Math.max(0,r.right-bounds.right),left=Math.max(0,bounds.left-r.left)
20
+ node.style.clipPath=`inset(-4px ${right}px -4px ${left}px)`
21
+ if(right>0){
22
+ const end=Math.max(0,r.width-right),start=Math.max(left,end-24)
23
+ const mask=`linear-gradient(to right,#000 ${start}px,transparent ${end}px)`
24
+ node.style.maskImage=mask;node.style.webkitMaskImage=mask
25
+ }
26
+ }
@@ -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.1'
3
- import { focusedSession } from './composer.mjs?v=0.3.1'
4
- import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.3.1'
5
- import { startComposerBridge } from './composer-bridge.mjs?v=0.3.1'
6
- import { identityFetch } from './identity.mjs?v=0.3.1'
2
+ import { PLUGIN_VERSION } from '../shared/state.mjs?v=0.3.3'
3
+ import { focusedSession } from './composer.mjs?v=0.3.3'
4
+ import { sessionCreationPayload, workspaceIssue } from './workspaces.mjs?v=0.3.3'
5
+ import { startComposerBridge } from './composer-bridge.mjs?v=0.3.3'
6
+ import { identityFetch } from './identity.mjs?v=0.3.3'
7
7
  export function tutorialAdapter(ctx, state, audio, pollReady, startBridge = startComposerBridge) {
8
8
  let narration
9
9
  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.3.1'
2
+ import {consumeTutorialRequest} from './tutorial-request.mjs?v=0.3.3'
3
3
  export const TUTORIAL_KEY = 'dsh-duplex-tutorial-v1'
4
4
  export const QUESTION = '什么是语音交互?请用一句话简单解释,不使用工具。'
5
5
  export const INPUT = '用一句话介绍语音助手。'
@@ -1,5 +1,5 @@
1
- import { WORK_MODES, AGENT_PERMISSION_TEXT, AGENT_WORKSPACE_NOTICE, workModeIssue, TASK_STATES, visibleTaskRows } from '../shared/work-mode.mjs'
2
- import { identityFetch } from './identity.mjs?v=0.3.1'
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.3'
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}
@@ -147,16 +147,22 @@ export async function mountWorkMode(container, {saved=()=>{}, cancel=null, initi
147
147
  const tasks=document.createElement('details')
148
148
  if(!cancel&&!preview){
149
149
  const title=document.createElement('summary'),list=document.createElement('ul'),refresh=document.createElement('button')
150
- title.textContent='任务状态';refresh.type='button';refresh.textContent='刷新'
150
+ title.textContent='会话与模型';refresh.type='button';refresh.textContent='刷新'
151
151
  const load=async()=>{
152
152
  refresh.disabled=true
153
153
  try{
154
- const rows=visibleTaskRows((await api('agent-tasks')).rows)
154
+ const {rows=[],main}=await api('agent-tasks')
155
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)
156
162
  for(const row of rows){
157
- const li=document.createElement('li');li.textContent=(row.name||'未命名任务')+' · '+(TASK_STATES[row.state]||'状态待确认');list.append(li)
163
+ append((row.name||'未命名任务')+' · '+(TASK_STATES[row.state]||'状态待确认'),row.model_info)
158
164
  }
159
- if(!rows.length)list.textContent='还没有任务'
165
+ if(!rows.length&&!main)list.textContent='还没有任务'
160
166
  }catch{list.textContent='暂时无法读取任务状态'}
161
167
  finally{refresh.disabled=false}
162
168
  }
@@ -74,7 +74,12 @@ export class AgentConnection {
74
74
  const rows=this.source.taskRows().map(row=>{
75
75
  // Local notification identity; never send native ticket metadata upstream.
76
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
77
+ const run=ticket?.assignments?.at(-1)
78
+ // Actual executor progress, not model selection metadata. Only project
79
+ // the latest assignment: an older run must not look like current work.
80
+ const progress=ticket?.attention?.question || run?.report?.summary || ticket?.ended?.reason
81
+ return {...row,...(ticket?.attention?.id?{attention_id:ticket.attention.id}:{}),
82
+ ...(typeof progress==='string'&&progress.trim()?{progress:progress.slice(0,4000)}:{})}
78
83
  })
79
84
  const key=r=>r.task_id+':'+r.run_id
80
85
  for(const r of rows)if(r.run_id && !r.finished_at && this.previousFinished?.has(key(r)))
@@ -26,6 +26,7 @@ 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
+ sidebar_layout: 'client/sidebar-layout',
29
30
  agent_entry: 'client/agent-entry',
30
31
  agent_tool_views: 'client/agent-tool-views',
31
32
  avatar_surface: 'shared/avatar-surface', avatar_surfaces: 'client/avatar-surfaces',
@@ -0,0 +1,13 @@
1
+ /** DSH 0.2.3 admits routes before dispatch; older hosts validate the request here. */
2
+ export function requestRejection(ctx, req, peer) {
3
+ if (peer) return peer.principal?.kind === 'owner' && !peer.signal?.aborted ? null : 403
4
+ const connection = ctx.connection
5
+ if (typeof connection?.admit === 'function') {
6
+ const admission = connection.admit(req)
7
+ if (admission?.rejection) return admission.rejection
8
+ const admitted = admission?.peer
9
+ return admitted?.principal?.kind === 'owner' && !admitted.signal?.aborted ? null : 403
10
+ }
11
+ if (typeof connection?.requestRejection === 'function') return connection.requestRejection(req)
12
+ return 503
13
+ }
@@ -1,8 +1,12 @@
1
+ import { requestRejection } from './auth.mjs'
1
2
  import { WebSocketServer } from 'ws'
2
3
  import { spawn } from 'node:child_process'
3
4
  import { accessSync, constants } from 'node:fs'
4
5
  import { fileURLToPath } from 'node:url'
5
6
  import { randomBytes, timingSafeEqual } from 'node:crypto'
7
+ import {mkdtempSync,rm} from 'node:fs'
8
+ import {tmpdir} from 'node:os'
9
+ import {join} from 'node:path'
6
10
  import { AVATAR_SIZES, avatarSize, avatarFrame, avatarInputEffect, AvatarHeartbeat } from '../shared/avatar.mjs'
7
11
  import { AVATAR_UI_PROTOCOL, avatarSurface, avatarSurfaceAction } from '../shared/avatar-surface.mjs'
8
12
  import {verifyDesktopAssets,desktopAssetsPath} from './avatar-assets.mjs'
@@ -20,7 +24,7 @@ export function sameSecret(a, b) {
20
24
  }
21
25
 
22
26
  /** Private, loopback-only IPC. The companion never receives DSH/server credentials. */
23
- export async function launchAvatar({onCommand,onExit,signal,size,ownerKind='browser'}, {spawnImpl=spawn, binary=avatarBinary(), env=process.env, assets=desktopAssetsPath}={}) {
27
+ export async function launchAvatar({onCommand,onExit,signal,size,ownerKind='browser'}, {spawnImpl=spawn, binary=avatarBinary(), env=process.env, assets=desktopAssetsPath,platform=process.platform}={}) {
24
28
  if(!binary)throw Error('desktop_platform_unsupported')
25
29
  if(process.platform==='linux'&&!env.DISPLAY&&!env.WAYLAND_DISPLAY)throw Error('desktop_display_unavailable')
26
30
  try{accessSync(binary,constants.X_OK)}catch{throw Error('desktop_helper_missing')}
@@ -29,14 +33,21 @@ export async function launchAvatar({onCommand,onExit,signal,size,ownerKind='brow
29
33
  const ipc=new WebSocketServer({host:'127.0.0.1',port:0,maxPayload:2048,
30
34
  verifyClient:({req})=>sameSecret(req.headers['sec-websocket-protocol'],`duet-avatar-${token}`)})
31
35
  await new Promise((resolve,reject)=>{ipc.once('listening',resolve);ipc.once('error',reject)})
32
- let child,peer,closed=false,ready=false,timeout,killTimer,abort
36
+ let child,peer,closed=false,ready=false,timeout,killTimer,abort,userData,visibility=null
37
+ const isRunning=()=>child&&child.exitCode===null&&child.signalCode==null
38
+ const cleanupData=()=>{if(userData){const path=userData;userData=null;rm(path,{recursive:true,force:true,maxRetries:10,retryDelay:200},()=>{})}}
39
+ const closeIPC=()=>{for(const ws of ipc.clients)ws.terminate();ipc.close()}
33
40
  const stop=()=>{
34
41
  if(closed)return
35
42
  closed=true;clearTimeout(timeout)
36
43
  signal?.removeEventListener('abort',abort)
37
- for(const ws of ipc.clients)ws.terminate()
38
- ipc.close()
39
- if(child&&child.exitCode===null){child.kill();killTimer=setTimeout(()=>{if(child.exitCode===null)child.kill('SIGKILL')},2000);killTimer.unref()}
44
+ if(isRunning()){
45
+ // Let the renderer close WebView2 normally before forcing the native tree down.
46
+ // The Windows helper owns a kill-on-close Job Object for its descendants.
47
+ killTimer=setTimeout(()=>{closeIPC();if(isRunning())child.kill('SIGKILL')},2000);killTimer.unref()
48
+ if(peer?.readyState===1){try{peer.send(JSON.stringify({type:'shutdown'}))}catch{closeIPC();child.kill()}}
49
+ else {closeIPC();if(!peer)child.kill()}
50
+ }else {closeIPC();cleanupData()}
40
51
  }
41
52
  const initialized=new Promise((resolve,reject)=>{
42
53
  const fail=code=>{if(closed)return;stop();if(!ready)reject(Error(code));else onExit(code)}
@@ -47,9 +58,15 @@ export async function launchAvatar({onCommand,onExit,signal,size,ownerKind='brow
47
58
  if(peer){ws.close(1008);return}peer=ws
48
59
  ws.on('error',()=>{})
49
60
  ws.on('message',raw=>{
61
+ if(closed)return
50
62
  try{
51
63
  const msg=JSON.parse(raw)
52
- if(msg.type==='ready'&&!ready){if(msg.protocol!==AVATAR_UI_PROTOCOL){fail('desktop_helper_upgrade_required');return}ready=true;clearTimeout(timeout);resolve()}
64
+ if(msg.type==='ready'&&!ready){
65
+ if(msg.protocol!==AVATAR_UI_PROTOCOL){fail('desktop_helper_upgrade_required');return}
66
+ if(typeof msg.window_visible==='boolean')visibility={visible:msg.window_visible,fullscreenSuppressed:msg.fullscreen_suppressed===true}
67
+ if(visibility&&!visibility.visible&&!visibility.fullscreenSuppressed){fail('desktop_renderer_failed');return}
68
+ ready=true;clearTimeout(timeout);resolve()
69
+ }
53
70
  else if(ready&&msg.type==='surface_action')onCommand(avatarSurfaceAction(msg))
54
71
  else if(ready&&msg.type==='menu_action')onCommand(avatarMenuAction(msg))
55
72
  else if(ready&&msg.type==='avatar_geometry')onCommand({type:'avatar_geometry',position:avatarGeometry(msg.position)})
@@ -66,26 +83,28 @@ export async function launchAvatar({onCommand,onExit,signal,size,ownerKind='brow
66
83
  try{
67
84
  // No shell, user-supplied executable, detached daemon, inherited credentials, or CLI token.
68
85
  const safeEnv=Object.fromEntries(['PATH','HOME','USERPROFILE','LOCALAPPDATA','APPDATA','SYSTEMROOT','WINDIR','TEMP','TMP','TMPDIR','DISPLAY','WAYLAND_DISPLAY','XDG_RUNTIME_DIR','DBUS_SESSION_BUS_ADDRESS','LANG','LC_ALL'].filter(k=>env[k]).map(k=>[k,env[k]]))
69
- child=spawnImpl(binary,[],{stdio:'ignore',windowsHide:true,env:{...safeEnv,
86
+ if(platform==='win32')userData=mkdtempSync(join(tmpdir(),'dsh-duet-webview-'))
87
+ child=spawnImpl(binary,[],{stdio:'ignore',windowsHide:false,env:{...safeEnv,
88
+ ...(userData?{DUET_AVATAR_USER_DATA:userData}:{}),
70
89
  DUET_AVATAR_ASSETS:assetsPath,DUET_AVATAR_IPC:`ws://127.0.0.1:${ipc.address().port}`,DUET_AVATAR_TOKEN:token,DUET_AVATAR_SIZE:avatarSize(size),
71
90
  DUET_AVATAR_OWNER_KIND:['desktop','chrome','edge','firefox','safari','browser'].includes(ownerKind)?ownerKind:'browser'}})
72
- child.once('error',()=>fail('desktop_launch_failed'))
73
- child.once('exit',code=>{clearTimeout(killTimer);fail(code===78?'desktop_webview2_missing':'desktop_closed')})
91
+ child.once('error',()=>{cleanupData();fail('desktop_launch_failed')})
92
+ child.once('exit',code=>{clearTimeout(killTimer);closeIPC();cleanupData();fail(code===78?'desktop_webview2_missing':'desktop_closed')})
74
93
  timeout=setTimeout(()=>fail('desktop_start_timeout'),20000);timeout.unref()
75
- }catch{fail('desktop_launch_failed')}
94
+ }catch{cleanupData();fail('desktop_launch_failed')}
76
95
  })
77
96
  await initialized
78
- return {close:stop,send(frame){if(peer?.readyState===1&&peer.bufferedAmount<16000)peer.send(JSON.stringify(frame))}}
97
+ return {visibility,close:stop,send(frame){if(peer?.readyState===1&&peer.bufferedAmount<16000)peer.send(JSON.stringify(frame))}}
79
98
  }
80
99
 
81
100
  /** Exactly one owning DSH page per Host; other pages cannot drive its companion. */
82
101
  export function registerAvatarHost(ctx, {launch=launchAvatar}={}) {
83
102
  const server=new WebSocketServer({noServer:true,maxPayload:65536}),clients=new Set()
84
103
  let owner=null,closed=false
85
- const unregister=ctx.webServer.registerUpgrade({path:'/duet/avatar/ws',handler(req,socket,head){
104
+ const unregister=ctx.webServer.registerUpgrade({path:'/duet/avatar/ws',handler(req,socket,head,peer){
86
105
  let allowed=!req.headers.origin
87
106
  try{if(req.headers.origin)allowed=new URL(req.headers.origin).host===req.headers.host}catch{}
88
- if(closed||!allowed||ctx.connection.requestRejection(req)||clients.size>=8){socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n');return}
107
+ if(closed||!allowed||requestRejection(ctx,req,peer)||clients.size>=8){socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n');return}
89
108
  server.handleUpgrade(req,socket,head,ws=>{
90
109
  clients.add(ws);let helper,starting=false,ended=false,frames=0,second=Date.now(),alive=Date.now()
91
110
  const lifetime=new AbortController()