dsh-agent-floor 0.3.0 → 0.4.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.md +7 -7
- package/client.js +129 -149
- package/package.json +1 -1
- package/scripts/harness.js +33 -22
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Agent Floor · 常驻监控条
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在 DeepSeek Harness **左侧边栏底部(Settings 旁边)**挂一行常驻状态:不用开标签页、也不覆盖正文,随时能瞄一眼哪个会话在跑、跑到第几步、烧了多少 token、改了哪些文件。
|
|
4
4
|
|
|
5
5
|
DSH 自带的「任务管理」页已经能看到 agent 树和后台任务,但它是**按会话打开的标签页**,而且没有步/轮/token/改动文件这些指标。这个插件只补这块,不重复画树。
|
|
6
6
|
|
|
7
7
|
## 长什么样
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- **侧边栏底部**:`● 2 在跑 / 5 在岗` 一行常驻(有会话在跑时圆点呼吸),不挡正文
|
|
10
|
+
- **点一下**:在它上方弹出面板 —— 每个会话一行
|
|
11
|
+
- 面板每行:状态点、名字(组长带 `带队 N`)、`第N步·第T轮 · 12.3k tok`、正在跑的 `bash · pnpm run build` 或 `改 client.js · index.js`
|
|
11
12
|
- 点任意一行 → 跳到那个会话
|
|
12
|
-
- **按住标题栏拖动**可以把监控条挪到任意位置(位置存在 localStorage,自动记住)
|
|
13
13
|
|
|
14
14
|
## 装
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
dsh plugin install dsh-agent-floor # npm,0.
|
|
17
|
+
dsh plugin install dsh-agent-floor # npm,0.4.0+
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
或加市场索引源:`https://raw.githubusercontent.com/ITxuezhe/dsh-agent-floor/main/market/index.json`
|
|
@@ -23,13 +23,13 @@ dsh plugin install dsh-agent-floor # npm,0.3.0+
|
|
|
23
23
|
|
|
24
24
|
## 数据从哪来
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
插件挂两个官方插槽:`sidebar.footer.action`(侧边栏底部那一行)与 `shell.overlay`(弹出面板,避免被侧边栏裁剪)。客户端每 2 秒(收起时 6 秒)拉一次只读路由 `GET /dsh-agent-floor/state`。
|
|
27
27
|
Host 半监听会话事件折叠成快照,并按会话 cwd 跑 `git status --porcelain`(10 秒缓存、失败降级为空)拿真实改动文件。
|
|
28
28
|
|
|
29
29
|
- 状态:`running` 或 45 秒内有动静 → RUNNING;5 分钟内 → STANDBY;否则 IDLE
|
|
30
30
|
- 子代理靠 `parentSession` 归到组长名下,空闲超过 10 分钟自动淡出
|
|
31
31
|
- 展开/收起状态存在 localStorage `dsh.agent-floor.open`
|
|
32
|
-
-
|
|
32
|
+
- 面板点空白处或 Esc 关闭
|
|
33
33
|
|
|
34
34
|
## 自检
|
|
35
35
|
|
package/client.js
CHANGED
|
@@ -8,35 +8,36 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
const inject = ['slots'];
|
|
9
9
|
const ROUTE = '/dsh-agent-floor/state';
|
|
10
10
|
const OPEN_KEY = 'dsh.agent-floor.open';
|
|
11
|
-
const POS_KEY = 'dsh.agent-floor.pos';
|
|
12
11
|
const CHILD_TTL = 10 * 60 * 1000;
|
|
13
12
|
const MAX_ROWS = 8;
|
|
14
13
|
|
|
15
14
|
const CSS = `
|
|
16
|
-
.fg-root{
|
|
17
|
-
font:12px/1.5 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
15
|
+
.fg-root{font:11.5px/1.45 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
18
16
|
color:var(--dsw-alias-label-primary,#1c1c1e);}
|
|
19
|
-
.fg-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
box-shadow:0 8px 28px rgba(0,0,0,.12);}
|
|
24
|
-
.fg-head{display:flex;align-items:center;gap:7px;padding:7px 10px;cursor:grab;
|
|
25
|
-
user-select:none;-webkit-user-select:none;touch-action:none;}
|
|
26
|
-
.fg-head.dragging{cursor:grabbing;}
|
|
27
|
-
.fg-head:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.03));}
|
|
17
|
+
.fg-chip{display:flex;align-items:center;gap:6px;width:100%;padding:5px 8px;
|
|
18
|
+
border:0;border-radius:8px;background:transparent;cursor:pointer;
|
|
19
|
+
font:inherit;color:inherit;text-align:left;}
|
|
20
|
+
.fg-chip:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.04));}
|
|
28
21
|
.fg-pulse{width:7px;height:7px;border-radius:50%;flex:0 0 auto;
|
|
29
22
|
background:var(--dsw-alias-state-idle-primary,#9aa0a6);}
|
|
30
23
|
.fg-pulse.on{background:var(--dsw-alias-state-success-primary,#1a9b4e);
|
|
31
24
|
animation:fg-breathe 1.6s ease-in-out infinite;}
|
|
32
25
|
@keyframes fg-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}
|
|
33
|
-
.fg-sum{font-weight:600;
|
|
26
|
+
.fg-sum{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
34
27
|
.fg-sum i{font-style:normal;font-weight:500;opacity:.55;}
|
|
35
|
-
.fg-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
.fg-panel{position:fixed;left:12px;bottom:64px;z-index:61;width:290px;max-height:min(420px,60vh);
|
|
29
|
+
overflow:auto;border-radius:12px;padding:4px;
|
|
30
|
+
background:var(--dsw-alias-bg-overlay,#fff);
|
|
31
|
+
border:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.09));
|
|
32
|
+
box-shadow:0 10px 30px rgba(0,0,0,.14);
|
|
33
|
+
font:12px/1.5 ui-sans-serif,-apple-system,"SF Pro Text","PingFang SC",system-ui,sans-serif;
|
|
34
|
+
color:var(--dsw-alias-label-primary,#1c1c1e);}
|
|
35
|
+
.fg-panel-head{display:flex;align-items:center;gap:7px;padding:6px 8px 7px;font-weight:600;
|
|
36
|
+
border-bottom:1px solid var(--dsw-alias-border-l1,rgba(0,0,0,.07));margin-bottom:4px;}
|
|
37
|
+
.fg-panel-head span.close{margin-left:auto;cursor:pointer;opacity:.45;font-weight:500;padding:0 3px;}
|
|
38
|
+
.fg-panel-head span.close:hover{opacity:.9;}
|
|
38
39
|
.fg-row{display:grid;grid-template-columns:9px 1fr auto;gap:2px 7px;
|
|
39
|
-
padding:6px
|
|
40
|
+
padding:6px 8px;cursor:pointer;align-items:center;border-radius:8px;}
|
|
40
41
|
.fg-row:hover{background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,.035));}
|
|
41
42
|
.fg-dot{width:7px;height:7px;border-radius:50%;
|
|
42
43
|
background:var(--dsw-alias-state-idle-primary,#c2c6cc);}
|
|
@@ -47,7 +48,7 @@ window.__ModuleLoader__.load({
|
|
|
47
48
|
.fg-num{font-variant-numeric:tabular-nums;opacity:.6;white-space:nowrap;font-size:11px;}
|
|
48
49
|
.fg-file{grid-column:2 / 4;font-size:11px;opacity:.5;overflow:hidden;
|
|
49
50
|
text-overflow:ellipsis;white-space:nowrap;}
|
|
50
|
-
.fg-more{grid-column:1 / 4;padding:5px
|
|
51
|
+
.fg-more{grid-column:1 / 4;padding:5px 8px;font-size:11px;opacity:.5;}
|
|
51
52
|
`;
|
|
52
53
|
|
|
53
54
|
function ensureStyle() {
|
|
@@ -66,31 +67,47 @@ window.__ModuleLoader__.load({
|
|
|
66
67
|
return (n / 1e6).toFixed(1) + 'M';
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
70
|
+
// One shared poller for every mount point, so the chip and the panel never
|
|
71
|
+
// fetch twice and always show the same snapshot.
|
|
72
|
+
const store = { open: false, data: null, subs: new Set(), timer: null, started: false };
|
|
73
|
+
|
|
74
|
+
function readOpen() {
|
|
75
|
+
try { return localStorage.getItem(OPEN_KEY) === '1'; } catch { return false; }
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function
|
|
78
|
-
|
|
78
|
+
function setOpen(next) {
|
|
79
|
+
store.open = next;
|
|
80
|
+
try { localStorage.setItem(OPEN_KEY, next ? '1' : '0'); } catch {}
|
|
81
|
+
notify();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function notify() {
|
|
85
|
+
store.subs.forEach((fn) => { try { fn(); } catch {} });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function startPolling() {
|
|
89
|
+
if (store.started) return;
|
|
90
|
+
store.started = true;
|
|
91
|
+
const tick = () => {
|
|
92
|
+
Promise.resolve()
|
|
93
|
+
.then(() => fetch(ROUTE, { headers: { accept: 'application/json' } }))
|
|
94
|
+
.then((r) => (r && r.ok ? r.json() : null))
|
|
95
|
+
.then((d) => { if (d) { store.data = d; notify(); } })
|
|
96
|
+
.catch(() => {})
|
|
97
|
+
.then(() => { store.timer = setTimeout(tick, store.open ? 2000 : 6000); });
|
|
98
|
+
};
|
|
99
|
+
tick();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function useStore() {
|
|
103
|
+
const [, bump] = useState(0);
|
|
79
104
|
useEffect(() => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.then((d) => { if (alive && d) setData(d); })
|
|
87
|
-
.catch(() => {})
|
|
88
|
-
.then(() => { if (alive) timer = setTimeout(tick, open ? 2000 : 6000); });
|
|
89
|
-
};
|
|
90
|
-
tick();
|
|
91
|
-
return () => { alive = false; if (timer) clearTimeout(timer); };
|
|
92
|
-
}, [open]);
|
|
93
|
-
return data;
|
|
105
|
+
const fn = () => bump((v) => v + 1);
|
|
106
|
+
store.subs.add(fn);
|
|
107
|
+
startPolling();
|
|
108
|
+
return () => { store.subs.delete(fn); };
|
|
109
|
+
}, []);
|
|
110
|
+
return store;
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
function deriveAgents(data) {
|
|
@@ -153,6 +170,17 @@ window.__ModuleLoader__.load({
|
|
|
153
170
|
return '';
|
|
154
171
|
}
|
|
155
172
|
|
|
173
|
+
function openSession(ctx, a) {
|
|
174
|
+
const id = a && a.id;
|
|
175
|
+
if (!id) return;
|
|
176
|
+
try {
|
|
177
|
+
const ui = ctx && typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : null;
|
|
178
|
+
if (ui && typeof ui.openSession === 'function') { ui.openSession(id); return; }
|
|
179
|
+
const ses = ctx && typeof ctx.get === 'function' ? ctx.get('sessions') : null;
|
|
180
|
+
if (ses && typeof ses.scope === 'function') ses.scope(id);
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
function MonitorRow(props) {
|
|
157
185
|
const a = props.agent;
|
|
158
186
|
const cls = 'fg-dot ' + (a.status === 'RUNNING' ? 'run' : a.status === 'STANDBY' ? 'wait' : '');
|
|
@@ -170,120 +198,69 @@ window.__ModuleLoader__.load({
|
|
|
170
198
|
]);
|
|
171
199
|
}
|
|
172
200
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
/** Sidebar-foot chip: always visible, one line, no overlay over the page. */
|
|
202
|
+
function FloorChip(props) {
|
|
203
|
+
const ctx = (props && props.ctx) || null;
|
|
204
|
+
const s = useStore();
|
|
205
|
+
const agents = deriveAgents(s.data);
|
|
206
|
+
const running = agents.filter((a) => a.status === 'RUNNING').length;
|
|
207
|
+
useEffect(() => { ensureStyle(); }, []);
|
|
208
|
+
const label = agents.length === 0
|
|
209
|
+
? '暂无会话'
|
|
210
|
+
: (running ? running + ' 在跑' : '全部空闲') + ' / ' + agents.length + ' 在岗';
|
|
211
|
+
return h('div', { className: 'fg-root' },
|
|
212
|
+
h('button', {
|
|
213
|
+
className: 'fg-chip',
|
|
214
|
+
type: 'button',
|
|
215
|
+
title: running ? running + ' 个会话正在跑,点开看详情' : '点开看会话详情',
|
|
216
|
+
onClick: () => setOpen(!s.open),
|
|
217
|
+
}, [
|
|
218
|
+
h('span', { className: 'fg-pulse' + (running ? ' on' : ''), key: 'p' }),
|
|
219
|
+
h('span', { className: 'fg-sum', key: 's' }, label),
|
|
220
|
+
]));
|
|
182
221
|
}
|
|
183
222
|
|
|
184
|
-
|
|
223
|
+
/** Frame-wide panel, only mounted while open; anchored above the chip. */
|
|
224
|
+
function FloorPanel(props) {
|
|
185
225
|
const ctx = (props && props.ctx) || null;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
const [pos, setPos] = useState(readPos);
|
|
190
|
-
const [dragging, setDragging] = useState(false);
|
|
191
|
-
const dragRef = useRef(null);
|
|
192
|
-
const movedRef = useRef(false);
|
|
193
|
-
const data = useFloor(open, props && props.initialData);
|
|
194
|
-
const agents = deriveAgents(data);
|
|
226
|
+
const s = useStore();
|
|
227
|
+
const agents = deriveAgents(s.data);
|
|
195
228
|
const running = agents.filter((a) => a.status === 'RUNNING').length;
|
|
196
229
|
const shown = agents.slice(0, MAX_ROWS);
|
|
197
230
|
const hidden = agents.length - shown.length;
|
|
198
|
-
|
|
199
|
-
const toggle = () => {
|
|
200
|
-
const next = !open;
|
|
201
|
-
setOpen(next);
|
|
202
|
-
try { localStorage.setItem(OPEN_KEY, next ? '1' : '0'); } catch {}
|
|
203
|
-
};
|
|
231
|
+
const ref = useRef(null);
|
|
204
232
|
|
|
205
233
|
useEffect(() => { ensureStyle(); }, []);
|
|
206
234
|
|
|
207
235
|
useEffect(() => {
|
|
208
|
-
if (!
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
const dy = e.clientY - d.y0;
|
|
214
|
-
if (Math.abs(dx) + Math.abs(dy) > 3) movedRef.current = true;
|
|
215
|
-
const maxX = Math.max(8, (window.innerWidth || 1200) - 120);
|
|
216
|
-
const maxY = Math.max(8, (window.innerHeight || 800) - 60);
|
|
217
|
-
setPos({
|
|
218
|
-
x: Math.min(maxX, Math.max(8, d.px + dx)),
|
|
219
|
-
y: Math.min(maxY, Math.max(8, d.py - dy)),
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
const up = () => {
|
|
223
|
-
setDragging(false);
|
|
224
|
-
const p = readPos();
|
|
225
|
-
try { localStorage.setItem(POS_KEY, JSON.stringify(snapRef.current || p)); } catch {}
|
|
236
|
+
if (!s.open) return undefined;
|
|
237
|
+
const onDown = (e) => {
|
|
238
|
+
const el = ref.current;
|
|
239
|
+
if (el && e && e.target && el.contains && el.contains(e.target)) return;
|
|
240
|
+
setOpen(false);
|
|
226
241
|
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
242
|
+
const onKey = (e) => { if (e && e.key === 'Escape') setOpen(false); };
|
|
243
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
244
|
+
document.addEventListener('keydown', onKey);
|
|
230
245
|
return () => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
window.removeEventListener('pointercancel', up);
|
|
246
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
247
|
+
document.removeEventListener('keydown', onKey);
|
|
234
248
|
};
|
|
235
|
-
}, [
|
|
249
|
+
}, [s.open]);
|
|
236
250
|
|
|
237
|
-
|
|
238
|
-
snapRef.current = pos;
|
|
251
|
+
if (!s.open) return null;
|
|
239
252
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
dragRef.current = { x0: e.clientX, y0: e.clientY, px: pos.x, py: pos.y };
|
|
243
|
-
movedRef.current = false;
|
|
244
|
-
setDragging(true);
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const onHeadClick = () => {
|
|
248
|
-
if (movedRef.current) { movedRef.current = false; return; }
|
|
249
|
-
toggle();
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const openSession = (a) => {
|
|
253
|
-
const id = a && a.id;
|
|
254
|
-
if (!id) return;
|
|
255
|
-
try {
|
|
256
|
-
const ui = ctx && typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : null;
|
|
257
|
-
if (ui && typeof ui.openSession === 'function') { ui.openSession(id); return; }
|
|
258
|
-
const ses = ctx && typeof ctx.get === 'function' ? ctx.get('sessions') : null;
|
|
259
|
-
if (ses && typeof ses.scope === 'function') ses.scope(id);
|
|
260
|
-
} catch {}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
return h('div', { className: 'fg-root' }, h('div', {
|
|
264
|
-
className: 'fg-dock',
|
|
265
|
-
style: { left: pos.x + 'px', bottom: pos.y + 'px' },
|
|
266
|
-
}, [
|
|
267
|
-
h('div', {
|
|
268
|
-
className: 'fg-head' + (dragging ? ' dragging' : ''),
|
|
269
|
-
key: 'head',
|
|
270
|
-
onPointerDown: onHeadDown,
|
|
271
|
-
onClick: onHeadClick,
|
|
272
|
-
title: '拖动可移动位置 · 点击' + (open ? '收起' : '展开'),
|
|
273
|
-
}, [
|
|
253
|
+
return h('div', { className: 'fg-panel', ref }, [
|
|
254
|
+
h('div', { className: 'fg-panel-head', key: 'head' }, [
|
|
274
255
|
h('span', { className: 'fg-pulse' + (running ? ' on' : ''), key: 'p' }),
|
|
275
|
-
h('span', {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
]),
|
|
279
|
-
h('span', { className: 'fg-caret', key: 'c' }, open ? '⌄' : '⌃'),
|
|
256
|
+
h('span', { key: 't' }, running ? running + ' 个在跑' : '全部空闲'),
|
|
257
|
+
h('span', { key: 'n', style: { opacity: .5, fontWeight: 500 } }, '共 ' + agents.length + ' 个会话'),
|
|
258
|
+
h('span', { className: 'close', key: 'x', onClick: () => setOpen(false), title: '关闭' }, '✕'),
|
|
280
259
|
]),
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
]) : null,
|
|
286
|
-
]));
|
|
260
|
+
...shown.map((a) => h(MonitorRow, { key: a.id || a.name, agent: a, onOpen: (x) => openSession(ctx, x) })),
|
|
261
|
+
hidden > 0 ? h('div', { className: 'fg-more', key: 'more' }, '还有 ' + hidden + ' 个会话') : null,
|
|
262
|
+
agents.length === 0 ? h('div', { className: 'fg-more', key: 'empty' }, '暂无会话') : null,
|
|
263
|
+
]);
|
|
287
264
|
}
|
|
288
265
|
|
|
289
266
|
function apply(ctx) {
|
|
@@ -291,24 +268,27 @@ window.__ModuleLoader__.load({
|
|
|
291
268
|
const target = ready && ready.slots ? ready : ctx;
|
|
292
269
|
const slots = target && target.slots;
|
|
293
270
|
if (!slots) return;
|
|
271
|
+
const register = (name, id, order, label, Comp) => {
|
|
272
|
+
slots.inject(name, () => slots.register({ name, id, order, label }, (props) => h(Comp, { ...props, ctx })));
|
|
273
|
+
};
|
|
294
274
|
const render = () => {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}, () => h(MonitorBar, { ctx })));
|
|
275
|
+
store.open = readOpen();
|
|
276
|
+
// Chip lives in the sidebar foot next to Settings — out of the content area.
|
|
277
|
+
register('sidebar.footer.action', 'dsh-agent-floor', 10, 'Agent Floor', FloorChip);
|
|
278
|
+
// Panel is frame-wide so the sidebar can never clip it.
|
|
279
|
+
register('shell.overlay', 'dsh-agent-floor.panel', 940, 'Agent Floor', FloorPanel);
|
|
301
280
|
};
|
|
302
281
|
if (typeof target.effect === 'function') target.effect(render, 'dsh-agent-floor: mounts');
|
|
303
282
|
else render();
|
|
304
283
|
};
|
|
305
|
-
if (typeof ctx.inject === 'function')
|
|
306
|
-
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (ctx.slots) bridge(ctx);
|
|
284
|
+
if (ctx && typeof ctx.inject === 'function') ctx.inject(['slots'], bridge);
|
|
285
|
+
else bridge(ctx);
|
|
310
286
|
}
|
|
311
287
|
|
|
312
|
-
return {
|
|
288
|
+
return {
|
|
289
|
+
inject,
|
|
290
|
+
apply,
|
|
291
|
+
__dshTest: { deriveAgents, FloorChip, FloorPanel, MonitorRow, store },
|
|
292
|
+
};
|
|
313
293
|
},
|
|
314
294
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-floor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Agent Floor — a compact always-on dock for DeepSeek Harness: which session is running, how far along, how many tokens, which files changed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/scripts/harness.js
CHANGED
|
@@ -153,7 +153,7 @@ function main() {
|
|
|
153
153
|
throw new Error('client.js: 既没有 __dshTest,也找不到 `return { inject, apply };` —— 导出结构变了?');
|
|
154
154
|
}
|
|
155
155
|
src = src.replace(EXPORT_RE,
|
|
156
|
-
'return { inject, apply, __dshTest: { deriveAgents: deriveAgents,
|
|
156
|
+
'return { inject, apply, __dshTest: { deriveAgents: deriveAgents, FloorChip: FloorChip, FloorPanel: FloorPanel, MonitorRow: MonitorRow, store: store } };');
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const factoryFn = new Function(
|
|
@@ -187,23 +187,31 @@ function main() {
|
|
|
187
187
|
if (typeof mod.apply !== 'function') throw new Error('模块没有导出 apply()');
|
|
188
188
|
mod.apply(ctx);
|
|
189
189
|
if (!registered.length) throw new Error('apply() 没有注册任何组件到 shell.overlay');
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
const bySlot = (name) => registered.find((r) => r.spec && r.spec.name === name);
|
|
191
|
+
const chip = bySlot('sidebar.footer.action');
|
|
192
|
+
const panel = bySlot('shell.overlay');
|
|
193
|
+
if (!chip) throw new Error('apply() 没有把 chip 注册到 sidebar.footer.action');
|
|
194
|
+
if (!panel) throw new Error('apply() 没有把 panel 注册到 shell.overlay');
|
|
195
|
+
if (typeof chip.render !== 'function' || typeof panel.render !== 'function') {
|
|
196
|
+
throw new Error('slots.register 的 render 不是函数');
|
|
197
|
+
}
|
|
192
198
|
|
|
193
|
-
// 2)
|
|
194
|
-
const tree = renderNode(React.createElement(
|
|
195
|
-
if (!tree.length) throw new Error('
|
|
199
|
+
// 2) 真的把注册出来的 chip 渲染一次。
|
|
200
|
+
const tree = renderNode(React.createElement(chip.render, {}));
|
|
201
|
+
if (!tree.length) throw new Error('FloorChip 渲染结果为空');
|
|
196
202
|
const rootTag = tree[0].tag;
|
|
197
|
-
if (typeof rootTag !== 'string') throw new Error('
|
|
203
|
+
if (typeof rootTag !== 'string') throw new Error('FloorChip 顶层不是 DOM 标签: ' + String(rootTag));
|
|
198
204
|
if (!tree[0].props.className || String(tree[0].props.className).indexOf('fg-') !== 0) {
|
|
199
|
-
throw new Error('
|
|
205
|
+
throw new Error('FloorChip 顶层缺少 fg-* className: ' + JSON.stringify(tree[0].props.className));
|
|
200
206
|
}
|
|
201
|
-
const
|
|
207
|
+
const chipNodes = countNodes(tree);
|
|
208
|
+
const chipButton = findTag(tree, 'button');
|
|
209
|
+
if (!chipButton) throw new Error('FloorChip 没有渲染出 button(点不了)');
|
|
202
210
|
|
|
203
|
-
// 3) 用 5 个假 agent
|
|
211
|
+
// 3) 用 5 个假 agent 验证分组,再渲染面板。
|
|
204
212
|
const test = mod.__dshTest;
|
|
205
|
-
if (!test || typeof test.
|
|
206
|
-
throw new Error('client.js 没有暴露 __dshTest.
|
|
213
|
+
if (!test || typeof test.FloorPanel !== 'function' || typeof test.deriveAgents !== 'function') {
|
|
214
|
+
throw new Error('client.js 没有暴露 __dshTest.FloorPanel / deriveAgents');
|
|
207
215
|
}
|
|
208
216
|
const now = Date.now();
|
|
209
217
|
const sessions = [
|
|
@@ -217,34 +225,37 @@ function main() {
|
|
|
217
225
|
if (ordered.length !== 5) throw new Error('deriveAgents 期望 5 个 agent,实际 ' + ordered.length);
|
|
218
226
|
if (ordered.filter((o) => o.depth === 1).length !== 1) throw new Error('deriveAgents 没把子代理排成 depth 1');
|
|
219
227
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
const
|
|
228
|
+
test.store.open = true;
|
|
229
|
+
test.store.data = { sessions };
|
|
230
|
+
const chipOn = renderNode(React.createElement(chip.render, {}));
|
|
231
|
+
const panelTree = renderNode(React.createElement(panel.render, {}));
|
|
232
|
+
if (!panelTree.length) throw new Error('FloorPanel 打开状态下渲染结果为空');
|
|
224
233
|
let rowCount = 0;
|
|
225
|
-
(function
|
|
234
|
+
(function walk(n) {
|
|
226
235
|
if (!n || typeof n !== 'object') return;
|
|
227
236
|
const cls = n.props && n.props.className;
|
|
228
237
|
if (typeof cls === 'string' && cls.indexOf('fg-row') === 0) rowCount++;
|
|
229
|
-
for (const c of n.children || [])
|
|
230
|
-
})(
|
|
238
|
+
for (const c of n.children || []) walk(c);
|
|
239
|
+
})(panelTree[0]);
|
|
231
240
|
if (rowCount !== 5) throw new Error('展开状态应渲染 5 行,实际 ' + rowCount);
|
|
232
241
|
|
|
233
242
|
const row = renderNode(React.createElement(test.MonitorRow, { agent: ordered[0], onOpen: () => {} }));
|
|
234
243
|
if (!row.length || row[0].tag !== 'div') throw new Error('MonitorRow 顶层不是 div');
|
|
235
244
|
if (String(row[0].props.className).indexOf('fg-row') !== 0) throw new Error('MonitorRow 缺少 fg-row className');
|
|
236
245
|
|
|
237
|
-
// 4) 跑一次 effect
|
|
246
|
+
// 4) 跑一次 effect(轮询会发起一次假 fetch),确认不炸。
|
|
238
247
|
for (const fn of effects) {
|
|
239
248
|
const cleanup = fn();
|
|
240
249
|
if (typeof cleanup === 'function') cleanup();
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
console.log(' client : ' + target);
|
|
244
|
-
console.log('
|
|
245
|
-
console.log('
|
|
253
|
+
console.log(' chip : <' + rootTag + ' class="' + tree[0].props.className + '"> (' + chipNodes + ' nodes)');
|
|
254
|
+
console.log(' panel : <div fg-panel> (' + countNodes(panelTree) + ' nodes, ' + ordered.length + ' agents, chip ' + countNodes(chipOn) + ' nodes)');
|
|
246
255
|
console.log(' effects: ' + effects.length + ' 个已执行');
|
|
247
256
|
console.log('render ok');
|
|
257
|
+
// 共享轮询器会挂一个真实 setTimeout,自检到这里就该退出。
|
|
258
|
+
process.exit(0);
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
try {
|