dsh-open-desktop 0.4.2 → 0.4.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/README.md +13 -50
- package/host/exec.js +14 -4
- package/host/paths.js +1 -0
- package/host/refresh.js +17 -8
- package/package.json +6 -6
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# Open Desktop
|
|
1
|
+
# Open Desktop · dsh-open-desktop
|
|
2
2
|
|
|
3
|
-
把 DeepSeek Harness
|
|
3
|
+
把 DeepSeek Harness 的中栏变成**可拖拽的数据卡片墙**:每张卡片是一条真实会话,用 `view/` 里的前端代码渲染,自带刷新节奏。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-

|
|
5
|
+

|
|
8
6
|
|
|
9
7
|
## 安装
|
|
10
8
|
|
|
@@ -14,58 +12,23 @@ dsh plugin --profile desktop add dsh-open-desktop
|
|
|
14
12
|
|
|
15
13
|
要求 DSH `>=0.2.2-rc.3`。装完重启一次 DSH,侧栏出现「小组件」。
|
|
16
14
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
- **会话用完就沉底** → 卡片把结果留在板上,一眼能看到今天的数据。
|
|
20
|
-
- **dashboard 要手写** → 用一句话 + 模板新建,agent 在卡片自己的会话里把视图做出来。
|
|
21
|
-
- **看板容易假** → 每张卡有真实的数据年龄、失败状态和刷新节奏,不是静态截图。
|
|
22
|
-
|
|
23
|
-
## 特性
|
|
24
|
-
|
|
25
|
-
- **Bento 板面**:12 列网格,拖拽排序、拖右下角改尺寸;虚线占位表示目标位置,松手换位。
|
|
26
|
-
- **每卡独立刷新**:`template` / `command` / `file` / `url` 四种数据源,或每天固定时刻;属性弹窗里直接改频率。
|
|
27
|
-
- **唯一渲染路径**:`view/index.html + style.css + view.js`,沙箱 iframe + CSP,外链资源会被门禁打回。
|
|
28
|
-
- **设计系统注入**:`--od-*` token、`od-*` 组件类、`window.od` 运行时;卡片只写内容,不重画外壳。
|
|
29
|
-
- **30 张模板**:今天 / 工作 / 钱 / 信息 / 生活 / 数字资产,每类 5 张。
|
|
30
|
-
- **原生会话**:点「修改」进入卡片自己的 DSH 会话,顶部可预览卡片或返回板面。
|
|
15
|
+
## 是什么
|
|
31
16
|
|
|
32
|
-
|
|
17
|
+
- **卡片 = 一条 session 的持久展示位**:agent 在卡片目录里写代码(取数脚本、服务、前端)。
|
|
18
|
+
- **卡片内容 = `view/` 里的前端代码**:在沙箱 iframe 中渲染,Host 提供设计系统与取数。
|
|
19
|
+
- **板面 = 12 列 Bento 网格**:拖拽排序、拖右下角改尺寸;`⋯ → 属性…` 可改标题、尺寸和刷新频率。
|
|
20
|
+
- **数据源**:`template` / `command` / `file` / `url`,也可以每天固定时刻更新。
|
|
21
|
+
- 内置 30 张模板;新建卡片就是「一句话 + 一个模板」,agent 在卡片自己的会话里把它做出来。
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
拖拽时目标格子会留出同尺寸虚线占位,松手换位;支持触屏长按和键盘操作。
|
|
35
24
|
|
|
36
|
-

|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-

|
|
41
|
-
|
|
42
|
-
## 卡片模型
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
$DSH_HOME/open-desktop/
|
|
46
|
-
cards/<id>/card.json # 标题/尺寸/顺序/刷新约定
|
|
47
|
-
cards/<id>/view/ # 唯一渲染源:index.html + style.css + view.js
|
|
48
|
-
cards/<id>/data/ # 数据文件(agent 自由写入)
|
|
49
|
-
cards/<id>/... # 其它任何代码
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
发布前 `card_finish` 会跑静态门禁:裸色值、外链资源、小于 11px 字号、直接 `fetch`、`window.open`、JS 语法错误都会被打回。
|
|
27
|
+

