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/public/relay-settings.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
GATEWAY_UNAVAILABLE:['请先在主机上启动 Remote 网关。','Start the Remote gateway on the host first.'],
|
|
12
12
|
RELAY_OPERATION_BUSY:['主机正在处理上一次操作,请稍后刷新状态。','The previous operation is still running. Refresh shortly.'],
|
|
13
13
|
unauthorized:['请先连接主机,再设置云服务器中转。','Connect to your host before configuring its relay.'],
|
|
14
|
+
INVALID_RESPONSE:['主机返回了无法识别的中转状态,请检查连接地址和主机 Remote 版本。','Unrecognized relay response. Check the host URL and Remote version.'],
|
|
15
|
+
UNSUPPORTED_GATEWAY:['此主机尚不支持云中转设置,请更新主机 Remote。','Update the host Remote to use cloud relay settings.'],
|
|
14
16
|
}
|
|
15
17
|
function mount(target, { connection, path = '/relay', credentials } = {}) {
|
|
16
18
|
if (!target || target.dataset.relayMounted) return
|
|
@@ -28,19 +30,19 @@
|
|
|
28
30
|
const actions=el('div','relay-actions'),toggle=el('button'),refresh=el('button'),takeover=el('button');toggle.type=refresh.type=takeover.type='button';actions.append(takeover,toggle,refresh)
|
|
29
31
|
const hint=el('p','relay-muted'),notice=el('p','relay-notice');notice.setAttribute('role','status')
|
|
30
32
|
target.append(heading,intro,status,address,quota,binding,form,actions,hint,notice)
|
|
31
|
-
let identity='',value=null,lastRead=0,busy=false,loading=false,controller=null,destroyed=false
|
|
33
|
+
let identity='',value=null,lastRead=0,busy=false,loading=false,controller=null,destroyed=false,readError=false,failures=0
|
|
32
34
|
function context() { const ctx=connection();return { ...ctx, endpoint:ctx.url(path) } }
|
|
33
35
|
function current(ctx) { return !destroyed && ctx.valid() && identity===JSON.stringify([ctx.endpoint,ctx.headers?.authorization||'']) }
|
|
34
36
|
function syncIdentity() {
|
|
35
37
|
const ctx=context(),next=JSON.stringify([ctx.endpoint,ctx.headers?.authorization||''])
|
|
36
|
-
if(next!==identity){identity=next;controller?.abort();controller=null;keyInput.value='';adminInput.value='';value=null;notice.textContent='';lastRead=0;loading=false;busy=false;render()}
|
|
38
|
+
if(next!==identity){identity=next;controller?.abort();controller=null;keyInput.value='';adminInput.value='';value=null;notice.textContent='';lastRead=0;loading=false;busy=false;readError=false;failures=0;render()}
|
|
37
39
|
return ctx
|
|
38
40
|
}
|
|
39
41
|
function render() {
|
|
40
42
|
title.textContent=text('云服务器中转','Cloud relay')
|
|
41
43
|
intro.textContent=text('让手机通过公网连接这台主机。每位用户使用自己的中转密钥,首次开通会绑定此主机。','Connect to this host over the internet. Your personal relay key binds to this host when activated.')
|
|
42
|
-
const phase=value?.phase||'unconfigured'
|
|
43
|
-
const names={unconfigured:['尚未开通','Not configured'],disabled:['已停用','Disabled'],connecting:['正在连接','Connecting'],online:['已连接','Connected'],reconnecting:['正在重连','Reconnecting'],expired:['授权已到期','Expired'],'authorization-inactive':['授权已撤销或到期','Authorization inactive'],'quota-exceeded':['今日流量已用完','Daily quota reached'],'quota-unavailable':['流量服务暂不可用','Quota service unavailable'],error:['连接异常','Connection error']}
|
|
44
|
+
const phase=value?.phase||(readError?'unavailable':loading?'loading':'unconfigured')
|
|
45
|
+
const names={loading:['正在读取','Loading'],unavailable:['状态读取失败','Status unavailable'],unconfigured:['尚未开通','Not configured'],disabled:['已停用','Disabled'],connecting:['正在连接','Connecting'],online:['已连接','Connected'],reconnecting:['正在重连','Reconnecting'],expired:['授权已到期','Expired'],'authorization-inactive':['授权已撤销或到期','Authorization inactive'],'quota-exceeded':['今日流量已用完','Daily quota reached'],'quota-unavailable':['流量服务暂不可用','Quota service unavailable'],error:['连接异常','Connection error']}
|
|
44
46
|
badge.textContent=text(...(names[phase]||names.error));badge.dataset.phase=phase
|
|
45
47
|
status.textContent=busy?text('正在保存并绑定,请稍候…','Saving and binding…'):value?.error?text('请检查主机配置或刷新状态。','Check the host configuration or refresh.'):text('开通后会随 Remote 网关启动,无需单独运行工具。','Starts with the Remote gateway after activation.')
|
|
46
48
|
let safeUrl=''
|
|
@@ -71,19 +73,26 @@
|
|
|
71
73
|
}
|
|
72
74
|
async function load(force=false) {
|
|
73
75
|
const ctx=syncIdentity()
|
|
74
|
-
if(
|
|
75
|
-
loading
|
|
76
|
+
if(ctx.connected===false){notice.textContent=text('请先连接主机,再查看中转状态。','Connect to your host to read relay status.');return}
|
|
77
|
+
if(busy||loading||!force&&(document.hidden||!target.getClientRects().length||Date.now()-lastRead<Math.min(60000,5000*2**Math.min(failures,4))))return
|
|
78
|
+
loading=true;lastRead=Date.now();const abort=new AbortController();controller=abort
|
|
79
|
+
const timeout=Math.max(15000,root.DshNetwork?.profile().readTimeout||30000)
|
|
80
|
+
const timer=setTimeout(()=>abort.abort(),timeout)
|
|
76
81
|
render()
|
|
77
82
|
try {
|
|
78
83
|
const response=await root.fetch(ctx.endpoint,{headers:ctx.headers,credentials,cache:'no-store',signal:abort.signal})
|
|
79
|
-
|
|
84
|
+
let data
|
|
85
|
+
try{data=await response.json()}catch{throw Object.assign(Error('INVALID_RESPONSE'),{code:'INVALID_RESPONSE',status:response.status})}
|
|
80
86
|
if(!current(ctx))return
|
|
81
87
|
if(response.status===429&&data.daily){value={phase:'quota-exceeded',daily:data.daily,configured:false};notice.textContent=text('今日额度已用完。请用主机本地地址进入设置,或等待零点恢复。','Daily quota reached. Use the local host address or wait until reset.');return}
|
|
82
88
|
if(!response.ok)throw Object.assign(Error(data.error||'HTTP_'+response.status),{code:data.error,status:response.status})
|
|
83
|
-
if(data.supported!==true)throw Error('UNSUPPORTED_GATEWAY')
|
|
84
|
-
value=data;notice.textContent=''
|
|
89
|
+
if(data.supported!==true)throw Object.assign(Error('UNSUPPORTED_GATEWAY'),{code:'UNSUPPORTED_GATEWAY'})
|
|
90
|
+
value=data;notice.textContent='';readError=false;failures=0
|
|
85
91
|
}catch(error){
|
|
86
|
-
if(current(ctx)&&!busy&&controller===abort)
|
|
92
|
+
if(current(ctx)&&!busy&&controller===abort){
|
|
93
|
+
readError=true;failures++
|
|
94
|
+
notice.textContent=error.status===401?text('访问令牌无效,请在主机与连接中重新连接。','Invalid access token. Reconnect in Hosts and connections.'):error.status===404?text('请将此主机 Remote 升级到 0.8.0-rc.2 或更新版本后使用。','Upgrade this host Remote to 0.8.0-rc.2 or later.'):messages[error.code]?text(...messages[error.code]):abort.signal.aborted?text('读取中转状态超时,请检查网络后刷新。','Relay status timed out. Check the network and refresh.'):text('暂时无法连接主机读取中转状态,可稍后刷新。','Cannot reach the host for relay status. Refresh shortly.')
|
|
95
|
+
}
|
|
87
96
|
}finally{clearTimeout(timer);if(current(ctx)&&controller===abort){loading=false;render()}}
|
|
88
97
|
}
|
|
89
98
|
async function change(action) {
|
package/public/styles.css
CHANGED
|
@@ -868,9 +868,9 @@ button.overview-attention-item, button.overview-session-item { cursor:pointer; }
|
|
|
868
868
|
.about { text-align: center; color: var(--dsr-muted); font-size: 12px; margin-top: 16px; line-height: 1.8; }
|
|
869
869
|
|
|
870
870
|
/* 多服务器列表(分组) */
|
|
871
|
-
.group-bar { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px; }
|
|
872
|
-
.group-bar-label { font-size: 12px; color: var(--dsr-muted); white-space: nowrap; }
|
|
873
|
-
.group-select { flex: 1; min-width: 0; position: relative; }
|
|
871
|
+
.group-bar { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; padding: 0 14px 10px; }
|
|
872
|
+
.group-bar-label { flex-shrink: 0; font-size: 12px; color: var(--dsr-muted); white-space: nowrap; }
|
|
873
|
+
.group-select { flex: 1 1 auto; min-width: 0; position: relative; }
|
|
874
874
|
.group-select-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--dsr-bg-2); color: var(--dsr-text); border: 1px solid var(--dsr-line); border-radius: 10px; padding: 7px 9px; font: inherit; font-size: 13px; outline: none; cursor: pointer; }
|
|
875
875
|
.group-select-btn .caret { color: var(--dsr-muted); font-size: 10px; transition: transform .15s ease; }
|
|
876
876
|
.group-select-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 220px; overflow-y: auto; background: var(--dsr-panel); border: 1px solid var(--dsr-line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.28); padding: 4px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -880,9 +880,10 @@ button.overview-attention-item, button.overview-session-item { cursor:pointer; }
|
|
|
880
880
|
.server-list { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 6px; }
|
|
881
881
|
.server-empty { font-size: 12px; color: var(--dsr-muted); }
|
|
882
882
|
.srv-group { border: 1px solid var(--dsr-line); border-radius: 12px; background: var(--dsr-panel); overflow: hidden; }
|
|
883
|
-
.srv-group-head { display: flex; align-items: center; gap: 6px; padding:
|
|
884
|
-
.srv-group-name { flex: 1; min-width: 0; text-align: left; background: none; border: none; color: var(--dsr-text); font: inherit; font-size: 13px; font-weight: 600; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
|
|
885
|
-
.srv-group-
|
|
883
|
+
.srv-group-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
|
|
884
|
+
.srv-group-name { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: none; color: var(--dsr-text); font: inherit; font-size: 13px; font-weight: 600; padding: 2px 0; display: flex; align-items: center; gap: 6px; }
|
|
885
|
+
.srv-group-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
886
|
+
.srv-group-count { flex-shrink: 0; font-size: 10.5px; color: var(--dsr-muted); background: var(--dsr-bg-2); border-radius: 999px; padding: 0 7px; line-height: 16px; }
|
|
886
887
|
.srv-group-speed { flex-shrink: 0; padding: 3px 8px; font-size: 12px; }
|
|
887
888
|
.srv-group-del { flex-shrink: 0; width: 22px; height: 22px; border-radius: 7px; background: var(--dsr-panel); border: 1px solid var(--dsr-line); color: var(--dsr-muted); font-size: 11px; }
|
|
888
889
|
.srv-group-del:active { color: var(--dsr-error); }
|
|
@@ -891,25 +892,24 @@ button.overview-attention-item, button.overview-session-item { cursor:pointer; }
|
|
|
891
892
|
.switch.small .slider::before { width: 15px; height: 15px; left: 2px; top: 2px; }
|
|
892
893
|
.switch.small input:checked + .slider::before { transform: translateX(15px); }
|
|
893
894
|
.server-row {
|
|
894
|
-
display:
|
|
895
|
+
display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 5px 6px;
|
|
895
896
|
background: var(--dsr-bg-2); border: 1px solid var(--dsr-line); border-radius: 10px;
|
|
896
|
-
padding: 8px
|
|
897
|
+
padding: 9px 8px 9px 11px;
|
|
897
898
|
}
|
|
898
899
|
.server-row.active { border-color: var(--dsr-info-line); background: var(--dsr-info-soft); }
|
|
899
|
-
.server-main {
|
|
900
|
-
.server-note { font-size: 13px;
|
|
901
|
-
.server-url {
|
|
902
|
-
.server-token-badge { color: var(--dsr-muted); font-size: 10px; }
|
|
900
|
+
.server-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
901
|
+
.server-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
|
|
902
|
+
.server-url { min-width: 0; font-size: 11.5px; line-height: 1.4; color: var(--dsr-muted); overflow-wrap: anywhere; }
|
|
903
903
|
.server-badge {
|
|
904
|
-
flex-shrink: 0; font-size:
|
|
904
|
+
justify-self: end; flex-shrink: 0; min-width: 52px; text-align: center; font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
|
|
905
905
|
background: var(--dsr-accent-soft); color: var(--dsr-accent-strong);
|
|
906
906
|
border: 1px solid var(--dsr-accent-line); white-space: nowrap;
|
|
907
907
|
}
|
|
908
908
|
.server-badge.good { background: var(--dsr-success-soft); color: var(--dsr-success); border-color: var(--dsr-success-line); }
|
|
909
909
|
.server-badge.bad { background: var(--dsr-warning-soft); color: var(--dsr-warning); border-color: var(--dsr-warning-line); }
|
|
910
910
|
.server-edit, .server-del {
|
|
911
|
-
flex-shrink: 0; width:
|
|
912
|
-
background: var(--dsr-panel); border: 1px solid var(--dsr-line); color: var(--dsr-muted); font-size:
|
|
911
|
+
flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
|
|
912
|
+
background: var(--dsr-panel); border: 1px solid var(--dsr-line); color: var(--dsr-muted); font-size: 13px;
|
|
913
913
|
}
|
|
914
914
|
.server-edit:active { color: var(--dsr-accent-strong); }
|
|
915
915
|
.server-del:active { color: var(--dsr-error); }
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.subagent-page{position:fixed;inset:0;box-sizing:border-box;width:100%;height:100%;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;background:var(--dsr-bg);color:var(--dsr-text);overflow:hidden}
|
|
2
|
+
.subagent-page[open]{display:flex;flex-direction:column}.subagent-page::backdrop{background:var(--dsr-bg)}
|
|
3
|
+
.subagent-page-head{flex:none;display:flex;align-items:center;gap:22px;padding:max(16px,var(--dsr-safe-top,0px)) max(24px,env(safe-area-inset-right)) 16px max(24px,env(safe-area-inset-left));border-bottom:1px solid var(--dsr-line);background:var(--dsr-panel)}
|
|
4
|
+
.subagent-page-heading{min-width:0}.subagent-page-head h2{margin:5px 0 0;font-size:19px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
5
|
+
.subagent-page-back,.subtree button{font:inherit;cursor:pointer;color:inherit}
|
|
6
|
+
.subagent-page-back{flex:none;min-height:44px;border:1px solid var(--dsr-line);border-radius:10px;background:var(--dsr-bg-2);padding:8px 13px;font-size:13px}
|
|
7
|
+
.subagent-page-content{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:24px max(24px,env(safe-area-inset-right)) max(24px,var(--dsr-safe-b,0px)) max(24px,env(safe-area-inset-left))}
|
|
8
|
+
.subtree{max-width:1280px;margin-inline:auto;font-size:13px;line-height:1.5}
|
|
9
|
+
.subtree-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:12px}
|
|
10
|
+
.subtree-search{flex:1 1 240px;min-width:0;max-width:400px;box-sizing:border-box;min-height:44px;border:1px solid var(--dsr-line);border-radius:10px;padding:10px 13px;background:var(--dsr-panel);color:var(--dsr-text);font:inherit;font-size:14px}
|
|
11
|
+
.subtree-search::placeholder{color:var(--dsr-muted)}
|
|
12
|
+
.subtree-filters{display:flex;gap:3px;padding:3px;border:1px solid var(--dsr-line);border-radius:11px;background:var(--dsr-bg-2)}
|
|
13
|
+
.subtree-filters button{min-height:38px;border:0;border-radius:7px;background:transparent;padding:7px 12px;color:var(--dsr-muted);font-size:12px}
|
|
14
|
+
.subtree-filters button[aria-pressed=true]{background:var(--dsr-accent-soft);color:var(--dsr-accent-strong);box-shadow:inset 0 0 0 1px var(--dsr-accent-line)}
|
|
15
|
+
.subtree-toolbar-actions{display:flex;align-items:center;gap:8px;margin-inline-start:auto}
|
|
16
|
+
.subtree-quiet,.subtree-action{min-height:44px;padding:9px 12px;border:1px solid var(--dsr-line);border-radius:9px;background:var(--dsr-panel);font-size:12px!important}
|
|
17
|
+
.subtree button:disabled{opacity:.6;cursor:default}
|
|
18
|
+
.subtree-summary{display:flex;flex-wrap:wrap;gap:6px 18px;margin:15px 0;color:var(--dsr-muted);font-size:12px;font-variant-numeric:tabular-nums}
|
|
19
|
+
.subtree-layout{display:grid;grid-template-columns:minmax(0,1fr) 320px;align-items:start;gap:24px}
|
|
20
|
+
.subtree-outline{min-width:0;padding:20px 16px;background:var(--dsr-bg-2);border:1px solid var(--dsr-line);border-radius:16px}
|
|
21
|
+
.subtree-list{list-style:none;padding:0 0 0 22px;margin:0 0 0 21px;border-inline-start:1px solid var(--dsr-divider)}
|
|
22
|
+
.subtree-root-list{padding:0;margin:0;border:0}.subtree-list>li{position:relative;padding-block:6px}
|
|
23
|
+
.subtree-list:not(.subtree-root-list)>li::before{content:'';position:absolute;inset-inline-start:-22px;top:37px;width:22px;border-top:1px solid var(--dsr-divider)}
|
|
24
|
+
.subtree-row{display:flex;align-items:center;gap:4px;min-width:0}
|
|
25
|
+
.subtree-disclosure,.subtree-leaf{flex:none;display:flex;align-items:center;justify-content:center;width:36px;min-height:44px;border:0;border-radius:8px;background:transparent;font-size:22px!important;color:var(--dsr-muted)!important}
|
|
26
|
+
.subtree-node{display:block;flex:1;min-width:0;width:100%;text-align:start;border:1px solid var(--dsr-line);border-radius:11px;padding:11px 13px;background:var(--dsr-panel);transition:border-color .15s,background .15s}
|
|
27
|
+
.subtree-node:hover{border-color:var(--dsr-accent-line);background:var(--dsr-panel-2)}
|
|
28
|
+
.subtree-node[aria-pressed=true]{border-color:var(--dsr-accent);background:var(--dsr-accent-soft);box-shadow:0 0 0 1px var(--dsr-accent-line)}
|
|
29
|
+
.subtree-node-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}
|
|
30
|
+
.subtree-node-head strong{min-width:0;font-size:14px;font-weight:600;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
31
|
+
.subtree-node-meta{display:flex;flex-wrap:wrap;gap:3px 12px;margin-top:5px;font-size:11px;color:var(--dsr-muted)}
|
|
32
|
+
.subtree-badge{display:inline-flex;align-items:center;gap:5px;flex:none;white-space:nowrap;border-radius:6px;padding:3px 7px;background:var(--dsr-panel-2);color:var(--dsr-muted);font-size:11px;font-weight:500}
|
|
33
|
+
.subtree-badge::before{content:'·';font-size:18px;line-height:10px}.subtree-badge[data-activity=running]{color:var(--dsr-accent-strong);background:var(--dsr-accent-soft)}
|
|
34
|
+
.subtree-badge[data-activity=waiting],.subtree-badge[data-activity=diagnostic]{color:var(--dsr-warning);background:var(--dsr-warning-soft)}
|
|
35
|
+
.subtree-badge[data-activity=diagnostic]::before{content:'!';font-size:11px}
|
|
36
|
+
.subtree-detail{position:sticky;top:0;min-width:0;padding:21px;border:1px solid var(--dsr-line);border-radius:16px;background:var(--dsr-panel)}
|
|
37
|
+
.subtree-eyebrow{font-size:11px;color:var(--dsr-muted);letter-spacing:.06em}.subtree-detail h3{font-size:18px;line-height:1.4;margin:9px 0 12px;overflow-wrap:anywhere}
|
|
38
|
+
.subtree-detail-badges{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:20px}.subtree-kind{font-size:11px;color:var(--dsr-muted)}
|
|
39
|
+
.subtree-field-label{margin-top:16px;font-size:11px;color:var(--dsr-muted)}.subtree-path{font-size:12px;line-height:1.7;margin:5px 0 0;overflow-wrap:anywhere}
|
|
40
|
+
.subtree-id{display:block;font-size:11px;line-height:1.6;margin-top:6px;padding:8px;border-radius:7px;background:var(--dsr-code-bg);overflow-wrap:anywhere;user-select:text}
|
|
41
|
+
.subtree-parent{max-width:100%;min-width:44px;min-height:44px;text-align:start;overflow-wrap:anywhere;padding:4px 0;border:0;background:transparent;color:var(--dsr-accent-strong)!important;font-size:12px!important}
|
|
42
|
+
.subtree-detail-actions{display:flex;flex-direction:column;gap:9px;margin-top:22px}.subtree-action{text-align:center}
|
|
43
|
+
.subtree-primary{background:var(--dsr-accent)!important;color:var(--dsr-on-accent)!important;border-color:var(--dsr-accent)!important;font-weight:650!important}
|
|
44
|
+
.subtree-danger{color:var(--dsr-warning)!important;border-color:var(--dsr-warning-line)!important;background:var(--dsr-warning-soft)!important}
|
|
45
|
+
.subtree-note{font-size:11px;color:var(--dsr-muted);line-height:1.7;margin:13px 0 0;overflow-wrap:anywhere}
|
|
46
|
+
.subtree-notice{padding:12px;border:1px solid var(--dsr-warning-line);border-radius:9px;background:var(--dsr-warning-soft);color:var(--dsr-warning);font-size:12px;line-height:1.65}
|
|
47
|
+
.subtree-reason{font-size:11px;color:var(--dsr-muted);display:block;margin-bottom:16px;overflow-wrap:anywhere}
|
|
48
|
+
.subtree-feedback{list-style:none;padding:18px!important;margin:8px 0;border:1px dashed var(--dsr-divider);border-radius:10px;color:var(--dsr-muted);font-size:12px;overflow-wrap:anywhere}
|
|
49
|
+
.subtree-feedback strong{font-size:13px;color:var(--dsr-text);font-weight:500}.subtree-feedback p{margin:7px 0 10px}.subtree-warning{border-color:var(--dsr-warning-line);background:var(--dsr-warning-soft)}
|
|
50
|
+
.subtree-depth{color:var(--dsr-accent-strong)}.subtree :is(button,input):focus-visible,.subagent-page-back:focus-visible{outline:2px solid var(--dsr-accent);outline-offset:3px}.subtree-detail h3:focus{outline:none}
|
|
51
|
+
.subtree-back-to-tree{display:none}
|
|
52
|
+
.subagents-entry{flex:none;font:inherit;font-size:12px;color:var(--dsr-text);background:transparent;border:1px solid var(--dsr-line);border-radius:9px;min-height:44px;padding:6px 9px;cursor:pointer}
|
|
53
|
+
body.viewing-subagent .composer-wrap,body.viewing-subagent .ds-composer,body.viewing-subagent #btn-session-more,body.viewing-subagent #btn-rename-session,body.viewing-subagent #btn-archive-session,body.viewing-subagent #btn-cancel,body.viewing-subagent [data-goal],body.viewing-subagent #queue-dock{display:none!important}
|
|
54
|
+
@media(max-width:800px){.subtree-layout{grid-template-columns:minmax(0,1fr);gap:16px}.subtree-detail{position:static}.subtree-search{max-width:none}.subtree-outline{padding:12px 8px}.subtree-disclosure,.subtree-leaf{width:32px}.subtree-node{padding:10px}.subtree-node-head{align-items:start;flex-wrap:wrap;gap:5px}.subtree-node-head strong{flex:1 1 120px}.subtree-detail-actions{flex-direction:row;flex-wrap:wrap}.subtree-detail-actions>*{flex:1 1 160px}.subtree .subtree-filters button{min-height:44px}.subtree .subtree-disclosure{min-width:44px}.subtree-list .subtree-list .subtree-list .subtree-list{padding-inline-start:0;margin-inline-start:8px;border-color:transparent}.subtree-list .subtree-list .subtree-list .subtree-list>li::before{display:none}}
|
|
55
|
+
@media(max-width:480px){.subagent-page-head{gap:12px;padding:max(12px,var(--dsr-safe-top,0px)) 12px 12px}.subagent-page-head h2{font-size:16px}.subagent-page-content{padding:16px 12px max(16px,var(--dsr-safe-b,0px))}.subtree-toolbar{gap:10px}.subtree-search{flex-basis:100%}.subtree-toolbar-actions{gap:4px}.subtree-quiet{padding-inline:9px}.subtree-filters button{padding-inline:10px}.subtree-summary{gap:5px 12px}.subtree-list{padding-inline-start:12px;margin-inline-start:14px}.subtree-list:not(.subtree-root-list)>li::before{inset-inline-start:-12px;width:12px}.subtree-root-list{padding:0;margin:0}.subtree-node-head strong{flex-basis:100px}.subtree-detail{padding:18px}}
|
|
56
|
+
@media(prefers-reduced-motion:reduce){.subtree-node{transition:none}}
|
|
57
|
+
@media(max-width:800px){.subtree-back-to-tree{display:block;margin-bottom:8px}}
|
|
58
|
+
@media(max-width:800px){.subtree-leaf{min-width:44px}}
|
|
59
|
+
@media(max-width:800px){.subtree-search{font-size:16px}}
|
|
60
|
+
.subtree-list .subtree-list .subtree-list .subtree-list .subtree-list .subtree-list{padding-inline-start:0;margin-inline-start:10px;border-color:transparent}
|
|
61
|
+
.subtree-list .subtree-list .subtree-list .subtree-list .subtree-list .subtree-list>li::before{display:none}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/* Shared, dependency-free subagent browser. Only explicit disclosure reads a new level. */
|
|
2
|
+
(function (root) {
|
|
3
|
+
'use strict'
|
|
4
|
+
let view = null, page = null, pageBody = null, pageTitle = null
|
|
5
|
+
const memories = new Map()
|
|
6
|
+
const text = (cn, en) => String(root.I18N?.lang || 'zh').startsWith('en') ? en : cn
|
|
7
|
+
function node(tag, label, cls) {
|
|
8
|
+
const el = document.createElement(tag)
|
|
9
|
+
if (label !== undefined) el.textContent = label
|
|
10
|
+
if (cls) el.className = cls
|
|
11
|
+
return el
|
|
12
|
+
}
|
|
13
|
+
function button(label, action, cls, key) {
|
|
14
|
+
const el = node('button', label, cls)
|
|
15
|
+
el.type = 'button'
|
|
16
|
+
if (key) el.dataset.subFocus = key
|
|
17
|
+
el.addEventListener('click', action)
|
|
18
|
+
return el
|
|
19
|
+
}
|
|
20
|
+
const valid = v => view === v && !v.paused && v.options.valid()
|
|
21
|
+
const modeLabel = mode => mode === 'one-shot' ? text('单次任务', 'One-shot task') : mode === 'continuable' ? text('可续接任务', 'Continuable task') : text('模式未知', 'Unknown mode')
|
|
22
|
+
const activityLabel = activity => activity === 'running' ? text('运行中', 'Running') : activity === 'waiting' ? text('等待中', 'Waiting') : activity === 'inactive' ? text('未运行', 'Inactive') : text('状态未知', 'Unknown status')
|
|
23
|
+
function reasonLabel(reason) {
|
|
24
|
+
if (reason === 'migration-required') return text('请先在 DSH 中打开原会话完成迁移,再刷新目录', 'Open the source session in DSH to complete migration, then refresh the catalog')
|
|
25
|
+
if (reason === 'external') return text('这是外部代理任务,请在 DSH 中查看', 'This is an external-agent task. View it in DSH')
|
|
26
|
+
return ({ unsupported: text('当前版本无法识别此任务类型', 'This task type is not supported by the current version'), unavailable: text('记录暂时无法读取,可刷新重试', 'Record unavailable. Refresh to try again'), corrupt: text('任务信息不一致,暂不能打开', 'Task information is inconsistent. This record cannot be opened'), cycle: text('目录关系重复或形成循环', 'The catalog contains a repeated or circular relationship') })[reason] || text('此目录项暂时不可用', 'This catalog entry is unavailable')
|
|
27
|
+
}
|
|
28
|
+
function status(entry, diagnostic) {
|
|
29
|
+
const value = diagnostic ? 'diagnostic' : ['running', 'waiting', 'inactive'].includes(entry.activity) ? entry.activity : 'unknown'
|
|
30
|
+
const el = node('span', diagnostic ? text('目录异常', 'Catalog issue') : activityLabel(value), 'subtree-badge')
|
|
31
|
+
el.dataset.activity = value
|
|
32
|
+
return el
|
|
33
|
+
}
|
|
34
|
+
function model(v) {
|
|
35
|
+
const rootItem = { key: 'root', id: v.id, label: v.options.title || v.id, parent: null, depth: 0, entry: { activity: v.options.activity }, children: [] }
|
|
36
|
+
const byKey = new Map([['root', rootItem]])
|
|
37
|
+
let count = 0, running = 0, issues = 0, limited = false
|
|
38
|
+
function visit(parent, ancestors) {
|
|
39
|
+
const cached = v.cache.get(parent.id)
|
|
40
|
+
for (const entry of cached?.value?.entries || []) {
|
|
41
|
+
if (byKey.size > 300) { limited = true; break }
|
|
42
|
+
const diagnostic = entry.kind === 'diagnostic' || !entry.id || ancestors.has(entry.id)
|
|
43
|
+
const item = { key: parent.key + '/' + (entry.id ? encodeURIComponent(entry.id) : 'unknown-' + parent.children.length), id: entry.id || '', label: entry.label || entry.id?.slice(0, 12) || text('异常条目', 'Catalog issue'), entry, parent, depth: parent.depth + 1, diagnostic, reason: ancestors.has(entry.id) ? 'cycle' : entry.reason, children: [] }
|
|
44
|
+
byKey.set(item.key, item); parent.children.push(item)
|
|
45
|
+
if (diagnostic) issues++
|
|
46
|
+
else {
|
|
47
|
+
count++; if (entry.activity === 'running') running++
|
|
48
|
+
if (item.depth < 16) visit(item, new Set([...ancestors, item.id]))
|
|
49
|
+
else if (entry.hasChildren !== false) limited = true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
visit(rootItem, new Set([v.id]))
|
|
54
|
+
return { rootItem, byKey, count, running, issues, limited }
|
|
55
|
+
}
|
|
56
|
+
async function read(v, id, force = false) {
|
|
57
|
+
if (!valid(v)) return
|
|
58
|
+
const previous = v.cache.get(id)
|
|
59
|
+
if (previous?.loading || (!force && (previous?.value || previous?.error))) return
|
|
60
|
+
const item = { ...previous, loading: true, error: '' }
|
|
61
|
+
v.cache.set(id, item); paint(v)
|
|
62
|
+
try {
|
|
63
|
+
const value = await v.options.read(id)
|
|
64
|
+
if (!valid(v)) { v.cache.delete(id); return }
|
|
65
|
+
if (!Array.isArray(value?.entries)) throw new Error(text('未能读取子代理目录', 'Subagent catalog unavailable'))
|
|
66
|
+
item.value = value; item.updatedAt = Date.now()
|
|
67
|
+
const ancestors = new Set([v.id, id])
|
|
68
|
+
let parent = [...model(v).byKey.values()].find(item => !item.diagnostic && item.id === id)
|
|
69
|
+
for (; parent; parent = parent.parent) ancestors.add(parent.id)
|
|
70
|
+
for (const entry of value.entries) if (entry.kind !== 'diagnostic' && entry.id && !ancestors.has(entry.id)) v.options.remember(entry, id)
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (!valid(v)) { v.cache.delete(id); return }
|
|
73
|
+
item.error = String(error.message || error)
|
|
74
|
+
} finally { item.loading = false; if (valid(v)) paint(v) }
|
|
75
|
+
}
|
|
76
|
+
async function refresh(v) {
|
|
77
|
+
if (!valid(v) || v.refreshing) return
|
|
78
|
+
v.refreshing = true; paint(v)
|
|
79
|
+
const seen = new Set()
|
|
80
|
+
async function visit(id, depth) {
|
|
81
|
+
if (!valid(v) || seen.has(id) || seen.size >= 300 || depth > 16) return
|
|
82
|
+
seen.add(id); await read(v, id, true)
|
|
83
|
+
if (!valid(v) || !v.expanded.has(id)) return
|
|
84
|
+
for (const entry of v.cache.get(id)?.value?.entries || []) {
|
|
85
|
+
if (entry.kind !== 'diagnostic' && entry.id && v.expanded.has(entry.id)) await visit(entry.id, depth + 1)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
try { await visit(v.id, 0) } finally { v.refreshing = false; if (valid(v)) paint(v) }
|
|
89
|
+
}
|
|
90
|
+
function shell(v) {
|
|
91
|
+
const el = v.el = node('section', undefined, 'subtree')
|
|
92
|
+
const toolbar = node('div', undefined, 'subtree-toolbar')
|
|
93
|
+
const search = v.search = node('input', undefined, 'subtree-search')
|
|
94
|
+
search.type = 'search'; search.placeholder = text('查找已读取的名称或 ID', 'Find a loaded name or ID')
|
|
95
|
+
search.setAttribute('aria-label', search.placeholder)
|
|
96
|
+
search.addEventListener('input', () => { v.query = search.value; paint(v) })
|
|
97
|
+
const filters = node('div', undefined, 'subtree-filters')
|
|
98
|
+
filters.setAttribute('aria-label', text('按状态筛选', 'Filter by status'))
|
|
99
|
+
v.filters = []
|
|
100
|
+
for (const [key, label] of [['all', text('全部', 'All')], ['running', text('运行中', 'Running')], ['diagnostic', text('异常', 'Issues')]]) {
|
|
101
|
+
const b = button(label, () => { v.filter = key; paint(v) }, '', 'filter:' + key)
|
|
102
|
+
filters.append(b); v.filters.push([key, b])
|
|
103
|
+
}
|
|
104
|
+
toolbar.append(search, filters)
|
|
105
|
+
const actions = node('div', undefined, 'subtree-toolbar-actions')
|
|
106
|
+
const collapse = button(text('收起分支', 'Collapse branches'), () => { v.expanded.clear(); v.expanded.add(v.id); paint(v) }, 'subtree-quiet', 'collapse')
|
|
107
|
+
v.collapseButton = collapse
|
|
108
|
+
const refreshButton = v.refreshButton = button(text('刷新', 'Refresh'), () => void refresh(v), 'subtree-quiet', 'refresh')
|
|
109
|
+
actions.append(collapse, refreshButton); toolbar.append(actions)
|
|
110
|
+
v.summary = node('div', undefined, 'subtree-summary'); v.summary.setAttribute('role', 'status')
|
|
111
|
+
const layout = node('div', undefined, 'subtree-layout')
|
|
112
|
+
v.tree = node('div', undefined, 'subtree-outline'); v.tree.setAttribute('aria-label', text('子代理层级', 'Subagent hierarchy'))
|
|
113
|
+
v.detail = node('aside', undefined, 'subtree-detail'); v.detail.setAttribute('aria-label', text('所选节点详情', 'Selected node details'))
|
|
114
|
+
layout.append(v.tree, v.detail); el.append(toolbar, v.summary, layout)
|
|
115
|
+
}
|
|
116
|
+
function select(v, item) {
|
|
117
|
+
v.selected = item.key; paint(v)
|
|
118
|
+
if (root.matchMedia?.('(max-width:800px)').matches) v.detail.scrollIntoView({ behavior: root.matchMedia('(prefers-reduced-motion:reduce)').matches ? 'auto' : 'smooth', block: 'start' })
|
|
119
|
+
v.detailTitle?.focus({ preventScroll: true })
|
|
120
|
+
}
|
|
121
|
+
function details(v, item, outsideFilter) {
|
|
122
|
+
const box = v.detail; box.replaceChildren()
|
|
123
|
+
box.append(button(text('↑ 返回层级', '↑ Back to hierarchy'), () => {
|
|
124
|
+
const card = v.cards.get(item.key) || v.cards.get('root')
|
|
125
|
+
card?.scrollIntoView({ block: 'center' }); card?.focus({ preventScroll: true })
|
|
126
|
+
}, 'subtree-parent subtree-back-to-tree', 'back-to-tree'))
|
|
127
|
+
box.append(node('div', text('节点详情', 'Node details'), 'subtree-eyebrow'))
|
|
128
|
+
const title = v.detailTitle = node('h3', item.label); title.tabIndex = -1; box.append(title)
|
|
129
|
+
if (outsideFilter) box.append(node('p', text('此选中节点不在当前筛选结果中。', 'This selected node is outside the current filter.'), 'subtree-note'))
|
|
130
|
+
const badges = node('div', undefined, 'subtree-detail-badges')
|
|
131
|
+
if (item.key === 'root') badges.append(node('span', text('当前会话', 'Current session'), 'subtree-kind'))
|
|
132
|
+
else badges.append(node('span', item.diagnostic ? text('不可打开', 'Unavailable') : modeLabel(item.entry.mode), 'subtree-kind'))
|
|
133
|
+
badges.append(status(item.entry, item.diagnostic)); box.append(badges)
|
|
134
|
+
const path = []; for (let p = item; p; p = p.parent) path.unshift(p.label)
|
|
135
|
+
box.append(node('div', text('所在分支', 'Branch'), 'subtree-field-label'), node('p', path.join(' › '), 'subtree-path'))
|
|
136
|
+
if (item.parent) {
|
|
137
|
+
box.append(node('div', text('直接父会话', 'Direct parent'), 'subtree-field-label'))
|
|
138
|
+
box.append(button(item.parent.label, () => select(v, item.parent), 'subtree-parent', 'parent:' + item.key))
|
|
139
|
+
}
|
|
140
|
+
box.append(node('div', text('会话 ID', 'Session ID'), 'subtree-field-label'), node('code', item.id || '—', 'subtree-id'))
|
|
141
|
+
if (item.diagnostic) {
|
|
142
|
+
box.append(node('p', reasonLabel(item.reason), 'subtree-notice'))
|
|
143
|
+
if (item.reason) box.append(node('code', item.reason, 'subtree-reason'))
|
|
144
|
+
box.append(button(text('刷新目录', 'Refresh catalog'), () => void read(v, item.parent.id, true), 'subtree-action', 'retry-detail')); return
|
|
145
|
+
}
|
|
146
|
+
const cached = v.cache.get(item.id)
|
|
147
|
+
if (cached?.value) box.append(node('p', text(`已读取 ${item.children.filter(c => !c.diagnostic).length} 个直接子代理`, `${item.children.filter(c => !c.diagnostic).length} direct subagents loaded`), 'subtree-note'))
|
|
148
|
+
else if (item.entry.hasChildren !== false && item.key !== 'root') box.append(node('p', text('展开节点前的箭头,读取下一层任务。', 'Expand the node arrow to load the next level.'), 'subtree-note'))
|
|
149
|
+
const actions = node('div', undefined, 'subtree-detail-actions')
|
|
150
|
+
actions.append(button(item.key === 'root' ? text('返回当前对话', 'Back to current chat') : text('打开只读记录 ↗', 'Open read-only record ↗'), () => {
|
|
151
|
+
if (!valid(v)) return
|
|
152
|
+
root.DshSubagents.close(); if (item.parent) void v.options.open(item.entry, item.parent.id)
|
|
153
|
+
}, 'subtree-action subtree-primary', 'open:' + item.key))
|
|
154
|
+
const parentCatalog = item.parent && v.cache.get(item.parent.id)?.value
|
|
155
|
+
if (item.entry.mode === 'continuable' && item.entry.activity === 'running' && parentCatalog?.parentAvailable !== false) {
|
|
156
|
+
actions.append(button(text('中断任务', 'Interrupt task'), () => { if (valid(v)) void v.options.interrupt(item.id, item.parent.id) }, 'subtree-action subtree-danger', 'interrupt:' + item.key))
|
|
157
|
+
}
|
|
158
|
+
box.append(actions, node('p', item.parent ? text('打开记录后,返回会进入它的直接父会话。', 'From a record, Back opens its direct parent session.') : text('选择树中的子代理,查看任务详情。', 'Select a subagent in the tree to inspect its details.'), 'subtree-note'))
|
|
159
|
+
}
|
|
160
|
+
function paint(v) {
|
|
161
|
+
if (!valid(v)) return
|
|
162
|
+
const focused = document.activeElement?.dataset?.subFocus
|
|
163
|
+
const m = model(v), query = v.query.trim().toLocaleLowerCase(), filtering = !!query || v.filter !== 'all'
|
|
164
|
+
const matches = new Set()
|
|
165
|
+
function match(item) {
|
|
166
|
+
const own = (!query || `${item.label} ${item.id}`.toLocaleLowerCase().includes(query)) && (v.filter === 'all' || (v.filter === 'diagnostic' ? item.diagnostic : !item.diagnostic && item.entry.activity === 'running'))
|
|
167
|
+
const descendant = item.children.map(match).some(Boolean)
|
|
168
|
+
if (own || descendant) matches.add(item.key)
|
|
169
|
+
return own || descendant
|
|
170
|
+
}
|
|
171
|
+
m.rootItem.children.forEach(match)
|
|
172
|
+
v.refreshButton.disabled = !!v.refreshing; v.refreshButton.textContent = v.refreshing ? text('刷新中…', 'Refreshing…') : text('刷新', 'Refresh')
|
|
173
|
+
v.collapseButton.disabled = filtering
|
|
174
|
+
v.collapseButton.title = filtering ? text('清除筛选后可收起分支', 'Clear filters to collapse branches') : ''
|
|
175
|
+
for (const [key, b] of v.filters) b.setAttribute('aria-pressed', String(key === v.filter))
|
|
176
|
+
const labels = [text(`已读取 ${m.count} 个子代理`, `${m.count} subagents loaded`), text(`${m.running} 个运行中`, `${m.running} running`), text(`${m.issues} 个目录异常`, `${m.issues} catalog issues`)]
|
|
177
|
+
if (v.summarySignature !== labels.join('|')) {
|
|
178
|
+
v.summarySignature = labels.join('|'); v.summary.replaceChildren()
|
|
179
|
+
for (const label of labels) v.summary.append(node('span', label))
|
|
180
|
+
}
|
|
181
|
+
v.tree.replaceChildren()
|
|
182
|
+
v.cards = new Map()
|
|
183
|
+
function feedback(parent, list) {
|
|
184
|
+
const cached = v.cache.get(parent.id)
|
|
185
|
+
if (cached?.error) {
|
|
186
|
+
const warning = node('li', undefined, 'subtree-feedback subtree-warning')
|
|
187
|
+
warning.append(node('strong', cached.value ? text('刷新失败,保留上次目录', 'Refresh failed. Showing the last catalog') : text('暂时无法读取目录', 'Catalog unavailable')), node('p', cached.error))
|
|
188
|
+
warning.append(button(text('重试', 'Retry'), () => void read(v, parent.id, true), 'subtree-action', 'retry:' + parent.key)); list.append(warning)
|
|
189
|
+
}
|
|
190
|
+
if (cached?.loading) list.append(node('li', text('正在读取这一层…', 'Loading this level…'), 'subtree-feedback'))
|
|
191
|
+
if (cached?.value && !cached.value.entries.length && !cached.error) {
|
|
192
|
+
const empty = node('li', undefined, 'subtree-feedback')
|
|
193
|
+
empty.append(node('strong', text('暂无子代理', 'No subagents')), node('p', text('此会话还没有子代理记录。产生新任务后可刷新查看。', 'This session has no subagent records yet. Refresh after new tasks are created.'))); list.append(empty)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function row(item) {
|
|
197
|
+
const li = node('li'), line = node('div', undefined, 'subtree-row')
|
|
198
|
+
const cached = v.cache.get(item.id), expanded = v.expanded.has(item.id)
|
|
199
|
+
const canExpand = !item.diagnostic && item.depth < 16 && (cached?.value ? cached.value.entries.length > 0 : item.key === 'root' || item.entry.hasChildren !== false)
|
|
200
|
+
if (canExpand) {
|
|
201
|
+
const toggle = button(expanded ? '⌄' : '›', () => {
|
|
202
|
+
if (expanded) v.expanded.delete(item.id)
|
|
203
|
+
else { v.expanded.add(item.id); void read(v, item.id) }
|
|
204
|
+
paint(v)
|
|
205
|
+
}, 'subtree-disclosure', 'toggle:' + item.key)
|
|
206
|
+
toggle.setAttribute('aria-expanded', String(expanded)); toggle.setAttribute('aria-label', (expanded ? text('收起 ', 'Collapse ') : text('展开 ', 'Expand ')) + item.label); line.append(toggle)
|
|
207
|
+
} else line.append(node('span', '·', 'subtree-leaf'))
|
|
208
|
+
const card = button(undefined, () => select(v, item), 'subtree-node', 'select:' + item.key)
|
|
209
|
+
v.cards.set(item.key, card)
|
|
210
|
+
card.setAttribute('aria-pressed', String(item.key === v.selected)); card.title = item.id
|
|
211
|
+
const head = node('span', undefined, 'subtree-node-head'); head.append(node('strong', item.label), status(item.entry, item.diagnostic))
|
|
212
|
+
const meta = node('span', undefined, 'subtree-node-meta')
|
|
213
|
+
meta.append(node('span', item.key === 'root' ? text('当前会话 · 树的起点', 'Current session · Tree root') : item.diagnostic ? reasonLabel(item.reason) : modeLabel(item.entry.mode)))
|
|
214
|
+
if (item.depth >= 4) meta.append(node('span', text(`第 ${item.depth} 层`, `Level ${item.depth}`), 'subtree-depth'))
|
|
215
|
+
if (!item.diagnostic && cached?.value && item.children.length) meta.append(node('span', text(`${item.children.length} 个下级条目`, `${item.children.length} child entries`)))
|
|
216
|
+
card.append(head, meta); line.append(card); li.append(line)
|
|
217
|
+
if (!item.diagnostic && (expanded || filtering)) {
|
|
218
|
+
const list = node('ul', undefined, 'subtree-list')
|
|
219
|
+
for (const child of item.children) if (!filtering || matches.has(child.key)) list.append(row(child))
|
|
220
|
+
if (!filtering || cached?.loading || cached?.error) feedback(item, list)
|
|
221
|
+
if (list.children.length) li.append(list)
|
|
222
|
+
}
|
|
223
|
+
return li
|
|
224
|
+
}
|
|
225
|
+
const treeList = node('ul', undefined, 'subtree-list subtree-root-list'); treeList.append(row(m.rootItem)); v.tree.append(treeList)
|
|
226
|
+
if (filtering && v.cache.get(v.id)?.value && !v.cache.get(v.id)?.loading && !m.rootItem.children.some(c => matches.has(c.key))) {
|
|
227
|
+
const empty = node('div', undefined, 'subtree-feedback')
|
|
228
|
+
empty.append(node('strong', text('已读取目录中没有匹配项', 'No matches in the loaded catalog')), node('p', text('筛选仅检查已读取的节点,不会自动加载其他分支。', 'Filters only inspect loaded nodes and do not load other branches.')))
|
|
229
|
+
empty.append(button(text('清除筛选', 'Clear filters'), () => { v.query = ''; v.search.value = ''; v.filter = 'all'; paint(v) }, 'subtree-action', 'clear')); v.tree.append(empty)
|
|
230
|
+
}
|
|
231
|
+
if (m.limited) v.tree.append(node('p', text('目录较大,打开子代理记录可继续查看更深层。', 'Open a child record to explore more of this large catalog.'), 'subtree-note'))
|
|
232
|
+
const selected = m.byKey.get(v.selected) || m.rootItem
|
|
233
|
+
v.selected = selected.key; details(v, selected, filtering && selected.key !== 'root' && !matches.has(selected.key))
|
|
234
|
+
if (focused) for (const el of v.el.querySelectorAll('[data-sub-focus]')) if (el.dataset.subFocus === focused) el.focus({ preventScroll: true })
|
|
235
|
+
}
|
|
236
|
+
root.DshSubagents = {
|
|
237
|
+
configure(entry, options) {
|
|
238
|
+
if (!entry) return
|
|
239
|
+
entry.onclick = () => { if (options.valid()) root.DshSubagents.show(options) }
|
|
240
|
+
if (page?.open) { if (view?.id === options.sessionId) root.DshSubagents.mount(pageBody, options); else root.DshSubagents.close() }
|
|
241
|
+
},
|
|
242
|
+
show(options) {
|
|
243
|
+
if (!options.valid()) return
|
|
244
|
+
if (!page) {
|
|
245
|
+
page = node('dialog', undefined, 'subagent-page'); page.id = 'subagent-page'; page.setAttribute('aria-labelledby', 'subagent-page-title')
|
|
246
|
+
const head = node('header', undefined, 'subagent-page-head')
|
|
247
|
+
const back = button(text('‹ 返回对话', '‹ Back to chat'), () => root.DshSubagents.close(), 'subagent-page-back')
|
|
248
|
+
const titleBlock = node('div', undefined, 'subagent-page-heading'); titleBlock.append(node('span', text('会话 / 子代理', 'Conversation / Subagents'), 'subtree-eyebrow'))
|
|
249
|
+
pageTitle = node('h2'); pageTitle.id = 'subagent-page-title'; titleBlock.append(pageTitle); head.append(back, titleBlock)
|
|
250
|
+
pageBody = node('div', undefined, 'subagent-page-content'); page.append(head, pageBody)
|
|
251
|
+
page.addEventListener('close', () => { if (view?.options.valid()) view.options.onClose?.(); root.DshSubagents.pause() }); document.body.append(page)
|
|
252
|
+
}
|
|
253
|
+
pageTitle.textContent = options.title || options.sessionId
|
|
254
|
+
if (!page.open) { page.showModal(); options.onShow?.() }
|
|
255
|
+
if (!view || view.id !== options.sessionId || !view.options.valid()) {
|
|
256
|
+
const expanded = memories.get(options.sessionId) || new Set(); expanded.add(options.sessionId); memories.set(options.sessionId, expanded)
|
|
257
|
+
}
|
|
258
|
+
pageBody.replaceChildren(); root.DshSubagents.mount(pageBody, options)
|
|
259
|
+
},
|
|
260
|
+
close() { if (page?.open) { page.close(); root.DshSubagents.pause() } },
|
|
261
|
+
mount(target, options) {
|
|
262
|
+
if (!target || !options.valid()) return
|
|
263
|
+
if (!view || view.id !== options.sessionId || !view.options.valid()) {
|
|
264
|
+
if (view) memories.set(view.id, view.expanded)
|
|
265
|
+
if (memories.size > 20) memories.delete(memories.keys().next().value)
|
|
266
|
+
view = { id: options.sessionId, options, expanded: memories.get(options.sessionId) || new Set([options.sessionId]), cache: new Map(), paused: false, query: '', filter: 'all', selected: 'root' }; shell(view)
|
|
267
|
+
}
|
|
268
|
+
view.options = options; view.paused = false; target.append(view.el); paint(view)
|
|
269
|
+
const cached = view.cache.get(view.id)
|
|
270
|
+
if (cached?.value && Date.now() - cached.updatedAt >= 10000) void refresh(view); else void read(view, view.id)
|
|
271
|
+
},
|
|
272
|
+
pause() { if (view) view.paused = true },
|
|
273
|
+
reset() { root.DshSubagents.close(); view = null; memories.clear() },
|
|
274
|
+
}
|
|
275
|
+
})(window)
|
package/public/update.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.0-rc.
|
|
2
|
+
"version": "0.8.0-rc.3",
|
|
3
3
|
"apkUrl": "dsh-remote.apk",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"releasedAt": "2026-10-
|
|
6
|
-
"notes": "0.8.0 开发者预览 rc.2
|
|
4
|
+
"sha256": "cda79a6d4c43bac042b6b47bbdd141c3f7c6e0ac20c7a455b9fe204d32822908",
|
|
5
|
+
"releasedAt": "2026-10-17T12:41:14.228Z",
|
|
6
|
+
"notes": "0.8.0 开发者预览 rc.3:适配 DSH 0.2.1,新增独立子代理树形页面,统一二级设置界面;精简思考与工具调用展示并保留展开状态;支持重新下载同版本补丁安装包并校验 SHA-256;修复审批展示、公告与返回导航等测试反馈;峰谷提醒交由 dsh-cost-meter 管理,停用 Remote 独立提醒服务。",
|
|
7
7
|
"history": [
|
|
8
8
|
{
|
|
9
9
|
"version": "0.7.6",
|
package/public/version.json
CHANGED