dsh-duet 0.3.1 → 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 +17 -2
- package/node_modules/dsh-duet-superagent/lib/duet.js +99 -4
- 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-mbw1-2iK.js → runtime-Ow0S-7ZZ.js} +44 -4
- package/package.json +1 -1
- package/src/avatar/surface.mjs +6 -1
- package/src/client/agent-tasks.mjs +34 -5
- package/src/client/audio.mjs +1 -1
- package/src/client/avatar-surfaces.mjs +3 -3
- package/src/client/browser.mjs +22 -22
- package/src/client/composer-bridge.mjs +1 -1
- package/src/client/connection-hint.mjs +1 -1
- package/src/client/entry.js +2 -2
- package/src/client/feedback.mjs +1 -1
- package/src/client/identity.mjs +1 -1
- package/src/client/settings.html +4 -4
- package/src/client/tutorial-adapter.mjs +5 -5
- package/src/client/tutorial.mjs +1 -1
- package/src/client/work-mode.mjs +12 -6
- 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 +20 -0
|
@@ -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)})
|
package/src/shared/avatar-ui.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {avatarSize,AVATAR_SIZES} from './avatar.mjs'
|
|
2
|
+
/** Shared by live agent tasks and short-lived completion notices. */
|
|
3
|
+
export const taskBubbleCardStyle='display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:14px 16px;margin:0;border:1px solid #ffffff90;border-radius:20px;background:#f7f9fbe8;color:#253344;text-align:left;cursor:pointer;box-shadow:0 6px 18px -8px #172c4938;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);font:13px/1.5 -apple-system,BlinkMacSystemFont,system-ui,sans-serif'
|
|
2
4
|
const sizes=Object.keys(AVATAR_SIZES),names={large:'大(100%)',medium:'中(75%)',small:'小(50%)'}
|
|
3
5
|
export const nextAvatarSize=value=>sizes[(sizes.indexOf(avatarSize(value))+1)%sizes.length]
|
|
4
6
|
export function sizeButton(button,value,{label=false}={}) {
|
package/src/shared/state.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Desired voice mode is independent of a temporarily suspended connection. */
|
|
2
|
-
export const PLUGIN_VERSION = '0.3.
|
|
2
|
+
export const PLUGIN_VERSION = '0.3.2'
|
|
3
3
|
export const IDLE_RELEASE_MS = 60_000
|
|
4
4
|
|
|
5
5
|
const safeVersion = value => typeof value === 'string' && value.length <= 32 && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value) ? value : ''
|
package/src/shared/work-mode.mjs
CHANGED
|
@@ -9,6 +9,20 @@ export function effectiveWorkPolicy(config,policy='recommend_agent'){
|
|
|
9
9
|
const READ_KEY='duet.agent.visited.v1', visitKey=id=>READ_KEY+'.'+id
|
|
10
10
|
export const nativeWorkerId=id=>typeof id==='string' && /^worker-[a-f0-9]{32}$/.test(id)
|
|
11
11
|
const cachedVisits=new Map()
|
|
12
|
+
const completionTimers=new Map(),completionKey=id=>'duet.agent.completion-expiry.v1.'+id
|
|
13
|
+
/** Start once on receipt, not on the possibly skewed DSH completion clock. */
|
|
14
|
+
export function taskCompletionSeconds(row,now=Date.now()){
|
|
15
|
+
if(!nativeWorkerId(row?.session_id)||!Number.isFinite(row.finished_at)||taskCardState(row)!=='completed')return null
|
|
16
|
+
const stamp=JSON.stringify([row.run_id??null,row.finished_at]),key=completionKey(row.session_id)
|
|
17
|
+
let saved=completionTimers.get(key)
|
|
18
|
+
try{const stored=JSON.parse(localStorage.getItem(key));if(stored?.stamp===stamp&&Number.isFinite(stored.end))saved=stored}catch{}
|
|
19
|
+
if(saved?.stamp!==stamp||!Number.isFinite(saved.end)){
|
|
20
|
+
saved={stamp,end:now+10000};completionTimers.set(key,saved)
|
|
21
|
+
try{localStorage.setItem(key,JSON.stringify(saved))}catch{}
|
|
22
|
+
}
|
|
23
|
+
completionTimers.set(key,saved)
|
|
24
|
+
return Math.max(0,Math.min(10,Math.ceil((saved.end-now)/1000)))
|
|
25
|
+
}
|
|
12
26
|
const waitingReads=new Map(),waitingKey=id=>'duet.agent.waiting-read.v1.'+id
|
|
13
27
|
export function taskCardState(row){
|
|
14
28
|
return ['completed','merged','ready','ended'].includes(row.state)?'completed':['failed'].includes(row.state)?'failed':
|
|
@@ -45,6 +59,7 @@ export function visibleTaskRows(rows){
|
|
|
45
59
|
const old=legacyVisits()
|
|
46
60
|
return rows.filter(r=>{
|
|
47
61
|
if(!r)return false
|
|
62
|
+
if(taskCompletionSeconds(r)===0)return false
|
|
48
63
|
const visited=Math.max(Number(old[r.session_id])||0,cachedVisits.get(r.session_id)||0,storedVisit(r.session_id))
|
|
49
64
|
return r.finished_at ? visited<r.finished_at : taskCardState(r)!=='waiting'||!waitingWasRead(r)
|
|
50
65
|
})
|
|
@@ -97,3 +112,8 @@ export function workModeIssue(config) {
|
|
|
97
112
|
}
|
|
98
113
|
return null
|
|
99
114
|
}
|
|
115
|
+
export function taskModelLabel(info) {
|
|
116
|
+
if(!info || typeof info.provider!=='string' || typeof info.model!=='string')return '模型尚未记录'
|
|
117
|
+
const prefix={response:'最近使用',request:'最近请求',selection:'已选择',configured:'待使用'}[info.source]||'模型'
|
|
118
|
+
return `${prefix}:${info.provider} / ${info.model}`
|
|
119
|
+
}
|