dsh-remote-plugin 0.8.0-rc.2 → 0.8.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +21 -6
- package/package.json +1 -1
- package/public/activity.js +126 -0
- package/public/announcements.json +8 -0
- package/public/app.js +195 -113
- package/public/desktop/desktop.css +10 -10
- package/public/desktop/desktop.html +25 -9
- package/public/desktop/desktop.js +133 -47
- package/public/extensions.js +3 -2
- package/public/history.js +32 -11
- package/public/image-preview.js +132 -0
- package/public/index.html +32 -10
- package/public/md.js +41 -1
- package/public/network.js +29 -5
- package/public/relay-settings.js +19 -10
- package/public/styles.css +15 -15
- package/public/subagents.css +61 -0
- package/public/subagents.js +275 -0
- package/public/update.json +4 -4
- package/public/version.json +1 -1
- package/public/workflow.css +177 -1
- package/public/workflow.js +88 -8
package/apk/dsh-remote.apk
CHANGED
|
Binary file
|
package/gateway.cjs
CHANGED
|
@@ -2437,7 +2437,7 @@ function updateModernSessions(items) {
|
|
|
2437
2437
|
if (!item?.sessionId) continue
|
|
2438
2438
|
modernState.sessions.set(item.sessionId, item)
|
|
2439
2439
|
const cursor = Number(item.projections?.asOfSeq)
|
|
2440
|
-
if (Number.isSafeInteger(cursor) && cursor >= -1) modernState.sessionCursors.set(item.sessionId, cursor)
|
|
2440
|
+
if (item.projections?.kind !== 'cached' && Number.isSafeInteger(cursor) && cursor >= -1) modernState.sessionCursors.set(item.sessionId, cursor)
|
|
2441
2441
|
}
|
|
2442
2442
|
}
|
|
2443
2443
|
|
|
@@ -2503,13 +2503,26 @@ async function translateModernRpc(method, payload, rpcId, strictReceipt = false)
|
|
|
2503
2503
|
await refreshModernSessions()
|
|
2504
2504
|
summary = modernState.sessions.get(payload.sessionId)
|
|
2505
2505
|
}
|
|
2506
|
-
|
|
2506
|
+
if (summary?.formatStatus === 'migration-required') return legacyEnvelope(rpcId, modernError('Open the source session in DSH to complete migration, then refresh.', 'session/migration-required', { sessionId: payload.sessionId }))
|
|
2507
|
+
const isChild = !!payload.parentSessionId && typeof payload.subagentMode === 'string'
|
|
2508
|
+
let throughSeq = modernState.sessionCursors.get(payload.sessionId) ?? Number(summary?.projections?.asOfSeq)
|
|
2509
|
+
if (isChild || summary?.projections?.kind === 'cached') {
|
|
2510
|
+
// Cached storage watermarks are not connected stream sequence numbers.
|
|
2511
|
+
// Child logs also need a fresh durable cursor and Host address validation.
|
|
2512
|
+
const projection = await callUpstreamRemote('session/projections', { request: { sessionId: payload.sessionId } }, rpcId)
|
|
2513
|
+
if (!projection.body?.result?.ok) return projection.body || legacyEnvelope(rpcId, modernError('DSH history cursor unavailable'))
|
|
2514
|
+
if (projection.body.result.value?.kind === 'migration-required') return legacyEnvelope(rpcId, modernError('Open the source session in DSH to complete migration, then refresh.', 'session/migration-required', { sessionId: payload.sessionId }))
|
|
2515
|
+
throughSeq = projection.body.result.value?.asOfSeq
|
|
2516
|
+
if (projection.body.result.value) summary = { ...summary, projections: projection.body.result.value }
|
|
2517
|
+
}
|
|
2507
2518
|
if (!Number.isSafeInteger(throughSeq) || throughSeq < -1) {
|
|
2508
2519
|
return legacyEnvelope(rpcId, modernError('DSH did not expose a history cursor for this session', 'session-not-found'))
|
|
2509
2520
|
}
|
|
2510
2521
|
endpoint = 'session/page'
|
|
2511
2522
|
args = { request: {
|
|
2512
|
-
address:
|
|
2523
|
+
address: isChild
|
|
2524
|
+
? { kind: 'subagent', parentSessionId: payload.parentSessionId, childSessionId: payload.sessionId, mode: ['one-shot', 'continuable'].includes(payload.subagentMode) ? payload.subagentMode : 'unknown' }
|
|
2525
|
+
: { kind: 'session', sessionId: payload.sessionId },
|
|
2513
2526
|
throughSeq,
|
|
2514
2527
|
...(payload.beforeSeq === undefined ? {} : { beforeSeq: payload.beforeSeq }),
|
|
2515
2528
|
...(payload.maxMessages === undefined ? {} : { maxMessages: payload.maxMessages }),
|
|
@@ -2620,14 +2633,16 @@ async function translateModernRpc(method, payload, rpcId, strictReceipt = false)
|
|
|
2620
2633
|
const parent = await callUpstreamRemote('session/projections', { request: { sessionId: payload.parentSessionId } }, rpcId)
|
|
2621
2634
|
if (modernResponseNeedsLegacyFallback(parent)) return legacyFallback('generated subagent catalog unavailable')
|
|
2622
2635
|
if (!parent.body?.result?.ok) return parent.body || legacyEnvelope(rpcId, modernError('DSH subagent catalog read failed'))
|
|
2636
|
+
if (parent.body.result.value?.kind === 'migration-required') return legacyEnvelope(rpcId, modernError('Open the source session in DSH to complete migration, then refresh.', 'session/migration-required', { sessionId: payload.parentSessionId }))
|
|
2623
2637
|
const catalog = parent.body.result.value?.values?.subagentCatalog
|
|
2624
2638
|
if (!Array.isArray(catalog)) return legacyEnvelope(rpcId, modernError('DSH did not expose a subagent catalog projection', 'subagent/projections-unavailable'))
|
|
2625
2639
|
await refreshModernSessions()
|
|
2626
2640
|
const entries = await Promise.all(catalog.map(async child => {
|
|
2627
|
-
if (!['one-shot', 'continuable'].includes(child.mode)) return { kind: 'diagnostic', id: child.id, reason: 'unsupported' }
|
|
2641
|
+
if (!['one-shot', 'continuable'].includes(child.mode)) return { kind: 'diagnostic', id: child.id, ...(child.label === undefined ? {} : { label: child.label }), reason: child.mode === 'external' ? 'external' : 'unsupported' }
|
|
2628
2642
|
try {
|
|
2629
2643
|
const read = await callUpstreamRemote('session/projections', { request: { sessionId: child.id } })
|
|
2630
2644
|
if (!read.body?.result?.ok || !read.body.result.value) return { kind: 'diagnostic', id: child.id, reason: 'unavailable' }
|
|
2645
|
+
if (read.body.result.value.kind === 'migration-required') return { kind: 'diagnostic', id: child.id, ...(child.label === undefined ? {} : { label: child.label }), reason: 'migration-required' }
|
|
2631
2646
|
const values = read.body.result.value.values
|
|
2632
2647
|
const identity = values?.subagent
|
|
2633
2648
|
if (!identity || identity.mode !== child.mode) return { kind: 'diagnostic', id: child.id, reason: 'corrupt' }
|
|
@@ -2975,7 +2990,7 @@ function openModernSessionStream(ws, sessionId) {
|
|
|
2975
2990
|
// 直接按 session 地址 open 会被拒(session/agent-busy),错误帧还会污染事件流;
|
|
2976
2991
|
// 这些会话的投影变化由 control/workspaces 基线推送覆盖,无需单独 follow。
|
|
2977
2992
|
const summary = modernState.sessions.get(sessionId)
|
|
2978
|
-
if (summary?.origin === 'subagent') return
|
|
2993
|
+
if (summary?.origin === 'subagent' || summary?.formatStatus === 'migration-required') return
|
|
2979
2994
|
const streamId = 'session:' + sessionId
|
|
2980
2995
|
ws.send(JSON.stringify({
|
|
2981
2996
|
type: 'open', streamId, endpoint: 'session/follow',
|
|
@@ -3758,7 +3773,7 @@ function serveStatic(req, res, url) {
|
|
|
3758
3773
|
return
|
|
3759
3774
|
}
|
|
3760
3775
|
if (pathname === '/') pathname = '/index.html'
|
|
3761
|
-
if (pathname === '/admin') pathname = '/admin.html'
|
|
3776
|
+
if (pathname === '/admin' || pathname === '/admin/') pathname = '/admin.html'
|
|
3762
3777
|
if (pathname === '/announcements.json') {
|
|
3763
3778
|
void serveAnnouncements(req, res)
|
|
3764
3779
|
return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-plugin",
|
|
3
|
-
"version": "0.8.0-rc.
|
|
3
|
+
"version": "0.8.0-rc.3",
|
|
4
4
|
"description": "DSH Remote 官方 bundle 插件:DSH 左侧原生边栏入口 + 右侧抽屉内嵌管理控制台;内置网关随 DSH 自动启停(systemd 独立单元),抽屉直显令牌与设备监控;网关提供 /fs/* 文件传输端点(列表/断点下载/上传),配合 Android App 远程操控会话/审批/提问/goal 与文件互传(多服务器测速切换、聊天记录离线缓存)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* Compact, shared conversation activity. Durable events remain untouched. */
|
|
2
|
+
'use strict';
|
|
3
|
+
;(function(root){
|
|
4
|
+
const esc=value=>String(value??'').replace(/[&<>"']/g,char=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[char]))
|
|
5
|
+
const text=(zh,en)=>root.I18N?.lang==='en'?en:zh
|
|
6
|
+
const json=value=>{try{return typeof value==='string'?value:JSON.stringify(value,null,2)??''}catch{return String(value)}}
|
|
7
|
+
const cut=(value,length)=>{const source=String(value??'');return source.length>length?source.slice(0,length)+'…':source}
|
|
8
|
+
const brief=value=>cut(String(value??'').replace(/\s+/g,' ').trim(),100)
|
|
9
|
+
const icon=kind=>`<svg class="activity-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${kind==='reasoning'?'m12 3 2.4 6.6L21 12l-6.6 2.4L12 21l-2.4-6.6L3 12l6.6-2.4Z':'m8 7-5 5 5 5m8-10 5 5-5 5m-3-14-2 18'}"/></svg>`
|
|
10
|
+
function argumentHint(value){
|
|
11
|
+
if(typeof value==='string'){try{value=JSON.parse(value)}catch{return brief(value)}}
|
|
12
|
+
if(!value||typeof value!=='object')return ''
|
|
13
|
+
for(const key of ['description','command','cmd','path','file_path','pattern','query','url','line'])if(typeof value[key]==='string')return brief(value[key])
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
function shell(kind,key,title,hint,state,body,live=false,error=false){
|
|
17
|
+
return `<details class="chat-activity activity-${kind}${live?' is-live':''}${error?' is-error':''}" data-activity-key="${esc(key)}"><summary>${icon(kind)}<span class="activity-copy"><span class="activity-title">${esc(title)}</span>${hint?`<span class="activity-hint">${esc(hint)}</span>`:''}</span><span class="activity-state">${live?'<i aria-hidden="true"></i>':''}${esc(state)}</span><span class="activity-chevron" aria-hidden="true"></span></summary><div class="activity-body">${body}</div></details>`
|
|
18
|
+
}
|
|
19
|
+
function reasoning(value={}){
|
|
20
|
+
const source=String(value.text??'')
|
|
21
|
+
const hint=brief(source.split('\n').filter(line=>line.trim()).at(-1)||'')
|
|
22
|
+
return shell('reasoning',value.key,text(value.live?'思考中':'思考过程',value.live?'Thinking':'Reasoning'),hint,value.live?text('进行中','Live'):'',`<div class="activity-reasoning-text">${esc(cut(source,12000))}</div>`,!!value.live)
|
|
23
|
+
}
|
|
24
|
+
const errorOf=data=>!!(data?.error||data?.ok===false||data?.isError===true)
|
|
25
|
+
function tool(value={}){
|
|
26
|
+
const args=value.args,returned=Object.hasOwn(value,'result'),error=!!value.error
|
|
27
|
+
const section=(title,content)=>`<section><h4>${esc(title)}</h4><pre>${esc(cut(json(content),12000))}</pre></section>`
|
|
28
|
+
const body=(args===undefined?'':section(text('参数','Arguments'),args))+(returned?section(text('结果','Result'),value.result):`<p class="activity-note">${esc(text('当前记录中尚无对应结果。','No matching result in the loaded history.'))}</p>`)
|
|
29
|
+
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)
|
|
30
|
+
}
|
|
31
|
+
const dataOf=entry=>entry.event?.data||{}
|
|
32
|
+
const callId=data=>data.callId||data.message?.source?.callId
|
|
33
|
+
const resultOf=data=>data.error??data.result??data.output??data.message??data.text??data.content??data
|
|
34
|
+
const pairs=new WeakMap()
|
|
35
|
+
function prepare(entries){
|
|
36
|
+
const pending=new Map(),matched=new Map(),consumed=new Set()
|
|
37
|
+
for(const entry of entries){
|
|
38
|
+
const data=dataOf(entry),id=callId(data)
|
|
39
|
+
if(!id)continue
|
|
40
|
+
if(entry.event?.type==='tool/call'){const queue=pending.get(id)||[];queue.push(entry);pending.set(id,queue)}
|
|
41
|
+
else if(entry.event?.type==='tool/result'){
|
|
42
|
+
const queue=pending.get(id)||[]
|
|
43
|
+
const index=queue.findLastIndex(call=>data.turn==null||dataOf(call).turn==null||data.turn===dataOf(call).turn)
|
|
44
|
+
if(index>=0){const [call]=queue.splice(index,1);matched.set(call,entry);consumed.add(entry)}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return entries.filter(entry=>!consumed.has(entry)).map(entry=>{
|
|
48
|
+
if(entry.event?.type!=='tool/call')return entry
|
|
49
|
+
const result=matched.get(entry)
|
|
50
|
+
if(!result)return entry
|
|
51
|
+
const cached=pairs.get(entry)
|
|
52
|
+
if(cached?.result===result)return cached.entry
|
|
53
|
+
const data=dataOf(entry),output=dataOf(result)
|
|
54
|
+
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)}}}
|
|
55
|
+
pairs.set(entry,{result,entry:next});return next
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
function toolEvent(entry){
|
|
59
|
+
if(entry.view?.toolActivity)return tool(entry.view.toolActivity)
|
|
60
|
+
const data=dataOf(entry),isResult=entry.event?.type==='tool/result'
|
|
61
|
+
return tool({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})})
|
|
62
|
+
}
|
|
63
|
+
function reasoningKind(block){return block&&typeof block==='object'&&(block.type==='thinking'||block.type==='reasoning')}
|
|
64
|
+
function messageBlocks(entry){
|
|
65
|
+
const data=entry?.event?.data||{},message=data.message||{}
|
|
66
|
+
const blocks=Array.isArray(message.content)?message.content:(Array.isArray(data.content)?data.content:null)
|
|
67
|
+
return blocks?{data,message,blocks}:null
|
|
68
|
+
}
|
|
69
|
+
function stripReasoning(entry,rest){
|
|
70
|
+
const parts=messageBlocks(entry)
|
|
71
|
+
const data={...parts.data}
|
|
72
|
+
if(Array.isArray(parts.message.content))data.message={...parts.message,content:rest}
|
|
73
|
+
else data.content=rest
|
|
74
|
+
return {...entry,event:{...entry.event,data}}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Collapse a turn's process — every tool activity plus the reasoning blocks that would
|
|
78
|
+
* otherwise occupy a row inside each assistant message — into one disclosure.
|
|
79
|
+
* A user message starts a new turn; a turn without enough items keeps its original rows.
|
|
80
|
+
*/
|
|
81
|
+
function group(entries){
|
|
82
|
+
const isTool=entry=>{const type=entry?.event?.type;return type==='tool/call'||type==='tool/result'}
|
|
83
|
+
// Only a human message starts a new turn; injected system-reminder user events do not.
|
|
84
|
+
const isTurnStart=entry=>{
|
|
85
|
+
if(entry?.event?.type!=='user/message')return false
|
|
86
|
+
const data=entry.event.data||{},source=data.source??data.message?.source
|
|
87
|
+
return !source||source.kind==='user'
|
|
88
|
+
}
|
|
89
|
+
const out=[]
|
|
90
|
+
const emit=segment=>{
|
|
91
|
+
const items=[],stripped=new Map()
|
|
92
|
+
for(const entry of segment){
|
|
93
|
+
if(isTool(entry)){items.push({kind:'tool',seq:entry.seq,entry});continue}
|
|
94
|
+
const parts=messageBlocks(entry)
|
|
95
|
+
if(!parts)continue
|
|
96
|
+
const reasoning=parts.blocks.filter(reasoningKind)
|
|
97
|
+
if(!reasoning.length)continue
|
|
98
|
+
const rest=parts.blocks.filter(block=>!reasoningKind(block))
|
|
99
|
+
const copy=stripReasoning(entry,rest)
|
|
100
|
+
stripped.set(entry,{copy,empty:rest.length===0})
|
|
101
|
+
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}))
|
|
102
|
+
}
|
|
103
|
+
if(items.length>1){
|
|
104
|
+
let emitted=false
|
|
105
|
+
for(const entry of segment){
|
|
106
|
+
const decorated=stripped.get(entry)
|
|
107
|
+
if((isTool(entry)||decorated)&&!emitted){out.push({seq:items[0].seq,event:{type:'activity/group'},view:{activityGroup:{items}}});emitted=true}
|
|
108
|
+
if(isTool(entry))continue
|
|
109
|
+
if(decorated){if(!decorated.empty)out.push(decorated.copy);continue}
|
|
110
|
+
out.push(entry)
|
|
111
|
+
}
|
|
112
|
+
}else out.push(...segment)
|
|
113
|
+
}
|
|
114
|
+
let segment=[]
|
|
115
|
+
for(const entry of entries){
|
|
116
|
+
if(isTurnStart(entry)){emit(segment);segment=[];out.push(entry)}
|
|
117
|
+
else segment.push(entry)
|
|
118
|
+
}
|
|
119
|
+
emit(segment)
|
|
120
|
+
return out
|
|
121
|
+
}
|
|
122
|
+
function reasoningKey(data,index,fallback){return data?.turn!=null&&data?.step!=null?'reasoning:'+JSON.stringify([data.turn,data.step,index]):fallback}
|
|
123
|
+
const api={prepare,tool,toolEvent,reasoning,reasoningKey,group}
|
|
124
|
+
if(typeof module!=='undefined'&&module.exports)module.exports=api
|
|
125
|
+
else root.DshActivity=api
|
|
126
|
+
})(typeof window==='undefined'?globalThis:window)
|
|
@@ -177,6 +177,14 @@
|
|
|
177
177
|
"publishedAt": "2026-09-19T08:03:06+08:00",
|
|
178
178
|
"actionUrl": "https://github.com/Blank-not-black/dsh-Remote/releases/tag/v0.7.0-rc.1",
|
|
179
179
|
"actionText": "下载 0.7.0-rc.1 测试版"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"id": "2026-10-16-0.8.0-relay-trial",
|
|
183
|
+
"title": "0.8.0 预告 · 云中转试测招募",
|
|
184
|
+
"content": "感谢各位开发者持续使用 DSH Remote,也感谢大家耐心反馈问题和建议。这些来自实际使用的意见,是本次 0.8.0 调整的重要依据。\n\n0.8.0 主要变化\n① 整理为「会话、文件、更多」三个入口,整合待审批、待回答和常用操作。\n② 简化新建会话、工作区选择与设置流程,减少重复操作。\n③ 改进弱网状态反馈和断线恢复;结果未确认的操作不会自动重复发送。\n④ 增加聊天文本文件预览、改进上传体验,并修复 Windows 插件更新时的部分目录占用问题。\n\n目前 0.8.0-rc.2 已发布,正式版将根据试测反馈继续调整。本轮界面改动主要覆盖 Android 和手机、桌面 Web。\n\n云服务器中转试测\n测试版新增云中转:每位测试者连接自己的 DSH,在设置中填写个人中转密钥,绑定后即可通过专属公网地址连接。电脑上的 DSH 和 Remote 网关仍需保持运行。\n\n首批开放 5 个名额,测试周期约一周,具体有效期以授权通知为准。每位用户每日上传与下载合计 5GB,北京时间零点重置。我们主要收集连接成功率、响应延迟、实时输出与断线恢复方面的反馈。\n\n中转采用云端终止 TLS 的方式,运营者在技术上可接触经过的转发内容,请使用适合参与试测的环境和数据。\n\n如何申请\n请复制下方完整申请模板,打开 App 顶部「反馈 → 直接反馈」,选择「其他」,将模板粘贴到反馈内容栏,填写后提交。选择题请保留一个选项即可。\n\n【云中转试测申请】\n昵称:\n邮箱:\nQQ群内昵称/备注名:\nQQ号:\n电脑系统:Windows/Linux/macOS/其他\n主要问题:公网连接困难/延迟高/经常断线/传输慢/希望体验\n是否愿意反馈试测问题:愿意/暂时无法保证\n手机系统及补充说明(选填):\n\n填写的信息仅用于测试资格安排和试测联络,请勿提交中转密钥、Remote 令牌或模型 API Key。感谢大家继续帮助 DSH Remote 改善使用体验!",
|
|
185
|
+
"minVersion": "",
|
|
186
|
+
"maxVersion": "",
|
|
187
|
+
"publishedAt": "2026-10-16T09:27:32.340Z"
|
|
180
188
|
}
|
|
181
189
|
]
|
|
182
190
|
}
|