dsh-remote-plugin 0.8.6 → 0.8.8
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/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +169 -63
- package/index.mjs +36 -1
- package/package.json +1 -1
- package/public/activity.js +144 -49
- package/public/admin.html +33 -32
- package/public/admin.js +25 -6
- package/public/app.js +199 -57
- package/public/build.json +2 -2
- package/public/desktop/desktop.html +85 -74
- package/public/desktop/desktop.js +52 -27
- package/public/diagnostics.js +30 -4
- package/public/doctor.css +1 -1
- package/public/e2ee-transport.js +189 -18
- package/public/history.js +15 -2
- package/public/index.html +97 -76
- package/public/operations.js +59 -14
- package/public/plugin.html +27 -26
- package/public/relay-autopair.js +60 -26
- package/public/relay-devices.js +11 -5
- package/public/relay-settings.css +9 -0
- package/public/relay-settings.js +67 -9
- 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/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 +184 -0
- package/public/subagents.css +2 -0
- package/public/subagents.js +31 -10
- package/public/theme-vars.css +37 -2
- package/public/theme.js +4 -2
- package/public/update.json +12 -12
- package/public/version.json +1 -1
- package/public/workflow.css +19 -11
- package/public/workflow.js +25 -14
- package/skills/dsh-remote-doctor/references/wiki/connection.md +2 -0
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) {
|
|
@@ -182,7 +277,7 @@
|
|
|
182
277
|
return [...blocks].filter(([,value])=>value).map(([index,value])=>reasoning({text:value,key:`attempt:${event.seq}:${index}`})).join('')+failureHtml(failure(event),true)
|
|
183
278
|
}
|
|
184
279
|
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}
|
|
280
|
+
const api={hasVisibleText,prepare,tool,toolEvent,isToolEvent,reasoning,reasoningKey,group,groupHtml,turnHtml,failure,failureHtml,groupFailures,failureGroupHtml,attemptHtml,streamNotice}
|
|
186
281
|
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
187
282
|
else root.DshActivity=api
|
|
188
283
|
})(typeof window==='undefined'?globalThis:window)
|
package/public/admin.html
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
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="84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
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='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
10
|
+
<link rel="stylesheet" href="../styles.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
11
|
+
<link rel="stylesheet" href="../relay-settings.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
12
|
+
<link rel="stylesheet" href="../insights.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
13
|
+
<link rel="stylesheet" href="../setup.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
14
|
+
<link rel="stylesheet" href="../doctor.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
15
|
+
<link rel="stylesheet" href="../skins/blue-fish/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
16
|
+
<link rel="stylesheet" href="../skins/penguin/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
17
|
+
<link rel="stylesheet" href="../skins/bocchi/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
18
|
+
<link rel="stylesheet" href="../skins/kessoku/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
19
|
+
<link rel="stylesheet" href="../skins/nijika/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
20
|
+
<link rel="stylesheet" href="../skins/ryo/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
21
|
+
<link rel="stylesheet" href="../skins/kita/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
22
|
+
<link rel="stylesheet" href="../skins/penguin-logistics/skin.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
22
23
|
<style>
|
|
23
24
|
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 40px; }
|
|
24
25
|
.admin-title {
|
|
@@ -348,8 +349,8 @@
|
|
|
348
349
|
.admin-title .left { gap: 7px; }
|
|
349
350
|
}
|
|
350
351
|
</style>
|
|
351
|
-
<link rel="stylesheet" href="../remote-ui.css?dsr-build=
|
|
352
|
-
<link rel="stylesheet" href="../theme-picker.css?dsr-build=
|
|
352
|
+
<link rel="stylesheet" href="../remote-ui.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
353
|
+
<link rel="stylesheet" href="../theme-picker.css?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184">
|
|
353
354
|
</head>
|
|
354
355
|
<body>
|
|
355
356
|
<div class="admin-wrap">
|
|
@@ -580,7 +581,7 @@
|
|
|
580
581
|
'doctor.realtime': '实时消息通道', 'doctor.realtimePass': 'mux 与 host 通道均已连接', 'doctor.realtimeFail': '实时通道未全部建立;可先使用轮询,检查 DSH 后会自动恢复',
|
|
581
582
|
'doctor.start': '启动', 'doctor.showQr': '显示二维码', 'doctor.copyAddress': '复制地址', 'doctor.copyCommand': '复制命令',
|
|
582
583
|
'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': '喜多郁代',
|
|
584
|
+
'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': '企鹅物流',
|
|
584
585
|
'theme.panelTitle': '选择配色', 'theme.close': '关闭',
|
|
585
586
|
'repo': '仓库',
|
|
586
587
|
'donateTitle': '赞赏支持', 'donateThanks': '感谢你的支持 ☕',
|
|
@@ -699,7 +700,7 @@
|
|
|
699
700
|
'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
701
|
'doctor.start': 'Start', 'doctor.showQr': 'Show QR', 'doctor.copyAddress': 'Copy address', 'doctor.copyCommand': 'Copy command',
|
|
701
702
|
'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',
|
|
703
|
+
'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',
|
|
703
704
|
'theme.panelTitle': 'Choose theme', 'theme.close': 'Close',
|
|
704
705
|
'repo': 'Repo',
|
|
705
706
|
'donateTitle': 'Support', 'donateThanks': 'Thanks for your support ☕',
|
|
@@ -801,20 +802,20 @@
|
|
|
801
802
|
}
|
|
802
803
|
}
|
|
803
804
|
</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=
|
|
805
|
+
<script src="../setup.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
806
|
+
<script src="../qrcode.min.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
807
|
+
<script src="../i18n.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
808
|
+
<script src="../theme.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
809
|
+
<script src="../vendor/gsap/gsap.min.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
810
|
+
<script src="../motion.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
811
|
+
<script src="../remote-state.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
812
|
+
<script src="../remote-ui.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
813
|
+
<script src="../admin.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
814
|
+
<script src="../doctor.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
815
|
+
<script src="../doctor-entry.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
816
|
+
<script src="../sponsor-entry.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
817
|
+
<script src="../relay-devices.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
818
|
+
<script src="../relay-settings.js?dsr-build=84d998ae3a1302b3e1d02d3cdde5d8f3ad3f8bd963ec0323fd18a675015e1184"></script>
|
|
818
819
|
<script>window.mountAdminRelaySettings?.()</script>
|
|
819
820
|
</body>
|
|
820
821
|
</html>
|
package/public/admin.js
CHANGED
|
@@ -13,7 +13,7 @@ const pluginMode = location.pathname === '/remote'
|
|
|
13
13
|
const API = pluginMode ? '/remote/admin/api' : '/admin/api'
|
|
14
14
|
window.mountAdminRelaySettings = () => window.DshRelaySettings?.mount($('relay-settings'), {
|
|
15
15
|
connection: () => { const saved=token;return {url:route=>API+route,headers:adminHeaders({},saved),valid:()=>token===saved} },
|
|
16
|
-
path:'/relay', credentials:'same-origin'
|
|
16
|
+
path:'/relay', credentials:'same-origin', phonePairingCode, deviceManagement:!pluginMode
|
|
17
17
|
})
|
|
18
18
|
// 沙箱 iframe/隐私模式里 localStorage 可能抛 SecurityError, 不能让它杀死整个页面
|
|
19
19
|
const store = {
|
|
@@ -661,6 +661,27 @@ function pairTarget(st, accessToken) {
|
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
+
function pairQrSvg(url) {
|
|
665
|
+
const qr = window.qrcode(0, 'M')
|
|
666
|
+
qr.addData(url)
|
|
667
|
+
qr.make()
|
|
668
|
+
return qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true })
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
async function phonePairingCode(setupId) {
|
|
672
|
+
const st = lastState, currentToken = token
|
|
673
|
+
if (st?.mode !== 'gateway' || st.gatewayAuthError || !enabledHostIPs(st).length) return ''
|
|
674
|
+
let access = shownToken
|
|
675
|
+
if (st.deviceKeys?.enabled) {
|
|
676
|
+
const note = I18N.lang === 'en' ? 'Android phone' : 'Android 手机'
|
|
677
|
+
access = (await deviceKeyMutation('create', { note }))?.entry?.token
|
|
678
|
+
}
|
|
679
|
+
if (!access || token !== currentToken) return ''
|
|
680
|
+
const url = new URL(pairTarget(st, access).url)
|
|
681
|
+
url.searchParams.set('relaySetup', setupId)
|
|
682
|
+
return pairQrSvg(url.href)
|
|
683
|
+
}
|
|
684
|
+
|
|
664
685
|
function renderQr(st) {
|
|
665
686
|
const box = $('pair-box')
|
|
666
687
|
const accessToken = qrToken || shownToken
|
|
@@ -670,10 +691,7 @@ function renderQr(st) {
|
|
|
670
691
|
}
|
|
671
692
|
try {
|
|
672
693
|
const pt = pairTarget(st, accessToken)
|
|
673
|
-
|
|
674
|
-
qr.addData(pt.url)
|
|
675
|
-
qr.make()
|
|
676
|
-
$('pair-qr').innerHTML = qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true })
|
|
694
|
+
$('pair-qr').innerHTML = pairQrSvg(pt.url)
|
|
677
695
|
$('pair-hint').textContent = `${qrLabel ? qrLabel + ' · ' : ''}${t('pair.hint', { base: pt.base })}`
|
|
678
696
|
box.classList.remove('hidden')
|
|
679
697
|
} catch (e) {
|
|
@@ -1058,7 +1076,8 @@ const THEME_META = [
|
|
|
1058
1076
|
{ id: 'bocchi', sw: ['#FFD9E8', '#FFFFFF', '#D0105A'] },
|
|
1059
1077
|
{ id: 'nijika', sw: ['#FFF3D5', '#FFFFFF', '#94600C'] },
|
|
1060
1078
|
{ id: 'ryo', sw: ['#E9F1FA', '#FFFFFF', '#315D91'] },
|
|
1061
|
-
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] }
|
|
1079
|
+
{ id: 'kita', sw: ['#FFE9E5', '#FFFFFF', '#B6373C'] },
|
|
1080
|
+
{ id: 'penguin-logistics', sw: ['#12161B', '#1D252E', '#E9B66F'] }
|
|
1062
1081
|
]
|
|
1063
1082
|
|
|
1064
1083
|
function renderThemeBtn() {
|