@jiyr0119/dsh-service-console 0.2.0 → 0.2.1
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 +3 -4
- package/README.zh.md +2 -1
- package/dsh.plugin.json +1 -1
- package/dynamic/client.js +5 -8
- package/lib/client.js +42 -61
- package/lib/types/client/ServiceConsole.d.ts +6 -1
- package/lib/types/client/index.d.ts +0 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# DSH Service Console
|
|
2
2
|
|
|
3
|
-
**English**
|
|
3
|
+
**English**
|
|
4
4
|
|
|
5
5
|
> A local development service console for DSH: discover listening ports, identify services related to the current conversation or workspace, and safely inspect, stop, or restart them.
|
|
6
6
|
|
|
7
|
-
**DSH 本地开发服务控制台:发现监听端口,识别与当前对话或工作区相关的服务,并安全地查看、停止和重启。**
|
|
8
|
-
|
|
9
7
|
Single-purpose plugin for the DeepSeek Harness web UI. When the model (or you) starts a local dev server (`npm run dev`, Vite, Next.js, Uvicorn, Express, Rust, …), Service Console shows it in one place: which ports it listens on, which command and working directory started it, whether it belongs to this conversation or workspace, and whether it is safe to stop or restart.
|
|
10
8
|
|
|
11
9
|
## Features
|
|
@@ -15,7 +13,8 @@ Single-purpose plugin for the DeepSeek Harness web UI. When the model (or you) s
|
|
|
15
13
|
- **Control** — graceful stop to the process group, restart with a safe saved launch command. Every action is confirmed twice and re-validated against the current snapshot.
|
|
16
14
|
- **Safeguards** — PID-reuse / fingerprint checks before any signal; unknown and protected services are read-only; force-kill is off by default; no implicit auto-cleanup; command output is redacted.
|
|
17
15
|
- **All local services** — every listening service on this machine is visible; ownership is shown as a safety signal rather than a hidden category filter.
|
|
18
|
-
- **Search, config, i18n** — keyword filtering,
|
|
16
|
+
- **Search, config, i18n** — keyword filtering, graceful timeout / force-kill settings, and automatic Chinese/English labels from DSH's active locale.
|
|
17
|
+
- **On-demand scanning** — opening the console fetches the current snapshot once; use the refresh button for an explicit rescan. There is no background polling.
|
|
19
18
|
- **DSH-native inspector** — an expanded service record card presents process identity, ports, command, working directory and ownership evidence in the Web UI's token-based visual language.
|
|
20
19
|
|
|
21
20
|
## Install
|
package/README.zh.md
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
- **受控操作** — 对进程组优雅停止;对保存了安全启动命令的服务重启。每个动作均二次确认,并在操作前重新校验快照。
|
|
16
16
|
- **安全防护** — 任何信号前校验 PID 复用 / fingerprint;未知与受保护服务只读;强制终止默认关闭;无隐式自动清理;命令输出脱敏。
|
|
17
17
|
- **全量本机服务** — 展示本机全部监听服务;归属只作为安全提示,不再隐藏端口分类,用户可自行选择要查看或停止的服务。
|
|
18
|
-
- **搜索 / 配置 / 国际化** —
|
|
18
|
+
- **搜索 / 配置 / 国际化** — 支持关键字过滤、优雅超时 / 强制终止设置;中英文界面自动跟随 DSH 当前语言。
|
|
19
|
+
- **按需扫描** — 打开控制台时获取一次当前快照;点击刷新按钮才会主动重新扫描,不进行后台定时轮询。
|
|
19
20
|
- **DSH 原生检查卡片** — 展开详情采用 DSH Web token 化视觉风格,展示进程身份、端口、命令、工作目录和归属证据。
|
|
20
21
|
|
|
21
22
|
## 安装
|
package/dsh.plugin.json
CHANGED
package/dynamic/client.js
CHANGED
|
@@ -63,7 +63,8 @@ return {
|
|
|
63
63
|
|
|
64
64
|
function Panel() {
|
|
65
65
|
const [open, setLocal] = React.useState(store.open)
|
|
66
|
-
const
|
|
66
|
+
const locale = ctx.get('locale')
|
|
67
|
+
const [lang, setLang] = React.useState(() => String(locale && locale.getLocale && locale.getLocale().id || '').toLowerCase().startsWith('zh') ? 'zh' : 'en')
|
|
67
68
|
const [query, setQuery] = React.useState('')
|
|
68
69
|
const [showConfig, setShowConfig] = React.useState(false)
|
|
69
70
|
const [configData, setConfigData] = React.useState(null)
|
|
@@ -71,11 +72,10 @@ return {
|
|
|
71
72
|
const [confirming, setConfirming] = React.useState(null)
|
|
72
73
|
const [opResult, setOpResult] = React.useState(null)
|
|
73
74
|
const [expanded, setExpanded] = React.useState(null)
|
|
74
|
-
const [autoRefresh, setAutoRefresh] = React.useState(true)
|
|
75
75
|
const timeoutRef = React.useRef(null)
|
|
76
|
-
const intervalRef = React.useRef(null)
|
|
77
76
|
React.useEffect(() => subscribe(setLocal), [])
|
|
78
|
-
React.useEffect(() =>
|
|
77
|
+
React.useEffect(() => locale && locale.subscribe ? locale.subscribe(() => setLang(String(locale.getLocale().id || '').toLowerCase().startsWith('zh') ? 'zh' : 'en')) : undefined, [])
|
|
78
|
+
React.useEffect(() => () => { if (timeoutRef.current) timeoutRef.current() }, [])
|
|
79
79
|
|
|
80
80
|
const T = TEXTS[lang]
|
|
81
81
|
const scan = () => {
|
|
@@ -91,8 +91,7 @@ return {
|
|
|
91
91
|
}
|
|
92
92
|
React.useEffect(() => {
|
|
93
93
|
if (open && view.phase === 'idle') scan()
|
|
94
|
-
|
|
95
|
-
}, [open, autoRefresh])
|
|
94
|
+
}, [open, view.phase])
|
|
96
95
|
if (!open) return null
|
|
97
96
|
|
|
98
97
|
const runAction = (svc, action) => { setConfirming({ id: svc.id, action }); setOpResult(null) }
|
|
@@ -126,10 +125,8 @@ return {
|
|
|
126
125
|
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6, flexWrap: 'wrap' } },
|
|
127
126
|
React.createElement('strong', null, T.title),
|
|
128
127
|
React.createElement('span', { style: Object.assign({}, STYLE.muted, { padding: '3px 6px', border: '1px solid var(--dsw-alias-border-l1, #444)', borderRadius: 4 }) }, T.scopeMachine),
|
|
129
|
-
React.createElement('button', { onClick: () => setLang(lang === 'zh' ? 'en' : 'zh'), style: STYLE.btn }, lang === 'zh' ? 'EN' : '中'),
|
|
130
128
|
React.createElement('button', { onClick: () => { setShowConfig(!showConfig); if (!showConfig) loadConfig() }, style: STYLE.btn }, T.config),
|
|
131
129
|
React.createElement('span', { style: { flex: 1 } }),
|
|
132
|
-
React.createElement('label', { style: STYLE.muted }, React.createElement('input', { type: 'checkbox', checked: autoRefresh, onChange: (e) => setAutoRefresh(e.target.checked) }), T.auto),
|
|
133
130
|
React.createElement('button', { onClick: scan, style: STYLE.btn }, '↻'),
|
|
134
131
|
React.createElement('button', { onClick: () => setOpen(false), style: STYLE.btn }, T.close)
|
|
135
132
|
),
|
package/lib/client.js
CHANGED
|
@@ -39,51 +39,58 @@ window.__ModuleLoader__.load({
|
|
|
39
39
|
document.head.appendChild(tag);
|
|
40
40
|
}
|
|
41
41
|
var service_console_module_css_default = {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
42
|
+
"muted": "PuSt5a_muted",
|
|
43
|
+
"evidenceItem": "PuSt5a_evidenceItem",
|
|
44
|
+
"rowMain": "PuSt5a_rowMain",
|
|
45
|
+
"input": "PuSt5a_input",
|
|
46
|
+
"liveDot": "PuSt5a_liveDot",
|
|
46
47
|
"detailHeader": "PuSt5a_detailHeader",
|
|
47
|
-
"
|
|
48
|
+
"titleBlock": "PuSt5a_titleBlock",
|
|
48
49
|
"name": "PuSt5a_name",
|
|
49
|
-
"spacer": "PuSt5a_spacer",
|
|
50
|
-
"scopeLine": "PuSt5a_scopeLine",
|
|
51
50
|
"subtitle": "PuSt5a_subtitle",
|
|
52
|
-
"
|
|
51
|
+
"headerActions": "PuSt5a_headerActions",
|
|
52
|
+
"search": "PuSt5a_search",
|
|
53
53
|
"detailLabel": "PuSt5a_detailLabel",
|
|
54
|
+
"confirmRow": "PuSt5a_confirmRow",
|
|
55
|
+
"iconBtn": "PuSt5a_iconBtn",
|
|
54
56
|
"configRow": "PuSt5a_configRow",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"muted": "PuSt5a_muted",
|
|
58
|
-
"entryLabel": "PuSt5a_entryLabel",
|
|
59
|
-
"liveDot": "PuSt5a_liveDot",
|
|
60
|
-
"input": "PuSt5a_input",
|
|
61
|
-
"titleBlock": "PuSt5a_titleBlock",
|
|
57
|
+
"err": "PuSt5a_err",
|
|
58
|
+
"row": "PuSt5a_row",
|
|
62
59
|
"closeBtn": "PuSt5a_closeBtn",
|
|
60
|
+
"entryLabel": "PuSt5a_entryLabel",
|
|
61
|
+
"spacer": "PuSt5a_spacer",
|
|
62
|
+
"autoRefresh": "PuSt5a_autoRefresh",
|
|
63
63
|
"warn": "PuSt5a_warn",
|
|
64
|
-
"configBox": "PuSt5a_configBox",
|
|
65
|
-
"iconBtn": "PuSt5a_iconBtn",
|
|
66
|
-
"panel": "PuSt5a_panel",
|
|
67
64
|
"ok": "PuSt5a_ok",
|
|
68
65
|
"status": "PuSt5a_status",
|
|
69
66
|
"btn": "PuSt5a_btn",
|
|
70
|
-
"evidenceItem": "PuSt5a_evidenceItem",
|
|
71
|
-
"row": "PuSt5a_row",
|
|
72
|
-
"rowMain": "PuSt5a_rowMain",
|
|
73
|
-
"autoRefresh": "PuSt5a_autoRefresh",
|
|
74
67
|
"detailAccent": "PuSt5a_detailAccent",
|
|
75
|
-
"
|
|
68
|
+
"badge": "PuSt5a_badge",
|
|
69
|
+
"panel": "PuSt5a_panel",
|
|
70
|
+
"eyebrow": "PuSt5a_eyebrow",
|
|
71
|
+
"detailBox": "PuSt5a_detailBox",
|
|
72
|
+
"detailGrid": "PuSt5a_detailGrid",
|
|
73
|
+
"evidenceBlock": "PuSt5a_evidenceBlock",
|
|
76
74
|
"entry": "PuSt5a_entry",
|
|
75
|
+
"configBox": "PuSt5a_configBox",
|
|
76
|
+
"entryIcon": "PuSt5a_entryIcon",
|
|
77
|
+
"header": "PuSt5a_header",
|
|
77
78
|
"scopeHint": "PuSt5a_scopeHint",
|
|
78
|
-
"
|
|
79
|
-
"entryIcon": "PuSt5a_entryIcon"
|
|
79
|
+
"scopeLine": "PuSt5a_scopeLine"
|
|
80
80
|
};
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/client/ServiceConsole.tsx
|
|
83
83
|
let timerCtx = null;
|
|
84
|
+
let localeCtx = null;
|
|
84
85
|
function bindTimer(t) {
|
|
85
86
|
timerCtx = t;
|
|
86
87
|
}
|
|
88
|
+
function bindLocale(locale) {
|
|
89
|
+
localeCtx = locale;
|
|
90
|
+
}
|
|
91
|
+
function currentLanguage() {
|
|
92
|
+
return String(localeCtx?.getLocale()?.id || "").toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
93
|
+
}
|
|
87
94
|
async function api(path, payload) {
|
|
88
95
|
const response = await fetch("/dsh-sc/api/" + path, {
|
|
89
96
|
method: "POST",
|
|
@@ -152,7 +159,6 @@ window.__ModuleLoader__.load({
|
|
|
152
159
|
title: "Service Console",
|
|
153
160
|
subtitle: "本机监听服务",
|
|
154
161
|
search: "搜索服务、端口或路径…",
|
|
155
|
-
auto: "5s",
|
|
156
162
|
config: "配置",
|
|
157
163
|
close: "关闭",
|
|
158
164
|
noSvc: "未发现服务",
|
|
@@ -179,7 +185,6 @@ window.__ModuleLoader__.load({
|
|
|
179
185
|
title: "Service Console",
|
|
180
186
|
subtitle: "Listening services on this Mac",
|
|
181
187
|
search: "Search services, ports, or paths…",
|
|
182
|
-
auto: "5s",
|
|
183
188
|
config: "Config",
|
|
184
189
|
close: "Close",
|
|
185
190
|
noSvc: "no services found",
|
|
@@ -205,17 +210,19 @@ window.__ModuleLoader__.load({
|
|
|
205
210
|
};
|
|
206
211
|
function ServiceConsoleEntry() {
|
|
207
212
|
const [open, setLocal] = react.useState(store.open);
|
|
213
|
+
const [lang, setLang] = react.useState(currentLanguage());
|
|
208
214
|
react.useEffect(() => subscribe(setLocal), []);
|
|
215
|
+
react.useEffect(() => localeCtx?.subscribe(() => setLang(currentLanguage())), []);
|
|
209
216
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
210
217
|
className: service_console_module_css_default.entry,
|
|
211
218
|
onClick: () => setOpen(!store.open),
|
|
212
|
-
title: "Service Console",
|
|
213
|
-
"aria-label": "Service Console",
|
|
219
|
+
title: lang === "zh" ? "服务控制台" : "Service Console",
|
|
220
|
+
"aria-label": lang === "zh" ? "服务控制台" : "Service Console",
|
|
214
221
|
children: [
|
|
215
222
|
open ? "✕" : null,
|
|
216
223
|
!open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
217
224
|
className: service_console_module_css_default.entryLabel,
|
|
218
|
-
children: "Services"
|
|
225
|
+
children: lang === "zh" ? "服务" : "Services"
|
|
219
226
|
}) : null,
|
|
220
227
|
!open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
221
228
|
className: service_console_module_css_default.entryIcon,
|
|
@@ -226,7 +233,7 @@ window.__ModuleLoader__.load({
|
|
|
226
233
|
}
|
|
227
234
|
function ServiceConsolePanel() {
|
|
228
235
|
const [open, setLocal] = react.useState(store.open);
|
|
229
|
-
const [lang, setLang] = react.useState(
|
|
236
|
+
const [lang, setLang] = react.useState(currentLanguage());
|
|
230
237
|
const [query, setQuery] = react.useState("");
|
|
231
238
|
const [showConfig, setShowConfig] = react.useState(false);
|
|
232
239
|
const [configData, setConfigData] = react.useState(null);
|
|
@@ -239,13 +246,11 @@ window.__ModuleLoader__.load({
|
|
|
239
246
|
const [confirming, setConfirming] = react.useState(null);
|
|
240
247
|
const [opResult, setOpResult] = react.useState(null);
|
|
241
248
|
const [expanded, setExpanded] = react.useState(null);
|
|
242
|
-
const [autoRefresh, setAutoRefresh] = react.useState(true);
|
|
243
249
|
const timeoutRef = react.useRef(null);
|
|
244
|
-
const intervalRef = react.useRef(null);
|
|
245
250
|
react.useEffect(() => subscribe(setLocal), []);
|
|
251
|
+
react.useEffect(() => localeCtx?.subscribe(() => setLang(currentLanguage())), []);
|
|
246
252
|
react.useEffect(() => () => {
|
|
247
253
|
timeoutRef.current?.();
|
|
248
|
-
intervalRef.current?.();
|
|
249
254
|
}, []);
|
|
250
255
|
const T = TEXTS[lang];
|
|
251
256
|
const scan = react.useCallback(() => {
|
|
@@ -290,16 +295,8 @@ window.__ModuleLoader__.load({
|
|
|
290
295
|
}, []);
|
|
291
296
|
react.useEffect(() => {
|
|
292
297
|
if (open && view.phase === "idle") scan();
|
|
293
|
-
if (open && autoRefresh) {
|
|
294
|
-
intervalRef.current = timerCtx?.interval(() => scan(), 5e3) ?? null;
|
|
295
|
-
return () => {
|
|
296
|
-
intervalRef.current?.();
|
|
297
|
-
intervalRef.current = null;
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
298
|
}, [
|
|
301
299
|
open,
|
|
302
|
-
autoRefresh,
|
|
303
300
|
scan,
|
|
304
301
|
view.phase
|
|
305
302
|
]);
|
|
@@ -393,12 +390,6 @@ window.__ModuleLoader__.load({
|
|
|
393
390
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
394
391
|
className: service_console_module_css_default.headerActions,
|
|
395
392
|
children: [
|
|
396
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
397
|
-
className: service_console_module_css_default.iconBtn,
|
|
398
|
-
onClick: () => setLang(lang === "zh" ? "en" : "zh"),
|
|
399
|
-
"aria-label": "Toggle language",
|
|
400
|
-
children: lang === "zh" ? "EN" : "中"
|
|
401
|
-
}),
|
|
402
393
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
403
394
|
className: service_console_module_css_default.iconBtn,
|
|
404
395
|
onClick: () => {
|
|
@@ -432,19 +423,7 @@ window.__ModuleLoader__.load({
|
|
|
432
423
|
className: service_console_module_css_default.scopeHint,
|
|
433
424
|
children: ["· ", T.subtitle]
|
|
434
425
|
}),
|
|
435
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer })
|
|
436
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
437
|
-
className: service_console_module_css_default.autoRefresh,
|
|
438
|
-
children: [
|
|
439
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
440
|
-
type: "checkbox",
|
|
441
|
-
checked: autoRefresh,
|
|
442
|
-
onChange: (e) => setAutoRefresh(e.target.checked)
|
|
443
|
-
}),
|
|
444
|
-
" ",
|
|
445
|
-
T.auto
|
|
446
|
-
]
|
|
447
|
-
})
|
|
426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer })
|
|
448
427
|
]
|
|
449
428
|
}),
|
|
450
429
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
@@ -663,6 +642,8 @@ window.__ModuleLoader__.load({
|
|
|
663
642
|
inject: ["slots", "timer"],
|
|
664
643
|
apply(ctx) {
|
|
665
644
|
bindTimer(ctx.timer);
|
|
645
|
+
const locale = ctx.get("locale");
|
|
646
|
+
if (locale) bindLocale(locale);
|
|
666
647
|
const slots = ctx.get("slots");
|
|
667
648
|
if (slots === void 0) return;
|
|
668
649
|
slots.inject("conversation.session.header.utilities", () => slots.register({
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
interface TimerLike {
|
|
3
3
|
timeout(callback: () => void, delay: number): () => void;
|
|
4
|
-
interval(callback: () => void, delay: number): () => void;
|
|
5
4
|
}
|
|
6
5
|
export declare function bindTimer(t: TimerLike): void;
|
|
6
|
+
export declare function bindLocale(locale: {
|
|
7
|
+
getLocale: () => {
|
|
8
|
+
id?: string;
|
|
9
|
+
};
|
|
10
|
+
subscribe: (fn: () => void) => () => void;
|
|
11
|
+
}): void;
|
|
7
12
|
export declare function ServiceConsoleEntry(): React.ReactElement;
|
|
8
13
|
export declare function ServiceConsolePanel(): React.ReactElement | null;
|
|
9
14
|
export {};
|
package/manifest.json
CHANGED
package/package.json
CHANGED