@unihc/dsh-process-manager 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +59 -2
- package/catalog.js +571 -0
- package/client.js +1537 -0
- package/collector.js +145 -0
- package/cordis.patch.yml +4 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +42 -0
- package/icon.svg +10 -0
- package/index.js +255 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/model.js +481 -0
- package/native.js +863 -0
- package/operations.js +540 -0
- package/package.json +61 -4
package/collector.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalise the raw PowerShell snapshot into plain JSON with stable types.
|
|
3
|
+
* Pure functions: every value is defensive because WMI happily returns null,
|
|
4
|
+
* empty strings, or objects instead of primitives on some Windows builds.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function text(value, max = 2000) {
|
|
8
|
+
if (value === null || value === undefined) return ''
|
|
9
|
+
const result = String(value).trim()
|
|
10
|
+
return result.length > max ? `${result.slice(0, max - 1)}…` : result
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function num(value, fallback = 0) {
|
|
14
|
+
const result = Number(value)
|
|
15
|
+
return Number.isFinite(result) ? result : fallback
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function bool(value) {
|
|
19
|
+
return value === true || value === 1 || value === '1' || value === 'true'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function exeNameOf(path) {
|
|
23
|
+
const value = String(path ?? '')
|
|
24
|
+
const parts = value.split(/[\\/]/)
|
|
25
|
+
return parts[parts.length - 1] || ''
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function normalizeService(raw) {
|
|
29
|
+
return {
|
|
30
|
+
name: text(raw?.n ?? raw?.name, 200),
|
|
31
|
+
display: text(raw?.d ?? raw?.display, 300),
|
|
32
|
+
description: text(raw?.ds ?? raw?.description, 400),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function normalizeProcesses(raw) {
|
|
37
|
+
const list = Array.isArray(raw?.processes) ? raw.processes : []
|
|
38
|
+
const processes = []
|
|
39
|
+
for (const item of list) {
|
|
40
|
+
const pid = num(item?.pid, -1)
|
|
41
|
+
if (!Number.isInteger(pid) || pid < 0) continue
|
|
42
|
+
processes.push({
|
|
43
|
+
pid,
|
|
44
|
+
ppid: num(item?.ppid, 0),
|
|
45
|
+
name: text(item?.name, 260),
|
|
46
|
+
path: text(item?.path, 1000),
|
|
47
|
+
cmdline: text(item?.cmdline, 800),
|
|
48
|
+
company: text(item?.company, 300),
|
|
49
|
+
product: text(item?.product, 300),
|
|
50
|
+
description: text(item?.desc, 400),
|
|
51
|
+
version: text(item?.version, 80),
|
|
52
|
+
started_at: text(item?.started, 64),
|
|
53
|
+
session_id: num(item?.session, 0),
|
|
54
|
+
has_window: bool(item?.window),
|
|
55
|
+
window_title: text(item?.title, 300),
|
|
56
|
+
mem_bytes: Math.max(0, num(item?.mem, 0)),
|
|
57
|
+
cpu_percent: Math.max(0, Math.min(100, num(item?.cpu, 0))),
|
|
58
|
+
services: Array.isArray(item?.svc) ? item.svc.map(normalizeService).filter(service => service.name) : [],
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
return processes
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function normalizeRun(raw) {
|
|
65
|
+
const list = Array.isArray(raw?.run) ? raw.run : []
|
|
66
|
+
return list.map(entry => ({
|
|
67
|
+
source: 'run',
|
|
68
|
+
hive: text(entry?.hive, 8),
|
|
69
|
+
key: text(entry?.key, 24),
|
|
70
|
+
name: text(entry?.name, 300),
|
|
71
|
+
command: text(entry?.cmd, 1200),
|
|
72
|
+
exe_path: text(entry?.exe, 1000),
|
|
73
|
+
publisher: text(entry?.pub, 300),
|
|
74
|
+
approved: text(entry?.approved, 16) || 'enabled',
|
|
75
|
+
raw: text(entry?.raw, 64),
|
|
76
|
+
})).filter(entry => entry.name)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function normalizeFolder(raw) {
|
|
80
|
+
const list = Array.isArray(raw?.folder) ? raw.folder : []
|
|
81
|
+
return list.map(entry => ({
|
|
82
|
+
source: 'folder',
|
|
83
|
+
scope: text(entry?.scope, 12) || 'user',
|
|
84
|
+
file: text(entry?.file, 300),
|
|
85
|
+
path: text(entry?.path, 1200),
|
|
86
|
+
target: text(entry?.target, 1000),
|
|
87
|
+
exe_path: text(entry?.exe, 1000),
|
|
88
|
+
publisher: text(entry?.pub, 300),
|
|
89
|
+
approved: text(entry?.approved, 16) || 'enabled',
|
|
90
|
+
raw: text(entry?.raw, 64),
|
|
91
|
+
})).filter(entry => entry.file)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function normalizeTask(raw) {
|
|
95
|
+
const list = Array.isArray(raw?.tasks) ? raw.tasks : []
|
|
96
|
+
return list.map(entry => ({
|
|
97
|
+
source: 'task',
|
|
98
|
+
path: text(entry?.path, 600),
|
|
99
|
+
name: text(entry?.name, 300),
|
|
100
|
+
state: text(entry?.state, 40),
|
|
101
|
+
triggers: Array.isArray(entry?.triggers) ? entry.triggers.map(item => text(item, 40)).filter(Boolean) : [],
|
|
102
|
+
exec: text(entry?.exec, 1000),
|
|
103
|
+
args: text(entry?.args, 800),
|
|
104
|
+
author: text(entry?.author, 300),
|
|
105
|
+
description: text(entry?.desc, 600),
|
|
106
|
+
hidden: bool(entry?.hidden),
|
|
107
|
+
})).filter(entry => entry.name)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function normalizeAutoService(raw) {
|
|
111
|
+
const list = Array.isArray(raw?.services) ? raw.services : []
|
|
112
|
+
return list.map(entry => ({
|
|
113
|
+
source: 'service',
|
|
114
|
+
name: text(entry?.name, 300),
|
|
115
|
+
display: text(entry?.display, 400),
|
|
116
|
+
state: text(entry?.state, 40),
|
|
117
|
+
start: text(entry?.start, 20),
|
|
118
|
+
pid: num(entry?.pid, 0),
|
|
119
|
+
path: text(entry?.path, 1200),
|
|
120
|
+
exe: text(entry?.exe, 1000),
|
|
121
|
+
publisher: text(entry?.pub, 300),
|
|
122
|
+
description: text(entry?.desc, 800),
|
|
123
|
+
delayed: bool(entry?.delayed),
|
|
124
|
+
type: text(entry?.type, 60),
|
|
125
|
+
})).filter(entry => entry.name)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function normalizeStartup(raw) {
|
|
129
|
+
return {
|
|
130
|
+
run: normalizeRun(raw),
|
|
131
|
+
folder: normalizeFolder(raw),
|
|
132
|
+
tasks: normalizeTask(raw),
|
|
133
|
+
services: normalizeAutoService(raw),
|
|
134
|
+
collected_at: text(raw?.collected_at, 64),
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function normalizeSnapshot(raw) {
|
|
139
|
+
return {
|
|
140
|
+
collected_at: text(raw?.collected_at, 64) || new Date().toISOString(),
|
|
141
|
+
cores: Math.max(1, num(raw?.cores, 1)),
|
|
142
|
+
processes: normalizeProcesses(raw),
|
|
143
|
+
startup: normalizeStartup(raw?.startup),
|
|
144
|
+
}
|
|
145
|
+
}
|
package/cordis.patch.yml
ADDED
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
|
@@ -0,0 +1 @@
|
|
|
1
|
+

|
package/docs/preview.svg
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="300" viewBox="0 0 640 300" fill="none">
|
|
2
|
+
<rect x="52" y="28" width="536" height="244" rx="18" fill="rgba(138,149,163,0.07)" stroke="#8a95a3" stroke-width="1.5"/>
|
|
3
|
+
<circle cx="78" cy="52" r="3.2" fill="#3f9b6b"/>
|
|
4
|
+
<circle cx="90" cy="52" r="3.2" fill="#c9a13f"/>
|
|
5
|
+
<circle cx="102" cy="52" r="3.2" fill="#2f6f9f"/>
|
|
6
|
+
<rect x="76" y="68" width="300" height="20" rx="10" fill="rgba(138,149,163,0.10)" stroke="#a7b0bc" stroke-width="1.2"/>
|
|
7
|
+
<circle cx="90" cy="78" r="3.4" fill="none" stroke="#a7b0bc" stroke-width="1.4"/>
|
|
8
|
+
<path d="M92.6 80.6 96 84" stroke="#a7b0bc" stroke-width="1.4" stroke-linecap="round"/>
|
|
9
|
+
<rect x="106" y="75" width="120" height="6" rx="3" fill="rgba(138,149,163,0.45)"/>
|
|
10
|
+
<rect x="392" y="68" width="78" height="20" rx="10" fill="rgba(47,111,159,0.16)" stroke="#2f6f9f" stroke-width="1.2"/>
|
|
11
|
+
<rect x="480" y="68" width="78" height="20" rx="10" fill="none" stroke="#a7b0bc" stroke-width="1.2"/>
|
|
12
|
+
|
|
13
|
+
<rect x="76" y="102" width="472" height="34" rx="8" fill="rgba(138,149,163,0.05)" stroke="#b7c0ca" stroke-width="1.2"/>
|
|
14
|
+
<circle cx="94" cy="119" r="5" fill="#3f9b6b"/>
|
|
15
|
+
<rect x="108" y="111" width="132" height="6" rx="3" fill="rgba(110,120,134,0.55)"/>
|
|
16
|
+
<rect x="108" y="122" width="86" height="5" rx="2.5" fill="rgba(138,149,163,0.38)"/>
|
|
17
|
+
<rect x="336" y="114" width="42" height="12" rx="6" fill="rgba(63,155,107,0.18)" stroke="#3f9b6b" stroke-width="1"/>
|
|
18
|
+
<rect x="496" y="110" width="34" height="18" rx="9" fill="#3f9b6b"/>
|
|
19
|
+
<circle cx="521" cy="119" r="6" fill="#ffffff"/>
|
|
20
|
+
|
|
21
|
+
<rect x="76" y="146" width="472" height="34" rx="8" fill="rgba(138,149,163,0.05)" stroke="#b7c0ca" stroke-width="1.2"/>
|
|
22
|
+
<circle cx="94" cy="163" r="5" fill="#7d8894"/>
|
|
23
|
+
<rect x="108" y="155" width="104" height="6" rx="3" fill="rgba(110,120,134,0.55)"/>
|
|
24
|
+
<rect x="108" y="166" width="142" height="5" rx="2.5" fill="rgba(138,149,163,0.38)"/>
|
|
25
|
+
<rect x="336" y="158" width="42" height="12" rx="6" fill="rgba(138,149,163,0.16)" stroke="#a7b0bc" stroke-width="1"/>
|
|
26
|
+
<rect x="496" y="154" width="34" height="18" rx="9" fill="rgba(138,149,163,0.35)" stroke="#a7b0bc" stroke-width="1"/>
|
|
27
|
+
<circle cx="505" cy="163" r="6" fill="#ffffff"/>
|
|
28
|
+
|
|
29
|
+
<rect x="76" y="190" width="472" height="34" rx="8" fill="rgba(138,149,163,0.05)" stroke="#b7c0ca" stroke-width="1.2"/>
|
|
30
|
+
<circle cx="94" cy="207" r="5" fill="#2f6f9f"/>
|
|
31
|
+
<rect x="108" y="199" width="156" height="6" rx="3" fill="rgba(110,120,134,0.55)"/>
|
|
32
|
+
<rect x="108" y="210" width="74" height="5" rx="2.5" fill="rgba(138,149,163,0.38)"/>
|
|
33
|
+
<rect x="336" y="202" width="42" height="12" rx="6" fill="rgba(47,111,159,0.16)" stroke="#2f6f9f" stroke-width="1"/>
|
|
34
|
+
<rect x="496" y="198" width="34" height="18" rx="9" fill="#2f6f9f"/>
|
|
35
|
+
<circle cx="521" cy="207" r="6" fill="#ffffff"/>
|
|
36
|
+
|
|
37
|
+
<rect x="76" y="238" width="112" height="18" rx="9" fill="rgba(138,149,163,0.12)"/>
|
|
38
|
+
<rect x="196" y="238" width="92" height="18" rx="9" fill="rgba(138,149,163,0.12)"/>
|
|
39
|
+
<rect x="296" y="238" width="132" height="18" rx="9" fill="rgba(138,149,163,0.12)"/>
|
|
40
|
+
<circle cx="524" cy="247" r="7" fill="none" stroke="#3f9b6b" stroke-width="1.6"/>
|
|
41
|
+
<path d="M520.6 247.2 523 249.4 527.6 244.6" stroke="#3f9b6b" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
+
</svg>
|
package/icon.svg
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
|
|
2
|
+
<circle cx="8" cy="11" r="2" fill="#2f6f9f"/>
|
|
3
|
+
<path d="M13 11h9" stroke="#7d8894" stroke-width="2.6" stroke-linecap="round"/>
|
|
4
|
+
<rect x="25" y="8" width="7" height="6" rx="3" fill="#3f9b6b"/>
|
|
5
|
+
<circle cx="29.4" cy="11" r="1.8" fill="#fff"/>
|
|
6
|
+
<circle cx="8" cy="18" r="2" fill="#7d8894"/>
|
|
7
|
+
<path d="M13 18h16" stroke="#7d8894" stroke-width="2.6" stroke-linecap="round"/>
|
|
8
|
+
<circle cx="8" cy="25" r="2" fill="#7d8894"/>
|
|
9
|
+
<path d="M13 25h11" stroke="#7d8894" stroke-width="2.6" stroke-linecap="round"/>
|
|
10
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process and startup panel for DeepSeek Harness.
|
|
3
|
+
*
|
|
4
|
+
* Commands (panel): snapshot file, inspect, stop (user-confirmed), toggle one
|
|
5
|
+
* startup entry (user-confirmed), AI explanation, open a Windows tool.
|
|
6
|
+
* Tools (agent): read-only list, autostart summary, and one-target inspection.
|
|
7
|
+
* Mutations never run from a tool; the panel always asks the user first.
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
createSnapshotFile, describeSnapshotForTool, explainProcess, getSnapshot, inspectProcess,
|
|
11
|
+
invalidateSnapshot, openTool, renderInspectText, renderSnapshotText, renderStartupText,
|
|
12
|
+
stopTargets, toggleStartup,
|
|
13
|
+
} from './operations.js'
|
|
14
|
+
import { compactStartup } from './model.js'
|
|
15
|
+
import { isWindows } from './native.js'
|
|
16
|
+
|
|
17
|
+
export const inject = ['commands', 'tools', 'llm', 'agentDefaultModel']
|
|
18
|
+
|
|
19
|
+
const busy = new Set()
|
|
20
|
+
|
|
21
|
+
function errorResult(code, message, extra = {}) {
|
|
22
|
+
return { ok: false, code, message, ...extra }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function parsePayload(rawInput) {
|
|
26
|
+
const text = String(rawInput ?? '').trim()
|
|
27
|
+
if (text === '') return {}
|
|
28
|
+
let value
|
|
29
|
+
try {
|
|
30
|
+
value = JSON.parse(text)
|
|
31
|
+
} catch {
|
|
32
|
+
const error = new Error('操作参数不是合法 JSON')
|
|
33
|
+
error.code = 'BAD_ARGS'
|
|
34
|
+
throw error
|
|
35
|
+
}
|
|
36
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
37
|
+
const error = new Error('操作参数必须是对象')
|
|
38
|
+
error.code = 'BAD_ARGS'
|
|
39
|
+
throw error
|
|
40
|
+
}
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isAbort(error, signal) {
|
|
45
|
+
return (signal && signal.aborted) || (error && (error.name === 'AbortError' || error.code === 'ABORTED'))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function sessionIdOf(agent) {
|
|
49
|
+
return agent?.session?.header?.id
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function withSessionLock(sessionId, operation) {
|
|
53
|
+
if (typeof sessionId !== 'string' || sessionId === '') return operation()
|
|
54
|
+
if (busy.has(sessionId)) {
|
|
55
|
+
const error = new Error('该会话已有进程操作正在进行,请稍后再试')
|
|
56
|
+
error.code = 'BUSY'
|
|
57
|
+
throw error
|
|
58
|
+
}
|
|
59
|
+
busy.add(sessionId)
|
|
60
|
+
try {
|
|
61
|
+
return await operation()
|
|
62
|
+
} finally {
|
|
63
|
+
busy.delete(sessionId)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function commandFailure(error, signal) {
|
|
68
|
+
if (isAbort(error, signal)) return errorResult('ABORTED', '操作已取消')
|
|
69
|
+
const extra = {}
|
|
70
|
+
if (Array.isArray(error?.results)) extra.results = error.results
|
|
71
|
+
return errorResult(error?.code ?? 'OP_FAILED', error instanceof Error ? error.message : String(error), extra)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function registerPanelCommand(ctx, definition) {
|
|
75
|
+
ctx.commands.register({
|
|
76
|
+
name: definition.name,
|
|
77
|
+
description: definition.description,
|
|
78
|
+
recordInput: false,
|
|
79
|
+
async handler({ agent, rawInput, signal }) {
|
|
80
|
+
try {
|
|
81
|
+
const result = await definition.run({ agent, payload: parsePayload(rawInput), signal })
|
|
82
|
+
return { kind: 'success', text: JSON.stringify(result) }
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return { kind: 'error', text: JSON.stringify(commandFailure(error, signal)) }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function unsupportedToolResult(lang) {
|
|
91
|
+
return {
|
|
92
|
+
supported: false,
|
|
93
|
+
platform: process.platform,
|
|
94
|
+
message: lang === 'en'
|
|
95
|
+
? 'This tool supports Windows only; the current host is not Windows.'
|
|
96
|
+
: '该工具仅支持 Windows,当前宿主不是 Windows。',
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function apply(ctx) {
|
|
101
|
+
registerPanelCommand(ctx, {
|
|
102
|
+
name: 'process-snapshot',
|
|
103
|
+
description: '采集当前 Windows 进程与开机启动项快照,写入工作区供「进程与启动项」面板读取',
|
|
104
|
+
async run({ agent }) {
|
|
105
|
+
return createSnapshotFile(agent)
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
registerPanelCommand(ctx, {
|
|
110
|
+
name: 'process-inspect',
|
|
111
|
+
description: '只读检查一个进程/可执行文件:版本、发布者、签名、服务、父进程与关联启动项',
|
|
112
|
+
async run({ payload, signal }) {
|
|
113
|
+
return inspectProcess(payload, { signal })
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
registerPanelCommand(ctx, {
|
|
118
|
+
name: 'process-stop',
|
|
119
|
+
description: '结束面板中用户确认过的进程(正常关闭或强制结束整组)',
|
|
120
|
+
async run({ agent, payload, signal }) {
|
|
121
|
+
const sessionId = sessionIdOf(agent)
|
|
122
|
+
return withSessionLock(sessionId, () => stopTargets(payload, {
|
|
123
|
+
signal,
|
|
124
|
+
elevate: payload?.elevate === true,
|
|
125
|
+
}))
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
registerPanelCommand(ctx, {
|
|
130
|
+
name: 'process-startup-set',
|
|
131
|
+
description: '启用或禁用面板中用户确认过的一个开机启动项(Run/启动文件夹/计划任务/服务)',
|
|
132
|
+
async run({ agent, payload, signal }) {
|
|
133
|
+
const sessionId = sessionIdOf(agent)
|
|
134
|
+
return withSessionLock(sessionId, () => toggleStartup(payload, {
|
|
135
|
+
signal,
|
|
136
|
+
elevate: payload?.elevate === true,
|
|
137
|
+
}))
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
registerPanelCommand(ctx, {
|
|
142
|
+
name: 'process-explain',
|
|
143
|
+
description: '让 AI 只读解释一个进程或启动项是什么、干什么用、关掉有什么影响',
|
|
144
|
+
async run({ agent, payload, signal }) {
|
|
145
|
+
const sessionId = sessionIdOf(agent)
|
|
146
|
+
return explainProcess(ctx, payload, { signal, sessionId })
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
registerPanelCommand(ctx, {
|
|
151
|
+
name: 'process-tool',
|
|
152
|
+
description: '打开 Windows 任务管理器 / 启动应用设置 / 服务管理器,或定位文件',
|
|
153
|
+
async run({ payload }) {
|
|
154
|
+
return openTool(payload)
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
ctx.tools.register({
|
|
159
|
+
name: 'process_list',
|
|
160
|
+
description: 'Read-only Windows process snapshot grouped by application: label, publisher, purpose, memory, CPU, PIDs and whether the app is started by an autostart entry. Use it to answer which processes are running and what they are. It never stops a process; stopping and autostart changes are user-only actions in the Processes and startup panel.',
|
|
161
|
+
parameters: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
additionalProperties: false,
|
|
164
|
+
properties: {
|
|
165
|
+
query: { type: 'string', description: 'Optional case-insensitive filter over app name, publisher, purpose or PID.' },
|
|
166
|
+
sort: { type: 'string', enum: ['memory', 'cpu', 'name'], description: 'Sort order. Defaults to memory.' },
|
|
167
|
+
limit: { type: 'number', description: 'Maximum groups to return (1-120). Defaults to 40.' },
|
|
168
|
+
lang: { type: 'string', enum: ['zh', 'en'], description: 'Language for the rendered text. Defaults to zh.' },
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
output: {
|
|
172
|
+
schema: { type: 'object', properties: {}, additionalProperties: true },
|
|
173
|
+
render(args, value) {
|
|
174
|
+
if (value?.supported === false) return [{ type: 'text', text: value.message }]
|
|
175
|
+
return [{ type: 'text', text: renderSnapshotText(value, args?.lang) }]
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
timeoutMs: 90000,
|
|
179
|
+
async execute(args, exec) {
|
|
180
|
+
if (!isWindows()) return unsupportedToolResult(args?.lang)
|
|
181
|
+
const snapshot = await getSnapshot()
|
|
182
|
+
return describeSnapshotForTool(snapshot, {
|
|
183
|
+
query: typeof args?.query === 'string' ? args.query : '',
|
|
184
|
+
sort: args?.sort === 'cpu' || args?.sort === 'name' ? args.sort : 'memory',
|
|
185
|
+
limit: Number(args?.limit ?? 40),
|
|
186
|
+
lang: args?.lang,
|
|
187
|
+
})
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
ctx.tools.register({
|
|
192
|
+
name: 'process_autostart',
|
|
193
|
+
description: 'Read-only Windows startup inventory: registry Run entries, Startup-folder shortcuts, logon/boot scheduled tasks and automatic services, each with enabled state, publisher, purpose and whether it is running now. It never enables or disables anything; that is a user-only action in the Processes and startup panel.',
|
|
194
|
+
parameters: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
additionalProperties: false,
|
|
197
|
+
properties: {
|
|
198
|
+
source: { type: 'string', enum: ['all', 'run', 'folder', 'task', 'service'], description: 'Restrict to one kind of startup entry. Defaults to all.' },
|
|
199
|
+
includeSystem: { type: 'boolean', description: 'Include Windows-owned tasks and services. Defaults to false.' },
|
|
200
|
+
lang: { type: 'string', enum: ['zh', 'en'], description: 'Language for the rendered text. Defaults to zh.' },
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
output: {
|
|
204
|
+
schema: { type: 'object', properties: {}, additionalProperties: true },
|
|
205
|
+
render(args, value) {
|
|
206
|
+
if (value?.supported === false) return [{ type: 'text', text: value.message }]
|
|
207
|
+
return [{ type: 'text', text: renderStartupText(value, args?.lang) }]
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
timeoutMs: 90000,
|
|
211
|
+
async execute(args, exec) {
|
|
212
|
+
if (!isWindows()) return unsupportedToolResult(args?.lang)
|
|
213
|
+
const snapshot = await getSnapshot()
|
|
214
|
+
const source = ['run', 'folder', 'task', 'service'].includes(args?.source) ? args.source : 'all'
|
|
215
|
+
const compact = compactStartup(snapshot, { includeSystem: args?.includeSystem === true })
|
|
216
|
+
if (source !== 'all') compact.entries = compact.entries.filter(entry => entry.source === source)
|
|
217
|
+
return compact
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
ctx.tools.register({
|
|
222
|
+
name: 'process_inspect',
|
|
223
|
+
description: 'Read-only inspection of one Windows process or executable: path, publisher, product, version, Authenticode signature, command line, parent chain, hosted services and matching startup entries, plus a curated purpose and risk. It never stops anything.',
|
|
224
|
+
parameters: {
|
|
225
|
+
type: 'object',
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
properties: {
|
|
228
|
+
pid: { type: 'number', description: 'Process ID to inspect.' },
|
|
229
|
+
name: { type: 'string', description: 'Executable name such as chrome.exe; the first running match is used.' },
|
|
230
|
+
path: { type: 'string', description: 'Absolute executable path to inspect instead of a process.' },
|
|
231
|
+
lang: { type: 'string', enum: ['zh', 'en'], description: 'Language for the rendered text. Defaults to zh.' },
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
output: {
|
|
235
|
+
schema: { type: 'object', properties: {}, additionalProperties: true },
|
|
236
|
+
render(args, value) {
|
|
237
|
+
if (value?.supported === false) return [{ type: 'text', text: value.message }]
|
|
238
|
+
return [{ type: 'text', text: renderInspectText(value, args?.lang) }]
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
timeoutMs: 90000,
|
|
242
|
+
async execute(args, exec) {
|
|
243
|
+
if (!isWindows()) return unsupportedToolResult(args?.lang)
|
|
244
|
+
return inspectProcess({
|
|
245
|
+
pid: Number(args?.pid ?? 0),
|
|
246
|
+
name: args?.name,
|
|
247
|
+
path: args?.path,
|
|
248
|
+
}, { signal: exec.signal })
|
|
249
|
+
},
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
// The snapshot cache is a derived cache; clearing it on unload keeps the
|
|
253
|
+
// module re-load path from serving a snapshot taken by a previous generation.
|
|
254
|
+
ctx.effect(() => () => invalidateSnapshot(), 'process-manager: snapshot cache')
|
|
255
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Processes and startup",
|
|
4
|
+
"description": "A persistent right-sidebar panel for Windows processes and startup entries: running processes grouped by app with a plain-language purpose, publisher, path, hosted services and matching startup entries, plus registry Run keys, Startup-folder shortcuts, logon/boot scheduled tasks and automatic services with their enabled and running state. Stopping a process or changing an entry always asks the user in the panel; disabling an entry uses the same reversible StartupApproved flag as Task Manager and asks for UAC when Windows requires it. Windows 10/11 only. Sampling is read-only and the snapshot is written to process-reports/ in the workspace; clicking “Explain with AI” sends one read-only fact request to the configured model. UWP startup tasks, Windows-owned tasks/services and kernel drivers stay read-only.",
|
|
5
|
+
"detail": "docs/DETAIL.md"
|
|
6
|
+
}
|
|
7
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "进程与启动项",
|
|
4
|
+
"description": "右侧栏常驻的 Windows 进程与启动项面板:按应用分组展示正在运行的进程,给出中文用途说明、发布者、路径、托管的系统服务与关联启动项;另外列出注册表 Run、启动文件夹、登录/开机计划任务和自动启动服务,并标出当前是否启用、是否正在运行。结束进程和启停自启都需要在面板里二次确认;禁用自启使用与任务管理器相同的可逆 StartupApproved 开关,需要管理员权限时弹出 UAC。仅支持 Windows 10/11。采样只读,快照写入工作区 process-reports/;点击「AI 解读」会向当前模型发送一次只读事实请求。UWP 商店启动任务、Windows 自带任务与系统服务、内核驱动保持只读,不在面板里修改。",
|
|
5
|
+
"detail": "docs/DETAIL.zh.md"
|
|
6
|
+
}
|
|
7
|
+
}
|