|
|
53
28
|
|
|
54
29
|
## 开发
|
|
55
30
|
|
|
56
|
-
|
|
57
|
-
npm install
|
|
58
|
-
npm run build # src/client/ → client.js(esbuild,react 由宿主注入)
|
|
59
|
-
npm test # 214 条测试
|
|
60
|
-
npm run harness # 可选:普通浏览器里的拖拽验证台
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
`client.js` 是构建产物,不要直接改;改 `src/client/`。Host 代码在 `host/`。
|
|
64
|
-
|
|
65
|
-
## 兼容性
|
|
66
|
-
|
|
67
|
-
- DSH `>=0.2.2-rc.3 <0.3.0-0`
|
|
68
|
-
- 已验证:macOS desktop profile,DSH `0.2.2-rc.3`
|
|
31
|
+
构建、测试和目录结构见 [GitHub 仓库](https://github.com/Howell5/openDesktop)。
|
|
69
32
|
|
|
70
33
|
## License
|
|
71
34
|
|
package/host/exec.js
CHANGED
|
@@ -27,23 +27,33 @@ async function confine(ctx, argv, workspaceRoot) {
|
|
|
27
27
|
return argv
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export async function runCommand(ctx, commandLine, { workspaceRoot = '', timeoutMs =
|
|
30
|
+
export async function runCommand(ctx, commandLine, { workspaceRoot = '', timeoutMs = 30_000 } = {}) {
|
|
31
31
|
const parts = tokenize(commandLine)
|
|
32
32
|
if (parts.length === 0) throw Object.assign(new Error('命令为空'), { code: 'bad-command' })
|
|
33
33
|
const argv = await confine(ctx, parts, workspaceRoot)
|
|
34
|
+
const limit = Math.min(120_000, Math.max(1000, Number(timeoutMs) || 30_000))
|
|
34
35
|
return new Promise((resolve, reject) => {
|
|
35
36
|
execFile(
|
|
36
37
|
argv[0],
|
|
37
38
|
argv.slice(1),
|
|
38
39
|
{
|
|
39
|
-
timeout:
|
|
40
|
+
timeout: limit,
|
|
40
41
|
maxBuffer: 512 * 1024,
|
|
41
42
|
cwd: workspaceRoot && workspaceRoot !== '' ? workspaceRoot : undefined,
|
|
42
43
|
env: { ...process.env, LANG: 'en_US.UTF-8' },
|
|
43
44
|
},
|
|
44
|
-
(error, stdout) => {
|
|
45
|
+
(error, stdout, stderr) => {
|
|
45
46
|
if (error) {
|
|
46
|
-
|
|
47
|
+
const stderrText = String((stderr && String(stderr).trim()) || (error && error.stderr) || '').trim()
|
|
48
|
+
const timedOut = error.killed === true || error.signal === 'SIGTERM' || error.code === 'ETIMEDOUT'
|
|
49
|
+
const firstLine = stderrText.split('\n').map((line) => line.trim()).filter(Boolean)[0] || ''
|
|
50
|
+
const reason = timedOut
|
|
51
|
+
? `超时(${limit}ms 未完成,已终止)`
|
|
52
|
+
: (firstLine.slice(0, 300) || String(error.code || '未知错误'))
|
|
53
|
+
reject(Object.assign(
|
|
54
|
+
new Error(`命令「${String(commandLine).slice(0, 120)}」执行失败:${reason}`),
|
|
55
|
+
{ code: 'script-failed', stderr: stderrText.slice(0, 4000) },
|
|
56
|
+
))
|
|
47
57
|
return
|
|
48
58
|
}
|
|
49
59
|
resolve(String(stdout ?? ''))
|
package/host/paths.js
CHANGED
|
@@ -69,6 +69,7 @@ export function normalizeRefresh(raw) {
|
|
|
69
69
|
if (file !== '') refresh.file = file
|
|
70
70
|
if (url !== '') refresh.url = url
|
|
71
71
|
if (source.params && typeof source.params === 'object') refresh.params = { ...source.params }
|
|
72
|
+
if (Number.isFinite(Number(source.timeoutMs))) refresh.timeoutMs = clampInt(Number(source.timeoutMs), 1000, 120_000, 30_000)
|
|
72
73
|
return refresh
|
|
73
74
|
}
|
|
74
75
|
|
package/host/refresh.js
CHANGED
|
@@ -36,6 +36,7 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
36
36
|
const generations = new Map()
|
|
37
37
|
const signatures = new Map()
|
|
38
38
|
const running = new Set()
|
|
39
|
+
const queued = new Set()
|
|
39
40
|
const templates = inject?.templates ?? TEMPLATES
|
|
40
41
|
const pathOf = inject?.pathOf ?? (() => '')
|
|
41
42
|
const onCommand = inject?.runCommand ?? ((command, options) => runCommand(ctx, command, options))
|
|
@@ -66,6 +67,8 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
66
67
|
return 'none'
|
|
67
68
|
}
|
|
68
69
|
const snapshot = () => ({ paused, data: Object.fromEntries([...data.entries()]) })
|
|
70
|
+
// 命令类刷新默认 30s:要大于脚本自己的网络超时(如 12s),否则脚本兜底前就被 Host 杀掉。
|
|
71
|
+
const timeoutOf = (card) => Math.max(1000, Math.min(120_000, Number(card?.refresh?.timeoutMs) || 30_000))
|
|
69
72
|
|
|
70
73
|
const resolveCardFile = (cardId, file) => {
|
|
71
74
|
const dir = pathOf(cardId)
|
|
@@ -74,16 +77,17 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
74
77
|
|
|
75
78
|
const pull = async (card, spec) => {
|
|
76
79
|
const workspaceRoot = pathOf(card.id)
|
|
80
|
+
const timeoutMs = timeoutOf(card)
|
|
77
81
|
if (spec.template) {
|
|
78
82
|
const template = templates[spec.template] ?? null
|
|
79
83
|
if (template === null) throw Object.assign(new Error(`没有 ${spec.template} 这个模板`), { code: 'unknown-template' })
|
|
80
84
|
return template.fetch(card, {
|
|
81
|
-
timeoutMs
|
|
82
|
-
runCommand: (command, options) => onCommand(command, { workspaceRoot, timeoutMs
|
|
85
|
+
timeoutMs,
|
|
86
|
+
runCommand: (command, options) => onCommand(command, { workspaceRoot, timeoutMs, ...options }),
|
|
83
87
|
})
|
|
84
88
|
}
|
|
85
89
|
if (spec.command) {
|
|
86
|
-
const output = await onCommand(spec.command, { workspaceRoot, timeoutMs
|
|
90
|
+
const output = await onCommand(spec.command, { workspaceRoot, timeoutMs })
|
|
87
91
|
return parseValue(output)
|
|
88
92
|
}
|
|
89
93
|
if (spec.file) {
|
|
@@ -91,7 +95,7 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
91
95
|
return parseValue(text)
|
|
92
96
|
}
|
|
93
97
|
if (spec.url) {
|
|
94
|
-
const response = await fetchImpl(spec.url, { signal: AbortSignal.timeout(
|
|
98
|
+
const response = await fetchImpl(spec.url, { signal: AbortSignal.timeout(timeoutMs), headers: { accept: 'application/json' } })
|
|
95
99
|
if (!response.ok) throw Object.assign(new Error(`HTTP ${response.status}`), { code: 'http-status' })
|
|
96
100
|
return response.json()
|
|
97
101
|
}
|
|
@@ -100,7 +104,8 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
100
104
|
|
|
101
105
|
const runOne = async (card) => {
|
|
102
106
|
if (paused || started === false) return
|
|
103
|
-
|
|
107
|
+
// 正在刷新时再次点击「重试」:排队一次,等当前这次结束后立刻再跑,而不是静默丢弃
|
|
108
|
+
if (running.has(card.id)) { queued.add(card.id); return }
|
|
104
109
|
if (!hasProvider(card)) {
|
|
105
110
|
if (data.delete(card.id)) emit()
|
|
106
111
|
return
|
|
@@ -117,12 +122,16 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
117
122
|
fetchedAt: previous?.fetchedAt ?? 0,
|
|
118
123
|
ttl: previous?.ttl ?? everyMs * 2,
|
|
119
124
|
sourceRef: sourceRefOf(card),
|
|
120
|
-
error: { code: String(error?.code ?? 'fetch-failed'), message: String(error?.message ?? error).slice(0,
|
|
125
|
+
error: { code: String(error?.code ?? 'fetch-failed'), message: String(error?.message ?? error).slice(0, 800), at: Date.now() },
|
|
121
126
|
})
|
|
122
127
|
} finally {
|
|
123
128
|
running.delete(card.id)
|
|
124
129
|
}
|
|
125
130
|
emit()
|
|
131
|
+
if (queued.delete(card.id)) {
|
|
132
|
+
const latest = cards?.get?.(card.id) ?? card
|
|
133
|
+
void runOne(latest)
|
|
134
|
+
}
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
const clearTimer = (id) => {
|
|
@@ -171,9 +180,9 @@ export function createRefresh({ ctx, cards, inject } = {}) {
|
|
|
171
180
|
|
|
172
181
|
return {
|
|
173
182
|
start: (list) => { started = true; sync(list) },
|
|
174
|
-
stop: () => { started = false; for (const id of [...timers.keys()]) clearTimer(id); timers.clear(); signatures.clear() },
|
|
183
|
+
stop: () => { started = false; queued.clear(); for (const id of [...timers.keys()]) clearTimer(id); timers.clear(); signatures.clear() },
|
|
175
184
|
sync,
|
|
176
|
-
pause: () => { paused = true; for (const id of [...timers.keys()]) clearTimer(id); signatures.clear(); emit() },
|
|
185
|
+
pause: () => { paused = true; queued.clear(); for (const id of [...timers.keys()]) clearTimer(id); signatures.clear(); emit() },
|
|
177
186
|
resume: () => { paused = false; sync(cards?.list?.() ?? []); emit() },
|
|
178
187
|
snapshot,
|
|
179
188
|
refresh: (list) => { for (const card of Array.isArray(list) ? list : []) void runOne(card) },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-open-desktop",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "把 DSH 的中栏变成可拖拽的数据卡片墙:每张卡片是一条真实会话,用 view/ 里的前端代码渲染,自带刷新节奏。",
|
|
6
6
|
"keywords": [
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"react": "^19.3.1",
|
|
59
59
|
"react-dom": "^19.3.1"
|
|
60
60
|
},
|
|
61
|
-
"homepage": "https://github.com/Howell5/
|
|
61
|
+
"homepage": "https://github.com/Howell5/openDesktop#readme",
|
|
62
62
|
"repository": {
|
|
63
63
|
"type": "git",
|
|
64
|
-
"url": "git+https://github.com/Howell5/
|
|
64
|
+
"url": "git+https://github.com/Howell5/openDesktop.git",
|
|
65
|
+
"directory": "plugin"
|
|
65
66
|
},
|
|
66
67
|
"bugs": {
|
|
67
|
-
"url": "https://github.com/Howell5/
|
|
68
|
+
"url": "https://github.com/Howell5/openDesktop/issues"
|
|
68
69
|
},
|
|
69
70
|
"engines": {
|
|
70
71
|
"dsh": ">=0.2.2-rc.3 <0.3.0-0"
|
|
71
|
-
}
|
|
72
|
-
"author": "Howell5"
|
|
72
|
+
}
|
|
73
73
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Howell5
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|