dsh-remote-plugin 0.8.7 → 0.9.0
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/README.en.md +16 -5
- package/README.md +15 -4
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +659 -130
- package/index.mjs +33 -1
- package/package.json +8 -3
- package/public/activity.js +196 -52
- package/public/admin.html +34 -32
- package/public/admin.js +11 -2
- package/public/app.js +1341 -223
- package/public/bc-integration.css +81 -0
- package/public/build.json +2 -2
- package/public/composer-tools.css +184 -0
- package/public/composer-tools.js +888 -0
- package/public/desktop/desktop.html +104 -76
- package/public/desktop/desktop.js +668 -101
- package/public/diagnostics.js +30 -4
- package/public/e2ee-transport.js +154 -7
- package/public/file-inbox.js +77 -18
- package/public/genui.css +10 -0
- package/public/genui.js +22 -4
- package/public/history.js +15 -2
- package/public/host-queue.js +232 -0
- package/public/host-schedule.js +301 -0
- package/public/host-state.css +19 -0
- package/public/index.html +347 -140
- package/public/md.js +21 -1
- package/public/network.js +33 -1
- package/public/onboarding.js +3 -3
- package/public/operations.js +26 -12
- package/public/plan-review.css +297 -0
- package/public/plan-review.js +621 -0
- package/public/plugin.html +29 -27
- package/public/relay-autopair.js +25 -10
- package/public/relay-settings.css +11 -0
- package/public/relay-settings.js +350 -28
- package/public/session-management.css +61 -0
- package/public/session-management.js +742 -0
- package/public/session-search.css +137 -0
- package/public/session-search.js +977 -0
- package/public/skins/blue-fish/preview.html +3 -3
- package/public/skins/bocchi/preview.html +5 -5
- package/public/skins/kita/preview.html +6 -6
- package/public/skins/miku/SOURCES.json +10 -0
- package/public/skins/miku/chibi.png +0 -0
- package/public/skins/miku/preview.html +33 -0
- package/public/skins/miku/skin.css +82 -0
- package/public/skins/nijika/preview.html +6 -6
- package/public/skins/penguin/preview.html +3 -3
- package/public/skins/penguin-logistics/cargo.svg +4 -0
- package/public/skins/penguin-logistics/console.svg +4 -0
- package/public/skins/penguin-logistics/mark.svg +4 -0
- package/public/skins/penguin-logistics/radio.svg +4 -0
- package/public/skins/penguin-logistics/skin.css +292 -0
- package/public/skins/penguin-logistics/standing.png +0 -0
- package/public/skins/ryo/preview.html +6 -6
- package/public/slash-suggestions.css +43 -0
- package/public/slash-suggestions.js +196 -0
- package/public/sponsor-entry.js +11 -3
- package/public/styles.css +141 -21
- package/public/subagents.css +7 -0
- package/public/subagents.js +83 -10
- package/public/theme-vars.css +102 -3
- package/public/theme.js +7 -4
- package/public/turn-diff.css +323 -0
- package/public/turn-diff.js +778 -0
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +322 -43
- package/public/workflow.js +148 -44
package/index.mjs
CHANGED
|
@@ -1448,6 +1448,7 @@ async function serveStatic(req, res, ctx) {
|
|
|
1448
1448
|
[`${MOUNT}/admin/api/device-keys/mode`, '/device-keys/mode'],
|
|
1449
1449
|
[`${MOUNT}/admin/api/device-keys/create`, '/device-keys/create'],
|
|
1450
1450
|
[`${MOUNT}/admin/api/device-keys/note`, '/device-keys/note'],
|
|
1451
|
+
[`${MOUNT}/admin/api/device-keys/host-state-access`, '/device-keys/host-state-access'],
|
|
1451
1452
|
[`${MOUNT}/admin/api/device-keys/rotate`, '/device-keys/rotate'],
|
|
1452
1453
|
[`${MOUNT}/admin/api/device-keys/revoke`, '/device-keys/revoke'],
|
|
1453
1454
|
])
|
|
@@ -1598,8 +1599,39 @@ async function serveStatic(req, res, ctx) {
|
|
|
1598
1599
|
|
|
1599
1600
|
// 斜杠命令桥接:客户端 → 网关 → 插件端点 → ctx.commands.execute
|
|
1600
1601
|
if (pathname === `${MOUNT}/api/command`) {
|
|
1602
|
+
if (req.method === 'GET') {
|
|
1603
|
+
res.setHeader('cache-control', 'no-store')
|
|
1604
|
+
if (!remoteCommandAuthorized(req)) return sendJson(res, 401, { ok: false, message: 'unauthorized' })
|
|
1605
|
+
const query = new URL(req.url, 'http://x').searchParams
|
|
1606
|
+
const sessionId = query.get('sessionId')
|
|
1607
|
+
if (!sessionId || sessionId.length > 256 || [...query.keys()].length !== 1) {
|
|
1608
|
+
return sendJson(res, 400, { ok: false, message: 'sessionId required' })
|
|
1609
|
+
}
|
|
1610
|
+
try {
|
|
1611
|
+
// Like DSH's commands/list, resolve the session first so commands registered
|
|
1612
|
+
// under the agent's context are included for an existing cold session.
|
|
1613
|
+
const controller = ctx.get?.('sessionController')
|
|
1614
|
+
const { agent } = typeof controller?.resolveAgent === 'function'
|
|
1615
|
+
? await controller.resolveAgent(sessionId)
|
|
1616
|
+
: await resolveAgent(ctx, sessionId)
|
|
1617
|
+
if (!agent) return sendJson(res, 404, { ok: false, message: 'agent not found' })
|
|
1618
|
+
const entries = await ctx.commands.list(agent)
|
|
1619
|
+
const commands = (Array.isArray(entries) ? entries : []).flatMap(entry => {
|
|
1620
|
+
const name = commandEntryName(entry)
|
|
1621
|
+
if (!/^[a-z][a-z0-9_-]{0,199}$/.test(name)) return []
|
|
1622
|
+
return [{
|
|
1623
|
+
name,
|
|
1624
|
+
description: typeof entry?.description === 'string' ? entry.description.slice(0, 500) : '',
|
|
1625
|
+
hint: typeof entry?.input?.hint === 'string' ? entry.input.hint.slice(0, 120) : '',
|
|
1626
|
+
}]
|
|
1627
|
+
})
|
|
1628
|
+
return sendJson(res, 200, { ok: true, commands })
|
|
1629
|
+
} catch {
|
|
1630
|
+
return sendJson(res, 503, { ok: false, message: 'command-list-unavailable' })
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1601
1633
|
if (req.method !== 'POST') {
|
|
1602
|
-
res.writeHead(405, { allow: 'POST' })
|
|
1634
|
+
res.writeHead(405, { allow: 'GET, POST' })
|
|
1603
1635
|
res.end()
|
|
1604
1636
|
return
|
|
1605
1637
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH Remote
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "DSH Remote:DeepSeek Harness 手机远程控制台,查看会话、接审批、回答提问、继续对话与收发文件;内置网关,支持 Android 与手机/桌面 WebUI。社区第三方插件,作者 Blank-not-black。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
7
7
|
"exports": {
|
|
@@ -40,7 +40,12 @@
|
|
|
40
40
|
"dsh",
|
|
41
41
|
"bundle",
|
|
42
42
|
"remote-control",
|
|
43
|
-
"mobile"
|
|
43
|
+
"mobile",
|
|
44
|
+
"android",
|
|
45
|
+
"webui",
|
|
46
|
+
"remote-approvals",
|
|
47
|
+
"file-transfer",
|
|
48
|
+
"self-hosted"
|
|
44
49
|
],
|
|
45
50
|
"license": "MIT",
|
|
46
51
|
"homepage": "https://github.com/Blank-not-black/dsh-Remote",
|
package/public/activity.js
CHANGED
|
@@ -29,11 +29,13 @@
|
|
|
29
29
|
const section=(title,content)=>`<section><h4>${esc(title)}</h4><pre>${esc(cut(json(content),12000))}</pre></section>`
|
|
30
30
|
const translated=returned?root.DshApprovalRecords?.feedbackHtml(value.result):''
|
|
31
31
|
const body=(args===undefined?'':section(text('参数','Arguments'),args))+(returned?(translated||section(text('结果','Result'),value.result)):`<p class="activity-note">${esc(text('当前记录中尚无对应结果。','No matching result in the loaded history.'))}</p>`)
|
|
32
|
+
+(value.children?.length?`<div class="activity-nested-tools">${value.children.map(tool).join('')}</div>`:'')
|
|
32
33
|
return shell('tool',value.key,value.name||text(returned?'工具结果':'工具调用',returned?'Tool result':'Tool call'),argumentHint(args),text(error?'返回错误':returned?'已返回':'已调用',error?'Error':returned?'Returned':'Called'),body,false,error)
|
|
33
34
|
}
|
|
34
35
|
const dataOf=entry=>entry.event?.data||{}
|
|
35
36
|
const callId=data=>data.callId||data.message?.source?.callId
|
|
36
37
|
const resultOf=data=>data.error??data.result??data.output??data.message??data.text??data.content??data
|
|
38
|
+
const isDispatch=type=>type==='tool/ptc-dispatch-start'||type==='tool/ptc-dispatch'
|
|
37
39
|
const pairs=new WeakMap()
|
|
38
40
|
function prepare(entries){
|
|
39
41
|
const pending=new Map(),matched=new Map(),consumed=new Set()
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
if(index>=0){const [call]=queue.splice(index,1);matched.set(call,entry);consumed.add(entry)}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
const paired=entries.filter(entry=>!consumed.has(entry)).map(entry=>{
|
|
51
53
|
if(entry.event?.type!=='tool/call')return entry
|
|
52
54
|
const result=matched.get(entry)
|
|
53
55
|
if(!result)return entry
|
|
@@ -57,72 +59,165 @@
|
|
|
57
59
|
const next={...entry,view:{...entry.view,toolActivity:{key:'tool:'+entry.seq,name:data.name||data.toolName,args:data.arguments??data.args??data.input,result:resultOf(output),error:errorOf(output)}}}
|
|
58
60
|
pairs.set(entry,{result,entry:next});return next
|
|
59
61
|
})
|
|
62
|
+
if(!paired.some(entry=>isDispatch(entry.event?.type)))return paired
|
|
63
|
+
const nodes=new Map(), children=new Map(), handled=new Set(), detached=new Map()
|
|
64
|
+
const key=(data,id)=>JSON.stringify([data.turn??null,id])
|
|
65
|
+
for(const entry of paired){
|
|
66
|
+
const data=dataOf(entry),type=entry.event?.type
|
|
67
|
+
if(type==='tool/call'&&callId(data))nodes.set(key(data,callId(data)),{entry,tool:toolFacts(entry)})
|
|
68
|
+
if(!isDispatch(type)||!data.subCallId||!data.parentCallId)continue
|
|
69
|
+
const id=key(data,data.subCallId),parent=key(data,data.parentCallId)
|
|
70
|
+
if(id===parent)continue
|
|
71
|
+
const previous=nodes.get(id)
|
|
72
|
+
if(previous && previous.parent!==parent)continue
|
|
73
|
+
nodes.set(id,{entry,parent,tool:{key:'tool:'+ (previous?.entry.seq??entry.seq),name:data.name??previous?.tool.name,args:data.arguments??previous?.tool.args,
|
|
74
|
+
...(type==='tool/ptc-dispatch'?{result:resultOf(data),error:errorOf(data)}:{})}})
|
|
75
|
+
handled.add(entry)
|
|
76
|
+
}
|
|
77
|
+
for(const [id,item] of nodes){
|
|
78
|
+
if(!item.parent)continue
|
|
79
|
+
const ancestors=new Set([id]);let ancestor=item.parent
|
|
80
|
+
while(ancestor&&nodes.has(ancestor)&&!ancestors.has(ancestor)&&ancestors.size<=16){ancestors.add(ancestor);ancestor=nodes.get(ancestor).parent}
|
|
81
|
+
if(ancestor){detached.set(item.entry,id);continue}
|
|
82
|
+
const nested=children.get(item.parent)||[];nested.push(id);children.set(item.parent,nested)
|
|
83
|
+
}
|
|
84
|
+
const nest=id=>({...nodes.get(id).tool,children:(children.get(id)||[]).map(nest)})
|
|
85
|
+
const roots=new Map([...nodes].filter(([,item])=>!item.parent).map(([id,item])=>[item.entry,id]))
|
|
86
|
+
return paired.filter(entry=>!handled.has(entry)||detached.has(entry)).map(entry=>{
|
|
87
|
+
const id=roots.get(entry)||detached.get(entry)
|
|
88
|
+
return id&&(detached.has(entry)||children.has(id))?{...entry,view:{...entry.view,toolActivity:nest(id)}}:entry
|
|
89
|
+
})
|
|
60
90
|
}
|
|
61
|
-
function
|
|
62
|
-
if(entry.view?.toolActivity)return
|
|
63
|
-
const data=dataOf(entry),
|
|
64
|
-
return
|
|
91
|
+
function toolFacts(entry){
|
|
92
|
+
if(entry.view?.toolActivity)return entry.view.toolActivity
|
|
93
|
+
const data=dataOf(entry),type=entry.event?.type,isResult=type==='tool/result'||type==='tool/ptc-dispatch'
|
|
94
|
+
return {key:'tool:'+entry.seq,name:data.name||data.toolName||(isResult?text('工具结果','Tool result'):undefined),...(isResult?{result:resultOf(data),error:errorOf(data)}:{args:data.arguments??data.args??data.input})}
|
|
65
95
|
}
|
|
96
|
+
const toolEvent=entry=>tool(toolFacts(entry))
|
|
97
|
+
const isToolEvent=type=>type==='tool/call'||type==='tool/result'||isDispatch(type)
|
|
66
98
|
function reasoningKind(block){return block&&typeof block==='object'&&(block.type==='thinking'||block.type==='reasoning')}
|
|
67
99
|
function messageBlocks(entry){
|
|
68
100
|
const data=entry?.event?.data||{},message=data.message||{}
|
|
69
101
|
const blocks=Array.isArray(message.content)?message.content:(Array.isArray(data.content)?data.content:null)
|
|
70
102
|
return blocks?{data,message,blocks}:null
|
|
71
103
|
}
|
|
72
|
-
function
|
|
104
|
+
function replaceBlocks(entry,rest){
|
|
73
105
|
const parts=messageBlocks(entry)
|
|
74
106
|
const data={...parts.data}
|
|
75
107
|
if(Array.isArray(parts.message.content))data.message={...parts.message,content:rest}
|
|
76
108
|
else data.content=rest
|
|
77
109
|
return {...entry,event:{...entry.event,data}}
|
|
78
110
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*/
|
|
84
|
-
function group(entries){
|
|
85
|
-
const isTool=entry=>{const type=entry?.event?.type;return type==='tool/call'||type==='tool/result'}
|
|
86
|
-
// Only a human message starts a new turn; injected system-reminder user events do not.
|
|
87
|
-
const isTurnStart=entry=>{
|
|
88
|
-
if(entry?.event?.type!=='user/message')return false
|
|
89
|
-
const data=entry.event.data||{},source=data.source??data.message?.source
|
|
90
|
-
return !source||source.kind==='user'
|
|
91
|
-
}
|
|
111
|
+
// Each consecutive run of reasoning and tool activity precedes its own reply.
|
|
112
|
+
function group(entries, { liveReasoning = [], running = false, suppressBlockTools = false, showTools = true } = {}){
|
|
113
|
+
const isBlockTool=block=>block?.type==='tool-call'||block?.type==='tool-result'
|
|
114
|
+
const separateCalls=new Set(entries.filter(entry=>entry.event?.type==='tool/call').map(entry=>callId(dataOf(entry))).filter(Boolean))
|
|
92
115
|
const out=[]
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
reasoning.forEach((block,index)=>items.push({kind:'reasoning',seq:Number(entry.seq)+(index+1)/1000,text:String(block.text??block.content??''),key:'reasoning:'+entry.seq+':'+index}))
|
|
116
|
+
let items=[], turn
|
|
117
|
+
function flush(active=false){
|
|
118
|
+
if(!items.length)return
|
|
119
|
+
out.push({seq:items[0].seq,event:{type:'activity/group'},view:{activityGroup:{items,running:active,turn}}})
|
|
120
|
+
items=[]
|
|
121
|
+
}
|
|
122
|
+
for(const entry of entries){
|
|
123
|
+
const event=entry.event||{},data=dataOf(entry)
|
|
124
|
+
if(data.turn!=null && turn!=null && data.turn!==turn)flush()
|
|
125
|
+
if(data.turn!=null)turn=data.turn
|
|
126
|
+
if(isToolEvent(event.type)){
|
|
127
|
+
if(showTools)items.push({kind:'tool',seq:entry.seq,entry})
|
|
128
|
+
continue
|
|
107
129
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if(
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
const parts=event.type==='assistant/message'?messageBlocks(entry):null
|
|
131
|
+
if(parts){
|
|
132
|
+
const reply=[]
|
|
133
|
+
for(const [index,block] of parts.blocks.entries()){
|
|
134
|
+
const seq=Number(entry.seq)+(index+1)/1000
|
|
135
|
+
if(reasoningKind(block)){
|
|
136
|
+
const value=String(block.text??block.content??'')
|
|
137
|
+
if(hasVisibleText(value))items.push({kind:'reasoning',seq,text:value,key:reasoningKey(data,index,'reasoning:'+entry.seq+':'+index)})
|
|
138
|
+
}else if(isBlockTool(block)){
|
|
139
|
+
const id=block.callId??block.id
|
|
140
|
+
if(showTools&&!(id?separateCalls.has(id):suppressBlockTools)){
|
|
141
|
+
const result=block.type==='tool-result'
|
|
142
|
+
items.push({kind:'embedded-tool',seq,tool:{key:'block:'+entry.seq+':'+index,id,name:block.name||block.toolName,
|
|
143
|
+
...(result?{result:resultOf(block),error:errorOf(block)}:{args:block.arguments??block.args??block.input})}})
|
|
144
|
+
}
|
|
145
|
+
}else if(block && (block.type!=='text'||hasVisibleText(block.text)))reply.push(block)
|
|
116
146
|
}
|
|
117
|
-
|
|
147
|
+
if(reply.length){flush();out.push(reply.length===parts.blocks.length?entry:replaceBlocks(entry,reply))}
|
|
148
|
+
continue
|
|
149
|
+
}
|
|
150
|
+
flush()
|
|
151
|
+
out.push(entry)
|
|
118
152
|
}
|
|
119
|
-
|
|
120
|
-
for(const
|
|
121
|
-
if(
|
|
122
|
-
|
|
153
|
+
const tail=Number(entries.at(-1)?.seq)||0
|
|
154
|
+
for(const [index,item] of liveReasoning.entries()){
|
|
155
|
+
if(!hasVisibleText(item.text))continue
|
|
156
|
+
if(item.turn!=null && turn!=null && item.turn!==turn)flush()
|
|
157
|
+
if(item.turn!=null)turn=item.turn
|
|
158
|
+
items.push({kind:'reasoning',seq:tail+(index+1)/1000,text:item.text,key:reasoningKey(item,item.index,'live-reasoning:'+index),live:true})
|
|
123
159
|
}
|
|
124
|
-
|
|
125
|
-
|
|
160
|
+
flush(running || liveReasoning.length>0)
|
|
161
|
+
const turns=new Map(), summaries=new Map()
|
|
162
|
+
let current
|
|
163
|
+
for(const entry of out){
|
|
164
|
+
const {type,time}=entry.event
|
|
165
|
+
const id=entry.event.data?.turn??entry.view?.activityGroup?.turn
|
|
166
|
+
if(type==='turn/start')current=id
|
|
167
|
+
if(type==='user/message'&¤t!=null){
|
|
168
|
+
const data=dataOf(entry), source=data.source??data.message?.source
|
|
169
|
+
const record=turns.get(current)
|
|
170
|
+
if(record?.groups.length&&(!source||source.kind==='user'))record.interleaved=true
|
|
171
|
+
}
|
|
172
|
+
if(id==null)continue
|
|
173
|
+
if(type==='turn/start')turns.set(id,{start:time,groups:[],interleaved:false})
|
|
174
|
+
const record=turns.get(id)
|
|
175
|
+
if(!record)continue
|
|
176
|
+
if(type==='activity/group')record.groups.push(entry)
|
|
177
|
+
if(type==='turn/end'&&record.groups.length&&!record.interleaved&&['completed','complete'].includes(entry.event.data?.reason?.kind)){
|
|
178
|
+
const first=record.groups[0]
|
|
179
|
+
const duration=Number.isFinite(record.start)&&Number.isFinite(time)?Math.max(1,Math.round((time-record.start)/1000)):null
|
|
180
|
+
let thoughts=0, calls=0
|
|
181
|
+
const counted=new Set()
|
|
182
|
+
for(const row of record.groups){
|
|
183
|
+
const group=row.view.activityGroup
|
|
184
|
+
group.summaryTurn=id
|
|
185
|
+
for(const item of group.items){
|
|
186
|
+
if(item.kind==='reasoning')thoughts++
|
|
187
|
+
else calls+=countToolTree(item.tool||item.entry?.view?.toolActivity,counted,item.tool?.id??(item.entry&&callId(dataOf(item.entry))))
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
summaries.set(first,{seq:first.seq-0.0001,event:{type:'activity/turn'},view:{activityTurn:{id,duration,thoughts,calls}}})
|
|
191
|
+
}
|
|
192
|
+
if(type==='turn/end')current=undefined
|
|
193
|
+
}
|
|
194
|
+
return out.flatMap(entry=>summaries.has(entry)?[summaries.get(entry),entry]:[entry])
|
|
195
|
+
}
|
|
196
|
+
function groupHtml(group, renderEntry){
|
|
197
|
+
const {items,running}=group
|
|
198
|
+
const tools=items.filter(item=>item.kind!=='reasoning')
|
|
199
|
+
const thoughts=items.length-tools.length
|
|
200
|
+
const failed=tools.some(item=>item.tool?.error||item.entry?.view?.toolActivity?.error||errorOf(item.entry?.event?.data))
|
|
201
|
+
const counts=[thoughts?text('思考','Reasoning'):'',tools.length?text(`${tools.length} 次工具调用`,`${tools.length} tool ${tools.length===1?'call':'calls'}`):''].filter(Boolean)
|
|
202
|
+
const title=running?text(items.at(-1).kind==='reasoning'?'思考中':'正在使用工具',items.at(-1).kind==='reasoning'?'Thinking':'Using tools'):counts.join(' · ')
|
|
203
|
+
const body=items.map(item=>item.kind==='reasoning'?reasoning(item):item.kind==='embedded-tool'?tool(item.tool):renderEntry(item.entry)).join('')
|
|
204
|
+
const owner=group.summaryTurn==null?'':` data-activity-turn="${esc(group.summaryTurn)}"`
|
|
205
|
+
return `<details class="chat-activity-group${failed?' is-error':''}${running?' is-running':''}" data-activity-key="activity-group:${esc(items[0].key||items[0].seq)}"${owner}><summary><span class="activity-chevron" aria-hidden="true"></span>${icon(thoughts?'reasoning':'tool')}<span class="activity-group-title">${esc(title)}</span></summary><div class="activity-group-body">${body}</div></details>`
|
|
206
|
+
}
|
|
207
|
+
function countToolTree(value,counted,id=value?.key){
|
|
208
|
+
if(id!=null){
|
|
209
|
+
if(counted.has(id))return 0
|
|
210
|
+
counted.add(id)
|
|
211
|
+
}
|
|
212
|
+
return 1+(value?.children||[]).reduce((count,child)=>count+countToolTree(child,counted),0)
|
|
213
|
+
}
|
|
214
|
+
function turnHtml({id,duration,thoughts,calls}){
|
|
215
|
+
const facts=[
|
|
216
|
+
thoughts&&text(`${thoughts} 段思考`,`${thoughts} reasoning ${thoughts===1?'block':'blocks'}`),
|
|
217
|
+
calls&&text(`${calls} 次工具调用`,`${calls} tool ${calls===1?'call':'calls'}`),
|
|
218
|
+
].filter(Boolean)
|
|
219
|
+
const elapsed=duration==null?'':text(`耗时 ${duration} 秒`,`${duration}s elapsed`)
|
|
220
|
+
return `<details class="chat-activity-turn" data-activity-summary="${esc(id)}" data-activity-key="activity-turn:${esc(id)}"><summary><span class="activity-chevron" aria-hidden="true"></span><span class="activity-turn-title">${esc(text('本轮过程','Run details'))}</span>${facts.length?`<span class="activity-turn-facts">${esc(facts.join(' · '))}</span>`:''}${elapsed?`<span class="activity-turn-time">${esc(elapsed)}</span>`:''}</summary></details>`
|
|
126
221
|
}
|
|
127
222
|
function reasoningKey(data,index,fallback){return data?.turn!=null&&data?.step!=null?'reasoning:'+JSON.stringify([data.turn,data.step,index]):fallback}
|
|
128
223
|
function failure(event) {
|
|
@@ -134,11 +229,58 @@
|
|
|
134
229
|
}
|
|
135
230
|
return null
|
|
136
231
|
}
|
|
137
|
-
function
|
|
232
|
+
function continuationHtml(continuation) {
|
|
233
|
+
if (!continuation) return ''
|
|
234
|
+
const label = continuation.pending ? text('正在确认…','Confirming…') : text('继续生成','Continue generating')
|
|
235
|
+
return `<button type="button" class="history-page-control" data-continue-generation="${continuation.ending}"${continuation.pending?' disabled':''}>${esc(label)}</button>`
|
|
236
|
+
}
|
|
237
|
+
function failureHtml(value,attempt=false,continuation) {
|
|
138
238
|
if(!value)return ''
|
|
139
239
|
const message=typeof value==='string'?value:value.message
|
|
140
240
|
const facts=[value.code,value.status?`HTTP ${value.status}`:''].filter(item=>typeof item==='string'&&item)
|
|
141
|
-
return `<div class="chat-runtime-error" role="status"><strong>${esc(text(attempt?'模型请求失败':'运行出错',attempt?'Model request failed':'Run failed'))}</strong><div>${esc(cut(message||text('主机未提供错误详情','The host did not provide error details'),4000))}</div>${facts.length?`<small>${esc(facts.join(' · '))}</small>`:''}</div>`
|
|
241
|
+
return `<div class="chat-runtime-error" role="status"><strong>${esc(text(attempt?'模型请求失败':'运行出错',attempt?'Model request failed':'Run failed'))}</strong><div>${esc(cut(message||text('主机未提供错误详情','The host did not provide error details'),4000))}</div>${facts.length?`<small>${esc(facts.join(' · '))}</small>`:''}${continuationHtml(continuation)}</div>`
|
|
242
|
+
}
|
|
243
|
+
const continuationViews = new WeakMap()
|
|
244
|
+
function withContinuation(box, entries, options) {
|
|
245
|
+
let view = continuationViews.get(box)
|
|
246
|
+
if (!view) {
|
|
247
|
+
view = { histories: new WeakMap(), decorated: new WeakMap() }
|
|
248
|
+
continuationViews.set(box, view)
|
|
249
|
+
box.addEventListener('click', async event => {
|
|
250
|
+
const button = event.target.closest?.('[data-continue-generation]')
|
|
251
|
+
if (!button || !box.contains(button) || button.disabled) return
|
|
252
|
+
const current = view.options, ending = Number(button.dataset.continueGeneration)
|
|
253
|
+
if (!current.valid() || current.ending !== ending) return
|
|
254
|
+
const previous = view.histories.get(current.history)
|
|
255
|
+
if (previous?.ending === ending) return
|
|
256
|
+
const operation = { ending, pending: true }
|
|
257
|
+
view.histories.set(current.history, operation)
|
|
258
|
+
current.render()
|
|
259
|
+
try {
|
|
260
|
+
if (!(await current.submit(ending))?.accepted) throw new Error(text('主机未接受续跑请求','The Host did not accept continuation'))
|
|
261
|
+
operation.pending = false
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (view.histories.get(current.history) === operation) view.histories.delete(current.history)
|
|
264
|
+
current.failed(error)
|
|
265
|
+
} finally {
|
|
266
|
+
if (current.valid()) current.render()
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
view.options = options
|
|
271
|
+
const { ending, history } = options
|
|
272
|
+
if (!Number.isSafeInteger(ending) || ending < 0) return entries
|
|
273
|
+
const operation = view.histories.get(history)
|
|
274
|
+
const pending = operation?.ending === ending && operation.pending
|
|
275
|
+
if (operation?.ending === ending && !pending) return entries
|
|
276
|
+
return entries.map(entry => {
|
|
277
|
+
if (entry.seq !== ending || entry.event?.type !== 'turn/end' || !failure(entry.event)) return entry
|
|
278
|
+
const decorated = view.decorated.get(entry)
|
|
279
|
+
if (decorated?.view.continuation.pending === pending) return decorated
|
|
280
|
+
const row = { ...entry, view: { ...entry.view, continuation: { ending, pending } } }
|
|
281
|
+
view.decorated.set(entry, row)
|
|
282
|
+
return row
|
|
283
|
+
})
|
|
142
284
|
}
|
|
143
285
|
const failureGroups=new WeakMap()
|
|
144
286
|
function groupFailures(entries) {
|
|
@@ -168,7 +310,9 @@
|
|
|
168
310
|
function failureGroupHtml(group,renderEntry) {
|
|
169
311
|
const latest=failure(group.items.at(-1)?.event)
|
|
170
312
|
const hint=typeof latest==='string'?latest:latest?.message
|
|
171
|
-
|
|
313
|
+
const selected = group.items.find(entry => entry.view?.continuation)
|
|
314
|
+
const body = group.items.map(entry => renderEntry(entry === selected ? { ...entry, view: { ...entry.view, continuation: undefined } } : entry)).join('')
|
|
315
|
+
return shell('error','failure-group:'+group.items[0].seq,text(`连续报错 · ${group.count} 条`,`${group.count} consecutive errors`),brief(hint),text('详情','Details'),body,false,true) + continuationHtml(selected?.view.continuation)
|
|
172
316
|
}
|
|
173
317
|
function attemptHtml(event) {
|
|
174
318
|
const blocks=new Map(),data=event?.data||{}
|
|
@@ -182,7 +326,7 @@
|
|
|
182
326
|
return [...blocks].filter(([,value])=>value).map(([index,value])=>reasoning({text:value,key:`attempt:${event.seq}:${index}`})).join('')+failureHtml(failure(event),true)
|
|
183
327
|
}
|
|
184
328
|
const streamNotice=()=>`<div class="activity-note" role="status">${esc(text('弱网精简已隐藏实时思考,完成后可查看;可在网络设置中关闭精简。','Live reasoning is hidden in weak-network mode. View it after completion or disable trimming in network settings.'))}</div>`
|
|
185
|
-
const api={hasVisibleText,prepare,tool,toolEvent,reasoning,reasoningKey,group,failure,failureHtml,groupFailures,failureGroupHtml,attemptHtml,streamNotice}
|
|
329
|
+
const api={hasVisibleText,prepare,tool,toolEvent,isToolEvent,reasoning,reasoningKey,group,groupHtml,turnHtml,failure,failureHtml,groupFailures,failureGroupHtml,attemptHtml,streamNotice,withContinuation}
|
|
186
330
|
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
187
331
|
else root.DshActivity=api
|
|
188
332
|
})(typeof window==='undefined'?globalThis:window)
|
package/public/admin.html
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="zh-CN">
|
|
3
3
|
<head>
|
|
4
|
-
<meta name="dsh-remote-build" content="
|
|
4
|
+
<meta name="dsh-remote-build" content="62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
7
7
|
<meta name="theme-color" content="#0D1117">
|
|
8
8
|
<title>DSH Remote · 管理</title>
|
|
9
|
-
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
10
|
-
<link rel="stylesheet" href="../styles.css?dsr-build=
|
|
11
|
-
<link rel="stylesheet" href="../relay-settings.css?dsr-build=
|
|
12
|
-
<link rel="stylesheet" href="../insights.css?dsr-build=
|
|
13
|
-
<link rel="stylesheet" href="../setup.css?dsr-build=
|
|
14
|
-
<link rel="stylesheet" href="../doctor.css?dsr-build=
|
|
15
|
-
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=
|
|
16
|
-
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=
|
|
17
|
-
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=
|
|
18
|
-
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=
|
|
19
|
-
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=
|
|
20
|
-
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=
|
|
21
|
-
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=
|
|
9
|
+
<script>/* 首帧前应用皮肤 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'&&t!=='penguin'&&t!=='penguin-night'&&t!=='bocchi'&&t!=='nijika'&&t!=='ryo'&&t!=='kita'&&t!=='penguin-logistics'&&t!=='miku'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
10
|
+
<link rel="stylesheet" href="../styles.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
11
|
+
<link rel="stylesheet" href="../relay-settings.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
12
|
+
<link rel="stylesheet" href="../insights.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
13
|
+
<link rel="stylesheet" href="../setup.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
14
|
+
<link rel="stylesheet" href="../doctor.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
15
|
+
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
16
|
+
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
17
|
+
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
18
|
+
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
19
|
+
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
20
|
+
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
21
|
+
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
22
|
+
<link rel="stylesheet" href="../skins/penguin-logistics/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
23
|
+
<link rel="stylesheet" href="../skins/miku/skin.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
22
24
|
<style>
|
|
23
25
|
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 40px; }
|
|
24
26
|
.admin-title {
|
|
@@ -348,8 +350,8 @@
|
|
|
348
350
|
.admin-title .left { gap: 7px; }
|
|
349
351
|
}
|
|
350
352
|
</style>
|
|
351
|
-
<link rel="stylesheet" href="../remote-ui.css?dsr-build=
|
|
352
|
-
<link rel="stylesheet" href="../theme-picker.css?dsr-build=
|
|
353
|
+
<link rel="stylesheet" href="../remote-ui.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
354
|
+
<link rel="stylesheet" href="../theme-picker.css?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979">
|
|
353
355
|
</head>
|
|
354
356
|
<body>
|
|
355
357
|
<div class="admin-wrap">
|
|
@@ -580,7 +582,7 @@
|
|
|
580
582
|
'doctor.realtime': '实时消息通道', 'doctor.realtimePass': 'mux 与 host 通道均已连接', 'doctor.realtimeFail': '实时通道未全部建立;可先使用轮询,检查 DSH 后会自动恢复',
|
|
581
583
|
'doctor.start': '启动', 'doctor.showQr': '显示二维码', 'doctor.copyAddress': '复制地址', 'doctor.copyCommand': '复制命令',
|
|
582
584
|
'doctor.reportCopied': '诊断报告已复制', 'doctor.commandCopied': '防火墙命令已复制,请确认网络范围后手动执行', 'doctor.addressCopied': '服务器地址已复制',
|
|
583
|
-
'theme.default': '默认深空', 'theme.dark': '落日', 'theme.light': '易北爱乐厅', 'theme.neutral': '草原孤塔', 'theme.mono': '黑曜白', 'theme.fish': '蓝色大肥鱼', 'theme.penguin': '企鹅女管·白昼', 'theme.penguin-night': '企鹅女管·极夜', 'theme.bocchi': '波奇酱', 'theme.nijika': '伊地知虹夏', 'theme.ryo': '山田凉', 'theme.kita': '喜多郁代',
|
|
585
|
+
'theme.default': '默认深空', 'theme.dark': '落日', 'theme.light': '易北爱乐厅', 'theme.neutral': '草原孤塔', 'theme.mono': '黑曜白', 'theme.fish': '蓝色大肥鱼', 'theme.penguin': '企鹅女管·白昼', 'theme.penguin-night': '企鹅女管·极夜', 'theme.bocchi': '波奇酱', 'theme.nijika': '伊地知虹夏', 'theme.ryo': '山田凉', 'theme.kita': '喜多郁代', 'theme.penguin-logistics': '企鹅物流', 'theme.miku': '初音未来',
|
|
584
586
|
'theme.panelTitle': '选择配色', 'theme.close': '关闭',
|
|
585
587
|
'repo': '仓库',
|
|
586
588
|
'donateTitle': '赞赏支持', 'donateThanks': '感谢你的支持 ☕',
|
|
@@ -699,7 +701,7 @@
|
|
|
699
701
|
'doctor.realtime': 'Realtime channels', 'doctor.realtimePass': 'Both mux and host channels are connected', 'doctor.realtimeFail': 'Realtime channels are incomplete. Polling remains available and recovery is automatic.',
|
|
700
702
|
'doctor.start': 'Start', 'doctor.showQr': 'Show QR', 'doctor.copyAddress': 'Copy address', 'doctor.copyCommand': 'Copy command',
|
|
701
703
|
'doctor.reportCopied': 'Diagnostic report copied', 'doctor.commandCopied': 'Firewall command copied. Review the network scope before running it.', 'doctor.addressCopied': 'Server address copied',
|
|
702
|
-
'theme.default': 'Default', 'theme.dark': 'Sunset', 'theme.light': 'Elbphilharmonie', 'theme.neutral': 'Prairie Tower', 'theme.mono': 'Monochrome', 'theme.fish': 'Blue Fat Fish', 'theme.penguin': 'Penguin Admin Day', 'theme.penguin-night': 'Penguin Admin Night', 'theme.bocchi': 'Bocchi', 'theme.nijika': 'Nijika', 'theme.ryo': 'Ryo', 'theme.kita': 'Kita',
|
|
704
|
+
'theme.default': 'Default', 'theme.dark': 'Sunset', 'theme.light': 'Elbphilharmonie', 'theme.neutral': 'Prairie Tower', 'theme.mono': 'Monochrome', 'theme.fish': 'Blue Fat Fish', 'theme.penguin': 'Penguin Admin Day', 'theme.penguin-night': 'Penguin Admin Night', 'theme.bocchi': 'Bocchi', 'theme.nijika': 'Nijika', 'theme.ryo': 'Ryo', 'theme.kita': 'Kita', 'theme.penguin-logistics': 'Penguin Logistics', 'theme.miku': 'Hatsune Miku',
|
|
703
705
|
'theme.panelTitle': 'Choose theme', 'theme.close': 'Close',
|
|
704
706
|
'repo': 'Repo',
|
|
705
707
|
'donateTitle': 'Support', 'donateThanks': 'Thanks for your support ☕',
|
|
@@ -801,20 +803,20 @@
|
|
|
801
803
|
}
|
|
802
804
|
}
|
|
803
805
|
</script>
|
|
804
|
-
<script src="../setup.js?dsr-build=
|
|
805
|
-
<script src="../qrcode.min.js?dsr-build=
|
|
806
|
-
<script src="../i18n.js?dsr-build=
|
|
807
|
-
<script src="../theme.js?dsr-build=
|
|
808
|
-
<script src="../vendor/gsap/gsap.min.js?dsr-build=
|
|
809
|
-
<script src="../motion.js?dsr-build=
|
|
810
|
-
<script src="../remote-state.js?dsr-build=
|
|
811
|
-
<script src="../remote-ui.js?dsr-build=
|
|
812
|
-
<script src="../admin.js?dsr-build=
|
|
813
|
-
<script src="../doctor.js?dsr-build=
|
|
814
|
-
<script src="../doctor-entry.js?dsr-build=
|
|
815
|
-
<script src="../sponsor-entry.js?dsr-build=
|
|
816
|
-
<script src="../relay-devices.js?dsr-build=
|
|
817
|
-
<script src="../relay-settings.js?dsr-build=
|
|
806
|
+
<script src="../setup.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
807
|
+
<script src="../qrcode.min.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
808
|
+
<script src="../i18n.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
809
|
+
<script src="../theme.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
810
|
+
<script src="../vendor/gsap/gsap.min.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
811
|
+
<script src="../motion.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
812
|
+
<script src="../remote-state.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
813
|
+
<script src="../remote-ui.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
814
|
+
<script src="../admin.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
815
|
+
<script src="../doctor.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
816
|
+
<script src="../doctor-entry.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
817
|
+
<script src="../sponsor-entry.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
818
|
+
<script src="../relay-devices.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
819
|
+
<script src="../relay-settings.js?dsr-build=62134119698eef6589b38ff6409a46d4160345043eb1aad1ba54e22b19d0b979"></script>
|
|
818
820
|
<script>window.mountAdminRelaySettings?.()</script>
|
|
819
821
|
</body>
|
|
820
822
|
</html>
|
package/public/admin.js
CHANGED
|
@@ -474,6 +474,7 @@ function renderDeviceKeys(st, isGateway) {
|
|
|
474
474
|
<button class="mini-btn" type="button" data-device-key-show="${esc(entry.id)}">${esc(window.DshRemoteUI?.t(revealedDeviceKeys.has(entry.id) ? 'hide' : 'show') || '显示令牌')}</button>
|
|
475
475
|
<button class="mini-btn" type="button" data-device-key-qr="${esc(entry.id)}">${esc(t('qrCode'))}</button>
|
|
476
476
|
<button class="mini-btn" type="button" data-device-key-rotate="${esc(entry.id)}">${esc(t('rotateToken'))}</button>
|
|
477
|
+
<button class="mini-btn" type="button" data-device-key-access="${esc(entry.id)}" aria-pressed="${!!entry.hostStateReadOnly}">${esc(t(entry.hostStateReadOnly ? 'deviceKeys.hostStateReadOnly' : 'deviceKeys.hostStateWritable'))}</button>
|
|
477
478
|
<button class="mini-btn" type="button" data-device-key-copy="${esc(entry.id)}">${esc(t('copyToken'))}</button>
|
|
478
479
|
<button class="mini-btn danger" type="button" data-device-key-revoke="${esc(entry.id)}">${esc(t('deviceKeys.revoke'))}</button>
|
|
479
480
|
</div>
|
|
@@ -792,6 +793,12 @@ async function editDeviceKeyNote(entry) {
|
|
|
792
793
|
await loadState()
|
|
793
794
|
}
|
|
794
795
|
|
|
796
|
+
async function toggleDeviceKeyAccess(entry) {
|
|
797
|
+
if (!entry || deviceKeyBusy) return
|
|
798
|
+
const out = await deviceKeyMutation('host-state-access', { id: entry.id, readOnly: !entry.hostStateReadOnly })
|
|
799
|
+
if (out) await loadState()
|
|
800
|
+
}
|
|
801
|
+
|
|
795
802
|
function showDeviceKeyQr(entry) {
|
|
796
803
|
if (!entry?.token) return
|
|
797
804
|
window.DshConsole?.select('devices')
|
|
@@ -878,7 +885,7 @@ $('btn-device-key-add').addEventListener('click', createDeviceKey)
|
|
|
878
885
|
$('device-key-rows').addEventListener('click', event => {
|
|
879
886
|
const button = event.target.closest('button')
|
|
880
887
|
if (!button) return
|
|
881
|
-
for (const [name,handler] of [['note',editDeviceKeyNote],['qr',showDeviceKeyQr],['rotate',rotateDeviceKey],['copy',copyDeviceKey],['revoke',revokeDeviceKey]]) {
|
|
888
|
+
for (const [name,handler] of [['note',editDeviceKeyNote],['qr',showDeviceKeyQr],['rotate',rotateDeviceKey],['copy',copyDeviceKey],['revoke',revokeDeviceKey],['access',toggleDeviceKeyAccess]]) {
|
|
882
889
|
const id=button.dataset['deviceKey'+name[0].toUpperCase()+name.slice(1)]
|
|
883
890
|
if (id) { handler(lastState?.deviceKeys?.entries?.find(entry=>entry.id===id)); return }
|
|
884
891
|
}
|
|
@@ -1076,7 +1083,9 @@ const THEME_META = [
|
|
|
1076
1083
|
{ id: 'bocchi', sw: ['#FFD9E8', '#FFFFFF', '#D0105A'] },
|
|
1077
1084
|
{ id: 'nijika', sw: ['#FFF3D5', '#FFFFFF', '#94600C'] },
|
|
1078
1085
|
{ id: 'ryo', sw: ['#E9F1FA', '#FFFFFF', '#315D91'] },
|
|
1079
|
-
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] }
|
|
1086
|
+
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] },
|
|
1087
|
+
{ id: 'penguin-logistics', sw: ['#12161B', '#1D252E', '#E9B66F'] },
|
|
1088
|
+
{ id: 'miku', sw: ['#F3FFFC', '#FFFFFF', '#126D69'] }
|
|
1080
1089
|
]
|
|
1081
1090
|
|
|
1082
1091
|
function renderThemeBtn() {
|