dsh-duet 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/avatar/desktop/companion.mjs +3 -4
- package/assets/avatar/desktop/manifest.json +1 -1
- package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
- package/desktop/bin/darwin-arm64/manifest.json +3 -3
- package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
- package/desktop/bin/win32-x64/manifest.json +3 -3
- package/node_modules/dsh-duet-superagent/lib/duet.d.ts +19 -3
- package/node_modules/dsh-duet-superagent/lib/duet.js +156 -10
- package/node_modules/dsh-duet-superagent/lib/{feishu-rAGM9U9b.js → feishu-CwKBb-B_.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/feishu-watch.js +1 -1
- package/node_modules/dsh-duet-superagent/lib/{github-pull-gSbjzypm.js → github-pull-DyfAy0yE.js} +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.d.ts +1 -1
- package/node_modules/dsh-duet-superagent/lib/github-watch.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/index.js +2 -2
- package/node_modules/dsh-duet-superagent/lib/{poll-Dh7J1cdM.js → poll-BBkmV_GM.js} +4 -1
- package/node_modules/dsh-duet-superagent/lib/{registry-BTgyFZ8S.d.ts → registry-Ehgir8LC.d.ts} +70 -61
- package/node_modules/dsh-duet-superagent/lib/{runtime-CbDPyQoo.js → runtime-Ow0S-7ZZ.js} +45 -5
- package/package.json +6 -2
- package/src/avatar/surface.mjs +6 -1
- package/src/client/agent-entry.mjs +27 -0
- package/src/client/agent-tasks.mjs +42 -10
- package/src/client/agent-tool-views.mjs +190 -0
- package/src/client/audio.mjs +1 -1
- package/src/client/avatar-surfaces.mjs +3 -3
- package/src/client/browser.mjs +35 -27
- package/src/client/composer-bridge.mjs +1 -1
- package/src/client/connection-hint.mjs +20 -5
- package/src/client/entry.js +10 -3
- package/src/client/feedback.mjs +1 -1
- package/src/client/identity.mjs +1 -1
- package/src/client/settings.html +84 -80
- package/src/client/tutorial-adapter.mjs +5 -5
- package/src/client/tutorial.mjs +1 -1
- package/src/client/work-mode.mjs +46 -9
- package/src/host/agent-connection.mjs +6 -1
- package/src/host/assets.mjs +2 -0
- package/src/host/plugin.mjs +4 -2
- package/src/shared/avatar-menu-ui.mjs +30 -12
- package/src/shared/avatar-menu.mjs +4 -1
- package/src/shared/avatar-surface.mjs +1 -0
- package/src/shared/avatar-ui.mjs +2 -0
- package/src/shared/state.mjs +1 -1
- package/src/shared/work-mode.mjs +64 -4
package/src/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,40 @@ 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
|
+
}
|
|
26
|
+
const waitingReads=new Map(),waitingKey=id=>'duet.agent.waiting-read.v1.'+id
|
|
27
|
+
export function taskCardState(row){
|
|
28
|
+
return ['completed','merged','ready','ended'].includes(row.state)?'completed':['failed'].includes(row.state)?'failed':
|
|
29
|
+
['stopped','dropped','closed','cancelled'].includes(row.state)?'stopped':
|
|
30
|
+
['queued','pending','running','progress'].includes(row.state)?'running':'waiting'
|
|
31
|
+
}
|
|
32
|
+
const waitingNotice=row=>JSON.stringify([row.attention_id||null,row.run_id||null,row.state])
|
|
33
|
+
function waitingWasRead(row){
|
|
34
|
+
let saved=waitingReads.get(row.session_id)
|
|
35
|
+
try{saved=localStorage.getItem(waitingKey(row.session_id))||saved}catch{}
|
|
36
|
+
return saved===waitingNotice(row)
|
|
37
|
+
}
|
|
38
|
+
export function noteTaskNoticeVisit(row,now=Date.now()){
|
|
39
|
+
if(!row||!nativeWorkerId(row.session_id))return
|
|
40
|
+
if(row.finished_at)noteTaskVisit(row.session_id,now)
|
|
41
|
+
else if(taskCardState(row)==='waiting'){
|
|
42
|
+
const value=waitingNotice(row);waitingReads.set(row.session_id,value)
|
|
43
|
+
try{localStorage.setItem(waitingKey(row.session_id),value)}catch{}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
12
46
|
function storedVisit(id){
|
|
13
47
|
try{return Number(localStorage.getItem(visitKey(id)))||0}catch{return 0}
|
|
14
48
|
}
|
|
@@ -23,16 +57,36 @@ export function noteTaskVisit(id,now=Date.now()){
|
|
|
23
57
|
}
|
|
24
58
|
export function visibleTaskRows(rows){
|
|
25
59
|
const old=legacyVisits()
|
|
26
|
-
return rows.filter(r=>
|
|
27
|
-
|
|
60
|
+
return rows.filter(r=>{
|
|
61
|
+
if(!r)return false
|
|
62
|
+
if(taskCompletionSeconds(r)===0)return false
|
|
63
|
+
const visited=Math.max(Number(old[r.session_id])||0,cachedVisits.get(r.session_id)||0,storedVisit(r.session_id))
|
|
64
|
+
return r.finished_at ? visited<r.finished_at : taskCardState(r)!=='waiting'||!waitingWasRead(r)
|
|
65
|
+
})
|
|
28
66
|
}
|
|
29
67
|
export const TASK_STATES={queued:'排队中',pending:'准备中',running:'运行中',progress:'运行中',waiting:'等待中',
|
|
30
68
|
waiting_user:'待你回答',ready:'结果就绪',ended:'执行已结束',completed:'已完成',merged:'已完成',
|
|
31
69
|
failed:'失败',blocked:'受阻',dropped:'已终止',stopped:'已停止',closed:'已关闭'}
|
|
32
70
|
export const WORK_MODES = {
|
|
33
|
-
direct: {name:'
|
|
71
|
+
direct: {name:'输入模式(传统)',description:'帮你把需求输入文本框'},
|
|
34
72
|
agent: {name:'代理模式',description:'直接帮你执行任务'},
|
|
35
73
|
}
|
|
74
|
+
export const AGENT_WORKSPACE_NOTICE = '代理模式只能在全新工作区和会话中使用;如果需要在历史会话中使用,请使用输入模式。'
|
|
75
|
+
const reminderKey='dsh.duet.agent-entry-reminders.v1'
|
|
76
|
+
const reminderConnections=new Map()
|
|
77
|
+
let reminderCount=0
|
|
78
|
+
export function agentEntryReminder(connectionId,storage){
|
|
79
|
+
if(!connectionId)return false
|
|
80
|
+
if(reminderConnections.has(connectionId))return reminderConnections.get(connectionId)
|
|
81
|
+
try{storage??=globalThis.localStorage}catch{}
|
|
82
|
+
try{const n=Number(storage?.getItem(reminderKey));if(Number.isSafeInteger(n)&&n>=0)reminderCount=Math.max(reminderCount,n)}catch{}
|
|
83
|
+
const show=reminderCount<10
|
|
84
|
+
reminderCount=Math.min(10,reminderCount+1)
|
|
85
|
+
try{storage?.setItem(reminderKey,String(reminderCount))}catch{}
|
|
86
|
+
reminderConnections.set(connectionId,show)
|
|
87
|
+
if(reminderConnections.size>100)reminderConnections.delete(reminderConnections.keys().next().value)
|
|
88
|
+
return show
|
|
89
|
+
}
|
|
36
90
|
export const AGENT_PERMISSION_TEXT = '启用代理模式后,dsh-duet 会以完整权限(danger-full-access)执行命令、读写文件和访问网络,无需逐项确认。任务从所选工作区开始,但访问不限于该目录;其他 DSH 会话的权限不变。'
|
|
37
91
|
export const validAgentWorkspaceId = id => typeof id === 'string' && id.length > 0 && id.length <= 512
|
|
38
92
|
export function roleModel(value) {
|
|
@@ -47,7 +101,8 @@ export function agentOptions(value = {}) {
|
|
|
47
101
|
if (!value || typeof value!=='object' || Array.isArray(value)) throw Error('invalid_agent_options')
|
|
48
102
|
const workspace_id=value.workspace_id??null
|
|
49
103
|
if(workspace_id!==null&&!validAgentWorkspaceId(workspace_id))throw Error('invalid_agent_workspace')
|
|
50
|
-
|
|
104
|
+
if(value.auto_switch_session!==undefined&&typeof value.auto_switch_session!=='boolean')throw Error('invalid_agent_auto_switch')
|
|
105
|
+
return {workspace_id,executor_model:roleModel(value.executor_model),manager_model:roleModel(value.manager_model),auto_switch_session:value.auto_switch_session!==false}
|
|
51
106
|
}
|
|
52
107
|
export function workModeIssue(config) {
|
|
53
108
|
if(config.work_mode_choice_version!==WORK_MODE_VERSION)return 'work_mode_choice_required'
|
|
@@ -57,3 +112,8 @@ export function workModeIssue(config) {
|
|
|
57
112
|
}
|
|
58
113
|
return null
|
|
59
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
|
+
}
|