aws-runtime-bridge 1.9.2 → 1.9.6
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/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -0
- package/dist/index.js +28 -4
- package/dist/middleware/auth.d.ts +8 -0
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +44 -0
- package/dist/routes/dashboard.d.ts +8 -0
- package/dist/routes/dashboard.d.ts.map +1 -0
- package/dist/routes/dashboard.js +1347 -0
- package/dist/routes/instance.d.ts +1 -0
- package/dist/routes/instance.d.ts.map +1 -1
- package/dist/routes/instance.js +53 -4
- package/dist/routes/instance.test.js +4 -0
- package/dist/routes/processes.js +1 -1
- package/dist/routes/runtime-binding.d.ts.map +1 -1
- package/dist/routes/runtime-binding.js +37 -0
- package/dist/routes/sessions.js +7 -7
- package/dist/routes/terminal.d.ts.map +1 -1
- package/dist/routes/terminal.js +137 -33
- package/dist/services/agent-process-manager.d.ts +12 -0
- package/dist/services/agent-process-manager.d.ts.map +1 -1
- package/dist/services/agent-process-manager.js +47 -13
- package/dist/services/orphan-monitor.js +2 -2
- package/dist/services/panel-auth.d.ts +26 -0
- package/dist/services/panel-auth.d.ts.map +1 -0
- package/dist/services/panel-auth.js +105 -0
- package/dist/services/process-detector.d.ts +16 -9
- package/dist/services/process-detector.d.ts.map +1 -1
- package/dist/services/process-detector.js +136 -66
- package/dist/services/session-output.d.ts.map +1 -1
- package/dist/services/session-output.js +106 -6
- package/package.json +1 -1
|
@@ -93,29 +93,35 @@ export class AgentProcessManager {
|
|
|
93
93
|
async discoverAllProcesses() {
|
|
94
94
|
log.debug('[discoverAllProcesses] Scanning for all agent processes');
|
|
95
95
|
// Get all processes from OS
|
|
96
|
-
const osProcesses = findClaudeCodeProcesses();
|
|
96
|
+
const osProcesses = await findClaudeCodeProcesses();
|
|
97
97
|
const managedProcesses = this.registry.getAll();
|
|
98
98
|
const discovered = [];
|
|
99
99
|
// Create a set of managed PIDs for quick lookup
|
|
100
100
|
const managedPids = new Set(managedProcesses.map(p => p.pid));
|
|
101
101
|
const managedAgentIds = new Set(managedProcesses.map(p => p.agentId));
|
|
102
|
+
const pidToRecord = new Map(managedProcesses.map(p => [p.pid, p]));
|
|
102
103
|
// Check each OS process
|
|
103
104
|
for (const proc of osProcesses) {
|
|
104
105
|
const isManagedByPid = managedPids.has(proc.pid);
|
|
105
106
|
const isManagedByAgentId = proc.agentId && managedAgentIds.has(proc.agentId);
|
|
107
|
+
const recordByPid = pidToRecord.get(proc.pid);
|
|
108
|
+
// ★ 关键修复:当命令行中无法提取 agentId 但 PID 匹配注册表时,继承注册表的 agentId
|
|
109
|
+
const resolvedAgentId = proc.agentId || recordByPid?.agentId;
|
|
106
110
|
if (isManagedByPid || isManagedByAgentId) {
|
|
107
111
|
// Process is managed - find its record
|
|
108
|
-
const record = managedProcesses.find(p => p.pid === proc.pid || p.agentId === proc.agentId);
|
|
112
|
+
const record = managedProcesses.find(p => p.pid === proc.pid || p.agentId === proc.agentId || p.agentId === resolvedAgentId);
|
|
109
113
|
discovered.push({
|
|
110
114
|
...proc,
|
|
115
|
+
agentId: resolvedAgentId,
|
|
111
116
|
managementStatus: 'managed',
|
|
112
117
|
sessionId: record?.sessionId,
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
|
-
else if (
|
|
120
|
+
else if (resolvedAgentId) {
|
|
116
121
|
// Process has agentId but not in registry - it's an orphan
|
|
117
122
|
discovered.push({
|
|
118
123
|
...proc,
|
|
124
|
+
agentId: resolvedAgentId,
|
|
119
125
|
managementStatus: 'orphan',
|
|
120
126
|
});
|
|
121
127
|
}
|
|
@@ -123,6 +129,7 @@ export class AgentProcessManager {
|
|
|
123
129
|
// Unknown agent process
|
|
124
130
|
discovered.push({
|
|
125
131
|
...proc,
|
|
132
|
+
agentId: resolvedAgentId,
|
|
126
133
|
managementStatus: 'unknown',
|
|
127
134
|
});
|
|
128
135
|
}
|
|
@@ -296,7 +303,7 @@ export class AgentProcessManager {
|
|
|
296
303
|
}
|
|
297
304
|
// Level 3: Terminate process tree
|
|
298
305
|
log.debug(`[stopProcess] Level 3: Terminating process tree for pid=${pid}`);
|
|
299
|
-
const treeResult = terminateProcessTree(pid);
|
|
306
|
+
const treeResult = await terminateProcessTree(pid);
|
|
300
307
|
// Wait for process tree to terminate
|
|
301
308
|
const treeExited = await waitForProcessExit(pid, 5000);
|
|
302
309
|
if (treeExited) {
|
|
@@ -396,7 +403,7 @@ export class AgentProcessManager {
|
|
|
396
403
|
// Update state
|
|
397
404
|
await this.registry.update(agentId, { state: 'stopping' });
|
|
398
405
|
// Direct process tree termination
|
|
399
|
-
const result = terminateProcessTree(pid);
|
|
406
|
+
const result = await terminateProcessTree(pid);
|
|
400
407
|
// Wait briefly for termination
|
|
401
408
|
const exited = await waitForProcessExit(pid, 2000);
|
|
402
409
|
if (exited) {
|
|
@@ -452,7 +459,7 @@ export class AgentProcessManager {
|
|
|
452
459
|
};
|
|
453
460
|
}
|
|
454
461
|
// Find orphan process
|
|
455
|
-
const orphan = findOrphanProcessByAgentId(agentId);
|
|
462
|
+
const orphan = await findOrphanProcessByAgentId(agentId);
|
|
456
463
|
if (!orphan) {
|
|
457
464
|
log.warn(`[reclaimOrphan] No orphan process found: agentId=${agentId}`);
|
|
458
465
|
return {
|
|
@@ -491,7 +498,7 @@ export class AgentProcessManager {
|
|
|
491
498
|
return { success: true, pid: orphan.pid, action: 'adopted' };
|
|
492
499
|
}
|
|
493
500
|
catch {
|
|
494
|
-
terminateProcessTree(orphan.pid);
|
|
501
|
+
await terminateProcessTree(orphan.pid);
|
|
495
502
|
return { success: false, pid: orphan.pid, action: 'terminated' };
|
|
496
503
|
}
|
|
497
504
|
}
|
|
@@ -506,7 +513,7 @@ export class AgentProcessManager {
|
|
|
506
513
|
}
|
|
507
514
|
// Different agent - this is a conflict, terminate the orphan
|
|
508
515
|
log.warn(`[reclaimOrphan] Terminating conflicting orphan: agentId=${agentId}, pid=${orphan.pid}`);
|
|
509
|
-
terminateProcessTree(orphan.pid);
|
|
516
|
+
await terminateProcessTree(orphan.pid);
|
|
510
517
|
return {
|
|
511
518
|
success: true,
|
|
512
519
|
pid: orphan.pid,
|
|
@@ -540,7 +547,7 @@ export class AgentProcessManager {
|
|
|
540
547
|
catch (error) {
|
|
541
548
|
log.error(`[reclaimOrphan] Failed to adopt orphan: agentId=${agentId}, pid=${orphan.pid}`, error);
|
|
542
549
|
// If adoption fails, terminate the process
|
|
543
|
-
terminateProcessTree(orphan.pid);
|
|
550
|
+
await terminateProcessTree(orphan.pid);
|
|
544
551
|
return {
|
|
545
552
|
success: false,
|
|
546
553
|
pid: orphan.pid,
|
|
@@ -559,7 +566,7 @@ export class AgentProcessManager {
|
|
|
559
566
|
// Load persisted sessions to find potential orphans
|
|
560
567
|
const sessions = await loadPersistedSessions();
|
|
561
568
|
// Find all agent processes
|
|
562
|
-
const allProcesses = findClaudeCodeProcesses();
|
|
569
|
+
const allProcesses = await findClaudeCodeProcesses();
|
|
563
570
|
const managedPids = new Set(this.registry.getAll().map(p => p.pid));
|
|
564
571
|
// Identify orphan processes
|
|
565
572
|
const orphans = allProcesses.filter(proc => {
|
|
@@ -578,7 +585,7 @@ export class AgentProcessManager {
|
|
|
578
585
|
if (!orphan.agentId) {
|
|
579
586
|
// No agentId - can't reclaim, just terminate
|
|
580
587
|
log.warn(`[scanAndReclaimAll] Orphan without agentId, terminating: pid=${orphan.pid}`);
|
|
581
|
-
terminateProcessTree(orphan.pid);
|
|
588
|
+
await terminateProcessTree(orphan.pid);
|
|
582
589
|
results.push({
|
|
583
590
|
agentId: 'unknown',
|
|
584
591
|
pid: orphan.pid,
|
|
@@ -596,7 +603,7 @@ export class AgentProcessManager {
|
|
|
596
603
|
// Also check persisted sessions for orphans that might not be in the process list
|
|
597
604
|
for (const session of sessions) {
|
|
598
605
|
if (session.agentId && !this.registry.isManaged(session.agentId)) {
|
|
599
|
-
const orphanByAgentId = findOrphanProcessByAgentId(session.agentId);
|
|
606
|
+
const orphanByAgentId = await findOrphanProcessByAgentId(session.agentId);
|
|
600
607
|
if (orphanByAgentId) {
|
|
601
608
|
const result = await this.reclaimOrphan(session.agentId);
|
|
602
609
|
// Avoid duplicates
|
|
@@ -659,7 +666,7 @@ export class AgentProcessManager {
|
|
|
659
666
|
* @returns Array of unmanaged process info
|
|
660
667
|
*/
|
|
661
668
|
async getUnmanagedProcesses() {
|
|
662
|
-
const allProcesses = findClaudeCodeProcesses();
|
|
669
|
+
const allProcesses = await findClaudeCodeProcesses();
|
|
663
670
|
const managedPids = new Set(this.registry.getAll().map(p => p.pid));
|
|
664
671
|
const managedAgentIds = new Set(this.registry.getAll().map(p => p.agentId));
|
|
665
672
|
return allProcesses.filter(proc => {
|
|
@@ -722,6 +729,33 @@ export class AgentProcessManager {
|
|
|
722
729
|
getStats() {
|
|
723
730
|
return this.registry.getStats();
|
|
724
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Clean up stale registry entries
|
|
734
|
+
*
|
|
735
|
+
* Removes records where:
|
|
736
|
+
* - state is 'terminated' or 'unknown'
|
|
737
|
+
* - the process is no longer running
|
|
738
|
+
*
|
|
739
|
+
* This prevents dead entries from accumulating and inflating counts.
|
|
740
|
+
*
|
|
741
|
+
* @returns Number of entries removed
|
|
742
|
+
*/
|
|
743
|
+
async cleanupStaleRegistry() {
|
|
744
|
+
const allRecords = this.registry.getAll();
|
|
745
|
+
let removed = 0;
|
|
746
|
+
for (const record of allRecords) {
|
|
747
|
+
if ((record.state === 'terminated' || record.state === 'unknown') &&
|
|
748
|
+
!isProcessRunning(record.pid)) {
|
|
749
|
+
await this.registry.remove(record.agentId);
|
|
750
|
+
removed++;
|
|
751
|
+
log.debug(`[cleanupStaleRegistry] Removed stale entry: agentId=${record.agentId}, pid=${record.pid}, state=${record.state}`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
if (removed > 0) {
|
|
755
|
+
log.info(`[cleanupStaleRegistry] Cleaned up ${removed} stale registry entries`);
|
|
756
|
+
}
|
|
757
|
+
return removed;
|
|
758
|
+
}
|
|
725
759
|
/**
|
|
726
760
|
* Remove a process from registry
|
|
727
761
|
*
|
|
@@ -73,7 +73,7 @@ export class OrphanMonitor {
|
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
// 检测孤儿进程
|
|
76
|
-
const orphans = detectOrphanProcesses(persistedSessions.map(s => ({
|
|
76
|
+
const orphans = await detectOrphanProcesses(persistedSessions.map(s => ({
|
|
77
77
|
agentId: s.agentId,
|
|
78
78
|
pid: s.pid,
|
|
79
79
|
workspacePath: s.workspacePath,
|
|
@@ -190,7 +190,7 @@ export class OrphanMonitor {
|
|
|
190
190
|
async autoCleanOrphan(agentId, pid) {
|
|
191
191
|
logger.info(`自动清理孤儿进程:agentId=${agentId}, pid=${pid}`);
|
|
192
192
|
// 使用进程树终止
|
|
193
|
-
const result = terminateProcessTree(pid);
|
|
193
|
+
const result = await terminateProcessTree(pid);
|
|
194
194
|
// 等待进程完全终止(最多 5 秒)
|
|
195
195
|
const exited = await waitForProcessExit(pid, 5000);
|
|
196
196
|
if (result.terminated > 0 && exited) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge 面板登录认证服务
|
|
3
|
+
*
|
|
4
|
+
* 管理面板登录凭据与会话,凭据读取自 ~/.aws-bridge/config.json,
|
|
5
|
+
* panelUsername/panelPassword 字段均不配置时默认 root/root。
|
|
6
|
+
*
|
|
7
|
+
* 会话使用服务端内存存储 + HttpOnly Cookie 实现,无需外部依赖。
|
|
8
|
+
*/
|
|
9
|
+
/** 生成一个新会话并返回会话 token */
|
|
10
|
+
export declare function createSession(): string;
|
|
11
|
+
/** 校验会话 token 是否有效;通过后更新最后使用时间 */
|
|
12
|
+
export declare function validateSession(token: string | undefined | null): boolean;
|
|
13
|
+
/** 销毁指定会话(登出) */
|
|
14
|
+
export declare function destroySession(token: string): void;
|
|
15
|
+
interface PanelCredentials {
|
|
16
|
+
username: string;
|
|
17
|
+
password: string;
|
|
18
|
+
}
|
|
19
|
+
/** 获取面板登录凭据,未配置时返回默认值 root/root */
|
|
20
|
+
export declare function getPanelCredentials(): PanelCredentials;
|
|
21
|
+
/** 校验用户名密码 */
|
|
22
|
+
export declare function validateCredentials(username: string, password: string): boolean;
|
|
23
|
+
/** 清除凭据缓存(配置文件变更后调用) */
|
|
24
|
+
export declare function clearCredentialsCache(): void;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=panel-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-auth.d.ts","sourceRoot":"","sources":["../../src/services/panel-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwCH,yBAAyB;AACzB,wBAAgB,aAAa,IAAI,MAAM,CAMtC;AAED,kCAAkC;AAClC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAWzE;AAED,iBAAiB;AACjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAElD;AAID,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA0BD,mCAAmC;AACnC,wBAAgB,mBAAmB,IAAI,gBAAgB,CAWtD;AAED,cAAc;AACd,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAGT;AAED,wBAAwB;AACxB,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge 面板登录认证服务
|
|
3
|
+
*
|
|
4
|
+
* 管理面板登录凭据与会话,凭据读取自 ~/.aws-bridge/config.json,
|
|
5
|
+
* panelUsername/panelPassword 字段均不配置时默认 root/root。
|
|
6
|
+
*
|
|
7
|
+
* 会话使用服务端内存存储 + HttpOnly Cookie 实现,无需外部依赖。
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { logger } from "../utils/logger.js";
|
|
14
|
+
const SESSION_TTL_MS = 24 * 60 * 60 * 1000; // 24 小时
|
|
15
|
+
const SESSION_CLEANUP_INTERVAL_MS = 60 * 60 * 1000; // 每小时清理一次
|
|
16
|
+
const sessions = new Map();
|
|
17
|
+
let cleanupTimer = null;
|
|
18
|
+
function startCleanupTimer() {
|
|
19
|
+
if (cleanupTimer)
|
|
20
|
+
return;
|
|
21
|
+
cleanupTimer = setInterval(() => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
let expired = 0;
|
|
24
|
+
for (const [token, session] of sessions) {
|
|
25
|
+
if (now - session.lastUsedAt > SESSION_TTL_MS) {
|
|
26
|
+
sessions.delete(token);
|
|
27
|
+
expired++;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (expired > 0) {
|
|
31
|
+
logger.info(`[panel-auth] 已清理 ${expired} 个过期面板会话`);
|
|
32
|
+
}
|
|
33
|
+
}, SESSION_CLEANUP_INTERVAL_MS);
|
|
34
|
+
cleanupTimer.unref();
|
|
35
|
+
}
|
|
36
|
+
/** 生成一个新会话并返回会话 token */
|
|
37
|
+
export function createSession() {
|
|
38
|
+
startCleanupTimer();
|
|
39
|
+
const token = randomUUID();
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
sessions.set(token, { token, createdAt: now, lastUsedAt: now });
|
|
42
|
+
return token;
|
|
43
|
+
}
|
|
44
|
+
/** 校验会话 token 是否有效;通过后更新最后使用时间 */
|
|
45
|
+
export function validateSession(token) {
|
|
46
|
+
if (!token)
|
|
47
|
+
return false;
|
|
48
|
+
const session = sessions.get(token);
|
|
49
|
+
if (!session)
|
|
50
|
+
return false;
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
if (now - session.lastUsedAt > SESSION_TTL_MS) {
|
|
53
|
+
sessions.delete(token);
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
session.lastUsedAt = now;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
/** 销毁指定会话(登出) */
|
|
60
|
+
export function destroySession(token) {
|
|
61
|
+
sessions.delete(token);
|
|
62
|
+
}
|
|
63
|
+
let cachedCredentials = null;
|
|
64
|
+
function getConfigFilePath() {
|
|
65
|
+
return path.join(os.homedir(), ".aws-bridge", "config.json");
|
|
66
|
+
}
|
|
67
|
+
function readCredentialsFromConfig() {
|
|
68
|
+
const configPath = getConfigFilePath();
|
|
69
|
+
if (!existsSync(configPath))
|
|
70
|
+
return null;
|
|
71
|
+
try {
|
|
72
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
73
|
+
const parsed = JSON.parse(raw);
|
|
74
|
+
const username = String(parsed.panelUsername || "").trim();
|
|
75
|
+
const password = String(parsed.panelPassword || "").trim();
|
|
76
|
+
if (username && password) {
|
|
77
|
+
return { username, password };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// 配置不可读时回退到默认值
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/** 获取面板登录凭据,未配置时返回默认值 root/root */
|
|
86
|
+
export function getPanelCredentials() {
|
|
87
|
+
if (cachedCredentials)
|
|
88
|
+
return cachedCredentials;
|
|
89
|
+
const fromConfig = readCredentialsFromConfig();
|
|
90
|
+
if (fromConfig) {
|
|
91
|
+
cachedCredentials = fromConfig;
|
|
92
|
+
return fromConfig;
|
|
93
|
+
}
|
|
94
|
+
cachedCredentials = { username: "root", password: "root" };
|
|
95
|
+
return cachedCredentials;
|
|
96
|
+
}
|
|
97
|
+
/** 校验用户名密码 */
|
|
98
|
+
export function validateCredentials(username, password) {
|
|
99
|
+
const creds = getPanelCredentials();
|
|
100
|
+
return username === creds.username && password === creds.password;
|
|
101
|
+
}
|
|
102
|
+
/** 清除凭据缓存(配置文件变更后调用) */
|
|
103
|
+
export function clearCredentialsCache() {
|
|
104
|
+
cachedCredentials = null;
|
|
105
|
+
}
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 用于检测孤儿进程(当 runtime-bridge 异常关闭后仍在运行的 Agent 进程)
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* 异步检测进程是否存活(防止阻塞事件循环)
|
|
8
|
+
*
|
|
9
|
+
* @param pid 进程 ID
|
|
10
|
+
* @returns 是否存活
|
|
11
|
+
*/
|
|
12
|
+
export declare function isProcessRunningAsync(pid: number): Promise<boolean>;
|
|
6
13
|
/**
|
|
7
14
|
* 检测进程是否存活
|
|
8
15
|
*
|
|
@@ -25,7 +32,7 @@ export interface ProcessInfo {
|
|
|
25
32
|
*
|
|
26
33
|
* @returns 匹配的进程列表
|
|
27
34
|
*/
|
|
28
|
-
export declare function findClaudeCodeProcesses(): ProcessInfo[]
|
|
35
|
+
export declare function findClaudeCodeProcesses(): Promise<ProcessInfo[]>;
|
|
29
36
|
/**
|
|
30
37
|
* 根据 agentId 查找孤儿进程
|
|
31
38
|
*
|
|
@@ -37,7 +44,7 @@ export declare function findClaudeCodeProcesses(): ProcessInfo[];
|
|
|
37
44
|
* @param agentId Agent ID
|
|
38
45
|
* @returns 进程信息或 undefined
|
|
39
46
|
*/
|
|
40
|
-
export declare function findOrphanProcessByAgentId(agentId: string): ProcessInfo | undefined
|
|
47
|
+
export declare function findOrphanProcessByAgentId(agentId: string): Promise<ProcessInfo | undefined>;
|
|
41
48
|
/**
|
|
42
49
|
* 通过工作目录路径查找孤儿进程
|
|
43
50
|
*
|
|
@@ -50,7 +57,7 @@ export declare function findOrphanProcessByAgentId(agentId: string): ProcessInfo
|
|
|
50
57
|
* @param workspacePath 工作目录路径
|
|
51
58
|
* @returns 匹配的进程信息或 undefined
|
|
52
59
|
*/
|
|
53
|
-
export declare function findOrphanProcessByWorkspace(workspacePath: string): ProcessInfo | undefined
|
|
60
|
+
export declare function findOrphanProcessByWorkspace(workspacePath: string): Promise<ProcessInfo | undefined>;
|
|
54
61
|
/**
|
|
55
62
|
* 根据 PID 终止进程
|
|
56
63
|
*
|
|
@@ -68,10 +75,10 @@ export declare function terminateProcess(pid: number): boolean;
|
|
|
68
75
|
* @param pid 进程 ID
|
|
69
76
|
* @returns { terminated: 成功终止的进程数,failed: 失败的进程数 }
|
|
70
77
|
*/
|
|
71
|
-
export declare function terminateProcessTree(pid: number): {
|
|
78
|
+
export declare function terminateProcessTree(pid: number): Promise<{
|
|
72
79
|
terminated: number;
|
|
73
80
|
failed: number;
|
|
74
|
-
}
|
|
81
|
+
}>;
|
|
75
82
|
/**
|
|
76
83
|
* 等待进程完全终止(轮询检测)
|
|
77
84
|
*
|
|
@@ -97,14 +104,14 @@ export declare function detectOrphanProcesses(persistedSessions: Array<{
|
|
|
97
104
|
pid?: number;
|
|
98
105
|
workspacePath?: string;
|
|
99
106
|
command?: string;
|
|
100
|
-
}>): Array<{
|
|
107
|
+
}>): Promise<Array<{
|
|
101
108
|
agentId: string;
|
|
102
109
|
process: ProcessInfo;
|
|
103
110
|
sessionInfo: {
|
|
104
111
|
workspacePath?: string;
|
|
105
112
|
command?: string;
|
|
106
113
|
};
|
|
107
|
-
}
|
|
114
|
+
}>>;
|
|
108
115
|
/**
|
|
109
116
|
* 进程健康状态
|
|
110
117
|
*/
|
|
@@ -159,7 +166,7 @@ export interface DiscoveredProcessInfo extends ProcessInfo {
|
|
|
159
166
|
* @param managedPids 已知被管理的 PID 集合(来自 ProcessRegistry)
|
|
160
167
|
* @returns 发现的进程列表
|
|
161
168
|
*/
|
|
162
|
-
export declare function discoverAllProcesses(managedPids?: Set<number>, managedAgentIds?: Set<string>): DiscoveredProcessInfo[]
|
|
169
|
+
export declare function discoverAllProcesses(managedPids?: Set<number>, managedAgentIds?: Set<string>): Promise<DiscoveredProcessInfo[]>;
|
|
163
170
|
/**
|
|
164
171
|
* 批量发现:扫描所有进程并补充注册表中缺失的进程状态
|
|
165
172
|
*
|
|
@@ -169,5 +176,5 @@ export declare function discoverAllProcesses(managedPids?: Set<number>, managedA
|
|
|
169
176
|
export declare function discoverAllProcessesFull(registryExport: Array<{
|
|
170
177
|
agentId: string;
|
|
171
178
|
pid: number;
|
|
172
|
-
}>): DiscoveredProcessInfo[]
|
|
179
|
+
}>): Promise<DiscoveredProcessInfo[]>;
|
|
173
180
|
//# sourceMappingURL=process-detector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-detector.d.ts","sourceRoot":"","sources":["../../src/services/process-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"process-detector.d.ts","sourceRoot":"","sources":["../../src/services/process-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuDH;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBrD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAkBtE;AAmOD;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAkBlG;AA4TD;;;;;;;;;;;GAWG;AACH,wBAAsB,4BAA4B,CAAC,aA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