dsh-remote-plugin 0.8.0-rc.8 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +12 -5
- package/README.md +12 -5
- package/apk/dsh-remote.apk +0 -0
- package/gateway.cjs +402 -165
- package/index.mjs +49 -20
- package/insights.mjs +33 -2
- package/package.json +2 -1
- package/plugin-center.mjs +12 -3
- package/plugin-transaction.mjs +18 -2
- package/public/admin.html +1 -1
- package/public/admin.js +2 -1
- package/public/app.js +296 -97
- package/public/approval-records.js +229 -0
- package/public/build.json +2 -2
- package/public/desktop/desktop.css +53 -1
- package/public/desktop/desktop.html +40 -2
- package/public/desktop/desktop.js +197 -60
- package/public/doctor-entry.js +33 -4
- package/public/doctor.js +41 -13
- package/public/extensions.css +96 -1
- package/public/extensions.js +43 -5
- package/public/index.html +45 -9
- package/public/insights.css +5 -0
- package/public/insights.js +40 -11
- package/public/md.js +7 -1
- package/public/onboarding.css +36 -0
- package/public/onboarding.js +253 -0
- package/public/operations.js +1 -1
- package/public/permission-presets.js +159 -0
- package/public/plugin-center.css +3 -0
- package/public/plugin-center.js +58 -9
- package/public/plugin.html +1 -1
- package/public/plugin.js +5 -1
- package/public/skills.js +16 -5
- package/public/skins/blue-fish/skin.css +51 -0
- package/public/styles.css +43 -1
- package/public/task-board.js +109 -0
- package/public/teams.js +35 -13
- package/public/theme.js +5 -11
- package/public/turn-results.js +2 -0
- package/public/update.json +8 -8
- package/public/version.json +1 -1
- package/public/workflow.css +6 -12
- package/public/workflow.js +13 -4
- package/skills/dsh-remote-doctor/SKILL.md +16 -0
- package/skills/dsh-remote-doctor/references/wiki/README.md +40 -0
- package/skills/dsh-remote-doctor/references/wiki/ai-guide.md +61 -0
- package/skills/dsh-remote-doctor/references/wiki/connection.md +74 -0
- package/skills/dsh-remote-doctor/references/wiki/errors.md +26 -0
- package/skills/dsh-remote-doctor/references/wiki/evidence.md +44 -0
- package/skills/dsh-remote-doctor/references/wiki/files.md +31 -0
- package/skills/dsh-remote-doctor/references/wiki/maintenance.md +30 -0
- package/skills/dsh-remote-doctor/references/wiki/notifications.md +29 -0
- package/skills/dsh-remote-doctor/references/wiki/operations.md +32 -0
- package/skills/dsh-remote-doctor/references/wiki/plugins.md +69 -0
- package/skills/dsh-remote-doctor/references/wiki/sessions.md +45 -0
- package/skills/dsh-remote-doctor/references/wiki/sources.md +27 -0
- package/task-board.mjs +57 -0
package/public/extensions.css
CHANGED
|
@@ -1 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
/* Optional plugin views share the host theme and adapt to their container. */
|
|
2
|
+
.ext-page{min-width:0;width:100%;padding:16px;color:var(--dsr-text)}
|
|
3
|
+
.ext-page.is-manage{padding:0}
|
|
4
|
+
.ext-page,.ext-page *{box-sizing:border-box}
|
|
5
|
+
.ext-page [hidden]{display:none!important}
|
|
6
|
+
.ext-header{display:flex;gap:14px;align-items:center;justify-content:space-between;margin-bottom:28px;flex-wrap:wrap}
|
|
7
|
+
.ext-host{min-width:0;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dsr-muted);font-size:13px;line-height:1.7}
|
|
8
|
+
.ext-header button,.ext-button{display:inline-flex;gap:12px;align-items:center;justify-content:center;flex-shrink:0;min-height:44px;max-width:100%;padding:10px 15px;border:1px solid var(--dsr-line);border-radius:12px;color:var(--dsr-text);background:var(--dsr-panel);font:inherit;font-size:13px;line-height:1.5;text-align:center;text-decoration:none;cursor:pointer}
|
|
9
|
+
.ext-button:hover,.ext-header button:hover{background:var(--dsr-panel-2);border-color:var(--dsr-muted)}
|
|
10
|
+
.ext-button-primary{background:var(--dsr-accent-soft);border-color:var(--dsr-accent-line);color:var(--dsr-accent-strong)}
|
|
11
|
+
.ext-button-primary:hover{background:var(--dsr-accent-soft);border-color:var(--dsr-accent)}
|
|
12
|
+
.ext-button:disabled{opacity:.6;cursor:wait}
|
|
13
|
+
.ext-page :is(button,input,select,summary):focus-visible{outline:2px solid var(--dsr-accent);outline-offset:3px}
|
|
14
|
+
.teams-page,.task-board{container-type:inline-size;min-width:0;max-width:1080px;margin:0 auto;line-height:1.6}
|
|
15
|
+
.ext-heading{margin-bottom:24px;max-width:70ch}
|
|
16
|
+
.ext-eyebrow{display:block;color:var(--dsr-accent-strong);font-size:11px;font-weight:650;letter-spacing:.1em;margin-bottom:7px}
|
|
17
|
+
.ext-heading h2{font-size:clamp(24px,4vw,30px);line-height:1.3;letter-spacing:-.025em;margin:0;font-weight:700}
|
|
18
|
+
.ext-heading p{margin:10px 0 0;color:var(--dsr-muted);font-size:14px;line-height:1.8;text-wrap:pretty}
|
|
19
|
+
.ext-toolbar{display:flex;gap:16px;flex-wrap:wrap;align-items:end;padding:18px;background:var(--dsr-panel);border:1px solid var(--dsr-line);border-radius:16px}
|
|
20
|
+
.ext-field{display:flex;flex:1 1 130px;min-width:0;flex-direction:column;gap:7px;color:var(--dsr-muted);font-size:12px;font-weight:500}
|
|
21
|
+
.ext-workspace{flex-basis:200px}.ext-search{flex-basis:180px}
|
|
22
|
+
.ext-field :is(select,input){width:100%;min-width:0;max-width:100%;min-height:44px;border:1px solid var(--dsr-line);border-radius:10px;padding:10px 12px;font:inherit;font-size:14px;line-height:1.5;color:var(--dsr-text);background:var(--dsr-bg);text-overflow:ellipsis}
|
|
23
|
+
.ext-check{display:flex;gap:9px;align-items:center;min-height:44px;color:var(--dsr-muted);font-size:13px;line-height:1.5;cursor:pointer}
|
|
24
|
+
.ext-check input{width:17px;height:17px;flex-shrink:0;margin:0;accent-color:var(--dsr-accent)}
|
|
25
|
+
.ext-note{font-size:12px;line-height:1.8;color:var(--dsr-muted);margin:14px 2px;overflow-wrap:break-word;word-break:normal}
|
|
26
|
+
.task-scope{margin-bottom:0}.task-scope+.ext-note{margin-top:5px}
|
|
27
|
+
.task-summary{display:flex;gap:4px 16px;flex-wrap:wrap;align-items:baseline;justify-content:space-between;margin:5px 2px 14px}
|
|
28
|
+
.task-summary .ext-note{margin:0}
|
|
29
|
+
.teams-list,.task-list{display:grid;gap:20px;min-width:0}
|
|
30
|
+
.task-list{grid-template-columns:repeat(auto-fill,minmax(min(100%,360px),1fr));align-items:start}
|
|
31
|
+
.teams-card,.task-card{min-width:0;border:1px solid var(--dsr-line);background:var(--dsr-panel);border-radius:18px;padding:24px;overflow-wrap:break-word;word-break:normal}
|
|
32
|
+
.ext-panel-head{display:flex;justify-content:space-between;align-items:flex-start;gap:14px;min-width:0}
|
|
33
|
+
.ext-panel-head>h3,.ext-panel-head>strong{min-width:0;margin:0;font-size:18px;line-height:1.5;font-weight:650;overflow-wrap:anywhere}
|
|
34
|
+
.ext-badge{display:inline-flex;flex-shrink:0;max-width:50%;border:1px solid var(--dsr-line);border-radius:8px;background:var(--dsr-panel-2);padding:4px 9px;font-size:11px;font-weight:600;line-height:1.6;color:var(--dsr-muted);text-align:center}
|
|
35
|
+
.ext-badge[data-tone=active]{border-color:var(--dsr-accent-line);background:var(--dsr-accent-soft);color:var(--dsr-accent-strong)}
|
|
36
|
+
.ext-badge[data-tone=attention]{border-color:var(--dsr-warning-line);background:var(--dsr-warning-soft);color:var(--dsr-warning)}
|
|
37
|
+
.ext-copy{white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;line-height:1.8;font-size:13px}
|
|
38
|
+
.team-description,.task-description{color:var(--dsr-muted);margin:12px 0 20px}
|
|
39
|
+
.ext-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:18px 0}
|
|
40
|
+
.ext-facts>div{min-width:0}.ext-facts dt{margin:0 0 5px;font-size:11px;line-height:1.7;color:var(--dsr-muted)}
|
|
41
|
+
.ext-facts dd{margin:0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
|
|
42
|
+
.ext-facts small{display:block;font-size:11px;line-height:1.8;color:var(--dsr-muted);margin-top:3px}
|
|
43
|
+
.ext-identifier{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;overflow-wrap:anywhere}
|
|
44
|
+
.ext-alert{border:1px solid var(--dsr-warning-line);border-left:3px solid var(--dsr-warning);border-radius:10px;background:var(--dsr-warning-soft);padding:13px 15px;margin:18px 0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
|
|
45
|
+
.ext-alert>strong{display:block;font-size:12px;color:var(--dsr-warning)}.ext-alert>p{margin:7px 0 0}
|
|
46
|
+
.ext-alert ul{padding-left:18px;margin:8px 0 0}.ext-alert li+li{margin-top:6px}
|
|
47
|
+
.ext-disclosure{border-top:1px solid var(--dsr-line);margin-top:16px}
|
|
48
|
+
.ext-disclosure>summary{list-style:none;display:flex;align-items:center;gap:10px;min-height:50px;padding:12px 0;color:var(--dsr-text);font-size:13px;font-weight:600;cursor:pointer}
|
|
49
|
+
.ext-disclosure>summary::-webkit-details-marker{display:none}
|
|
50
|
+
.ext-disclosure>summary:after{content:'›';font-size:20px;line-height:1;margin-left:auto;color:var(--dsr-muted);transition:transform .15s ease}
|
|
51
|
+
.ext-disclosure[open]>summary:after{transform:rotate(90deg)}
|
|
52
|
+
.ext-count{color:var(--dsr-muted);font-size:11px;font-weight:400;font-variant-numeric:tabular-nums}
|
|
53
|
+
.ext-detail-body{padding:3px 0 8px;min-width:0}
|
|
54
|
+
.ext-alert .ext-disclosure{margin-top:8px;border-color:var(--dsr-warning-line)}
|
|
55
|
+
.ext-alert .ext-disclosure>summary{min-height:44px;padding-bottom:4px}
|
|
56
|
+
.ext-empty{grid-column:1/-1;padding:28px 16px;margin:0;color:var(--dsr-muted);font-size:13px;text-align:center;line-height:1.8}
|
|
57
|
+
.team-overview{display:flex;gap:28px;padding:14px 0;margin:16px 0;border-top:1px solid var(--dsr-line);border-bottom:1px solid var(--dsr-line)}
|
|
58
|
+
.team-overview>span{display:flex;gap:10px;align-items:baseline;color:var(--dsr-muted);font-size:12px}
|
|
59
|
+
.team-overview b{font-size:19px;line-height:1.3;color:var(--dsr-text);font-weight:650;font-variant-numeric:tabular-nums}
|
|
60
|
+
.team-checks{margin:18px 0}.team-captain-action{display:flex;justify-content:flex-end;margin:20px 0 8px}
|
|
61
|
+
.team-members,.team-tasks,.team-messages{list-style:none;padding:0;margin:0}
|
|
62
|
+
.team-members{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:12px}
|
|
63
|
+
.team-member,.team-task{min-width:0;padding:16px;border:1px solid var(--dsr-line);border-radius:12px;background:var(--dsr-bg)}
|
|
64
|
+
.team-member{display:flex;flex-direction:column}
|
|
65
|
+
.team-member .ext-panel-head>strong,.team-task .ext-panel-head>strong{font-size:14px}
|
|
66
|
+
.team-member-state{max-width:50%;font-size:11px;line-height:1.8;color:var(--dsr-muted);text-align:right}
|
|
67
|
+
.team-role{margin:8px 0 0;color:var(--dsr-muted)}
|
|
68
|
+
.team-member-facts{grid-template-columns:minmax(0,1fr);gap:10px;margin:12px 0 16px}
|
|
69
|
+
.team-member-action{margin-top:auto}.team-member-action .ext-button{width:100%;background:var(--dsr-panel)}
|
|
70
|
+
.team-tasks{display:grid;gap:10px}.team-task-id{display:block;margin-top:4px;color:var(--dsr-muted);font-size:11px}
|
|
71
|
+
.team-task .ext-facts{margin-bottom:0}
|
|
72
|
+
.team-messages>li{padding:12px 0;border-bottom:1px solid var(--dsr-line);font-size:13px}.team-messages>li:last-child{border-bottom:0}.team-messages p{margin:6px 0 0}
|
|
73
|
+
.task-outcomes{padding:15px;border-radius:10px;background:var(--dsr-bg);margin:18px 0}
|
|
74
|
+
.task-schedule{padding:14px 0;margin:18px 0;border-top:1px solid var(--dsr-line);border-bottom:1px solid var(--dsr-line)}
|
|
75
|
+
.task-schedule-head{display:flex;gap:12px;justify-content:space-between;align-items:baseline;font-size:11px;color:var(--dsr-muted)}
|
|
76
|
+
.task-schedule-rule{margin:5px 0;font-size:13px;line-height:1.8;overflow-wrap:anywhere}
|
|
77
|
+
.task-schedule .ext-facts{grid-template-columns:minmax(0,1fr);margin:12px 0 0}
|
|
78
|
+
.task-schedule:has(+.ext-disclosure){border-bottom:0;padding-bottom:0;margin-bottom:0}
|
|
79
|
+
.task-parent{grid-template-columns:minmax(0,1fr);margin:16px 0}
|
|
80
|
+
.task-footer{display:flex;gap:14px;align-items:center;justify-content:space-between;border-top:1px solid var(--dsr-line);padding-top:16px;margin-top:20px}
|
|
81
|
+
.task-footer>span{min-width:0;font-size:10px;line-height:1.8;color:var(--dsr-muted)}.task-footer time{display:block;font-size:11px;font-variant-numeric:tabular-nums}
|
|
82
|
+
.task-footer .ext-button{font-size:12px;padding:10px 12px}
|
|
83
|
+
.pc-adaptation{font-size:13px;line-height:1.7;color:var(--dsr-muted);overflow-wrap:anywhere}.pc-adaptation a{color:var(--dsr-accent)}
|
|
84
|
+
@container(max-width:540px){
|
|
85
|
+
.ext-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:16px}
|
|
86
|
+
.ext-workspace{grid-column:1/-1}
|
|
87
|
+
.ext-toolbar>.ext-check{grid-column:1;font-size:12px}.ext-toolbar>.ext-button{grid-column:2;align-self:end;justify-self:end}
|
|
88
|
+
.teams-card,.task-card{padding:18px}.ext-panel-head{gap:10px}.ext-panel-head>h3{font-size:17px}.ext-badge{max-width:45%}
|
|
89
|
+
.team-overview{gap:22px}.team-overview>span{gap:7px}.team-captain-action .ext-button{width:100%}
|
|
90
|
+
.task-footer{flex-direction:column;align-items:stretch;gap:12px}.task-footer>span{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline}.task-footer .ext-button{width:100%}
|
|
91
|
+
}
|
|
92
|
+
@container(max-width:320px){
|
|
93
|
+
.ext-facts{grid-template-columns:minmax(0,1fr);gap:12px}.team-overview{gap:14px;flex-wrap:wrap}.ext-panel-head{flex-wrap:wrap}.ext-badge{max-width:100%}
|
|
94
|
+
}
|
|
95
|
+
@media(max-width:620px){.ext-page{padding:8px 0}.ext-header{margin-bottom:22px}}
|
|
96
|
+
@media(prefers-reduced-motion:reduce){.ext-disclosure>summary:after{transition:none}}
|
package/public/extensions.js
CHANGED
|
@@ -7,14 +7,49 @@ window.DshExtensions = (() => {
|
|
|
7
7
|
{ id: 'teams', name: '@nanmicoder/dsh-agent-teams', label: '查看智能体团队', summary: '查看智能体团队、任务与成员状态', verified: '0.1.24-rc.1' },
|
|
8
8
|
{ id: 'cost', name: 'dsh-cost-meter', label: '查看费用与额度', summary: '查看费用、套餐额度与峰谷提醒', verified: '1.8.17' },
|
|
9
9
|
{ id: 'context', name: 'dsh-context', label: '查看当前会话上下文', session: true, summary: '查看会话上下文用量与构成', verified: '0.64.0' },
|
|
10
|
+
{ id: 'tasks', name: '@linxin666/dsh-client-ui-task-board', label: '查看任务看板', summary: '只读查看任务、执行结果与计划时间', verified: '0.4.8' },
|
|
10
11
|
]
|
|
11
|
-
const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false })
|
|
12
|
+
const empty = () => ({ known: false, skills: false, cost: false, context: false, teams: false, tasks: false })
|
|
13
|
+
const helpUrl = 'https://github.com/Blank-not-black/dsh-Remote/blob/main/docs/wiki/plugins.md'
|
|
14
|
+
const reasons = {
|
|
15
|
+
'not-installed': ['未安装', 'Not installed'], disabled: ['配置未启用', 'Disabled in configuration'],
|
|
16
|
+
'runtime-unknown': ['运行状态未知', 'Runtime status unknown'], waiting: ['等待启动或依赖', 'Waiting for startup or dependencies'],
|
|
17
|
+
'runtime-failed': ['插件启动失败', 'Plugin startup failed'], 'restart-required': ['配置已更新,待重启 DSH', 'Configuration updated; restart DSH'],
|
|
18
|
+
unverified: ['运行中,接口待读取验证', 'Running; interface not verified yet'], available: ['接口读取成功', 'Interface read succeeded'],
|
|
19
|
+
unsupported: ['接口不兼容', 'Unsupported interface'], 'endpoint-missing': ['主机未提供适配接口', 'Adapter endpoint unavailable on host'], 'read-failed': ['接口读取失败,可重试', 'Interface read failed; retry available'],
|
|
20
|
+
timeout: ['接口读取超时,可重试', 'Interface read timed out; retry available'], 'host-denied': ['主机拒绝读取,请检查认证', 'Host denied access; check authentication'],
|
|
21
|
+
}
|
|
22
|
+
function diagnosticsFor(snapshot, item, config) {
|
|
23
|
+
return catalog.filter(feature => feature.name === item.name).map(feature => {
|
|
24
|
+
const installed = snapshot?.items?.find(row => row?.name === feature.name)
|
|
25
|
+
const runtime = [...(Array.isArray(installed?.runtime) ? installed.runtime : []), ...(snapshot?.runtime || []).filter(row => row?.name === feature.name)]
|
|
26
|
+
const changed = snapshot?.pendingRestart && snapshot.operations?.some(job => job.name === feature.name && job.restartRequired && ['complete','failed','interrupted'].includes(job.phase))
|
|
27
|
+
const observed = config && same(config) ? cache.observations?.[feature.id] : null
|
|
28
|
+
const fresh = observed && observed.version === installed?.version && Date.now() - observed.at < 300000
|
|
29
|
+
const code = !installed ? 'not-installed' : changed ? 'restart-required' : installed.enabled !== true ? 'disabled'
|
|
30
|
+
: snapshot.runtimeAvailable !== true ? 'runtime-unknown' : runtime.some(row => row?.phase === 'failed') ? 'runtime-failed'
|
|
31
|
+
: !runtime.length || runtime.some(row => row?.enabled === false || row?.phase !== 'active') ? 'waiting'
|
|
32
|
+
: snapshot.adaptations?.[feature.id]?.supported === false ? 'unsupported' : fresh ? observed.code : 'unverified'
|
|
33
|
+
return { id: feature.id, code, label: reasons[code][window.I18N?.lang === 'en' ? 1 : 0], helpUrl, checkedAt: fresh ? observed.at : null }
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
function reportAvailability(config, id, result) {
|
|
37
|
+
if (!config || !catalog.some(row => row.id === id) || !same(config)) return
|
|
38
|
+
const native = identity(config)
|
|
39
|
+
if (!native.valid() || config.valid && !config.valid()) return
|
|
40
|
+
const code = result?.ok === true && result.available !== false ? 'available'
|
|
41
|
+
: result?.code === 'unsupported' ? 'unsupported' : result?.code === 'not-installed' ? 'endpoint-missing'
|
|
42
|
+
: result?.code === 'host-denied' ? 'host-denied' : result?.code === 'timeout' ? 'timeout' : 'read-failed'
|
|
43
|
+
cache.observations ||= {}
|
|
44
|
+
cache.observations[id] = { code, at: Date.now(), version: cache.snapshot?.items?.find(row => row.name === catalog.find(feature => feature.id === id).name)?.version }
|
|
45
|
+
}
|
|
12
46
|
function capabilitiesOf(snapshot) {
|
|
13
47
|
if (snapshot?.ok !== true || !Array.isArray(snapshot.items) || !Array.isArray(snapshot.runtime)) return empty()
|
|
14
48
|
const result = { ...empty(), known: true }
|
|
15
49
|
for (const feature of catalog) {
|
|
16
50
|
const item = snapshot.items.find(row => row?.name === feature.name)
|
|
17
51
|
if (item?.enabled !== true || snapshot.runtimeAvailable !== true) continue
|
|
52
|
+
if (snapshot.adaptations?.[feature.id]?.supported === false) continue
|
|
18
53
|
if (item.runtime != null && !Array.isArray(item.runtime)) continue
|
|
19
54
|
const runtime = [...(item.runtime || []), ...snapshot.runtime.filter(row => row?.name === feature.name)]
|
|
20
55
|
result[feature.id] = runtime.length > 0 && runtime.every(row => row && row.enabled !== false && row.phase === 'active')
|
|
@@ -28,12 +63,14 @@ window.DshExtensions = (() => {
|
|
|
28
63
|
function identity(config) { return config.connection || config }
|
|
29
64
|
function same(config) {
|
|
30
65
|
const next = identity(config)
|
|
31
|
-
return cache && cache.connection.valid() && next.valid() &&
|
|
66
|
+
return cache && cache.connection.valid() && next.valid() && (typeof next.server === 'string'
|
|
67
|
+
? cache.connection.server === next.server && cache.connection.token === next.token : cache.connection === next)
|
|
32
68
|
}
|
|
33
69
|
function remember(config, snapshot) {
|
|
34
70
|
if (!config.valid()) return
|
|
35
71
|
if (!same(config)) { cache?.controller?.abort(); cache = { connection: identity(config) } }
|
|
36
72
|
cache.value = capabilitiesOf(snapshot); cache.at = Date.now()
|
|
73
|
+
cache.snapshot = snapshot
|
|
37
74
|
cache.serial = (cache.serial || 0) + 1
|
|
38
75
|
}
|
|
39
76
|
function invalidateCapabilities() { cache?.controller?.abort(); cache = null }
|
|
@@ -54,7 +91,7 @@ window.DshExtensions = (() => {
|
|
|
54
91
|
const snapshot = JSON.parse(body)
|
|
55
92
|
if (!response.ok || !config.valid() || cache !== record || snapshot?.ok !== true) return empty()
|
|
56
93
|
if ((record.serial || 0) !== serial) return record.value || empty()
|
|
57
|
-
record.value = capabilitiesOf(snapshot); record.at = Date.now(); return record.value
|
|
94
|
+
record.snapshot = snapshot; record.value = capabilitiesOf(snapshot); record.at = Date.now(); return record.value
|
|
58
95
|
} catch {
|
|
59
96
|
if (cache === record && config.valid() && (record.serial || 0) !== serial) return record.value || empty()
|
|
60
97
|
if (cache === record) { record.value = empty(); record.at = Date.now() }
|
|
@@ -65,7 +102,7 @@ window.DshExtensions = (() => {
|
|
|
65
102
|
return record.task
|
|
66
103
|
}
|
|
67
104
|
const node=(tag,text,cls)=>{const el=document.createElement(tag);if(text!=null)el.textContent=text;if(cls)el.className=cls;return el}
|
|
68
|
-
const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close();window.DshTeams?.close()}
|
|
105
|
+
const stopViews=()=>{window.DshSkillsCenter?.close();window.DshInsights?.close();window.DshTeams?.close();window.DshTasks?.close()}
|
|
69
106
|
function close(){if(current){const old=current;current=null;stopViews();window.DshPluginCenter?.close();old.target.replaceChildren()}}
|
|
70
107
|
function mount(config,target,initial='manage') {
|
|
71
108
|
close()
|
|
@@ -92,6 +129,7 @@ window.DshExtensions = (() => {
|
|
|
92
129
|
else {if(s.scroller)s.scroller.scrollTop=s.scroll;void window.DshPluginCenter.resume()}
|
|
93
130
|
}else if(route==='skills')await window.DshSkillsCenter.mount(config,view,{dedicated:true})
|
|
94
131
|
else if(route==='teams')await window.DshTeams.mount(config,view)
|
|
132
|
+
else if(route==='tasks')await window.DshTasks.mount(config,view)
|
|
95
133
|
else window.DshInsights.mount({tab:'cost',hostOverview:true,allowedTabs:['cost'],connection:config.connection,url:config.url},view)
|
|
96
134
|
if(valid()&&route!=='manage')config.scrollTop?.()
|
|
97
135
|
}
|
|
@@ -102,5 +140,5 @@ window.DshExtensions = (() => {
|
|
|
102
140
|
for(let parent=el.parentElement;parent;parent=parent.parentElement)if(parent.scrollHeight>parent.clientHeight&&/auto|scroll/.test(getComputedStyle(parent).overflowY))return parent
|
|
103
141
|
return document.scrollingElement
|
|
104
142
|
}
|
|
105
|
-
return {mount,close,capabilitiesOf,featuresFor,getCapabilities,remember,invalidateCapabilities,catalog:catalog.map(row=>Object.freeze({...row}))}
|
|
143
|
+
return {mount,close,capabilitiesOf,featuresFor,diagnosticsFor,reportAvailability,getCapabilities,remember,invalidateCapabilities,catalog:catalog.map(row=>Object.freeze({...row}))}
|
|
106
144
|
})()
|
package/public/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
9
9
|
<title>DSH Remote</title>
|
|
10
10
|
<script>/* 统一入口: 桌面浏览器(宽屏且 UA 非移动)访问根地址自动切换到桌面端, 手机/窄窗口继续 App 界面 */ (function(){try{if(new URLSearchParams(location.search).get('layout')==='mobile'){sessionStorage.setItem('dshRemoteLayout','mobile');return}if(sessionStorage.getItem('dshRemoteLayout')==='mobile')return;var proto=location.protocol;var ua=navigator.userAgent||'';var mobile=/Android|iPhone|iPad|iPod|Mobile|Windows Phone/i.test(ua);if((proto==='http:'||proto==='https:')&&!mobile&&window.innerWidth>=1024){var p=location.pathname;if(p==='/'||/\/index\.html$/.test(p)){location.replace('desktop/desktop.html'+location.search)}}}catch(e){}})()</script>
|
|
11
|
-
<script>/* 首帧前应用皮肤, 避免闪白/闪黑 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t=
|
|
11
|
+
<script>/* 首帧前应用皮肤, 避免闪白/闪黑 */ (function(){try{var t=localStorage.getItem('dshTheme');if(t!=='default'&&t!=='dark'&&t!=='light'&&t!=='neutral'&&t!=='mono'&&t!=='fish'){t='fish'}}catch(e){t='fish'}document.documentElement.setAttribute('data-theme',t)})()</script>
|
|
12
12
|
<link rel="manifest" href="manifest.webmanifest">
|
|
13
13
|
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
|
14
14
|
<link rel="stylesheet" href="styles.css">
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<link rel="stylesheet" href="plugin-center.css">
|
|
17
17
|
<link rel="stylesheet" href="skills.css">
|
|
18
18
|
<link rel="stylesheet" href="doctor.css">
|
|
19
|
+
<link rel="stylesheet" href="onboarding.css">
|
|
19
20
|
<link rel="stylesheet" href="extensions.css">
|
|
20
21
|
<link rel="stylesheet" href="insights.css">
|
|
21
22
|
<link rel="stylesheet" href="workflow.css">
|
|
@@ -156,14 +157,12 @@
|
|
|
156
157
|
<button class="menu-chip" data-cmd="/export" data-i18n="menu.export">/export 导出会话日志 ZIP</button>
|
|
157
158
|
<button class="menu-chip" data-cmd="/feedback" data-i18n="menu.feedback">/feedback 反馈当前会话</button>
|
|
158
159
|
<button class="menu-chip" data-cmd="/goal" data-i18n="menu.goal">/goal 设置/查看任务目标</button>
|
|
159
|
-
<button class="menu-chip" data-cmd="/permission" data-i18n="menu.permission">/permission 切换权限预设</button>
|
|
160
160
|
<button class="menu-chip" data-cmd="/plan" data-i18n="menu.plan">/plan 进入/退出计划模式</button>
|
|
161
161
|
</div>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</div>
|
|
162
|
+
</div>
|
|
163
|
+
<div class="menu-group" id="permission-menu-group">
|
|
164
|
+
<div class="menu-title" data-i18n="perm.groupLabel">权限模式</div>
|
|
165
|
+
<div class="menu-chips" id="permission-submenu" role="group" data-i18n-aria="perm.groupLabel"></div>
|
|
167
166
|
</div>
|
|
168
167
|
<div class="menu-group hidden" id="preset-menu-group">
|
|
169
168
|
<div class="menu-title" data-i18n="presets.menuTitle">预设</div>
|
|
@@ -244,6 +243,9 @@
|
|
|
244
243
|
<div class="overview-section-head"><span data-i18n="overview.attention">需要你处理</span><span id="overview-attention-count" class="overview-section-meta"></span></div>
|
|
245
244
|
<div id="overview-attention-list" class="overview-attention-list"></div>
|
|
246
245
|
|
|
246
|
+
<div class="overview-section-head"><span data-i18n="approval.recordsTitle">审批记录</span><span id="approval-records-count" class="overview-section-meta"></span></div>
|
|
247
|
+
<div id="approval-records-list" class="overview-attention-list approval-records-list"></div>
|
|
248
|
+
|
|
247
249
|
<div class="overview-section-head"><span data-i18n="overview.metrics">运行指标</span></div>
|
|
248
250
|
<div class="overview-metric-grid">
|
|
249
251
|
<div class="overview-metric"><span data-i18n="overview.dshVersion">DSH 版本</span><strong id="overview-dsh-version">—</strong></div>
|
|
@@ -1056,7 +1058,22 @@
|
|
|
1056
1058
|
'menu.compact': '/compact 压缩对话历史', 'menu.export': '/export 导出会话日志 ZIP',
|
|
1057
1059
|
'menu.feedback': '/feedback 反馈当前会话', 'menu.goal': '/goal 设置/查看任务目标',
|
|
1058
1060
|
'menu.permission': '/permission 切换权限预设', 'menu.plan': '/plan 进入/退出计划模式',
|
|
1059
|
-
'perm.
|
|
1061
|
+
'perm.groupLabel': '权限模式', 'perm.loading': '正在读取主机权限模式…', 'perm.current': '当前',
|
|
1062
|
+
'perm.hostUnavailable': '主机未提供权限模式目录,显示兼容的三种沙箱模式', 'perm.changeFailed': '切换权限模式失败',
|
|
1063
|
+
'perm.autoLabel': '自动审查', 'perm.autoBadge': 'EXP', 'perm.autoDesc': '无沙箱运行;每次原生工具调用和 PTC 内层调用前,由同一模型进行实验性审查。',
|
|
1064
|
+
'perm.autoConfirmTitle': '确认启用自动审查(实验)?', 'perm.autoConfirmEnable': '启用自动审查',
|
|
1065
|
+
'perm.autoConfirmDesc': '自动审查不使用沙箱。每次原生工具调用和 PTC 内层调用前,都会由与当前 agent 相同的模型进行审查;审查拒绝的调用由你批准或拒绝。此功能仍属实验性,可能误放行或误拒绝,并会消耗额外 token。',
|
|
1066
|
+
'perm.autoConfirmAck': '我已了解这些风险,并愿意继续',
|
|
1067
|
+
'perm.confirmTitle': '确认切换权限模式?', 'perm.confirmEnable': '启用该模式', 'perm.confirmCancel': '取消',
|
|
1068
|
+
'perm.confirmDesc': '该预设不使用文件沙箱,工具调用可能改动工作区之外的任何文件。请在了解风险后再继续。',
|
|
1069
|
+
'perm.confirmAck': '我已了解这些风险,并愿意继续',
|
|
1070
|
+
'approval.recordsTitle': '审批记录', 'approval.recordsEmpty': '暂无审批记录',
|
|
1071
|
+
'approval.kindRequest': '工具审批', 'approval.kindEscalation': '沙箱升权', 'approval.kindAuto': '自动审查转人工', 'approval.kindAutoDenied': '自动审查拒绝',
|
|
1072
|
+
'approval.outcomeAllowed': '已允许', 'approval.outcomeRejected': '已拒绝', 'approval.outcomeCancelled': '已取消', 'approval.outcomeUnavailable': '无应答者', 'approval.outcomePending': '待处理', 'approval.outcomeUnknown': '未知结果',
|
|
1073
|
+
'approval.whyAllowed': '你在审批提示中允许了一次该调用,工具继续执行。', 'approval.whyRejected': '你拒绝了该调用,工具未执行。',
|
|
1074
|
+
'approval.whyCancelled': '回合已结束或请求被撤回,审批自动取消。', 'approval.whyUnavailable': '没有可用的审批应答者,DSH 按拒绝处理。',
|
|
1075
|
+
'approval.whyPending': '仍在等待你的决定。', 'approval.whyAutoDenied': '自动审查判定风险过高且会话禁止人工放行,工具未执行。',
|
|
1076
|
+
'approval.noReason': '主机未给出原因', 'approval.justNow': '刚刚', 'approval.minutesAgo': '{n} 分钟前', 'approval.hoursAgo': '{n} 小时前',
|
|
1060
1077
|
'menu.modelTitle': '模型切换', 'menu.refresh': '刷新', 'menu.modelAuto': '点开时自动加载', 'menu.effortTitle': '思考深度',
|
|
1061
1078
|
'composer.placeholder': '给 DSH 发消息…', 'composer.running': '运行中…', 'composer.send': '发送', 'composer.fullscreen': '全屏编辑', 'composer.exitFullscreen': '退出全屏编辑', 'composer.addImage': '添加图片', 'composer.takePhoto': '拍照', 'composer.choosePhoto': '相册', 'composer.imageAdded': '已添加图片', 'composer.imageRemoved': '已移除图片', 'composer.removeImage': '移除图片', 'composer.imageUnsupported': '仅支持 PNG、JPEG、WebP 或 GIF 图片', 'composer.imageTooLarge': '单张图片不能超过 {size}', 'composer.imageLimit': '最多添加 {count} 张图片', 'composer.imageSlashUnsupported': '带图片时不能发送斜杠命令', 'composer.imageReadFailed': '图片读取失败:{msg}',
|
|
1062
1079
|
'pending.title': '待处理', 'pending.count': '{n} 项', 'pending.approvalTitle': '🔧 {tool} 请求批准', 'pending.noReason': '无说明',
|
|
@@ -1305,7 +1322,22 @@
|
|
|
1305
1322
|
'menu.compact': '/compact Compress conversation history', 'menu.export': '/export Export session log ZIP',
|
|
1306
1323
|
'menu.feedback': '/feedback Feedback current session', 'menu.goal': '/goal Set/view task goal',
|
|
1307
1324
|
'menu.permission': '/permission Switch permission preset', 'menu.plan': '/plan Enter/exit plan mode',
|
|
1308
|
-
'perm.
|
|
1325
|
+
'perm.groupLabel': 'Permission preset', 'perm.loading': 'Reading permission presets from the host…', 'perm.current': 'Current',
|
|
1326
|
+
'perm.hostUnavailable': 'The host did not expose a preset catalog; showing the three compatible sandbox modes', 'perm.changeFailed': 'Could not switch the permission preset',
|
|
1327
|
+
'perm.autoLabel': 'Auto review', 'perm.autoBadge': 'EXP', 'perm.autoDesc': 'Run without a sandbox after an experimental same-model review of every native tool call and PTC inner call.',
|
|
1328
|
+
'perm.autoConfirmTitle': 'Enable Auto review (experimental)?', 'perm.autoConfirmEnable': 'Enable Auto review',
|
|
1329
|
+
'perm.autoConfirmDesc': 'Auto review runs without a sandbox. Before every native tool call and PTC inner call, the same model as the current agent reviews whether to allow it; you approve or reject the calls it denies. It is still experimental: it may allow unsafe actions or reject useful ones, and it consumes extra tokens.',
|
|
1330
|
+
'perm.autoConfirmAck': 'I understand these risks and want to continue',
|
|
1331
|
+
'perm.confirmTitle': 'Switch this permission preset?', 'perm.confirmEnable': 'Enable this preset', 'perm.confirmCancel': 'Cancel',
|
|
1332
|
+
'perm.confirmDesc': 'This preset runs without a file sandbox, so tool calls can change any file outside the workspace. Continue only after you understand the risk.',
|
|
1333
|
+
'perm.confirmAck': 'I understand these risks and want to continue',
|
|
1334
|
+
'approval.recordsTitle': 'Approval records', 'approval.recordsEmpty': 'No approval records yet',
|
|
1335
|
+
'approval.kindRequest': 'Tool approval', 'approval.kindEscalation': 'Sandbox escalation', 'approval.kindAuto': 'Auto review → your decision', 'approval.kindAutoDenied': 'Auto review denial',
|
|
1336
|
+
'approval.outcomeAllowed': 'Allowed once', 'approval.outcomeRejected': 'Rejected', 'approval.outcomeCancelled': 'Cancelled', 'approval.outcomeUnavailable': 'Unavailable', 'approval.outcomePending': 'Pending', 'approval.outcomeUnknown': 'Unknown',
|
|
1337
|
+
'approval.whyAllowed': 'You allowed this call once from the approval prompt, so the tool continued.', 'approval.whyRejected': 'You rejected this call, so the tool body did not run.',
|
|
1338
|
+
'approval.whyCancelled': 'The turn ended or the request was withdrawn, so the approval was cancelled.', 'approval.whyUnavailable': 'No approval answerer was available, so DSH treated the call as rejected.',
|
|
1339
|
+
'approval.whyPending': 'Waiting for your decision.', 'approval.whyAutoDenied': 'Auto review judged the call too risky and the session forbids manual approval, so it did not run.',
|
|
1340
|
+
'approval.noReason': 'The host gave no reason', 'approval.justNow': 'just now', 'approval.minutesAgo': '{n} min ago', 'approval.hoursAgo': '{n} h ago',
|
|
1309
1341
|
'menu.modelTitle': 'Model', 'menu.refresh': 'Refresh', 'menu.modelAuto': 'Auto-loads when opened', 'menu.effortTitle': 'Reasoning effort',
|
|
1310
1342
|
'composer.placeholder': 'Message DSH…', 'composer.running': 'Running…', 'composer.send': 'Send', 'composer.fullscreen': 'Fullscreen editor', 'composer.exitFullscreen': 'Exit fullscreen editor', 'composer.addImage': 'Add image', 'composer.takePhoto': 'Camera', 'composer.choosePhoto': 'Gallery', 'composer.imageAdded': 'Image added', 'composer.imageRemoved': 'Image removed', 'composer.removeImage': 'Remove image', 'composer.imageUnsupported': 'Only PNG, JPEG, WebP or GIF images are supported', 'composer.imageTooLarge': 'Each image must be under {size}', 'composer.imageLimit': 'You can add up to {count} images', 'composer.imageSlashUnsupported': 'Slash commands cannot include images', 'composer.imageReadFailed': 'Could not read image: {msg}',
|
|
1311
1343
|
'pending.title': 'Inbox', 'pending.count': '{n} items', 'pending.approvalTitle': '🔧 {tool} requests approval', 'pending.noReason': 'No reason given',
|
|
@@ -1462,6 +1494,7 @@
|
|
|
1462
1494
|
<script src="skills.js"></script>
|
|
1463
1495
|
<script src="insights.js"></script>
|
|
1464
1496
|
<script src="teams.js"></script>
|
|
1497
|
+
<script src="task-board.js"></script>
|
|
1465
1498
|
<script src="extensions.js"></script>
|
|
1466
1499
|
<script src="diagnostics.js"></script>
|
|
1467
1500
|
<script src="doctor.js"></script>
|
|
@@ -1477,7 +1510,10 @@
|
|
|
1477
1510
|
<script src="relay-settings.js"></script>
|
|
1478
1511
|
<script src="subagents.js"></script>
|
|
1479
1512
|
<script src="session-presets.js"></script>
|
|
1513
|
+
<script src="permission-presets.js"></script>
|
|
1514
|
+
<script src="approval-records.js"></script>
|
|
1480
1515
|
<script src="doctor-entry.js"></script>
|
|
1516
|
+
<script src="onboarding.js"></script>
|
|
1481
1517
|
<script src="app.js"></script>
|
|
1482
1518
|
</body>
|
|
1483
1519
|
</html>
|
package/public/insights.css
CHANGED
|
@@ -21,3 +21,8 @@
|
|
|
21
21
|
.cost-host .ins-ledger-table { overflow-x:auto; }
|
|
22
22
|
.cost-host .ins-ledger-table table { width:100%; border-collapse:collapse; font-size:12px; }
|
|
23
23
|
.cost-host .ins-ledger-table th,.cost-host .ins-ledger-table td { text-align:left; padding:8px 6px; border-bottom:1px solid var(--dsr-line); white-space:nowrap; }
|
|
24
|
+
.ins-source{display:flex;gap:4px 18px;flex-wrap:wrap}
|
|
25
|
+
.ins-source>span{min-width:0;max-width:100%;overflow-wrap:break-word}
|
|
26
|
+
.ins-plan-row>span,.ins-events li>div>span{min-width:0;overflow-wrap:anywhere}
|
|
27
|
+
.ins-plan-row>strong{flex-shrink:0;white-space:nowrap}
|
|
28
|
+
.ins-section :is(h3,h4),.ins-plan>strong{overflow-wrap:anywhere}
|
package/public/insights.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
compaction: '压缩', prune: '裁剪', model: '模型变更', mode: '模式变更', counts: '累计变化',
|
|
17
17
|
detailsFailed: '变化记录暂不可用,点击刷新重试。', detailsLoading: '正在读取变化记录…',
|
|
18
18
|
session: '当前会话 API 费用', today: '今日 API 费用', equivalent: '含套餐等值估算', subagents: '子代理 API 费用(单列)', todayTokens: '今日 Token(全部渠道)', planEquivalent: '今日 Plan 等值(非实付)', localTokens: '本周期本地 Token', history: '近 7 日账本', api: 'API 费用', plan: 'Plan 等值',
|
|
19
|
-
balance: '账户余额', plans: '套餐额度 · 已用', source: '数据来源', assembled: '摘要读取于', queried: '供应商查询于',
|
|
19
|
+
balance: '账户余额', plans: '套餐额度 · 已用', customBalances: '自定义渠道余额', gatewayQuotas: '网关账户额度 · 已用', partial: '部分账户查询失败', source: '数据来源', assembled: '摘要读取于', queried: '供应商查询于',
|
|
20
20
|
estimateNote: '费用由插件账本按用量估算,以供应商账单为准;套餐等值金额不计入 API 费用,子代理费用单独列出。',
|
|
21
21
|
sessionMissing: '插件账本尚无此会话记录', noPlans: '主机未启用可展示的套餐额度。', off: '主机未开启查询',
|
|
22
22
|
error: '供应商查询失败', stale: '缓存数据', unknown: '暂无有效数据', unlimited: '不限量', reset: '重置',
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
compaction: 'Compaction', prune: 'Pruning', model: 'Model change', mode: 'Mode change', counts: 'Total changes',
|
|
32
32
|
detailsFailed: 'Change records are unavailable. Refresh to retry.', detailsLoading: 'Loading change records…',
|
|
33
33
|
session: 'Session API cost', today: 'Today API cost', equivalent: 'Estimate including plan equivalents', subagents: 'Subagent API cost (separate)', todayTokens: 'Tokens today (all channels)', planEquivalent: 'Plan equivalent today (not paid)', localTokens: 'Local tokens in this period', history: 'Last 7 ledger days', api: 'API cost', plan: 'Plan equivalent',
|
|
34
|
-
balance: 'Account balance', plans: 'Plan quotas · used', source: 'Source', assembled: 'Summary read at', queried: 'Provider queried at',
|
|
34
|
+
balance: 'Account balance', plans: 'Plan quotas · used', customBalances: 'Custom provider balances', gatewayQuotas: 'Gateway account quotas · used', partial: 'Some account queries failed', source: 'Source', assembled: 'Summary read at', queried: 'Provider queried at',
|
|
35
35
|
estimateNote: 'Costs are usage estimates from the plugin ledger. Provider invoices are authoritative. Plan equivalents and subagents are shown separately.',
|
|
36
36
|
sessionMissing: 'No ledger record for this session yet', noPlans: 'No visible plan quota is enabled on this host.', off: 'Query disabled on host',
|
|
37
37
|
error: 'Provider query failed', stale: 'Cached data', unknown: 'No valid data', unlimited: 'Unlimited', reset: 'Resets',
|
|
@@ -128,8 +128,37 @@
|
|
|
128
128
|
html += `<small>${esc(t('queried'))} · ${esc(time(plan.fetchedAt))}</small></div>`
|
|
129
129
|
}
|
|
130
130
|
html += '</section>'
|
|
131
|
+
const balances = Array.isArray(data.customBalances) ? data.customBalances.slice(0, 40) : []
|
|
132
|
+
if (balances.length) {
|
|
133
|
+
html += `<section class="ins-section"><h3>${esc(t('customBalances'))}</h3><div class="ins-metrics">`
|
|
134
|
+
for (const row of balances) {
|
|
135
|
+
const known = row.status === 'ok' && typeof row.remaining === 'number' && Number.isFinite(row.remaining)
|
|
136
|
+
html += metric(row.name, known ? (row.currency || '—') + ' ' + row.remaining.toFixed(2) : '—',
|
|
137
|
+
t(row.status === 'ok' ? 'queried' : ['off','error','stale','loading'].includes(row.status) ? row.status : 'unknown') + ' · ' + time(row.fetchedAt))
|
|
138
|
+
}
|
|
139
|
+
html += '</div></section>'
|
|
140
|
+
}
|
|
141
|
+
const gateways = Array.isArray(data.gatewayQuotas) ? data.gatewayQuotas.slice(0, 20) : []
|
|
142
|
+
if (gateways.length) {
|
|
143
|
+
html += `<section class="ins-section"><h3>${esc(t('gatewayQuotas'))}</h3>`
|
|
144
|
+
for (const source of gateways) {
|
|
145
|
+
html += `<div class="ins-plan"><strong>${esc(source.name)}</strong><p class="ins-note">${esc(t(source.status === 'ok' ? 'queried' : ['off','error','stale','loading','partial'].includes(source.status) ? source.status : 'unknown'))} · ${esc(time(source.fetchedAt))}</p>`
|
|
146
|
+
for (const account of (Array.isArray(source.accounts) ? source.accounts : []).slice(0, 16)) {
|
|
147
|
+
html += `<h4>${esc(account.provider)} · ${esc(account.name)}</h4>`
|
|
148
|
+
if (!['ok','partial'].includes(source.status) || account.status !== 'ok') { html += `<p class="ins-note">${esc(t(['off','error','stale','loading'].includes(account.status) ? account.status : 'unknown'))}</p>`; continue }
|
|
149
|
+
const rows = (Array.isArray(account.windows) ? account.windows : []).slice(0, 8)
|
|
150
|
+
if (!rows.length) html += `<p class="ins-note">${esc(t('unknown'))}</p>`
|
|
151
|
+
for (const row of rows) {
|
|
152
|
+
const percent = num(row.percent)
|
|
153
|
+
html += `<div class="ins-plan-row"><span>${esc(row.name)}</span><strong>${percent !== null && percent <= 100 ? percent.toFixed(1) + '%' : '—'}</strong></div>${bar(percent, account.name)}${row.resetsAt ? `<small>${esc(t('reset'))} · ${esc(row.resetsAt)}</small>` : ''}`
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
html += '</div>'
|
|
157
|
+
}
|
|
158
|
+
html += '</section>'
|
|
159
|
+
}
|
|
131
160
|
if (withHistory && Array.isArray(data.history) && data.history.length) html += `<section class="ins-section"><h3>${esc(t('history'))}</h3><div class="ins-ledger-table"><table><thead><tr><th>${esc(t('date'))}</th><th>Token</th><th>${esc(t('api'))}</th><th>${esc(t('plan'))}</th></tr></thead><tbody>${data.history.slice(-7).map(row => `<tr><td>${esc(row.date)}</td><td>${tokens(row.totalTokens)}</td><td>${money(row.apiCost)}</td><td>${money(row.planEquivalent)}</td></tr>`).join('')}</tbody></table></div></section>`
|
|
132
|
-
return html + `<
|
|
161
|
+
return html + `<footer class="ins-source"><span>${esc(t('source'))} · dsh-cost-meter</span><span>${esc(t('assembled'))} · ${esc(time(data.generatedAt))}</span></footer>`
|
|
133
162
|
}
|
|
134
163
|
|
|
135
164
|
let dialog, options, tab = 'context', generation = 0, controller, poll, debounce, page = false, inline = false, eventKind = '', allowedTabs = ['context','cost']
|
|
@@ -160,19 +189,18 @@
|
|
|
160
189
|
const response = await fetch(options.url(path), { method: body ? 'POST' : 'GET', headers: { authorization: 'Bearer ' + connection.token,
|
|
161
190
|
'x-dsh-remote-client': 'web', 'content-type': 'application/json' }, ...(body ? { body: JSON.stringify(body) } : {}), signal: attempt.signal })
|
|
162
191
|
if (!valid(g)) throw new Error('stale')
|
|
163
|
-
if (!response.ok) { const error = new Error('read-failed'); error.status = response.status; throw error }
|
|
164
192
|
const source = await response.text()
|
|
165
193
|
if (!valid(g)) throw new Error('stale')
|
|
166
194
|
if (source.length > 2 * 1024 * 1024) throw new Error('too-large')
|
|
167
195
|
const data = JSON.parse(source)
|
|
168
|
-
if (!obj(data) || data.ok !== true)
|
|
196
|
+
if (!response.ok || !obj(data) || data.ok !== true) { const error = new Error('read-failed'); error.status = response.status; error.code = response.status === 401 || response.status === 403 ? 'host-denied' : data?.code; throw error }
|
|
169
197
|
return data
|
|
170
198
|
} finally { clearTimeout(deadline); parent.removeEventListener('abort', abort) }
|
|
171
199
|
}
|
|
172
200
|
async function loadContext(force = false) {
|
|
173
201
|
const g = generation, head = contextOf(current()?.projections?.values?.contextTimeline)
|
|
174
202
|
if (!valid(g) || tab !== 'context' || detailTask || head?.unsupported) return
|
|
175
|
-
if (head && head.detailRev === undefined) { detailStatus = ''; render(); return }
|
|
203
|
+
if (head && head.detailRev === undefined) { detailStatus = ''; root.DshExtensions?.reportAvailability?.(options, 'context', { ok: true }); render(); return }
|
|
176
204
|
const revision = head?.detailRev ?? null
|
|
177
205
|
if (!force && detail && detailRevision === revision) return
|
|
178
206
|
detailTask = true; detailStatus = 'loading'; render()
|
|
@@ -183,9 +211,10 @@
|
|
|
183
211
|
if (next && num(next.rev) !== null && Array.isArray(next.events) && contextOf(next.head)) {
|
|
184
212
|
if (newest?.detailRev !== undefined && newest.detailRev !== next.rev) { detailStatus = 'changed'; return }
|
|
185
213
|
detail = { rev: next.rev, head: next.head, events: next.events }; detailRevision = newest?.detailRev ?? null; detailStatus = ''
|
|
214
|
+
root.DshExtensions?.reportAvailability?.(options, 'context', { ok: true })
|
|
186
215
|
} else if (next === null) detailStatus = 'missing'
|
|
187
|
-
else detailStatus = 'error'
|
|
188
|
-
} catch (error) { if (valid(g)) detailStatus = error.status === 404 ? 'missing' : 'error' }
|
|
216
|
+
else { detailStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'context', { code: 'unsupported' }) }
|
|
217
|
+
} catch (error) { if (valid(g)) { detailStatus = error.status === 404 ? 'missing' : 'error'; root.DshExtensions?.reportAvailability?.(options, 'context', { code: error.status === 404 ? 'not-installed' : ['AbortError','TimeoutError'].includes(error.name) ? 'timeout' : 'read-failed' }) } }
|
|
189
218
|
finally {
|
|
190
219
|
if (g === generation) { detailTask = false; render(); if (detailStatus === 'changed') scheduleContext() }
|
|
191
220
|
}
|
|
@@ -197,9 +226,9 @@
|
|
|
197
226
|
try {
|
|
198
227
|
const data = await request('/remote/api/insights/cost' + (options.sessionId ? '?sessionId=' + encodeURIComponent(options.sessionId) : ''), null, g)
|
|
199
228
|
if (!valid(g)) return
|
|
200
|
-
if (data.available === false || costOf(data)) { cost = data; costStatus = '' }
|
|
201
|
-
else costStatus = 'error'
|
|
202
|
-
} catch (error) { if (valid(g)) { costStatus = 'error'; if (error.status === 404) { cost = { available: false }; costStatus = '' } } }
|
|
229
|
+
if (data.available === false || costOf(data)) { cost = data; costStatus = ''; root.DshExtensions?.reportAvailability?.(options, 'cost', data) }
|
|
230
|
+
else { costStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'cost', { code: 'unsupported' }) }
|
|
231
|
+
} catch (error) { if (valid(g)) { costStatus = 'error'; root.DshExtensions?.reportAvailability?.(options, 'cost', { code: error.status === 404 ? 'not-installed' : ['AbortError','TimeoutError'].includes(error.name) ? 'timeout' : error.code || 'read-failed' }); if (error.status === 404) { cost = { available: false }; costStatus = '' } } }
|
|
203
232
|
finally { if (valid(g)) render() }
|
|
204
233
|
}
|
|
205
234
|
function scheduleContext() { clearTimeout(debounce); debounce = setTimeout(() => loadContext(), 400) }
|
package/public/md.js
CHANGED
|
@@ -257,13 +257,19 @@
|
|
|
257
257
|
i++
|
|
258
258
|
}
|
|
259
259
|
if (para.length) html += '<p>' + para.join('<br>') + '</p>'
|
|
260
|
+
else {
|
|
261
|
+
// A block-start check can match a line its full parser rejects. Keep
|
|
262
|
+
// that escaped line as text and always advance instead of spinning.
|
|
263
|
+
html += '<p>' + inline(line, fileLinks, imageHosts) + '</p>'
|
|
264
|
+
i++
|
|
265
|
+
}
|
|
260
266
|
}
|
|
261
267
|
return html
|
|
262
268
|
}
|
|
263
269
|
|
|
264
270
|
function mdToHtml(text, options) {
|
|
265
271
|
if (options?.imageLabel) imageLabel = String(options.imageLabel)
|
|
266
|
-
var raw = String(text == null ? '' : text)
|
|
272
|
+
var raw = String(text == null ? '' : text).replace(/\r\n?/g, '\n')
|
|
267
273
|
var parts = raw.split(/```/)
|
|
268
274
|
var out = ''
|
|
269
275
|
for (var i = 0; i < parts.length; i++) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* In-context task cards: no backdrop, forced navigation, or moving coach marks. */
|
|
2
|
+
.onboarding-entry { width:100%; border:1px solid var(--dsr-accent-line); border-radius:14px; background:var(--dsr-accent-soft); color:var(--dsr-text); text-align:left; cursor:pointer; font:inherit; }
|
|
3
|
+
.onboarding-entry { display:flex; flex-direction:column; gap:5px; padding:14px 16px; margin:0 0 16px; }
|
|
4
|
+
.onboarding-entry strong { font-size:15px; color:var(--dsr-accent-strong); }
|
|
5
|
+
.onboarding-entry span { color:var(--dsr-muted); font-size:12px; }
|
|
6
|
+
.onboarding-restart { margin:0; cursor:pointer; }
|
|
7
|
+
.onboarding-restart-copy { display:grid; gap:0; min-width:0; }
|
|
8
|
+
.onboarding-restart .setting-name,.onboarding-restart .setting-desc { display:block; overflow-wrap:anywhere; }
|
|
9
|
+
.onboarding-restart-icon::before { content:'?'; font-size:18px; font-weight:600; line-height:1; }
|
|
10
|
+
.onboarding-coach { flex:none; min-width:0; margin:0 0 12px; padding:12px; border:1px solid var(--dsr-accent-line); border-radius:14px; background:var(--dsr-bg-2); color:var(--dsr-text); font-size:13px; line-height:1.55; overflow-wrap:anywhere; }
|
|
11
|
+
.onboarding-coach[hidden],.onboarding-entry[hidden] { display:none!important; }
|
|
12
|
+
.onboarding-head,.onboarding-actions,.onboarding-navigation { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
|
|
13
|
+
.onboarding-head { justify-content:space-between; position:sticky; top:-12px; z-index:1; background:var(--dsr-bg-2); }
|
|
14
|
+
.onboarding-head-actions { display:flex; align-items:center; gap:2px; }
|
|
15
|
+
.onboarding-head-actions .onboarding-button { padding-left:7px; padding-right:7px; font-size:12px; }
|
|
16
|
+
.onboarding-coach.is-folded > :not(.onboarding-head) { display:none; }
|
|
17
|
+
.onboarding-eyebrow { color:var(--dsr-accent-strong); font-weight:700; font-size:12px; }
|
|
18
|
+
.onboarding-coach h2 { margin:4px 0 6px; font-size:17px; line-height:1.4; }
|
|
19
|
+
.onboarding-body { margin:0 0 6px; }
|
|
20
|
+
.onboarding-status { margin:6px 0; color:var(--dsr-muted); font-size:12px; }
|
|
21
|
+
.onboarding-details { margin:6px 0 10px; }
|
|
22
|
+
.onboarding-details summary { min-height:44px; padding:10px 0; cursor:pointer; color:var(--dsr-accent-strong); }
|
|
23
|
+
.onboarding-details ol { padding-left:22px; margin:4px 0 12px; }
|
|
24
|
+
.onboarding-details li { padding:3px 0; }
|
|
25
|
+
.onboarding-button { min-height:44px; padding:9px 12px; border:1px solid var(--dsr-line); border-radius:10px; color:var(--dsr-text); background:var(--dsr-panel); cursor:pointer; font:inherit; line-height:1.4; }
|
|
26
|
+
.onboarding-primary { border-color:var(--dsr-accent-line); color:var(--dsr-accent-strong); background:var(--dsr-accent-soft); }
|
|
27
|
+
.onboarding-button:disabled { opacity:.5; cursor:default; }
|
|
28
|
+
.onboarding-subtle { color:var(--dsr-muted); background:transparent; border-color:transparent; }
|
|
29
|
+
.onboarding-navigation { margin-top:6px; justify-content:flex-end; border-top:1px solid var(--dsr-line); padding-top:6px; }
|
|
30
|
+
.onboarding-target { outline:2px solid var(--dsr-accent-strong)!important; outline-offset:3px; }
|
|
31
|
+
.onboarding-button:focus-visible,.onboarding-entry:focus-visible,.onboarding-restart:focus-visible { outline:2px solid var(--dsr-accent-strong); outline-offset:2px; }
|
|
32
|
+
.workflow-settings-list .onboarding-restart:focus-visible { outline-offset:-3px; }
|
|
33
|
+
body.in-session .onboarding-coach { max-height:min(38dvh,280px); overflow-y:auto; overscroll-behavior:contain; }
|
|
34
|
+
.modal-card .onboarding-coach { padding:10px; font-size:12px; }
|
|
35
|
+
.modal-card .onboarding-coach h2 { font-size:15px; }
|
|
36
|
+
@media(max-height:520px) { body.in-session .onboarding-coach { max-height:30dvh; } }
|