aws-runtime-bridge 1.9.92 → 1.9.93
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/adapter/AcodeSdkAdapter.d.ts +22 -126
- package/dist/adapter/AdapterRegistry.d.ts +10 -38
- package/dist/adapter/ClaudeSdkAdapter.d.ts +21 -84
- package/dist/adapter/CodexSdkAdapter.d.ts +2 -10
- package/dist/adapter/OpencodeSdkAdapter.d.ts +6 -42
- package/dist/adapter/acode-tool-names.d.ts +3 -12
- package/dist/adapter/idle-poll-loop.d.ts +4 -16
- package/dist/adapter/index.d.ts +1 -4
- package/dist/adapter/instance-ai-config-resolver.d.ts +9 -29
- package/dist/adapter/types.d.ts +124 -242
- package/dist/adapters/cc-switch/common.d.ts +4 -14
- package/dist/adapters/cc-switch/index.d.ts +3 -11
- package/dist/adapters/cc-switch/mcp-acode.d.ts +1 -7
- package/dist/adapters/cc-switch/mcp-claude.d.ts +1 -5
- package/dist/adapters/cc-switch/mcp-claudecode.d.ts +1 -5
- package/dist/adapters/cc-switch/mcp-codex.d.ts +1 -7
- package/dist/adapters/cc-switch/mcp-opencode.d.ts +3 -11
- package/dist/adapters/cc-switch/mcp-placeholder.d.ts +1 -5
- package/dist/adapters/cc-switch/skill-acode.d.ts +1 -6
- package/dist/adapters/cc-switch/skill-claude.d.ts +1 -5
- package/dist/adapters/cc-switch/skill-claudecode.d.ts +1 -5
- package/dist/adapters/cc-switch/skill-opencode.d.ts +1 -5
- package/dist/adapters/cc-switch/skill-placeholder.d.ts +1 -5
- package/dist/config.d.ts +39 -57
- package/dist/index.d.ts +1 -5
- package/dist/middleware/auth.d.ts +4 -22
- package/dist/routes/acode-todos.d.ts +1 -9
- package/dist/routes/dashboard.d.ts +1 -6
- package/dist/routes/events.d.ts +1 -5
- package/dist/routes/file-browser.d.ts +2 -8
- package/dist/routes/file-diff-rollback.d.ts +13 -41
- package/dist/routes/file-snapshot.d.ts +1 -8
- package/dist/routes/git.d.ts +18 -91
- package/dist/routes/instance.d.ts +4 -15
- package/dist/routes/processes.d.ts +1 -5
- package/dist/routes/properties.d.ts +1 -5
- package/dist/routes/pty.d.ts +9 -36
- package/dist/routes/runtime-binding.d.ts +1 -4
- package/dist/routes/sessions.d.ts +2 -9
- package/dist/routes/sub-agents.d.ts +1 -12
- package/dist/routes/task-context.d.ts +1 -6
- package/dist/routes/terminal.d.ts +18 -92
- package/dist/routes/yml.d.ts +1 -5
- package/dist/services/acode-package.d.ts +2 -12
- package/dist/services/agent-event-store.d.ts +6 -26
- package/dist/services/agent-process-manager.d.ts +30 -184
- package/dist/services/ai-source-apply.d.ts +1 -3
- package/dist/services/auto-register.d.ts +29 -106
- package/dist/services/bridge-package-publish-hooks.d.ts +5 -19
- package/dist/services/cc-switch-sdk.d.ts +1 -6
- package/dist/services/cli-commands.d.ts +12 -33
- package/dist/services/event-delta-pusher.d.ts +5 -20
- package/dist/services/fileSnapshotStore.d.ts +7 -35
- package/dist/services/instance-ai-config-service.d.ts +4 -21
- package/dist/services/instance-service.d.ts +1 -10
- package/dist/services/instance-state.d.ts +5 -30
- package/dist/services/legacy-path-migration.d.ts +1 -1
- package/dist/services/lifecycle-state.d.ts +1 -4
- package/dist/services/mcp-launch-binding-queue.d.ts +2 -8
- package/dist/services/orphan-monitor.d.ts +20 -63
- package/dist/services/panel-auth.d.ts +12 -28
- package/dist/services/process-detector.d.ts +18 -122
- package/dist/services/process-registry.d.ts +30 -150
- package/dist/services/ring-buffer.d.ts +9 -42
- package/dist/services/runtime-binding.d.ts +2 -9
- package/dist/services/runtime-lifecycle-policy.d.ts +3 -15
- package/dist/services/session-output.d.ts +14 -67
- package/dist/services/startup-config-wizard.d.ts +3 -10
- package/dist/services/system-metrics.d.ts +1 -4
- package/dist/services/terminal-persistence.d.ts +10 -53
- package/dist/services/tool-installer.d.ts +6 -18
- package/dist/services/tunnel-client.d.ts +3 -18
- package/dist/services/windows-service-manager.d.ts +1 -13
- package/dist/services/workspace-files.d.ts +17 -57
- package/dist/services/workspace-watch.d.ts +2 -6
- package/dist/services/workspaceTaskChangeWatcher.d.ts +13 -51
- package/dist/types.d.ts +2 -8
- package/dist/utils/instance-ai-config-debug-logger.d.ts +5 -20
- package/dist/utils/logger.d.ts +7 -20
- package/dist/utils/mcp-utils.d.ts +8 -44
- package/dist/utils/path-utils.d.ts +3 -15
- package/dist/utils/sdk-package-loader.d.ts +2 -8
- package/dist/utils/validation.d.ts +3 -20
- package/dist/utils/yaml-utils.d.ts +8 -56
- package/node_modules/@cc-switch/sdk/dist/index.d.ts +1 -6
- package/node_modules/@cc-switch/sdk/dist/sdk.d.ts +11 -42
- package/package/acode/dist/ask-user-question-tool.d.ts +7 -20
- package/package/acode/dist/built-in-file-tools.d.ts +3 -6
- package/package/acode/dist/built-in-symbols-tool.d.ts +1 -4
- package/package/acode/dist/builtins/commandArtifacts.d.ts +1 -4
- package/package/acode/dist/builtins/shellOutputDecoder.d.ts +3 -18
- package/package/acode/dist/commands/commandLoader.d.ts +1 -4
- package/package/acode/dist/commands/commandParser.d.ts +1 -4
- package/package/acode/dist/compaction.d.ts +38 -175
- package/package/acode/dist/config.d.ts +1 -4
- package/package/acode/dist/fs-utils.d.ts +1 -19
- package/package/acode/dist/hooks/hookBus.d.ts +1 -4
- package/package/acode/dist/mcpToolNames.d.ts +2 -8
- package/package/acode/dist/parsers/ast-cache.d.ts +7 -20
- package/package/acode/dist/parsers/language-detector.d.ts +1 -5
- package/package/acode/dist/parsers/language-queries.d.ts +1 -1
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts +4 -12
- package/package/acode/dist/parsers/types.d.ts +19 -30
- package/package/acode/dist/runtime.d.ts +47 -269
- package/package/acode/dist/skill-tool.d.ts +3 -23
- package/package/acode/dist/sub-agent-manager.d.ts +41 -206
- package/package/acode/dist/sub-agent-store.d.ts +12 -61
- package/package/acode/dist/sub-agent-tools.d.ts +9 -18
- package/package/acode/dist/sub-agent-types.d.ts +32 -38
- package/package/acode/dist/todo-store.d.ts +8 -23
- package/package/acode/dist/todo-tool.d.ts +2 -2
- package/package/acode/dist/types.d.ts +17 -38
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +44 -161
- package/package/aws-client-agent-mcp/dist/config.d.ts +4 -18
- package/package/aws-client-agent-mcp/dist/constants.d.ts +1 -3
- package/package/aws-client-agent-mcp/dist/context-manager.d.ts +25 -95
- package/package/aws-client-agent-mcp/dist/context-manager.test.d.ts +1 -4
- package/package/aws-client-agent-mcp/dist/http-client.d.ts +15 -56
- package/package/aws-client-agent-mcp/dist/index.d.ts +1 -11
- package/package/aws-client-agent-mcp/dist/logger.d.ts +5 -22
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +76 -365
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +21 -83
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +15 -70
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts +4 -17
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts +23 -92
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts +5 -29
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +2 -9
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts +17 -55
- package/package/aws-client-agent-mcp/dist/types.d.ts +66 -125
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +30 -125
- package/package/cc-switch-sdk/dist/index.d.ts +1 -6
- package/package/cc-switch-sdk/dist/sdk.d.ts +11 -42
- package/package.json +1 -1
|
@@ -1,48 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 管理面板登录凭据与会话,凭据读取自 ~/.aws-bridge/config.json,
|
|
5
|
-
* panelUsername/panelPassword 字段均不配置时默认 root/root。
|
|
6
|
-
*
|
|
7
|
-
* 会话使用服务端内存存储 + HttpOnly Cookie 实现,无需外部依赖。
|
|
8
|
-
*/
|
|
9
|
-
/** 生成一个新会话并返回会话 token */
|
|
1
|
+
|
|
2
|
+
|
|
10
3
|
export declare function createSession(): string;
|
|
11
|
-
|
|
4
|
+
|
|
12
5
|
export declare function validateSession(token: string | undefined | null): boolean;
|
|
13
|
-
|
|
6
|
+
|
|
14
7
|
export declare function destroySession(token: string): void;
|
|
15
|
-
|
|
8
|
+
|
|
16
9
|
export declare function getAllSessions(): Array<{
|
|
17
10
|
token: string;
|
|
18
11
|
createdAt: number;
|
|
19
12
|
lastUsedAt: number;
|
|
20
13
|
}>;
|
|
21
|
-
|
|
14
|
+
|
|
22
15
|
export declare function getActiveSessionCount(): number;
|
|
23
16
|
interface PanelCredentials {
|
|
24
17
|
username: string;
|
|
25
18
|
password: string;
|
|
26
19
|
}
|
|
27
|
-
|
|
20
|
+
|
|
28
21
|
export declare function getPanelCredentials(): PanelCredentials;
|
|
29
|
-
|
|
22
|
+
|
|
30
23
|
export declare function validateCredentials(username: string, password: string): boolean;
|
|
31
|
-
|
|
24
|
+
|
|
32
25
|
export declare function clearCredentialsCache(): void;
|
|
33
|
-
|
|
34
|
-
* 检查 config.json 中是否已配置过面板凭据(panelUsername/panelPassword)。
|
|
35
|
-
* 用于首次登录引导:如果未配置过(文件不存在或缺少字段),应引导用户设置。
|
|
36
|
-
* 已配置过的场景(包括值正好为 root/root)不再重复引导。
|
|
37
|
-
*/
|
|
26
|
+
|
|
38
27
|
export declare function hasConfiguredCredentials(): boolean;
|
|
39
|
-
|
|
40
|
-
* 判断当前凭据是否为默认值 root/root。
|
|
41
|
-
*/
|
|
28
|
+
|
|
42
29
|
export declare function isDefaultCredentials(): boolean;
|
|
43
|
-
|
|
44
|
-
* 写入新的面板凭据到 config.json,并更新缓存。
|
|
45
|
-
* 主流程:读取现有配置 → 合并新字段 → 写回文件 → 清缓存。
|
|
46
|
-
*/
|
|
30
|
+
|
|
47
31
|
export declare function setPanelCredentials(username: string, password: string): void;
|
|
48
32
|
export {};
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 用于检测孤儿进程(当 runtime-bridge 异常关闭后仍在运行的 Agent 进程)
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 异步检测进程是否存活(防止阻塞事件循环)
|
|
8
|
-
*
|
|
9
|
-
* @param pid 进程 ID
|
|
10
|
-
* @returns 是否存活
|
|
11
|
-
*/
|
|
1
|
+
|
|
2
|
+
|
|
12
3
|
export declare function isProcessRunningAsync(pid: number): Promise<boolean>;
|
|
13
|
-
|
|
14
|
-
* 检测进程是否存活
|
|
15
|
-
*
|
|
16
|
-
* @param pid 进程 ID
|
|
17
|
-
* @returns 是否存活
|
|
18
|
-
*/
|
|
4
|
+
|
|
19
5
|
export declare function isProcessRunning(pid: number): boolean;
|
|
20
|
-
|
|
21
|
-
* 进程信息
|
|
22
|
-
*/
|
|
6
|
+
|
|
23
7
|
export interface ProcessInfo {
|
|
24
8
|
pid: number;
|
|
25
9
|
command: string;
|
|
@@ -27,78 +11,22 @@ export interface ProcessInfo {
|
|
|
27
11
|
agentId?: string;
|
|
28
12
|
startedAt?: string;
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
* 查找 Agent 相关的进程(Claude Code、OpenCode 等)
|
|
32
|
-
*
|
|
33
|
-
* @returns 匹配的进程列表
|
|
34
|
-
*/
|
|
14
|
+
|
|
35
15
|
export declare function findClaudeCodeProcesses(): Promise<ProcessInfo[]>;
|
|
36
|
-
|
|
37
|
-
* 根据 agentId 查找孤儿进程
|
|
38
|
-
*
|
|
39
|
-
* 检测策略(按优先级):
|
|
40
|
-
* 1. 通过命令行中的 agentId 直接匹配
|
|
41
|
-
* 2. Windows: 通过 PowerShell 在命令行中模糊搜索 agentId
|
|
42
|
-
* 3. Windows: 通过进程树搜索,覆盖 agentId 仅存在于祖先进程环境变量中的场景
|
|
43
|
-
*
|
|
44
|
-
* @param agentId Agent ID
|
|
45
|
-
* @returns 进程信息或 undefined
|
|
46
|
-
*/
|
|
16
|
+
|
|
47
17
|
export declare function findOrphanProcessByAgentId(agentId: string): Promise<ProcessInfo | undefined>;
|
|
48
|
-
|
|
49
|
-
* 通过工作目录路径查找孤儿进程
|
|
50
|
-
*
|
|
51
|
-
* 当 agentId 无法匹配到进程时,通过工作目录路径做宽泛搜索。
|
|
52
|
-
* 适用于以下场景:
|
|
53
|
-
* - runtime-bridge 重启后持久化会话丢失
|
|
54
|
-
* - agentId 可能仅在祖先进程环境变量中,命令行搜索不到
|
|
55
|
-
* - 进程树断链,无法通过祖先链匹配
|
|
56
|
-
*
|
|
57
|
-
* @param workspacePath 工作目录路径
|
|
58
|
-
* @returns 匹配的进程信息或 undefined
|
|
59
|
-
*/
|
|
18
|
+
|
|
60
19
|
export declare function findOrphanProcessByWorkspace(workspacePath: string): Promise<ProcessInfo | undefined>;
|
|
61
|
-
|
|
62
|
-
* 根据 PID 终止进程
|
|
63
|
-
*
|
|
64
|
-
* @param pid 进程 ID
|
|
65
|
-
* @returns 是否成功
|
|
66
|
-
*/
|
|
20
|
+
|
|
67
21
|
export declare function terminateProcess(pid: number): boolean;
|
|
68
|
-
|
|
69
|
-
* 终止进程树(包括所有子进程)
|
|
70
|
-
*
|
|
71
|
-
* 跨平台实现:
|
|
72
|
-
* - Windows: 使用 taskkill /T 终止整个进程树
|
|
73
|
-
* - Unix: 递归获取所有子进程并逐个终止
|
|
74
|
-
*
|
|
75
|
-
* @param pid 进程 ID
|
|
76
|
-
* @returns { terminated: 成功终止的进程数,failed: 失败的进程数 }
|
|
77
|
-
*/
|
|
22
|
+
|
|
78
23
|
export declare function terminateProcessTree(pid: number): Promise<{
|
|
79
24
|
terminated: number;
|
|
80
25
|
failed: number;
|
|
81
26
|
}>;
|
|
82
|
-
|
|
83
|
-
* 等待进程完全终止(轮询检测)
|
|
84
|
-
*
|
|
85
|
-
* @param pid 进程 ID
|
|
86
|
-
* @param timeoutMs 超时时间(毫秒)
|
|
87
|
-
* @returns 是否成功终止
|
|
88
|
-
*/
|
|
27
|
+
|
|
89
28
|
export declare function waitForProcessExit(pid: number, timeoutMs?: number): Promise<boolean>;
|
|
90
|
-
|
|
91
|
-
* 检测并收集所有孤儿进程信息
|
|
92
|
-
* 用于 runtime-bridge 启动时恢复控制
|
|
93
|
-
*
|
|
94
|
-
* 改进策略:
|
|
95
|
-
* 1. 检查持久化会话中的 PID 是否仍在运行(使用可靠的 isProcessRunning)
|
|
96
|
-
* 2. PID 存活时,优先从进程列表匹配详细信息,匹配不到则用持久化信息构造
|
|
97
|
-
* 3. 对于没有 PID 的会话,通过 agentId 搜索进程(包括环境变量搜索)
|
|
98
|
-
*
|
|
99
|
-
* @param persistedSessions 持久化的会话列表(包含 PID 信息)
|
|
100
|
-
* @returns 孤儿进程列表
|
|
101
|
-
*/
|
|
29
|
+
|
|
102
30
|
export declare function detectOrphanProcesses(persistedSessions: Array<{
|
|
103
31
|
agentId: string;
|
|
104
32
|
pid?: number;
|
|
@@ -112,9 +40,7 @@ export declare function detectOrphanProcesses(persistedSessions: Array<{
|
|
|
112
40
|
command?: string;
|
|
113
41
|
};
|
|
114
42
|
}>>;
|
|
115
|
-
|
|
116
|
-
* 进程健康状态
|
|
117
|
-
*/
|
|
43
|
+
|
|
118
44
|
export interface ProcessHealthStatus {
|
|
119
45
|
pid: number;
|
|
120
46
|
agentId: string;
|
|
@@ -124,55 +50,25 @@ export interface ProcessHealthStatus {
|
|
|
124
50
|
status: 'healthy' | 'unresponsive' | 'high_cpu' | 'high_memory' | 'dead';
|
|
125
51
|
lastUpdate: Date;
|
|
126
52
|
}
|
|
127
|
-
|
|
128
|
-
* 检测进程健康状态
|
|
129
|
-
*
|
|
130
|
-
* @param pid 进程 ID
|
|
131
|
-
* @param agentId Agent ID
|
|
132
|
-
* @returns 健康状态
|
|
133
|
-
*/
|
|
53
|
+
|
|
134
54
|
export declare function checkProcessHealth(pid: number, agentId: string): Promise<ProcessHealthStatus>;
|
|
135
|
-
|
|
136
|
-
* 批量检测会话健康状态
|
|
137
|
-
*
|
|
138
|
-
* @param sessions 持久化会话列表
|
|
139
|
-
* @returns 健康状态列表
|
|
140
|
-
*/
|
|
55
|
+
|
|
141
56
|
export declare function checkAllSessionsHealth(sessions: Array<{
|
|
142
57
|
agentId: string;
|
|
143
58
|
pid?: number;
|
|
144
59
|
}>): Promise<Map<string, ProcessHealthStatus>>;
|
|
145
|
-
|
|
146
|
-
* 发现进程管理状态
|
|
147
|
-
*/
|
|
60
|
+
|
|
148
61
|
export type ProcessManagementStatus = 'managed' | 'orphan' | 'unknown';
|
|
149
|
-
|
|
150
|
-
* 发现的进程信息(含管理状态)
|
|
151
|
-
*/
|
|
62
|
+
|
|
152
63
|
export interface DiscoveredProcessInfo extends ProcessInfo {
|
|
153
64
|
managementStatus: ProcessManagementStatus;
|
|
154
65
|
sessionId?: string;
|
|
155
66
|
isRunning: boolean;
|
|
156
67
|
lastSeen?: string;
|
|
157
68
|
}
|
|
158
|
-
|
|
159
|
-
* 全局发现:扫描机器上所有 Agent 进程,并标注管理状态
|
|
160
|
-
*
|
|
161
|
-
* 返回三类进程:
|
|
162
|
-
* - managed: 在注册表中且进程存活
|
|
163
|
-
* - orphan: 进程存在但不在注册表中(脱离控制)
|
|
164
|
-
* - unknown: 在注册表中但进程已死亡
|
|
165
|
-
*
|
|
166
|
-
* @param managedPids 已知被管理的 PID 集合(来自 ProcessRegistry)
|
|
167
|
-
* @returns 发现的进程列表
|
|
168
|
-
*/
|
|
69
|
+
|
|
169
70
|
export declare function discoverAllProcesses(managedPids?: Set<number>, managedAgentIds?: Set<string>): Promise<DiscoveredProcessInfo[]>;
|
|
170
|
-
|
|
171
|
-
* 批量发现:扫描所有进程并补充注册表中缺失的进程状态
|
|
172
|
-
*
|
|
173
|
-
* @param registryExport 注册表导出的进程记录(含 agentId, pid)
|
|
174
|
-
* @returns 完整的发现结果
|
|
175
|
-
*/
|
|
71
|
+
|
|
176
72
|
export declare function discoverAllProcessesFull(registryExport: Array<{
|
|
177
73
|
agentId: string;
|
|
178
74
|
pid: number;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 集中管理 Agent 进程生命周期状态,支持进程注册、追踪、状态管理和持久化
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 进程状态类型
|
|
8
|
-
*/
|
|
1
|
+
|
|
2
|
+
|
|
9
3
|
export type ProcessState = 'creating' | 'running' | 'stopping' | 'orphaned' | 'terminated' | 'unknown';
|
|
10
|
-
|
|
11
|
-
* 进程健康状态
|
|
12
|
-
*/
|
|
4
|
+
|
|
13
5
|
export interface HealthStatus {
|
|
14
6
|
cpu: number;
|
|
15
7
|
memoryMB: number;
|
|
16
8
|
status: string;
|
|
17
9
|
}
|
|
18
|
-
|
|
19
|
-
* 进程记录接口
|
|
20
|
-
*/
|
|
10
|
+
|
|
21
11
|
export interface ProcessRecord {
|
|
22
12
|
agentId: string;
|
|
23
13
|
sessionId: string;
|
|
@@ -32,9 +22,7 @@ export interface ProcessRecord {
|
|
|
32
22
|
orphanedAt?: string;
|
|
33
23
|
metadata?: Record<string, unknown>;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
* 持久化会话输入(用于重建注册表)
|
|
37
|
-
*/
|
|
25
|
+
|
|
38
26
|
export interface PersistedSessionInput {
|
|
39
27
|
agentId: string;
|
|
40
28
|
sessionId: string;
|
|
@@ -43,166 +31,58 @@ export interface PersistedSessionInput {
|
|
|
43
31
|
command?: string;
|
|
44
32
|
mode?: 'sdk';
|
|
45
33
|
}
|
|
46
|
-
|
|
47
|
-
* 获取持久化注册表文件路径
|
|
48
|
-
*
|
|
49
|
-
* @returns 注册表文件路径
|
|
50
|
-
*/
|
|
34
|
+
|
|
51
35
|
export declare function getProcessRegistryFile(): string;
|
|
52
|
-
|
|
53
|
-
* 进程注册表类
|
|
54
|
-
*
|
|
55
|
-
* 管理所有 Agent 进程的生命周期状态,提供注册、查询、更新和持久化功能
|
|
56
|
-
*/
|
|
36
|
+
|
|
57
37
|
export declare class ProcessRegistry {
|
|
58
38
|
private static instance;
|
|
59
39
|
private readonly records;
|
|
60
40
|
private readonly pidToAgentId;
|
|
61
|
-
|
|
62
|
-
* 私有构造函数,强制使用单例模式
|
|
63
|
-
*/
|
|
41
|
+
|
|
64
42
|
private constructor();
|
|
65
|
-
|
|
66
|
-
* 获取 ProcessRegistry 单例实例
|
|
67
|
-
*
|
|
68
|
-
* @returns ProcessRegistry 实例
|
|
69
|
-
*/
|
|
43
|
+
|
|
70
44
|
static getInstance(): ProcessRegistry;
|
|
71
|
-
|
|
72
|
-
* 持久化注册表状态到文件
|
|
73
|
-
*/
|
|
45
|
+
|
|
74
46
|
private persist;
|
|
75
47
|
private mutate;
|
|
76
|
-
|
|
77
|
-
* 注册新进程
|
|
78
|
-
*
|
|
79
|
-
* @param record - 进程记录(不包含 createdAt)
|
|
80
|
-
* @returns 是否注册成功
|
|
81
|
-
*/
|
|
48
|
+
|
|
82
49
|
register(record: Omit<ProcessRecord, 'createdAt'>): Promise<void>;
|
|
83
|
-
|
|
84
|
-
* 更新进程记录
|
|
85
|
-
*
|
|
86
|
-
* @param agentId - Agent ID
|
|
87
|
-
* @param updates - 要更新的字段
|
|
88
|
-
* @returns 是否更新成功
|
|
89
|
-
*/
|
|
50
|
+
|
|
90
51
|
update(agentId: string, updates: Partial<ProcessRecord>): Promise<boolean>;
|
|
91
|
-
|
|
92
|
-
* 通过 agentId 获取进程记录
|
|
93
|
-
*
|
|
94
|
-
* @param agentId - Agent ID
|
|
95
|
-
* @returns 进程记录或 undefined
|
|
96
|
-
*/
|
|
52
|
+
|
|
97
53
|
get(agentId: string): ProcessRecord | undefined;
|
|
98
|
-
|
|
99
|
-
* 通过 PID 获取进程记录
|
|
100
|
-
*
|
|
101
|
-
* @param pid - 进程 ID
|
|
102
|
-
* @returns 进程记录或 undefined
|
|
103
|
-
*/
|
|
54
|
+
|
|
104
55
|
getByPid(pid: number): ProcessRecord | undefined;
|
|
105
|
-
|
|
106
|
-
* 获取所有进程记录
|
|
107
|
-
*
|
|
108
|
-
* @returns 所有进程记录的数组
|
|
109
|
-
*/
|
|
56
|
+
|
|
110
57
|
getAll(): ProcessRecord[];
|
|
111
|
-
|
|
112
|
-
* 通过状态过滤进程记录
|
|
113
|
-
*
|
|
114
|
-
* @param state - 进程状态
|
|
115
|
-
* @returns 符合状态的进程记录数组
|
|
116
|
-
*/
|
|
58
|
+
|
|
117
59
|
getByState(state: ProcessState): ProcessRecord[];
|
|
118
|
-
|
|
119
|
-
* 检查进程是否被管理
|
|
120
|
-
*
|
|
121
|
-
* @param agentId - Agent ID
|
|
122
|
-
* @returns 是否被管理
|
|
123
|
-
*/
|
|
60
|
+
|
|
124
61
|
isManaged(agentId: string): boolean;
|
|
125
|
-
|
|
126
|
-
* 检查 PID 是否被管理
|
|
127
|
-
*
|
|
128
|
-
* @param pid - 进程 ID
|
|
129
|
-
* @returns 是否被管理
|
|
130
|
-
*/
|
|
62
|
+
|
|
131
63
|
isManagedByPid(pid: number): boolean;
|
|
132
|
-
|
|
133
|
-
* 标记进程为孤儿状态
|
|
134
|
-
*
|
|
135
|
-
* @param agentId - Agent ID
|
|
136
|
-
* @returns 是否标记成功
|
|
137
|
-
*/
|
|
64
|
+
|
|
138
65
|
markOrphaned(agentId: string): Promise<boolean>;
|
|
139
|
-
|
|
140
|
-
* 标记进程为终止状态
|
|
141
|
-
*
|
|
142
|
-
* @param agentId - Agent ID
|
|
143
|
-
* @returns 是否标记成功
|
|
144
|
-
*/
|
|
66
|
+
|
|
145
67
|
markTerminated(agentId: string): Promise<boolean>;
|
|
146
|
-
|
|
147
|
-
* 移除进程记录
|
|
148
|
-
*
|
|
149
|
-
* @param agentId - Agent ID
|
|
150
|
-
* @returns 是否移除成功
|
|
151
|
-
*/
|
|
68
|
+
|
|
152
69
|
remove(agentId: string): Promise<boolean>;
|
|
153
|
-
|
|
154
|
-
* 更新进程心跳时间
|
|
155
|
-
*
|
|
156
|
-
* @param agentId - Agent ID
|
|
157
|
-
* @returns 是否更新成功
|
|
158
|
-
*/
|
|
70
|
+
|
|
159
71
|
updateHeartbeat(agentId: string): Promise<boolean>;
|
|
160
|
-
|
|
161
|
-
* 更新进程健康状态
|
|
162
|
-
*
|
|
163
|
-
* @param agentId - Agent ID
|
|
164
|
-
* @param health - 健康状态
|
|
165
|
-
* @returns 是否更新成功
|
|
166
|
-
*/
|
|
72
|
+
|
|
167
73
|
updateHealth(agentId: string, health: HealthStatus): Promise<boolean>;
|
|
168
|
-
|
|
169
|
-
* 从持久化会话重建注册表
|
|
170
|
-
*
|
|
171
|
-
* @param sessions - 持久化会话数组
|
|
172
|
-
*/
|
|
74
|
+
|
|
173
75
|
rebuildFromPersisted(sessions: PersistedSessionInput[]): Promise<void>;
|
|
174
|
-
|
|
175
|
-
* 导出所有进程记录用于持久化
|
|
176
|
-
*
|
|
177
|
-
* @returns 所有进程记录的数组
|
|
178
|
-
*/
|
|
76
|
+
|
|
179
77
|
exportState(): ProcessRecord[];
|
|
180
|
-
|
|
181
|
-
* 获取进程数量统计
|
|
182
|
-
*
|
|
183
|
-
* @returns 各状态的进程数量
|
|
184
|
-
*/
|
|
78
|
+
|
|
185
79
|
getStats(): Record<ProcessState | 'total', number>;
|
|
186
|
-
|
|
187
|
-
* 清空所有进程记录
|
|
188
|
-
*/
|
|
80
|
+
|
|
189
81
|
clear(): Promise<void>;
|
|
190
82
|
}
|
|
191
|
-
|
|
192
|
-
* 获取 ProcessRegistry 单例实例的便捷函数
|
|
193
|
-
*
|
|
194
|
-
* @returns ProcessRegistry 实例
|
|
195
|
-
*/
|
|
83
|
+
|
|
196
84
|
export declare function getProcessRegistry(): ProcessRegistry;
|
|
197
|
-
|
|
198
|
-
* 加载持久化的进程注册表
|
|
199
|
-
*
|
|
200
|
-
* @returns 进程记录数组
|
|
201
|
-
*/
|
|
85
|
+
|
|
202
86
|
export declare function loadPersistedProcessRegistry(): Promise<ProcessRecord[]>;
|
|
203
|
-
|
|
204
|
-
* 保存进程注册表到持久化文件
|
|
205
|
-
*
|
|
206
|
-
* @param records - 进程记录数组
|
|
207
|
-
*/
|
|
87
|
+
|
|
208
88
|
export declare function savePersistedProcessRegistry(records: ProcessRecord[]): Promise<void>;
|
|
@@ -1,66 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
* 环状缓冲区
|
|
3
|
-
*
|
|
4
|
-
* 提供固定容量的泛型环状缓冲区,支持追加和按条件合并。
|
|
5
|
-
* 当缓冲区满时自动覆盖最旧的元素。
|
|
6
|
-
*/
|
|
1
|
+
|
|
7
2
|
export interface RingBufferEntry<T> {
|
|
8
3
|
data: T;
|
|
9
4
|
readonly timestamp: number;
|
|
10
5
|
readonly index: number;
|
|
11
6
|
}
|
|
12
7
|
export type RingBufferSlice<T> = readonly RingBufferEntry<T>[];
|
|
13
|
-
|
|
14
|
-
* 泛型环状缓冲区。
|
|
15
|
-
* 容量固定,写入超过容量后自动覆盖最旧条目。
|
|
16
|
-
* 每个 entry 携带单调递增 index,支持增量查询。
|
|
17
|
-
*/
|
|
8
|
+
|
|
18
9
|
export declare class RingBuffer<T> {
|
|
19
10
|
private readonly entries;
|
|
20
11
|
private readonly capacity;
|
|
21
12
|
private nextIndex;
|
|
22
13
|
private totalAppended;
|
|
23
14
|
constructor(capacity: number);
|
|
24
|
-
|
|
25
|
-
* 追加一条记录到缓冲区尾部。
|
|
26
|
-
* 缓冲区满时自动覆盖最旧的记录。
|
|
27
|
-
* @returns 新创建的条目
|
|
28
|
-
*/
|
|
15
|
+
|
|
29
16
|
append(item: T): RingBufferEntry<T>;
|
|
30
|
-
|
|
31
|
-
* 按条件追加或合并到最后一条记录。
|
|
32
|
-
* 如果缓冲区非空且 condition 返回 true,将 item 合并到最后一条记录中;
|
|
33
|
-
* 否则直接追加新记录。
|
|
34
|
-
*
|
|
35
|
-
* @param item 待追加的数据
|
|
36
|
-
* @param condition 判断是否与最后一条合并,接收最后一条条目
|
|
37
|
-
* @param merge 合并函数,接收已有数据和新增数据,返回合并结果
|
|
38
|
-
* @returns 被合并或新创建的条目
|
|
39
|
-
*/
|
|
17
|
+
|
|
40
18
|
appendOrMerge(item: T, condition: (lastEntry: RingBufferEntry<T>) => boolean, merge: (last: T, next: T) => T): RingBufferEntry<T>;
|
|
41
|
-
|
|
42
|
-
* 返回当前所有条目的快照。
|
|
43
|
-
*/
|
|
19
|
+
|
|
44
20
|
slice(): RingBufferSlice<T>;
|
|
45
|
-
|
|
46
|
-
* 返回当前条目数。
|
|
47
|
-
*/
|
|
21
|
+
|
|
48
22
|
get size(): number;
|
|
49
|
-
|
|
50
|
-
* 返回最近 N 条记录。
|
|
51
|
-
*/
|
|
23
|
+
|
|
52
24
|
getLastN(n: number): RingBufferSlice<T>;
|
|
53
|
-
|
|
54
|
-
* 返回自指定 index(不含)之后的记录。
|
|
55
|
-
* @returns 包含 entries、nextIndex(下一个待分配 index)、oldestIndex(最老条目的 index)
|
|
56
|
-
*/
|
|
25
|
+
|
|
57
26
|
getSinceIndex(index: number): {
|
|
58
27
|
entries: RingBufferSlice<T>;
|
|
59
28
|
nextIndex: number;
|
|
60
29
|
oldestIndex: number;
|
|
61
30
|
};
|
|
62
|
-
|
|
63
|
-
* 清空缓冲区。
|
|
64
|
-
*/
|
|
31
|
+
|
|
65
32
|
clear(): void;
|
|
66
33
|
}
|
|
@@ -3,11 +3,7 @@ export type RuntimeBindingState = {
|
|
|
3
3
|
instanceId?: string;
|
|
4
4
|
userId?: string;
|
|
5
5
|
schedulerBaseUrl?: string;
|
|
6
|
-
|
|
7
|
-
* Plain runtime access token issued by the scheduler.
|
|
8
|
-
* Stored locally with 0600 permissions so child MCP processes can authenticate
|
|
9
|
-
* scheduler calls without exposing the token in public status APIs.
|
|
10
|
-
*/
|
|
6
|
+
|
|
11
7
|
accessToken?: string;
|
|
12
8
|
tokenHash?: string;
|
|
13
9
|
createdAt?: string;
|
|
@@ -40,8 +36,5 @@ export declare function saveRuntimeBinding(input: {
|
|
|
40
36
|
schedulerBaseUrl?: string;
|
|
41
37
|
}): RuntimeBindingState;
|
|
42
38
|
export declare function clearRuntimeBinding(): void;
|
|
43
|
-
|
|
44
|
-
* 将旧路径 ~/.agentswork/runtime-bridge/ 下的配置文件迁移到新路径 ~/.aws-bridge/。
|
|
45
|
-
* 仅在旧路径存在且新路径不存在时执行,避免覆盖已有配置。
|
|
46
|
-
*/
|
|
39
|
+
|
|
47
40
|
export declare function migrateOldBindingDir(): void;
|
|
@@ -6,21 +6,9 @@ export interface GracefulShutdownPlan {
|
|
|
6
6
|
clearPersistedSessions: boolean;
|
|
7
7
|
stopTunnelClient: boolean;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
* Build shutdown side-effect policy from the requested restart mode.
|
|
11
|
-
* Main flow: explicit bridge shutdown cleans resources; scheduler restart keeps
|
|
12
|
-
* SDK/PTY processes and persisted metadata so the scheduler can restore state.
|
|
13
|
-
*/
|
|
9
|
+
|
|
14
10
|
export declare function buildGracefulShutdownPlan(preserveSessions: boolean): GracefulShutdownPlan;
|
|
15
|
-
|
|
16
|
-
* Decide whether startup may destructively clean persisted runtime sessions.
|
|
17
|
-
* Main flow: default bridge restart is non-destructive; operators can opt into
|
|
18
|
-
* legacy cleanup with AWS_BRIDGE_CLEAN_ORPHANS_ON_STARTUP=true.
|
|
19
|
-
*/
|
|
11
|
+
|
|
20
12
|
export declare function shouldCleanupPersistedSessionsOnStartup(preserveSessions: boolean, env?: NodeJS.ProcessEnv): boolean;
|
|
21
|
-
|
|
22
|
-
* Decide whether background orphan monitoring may terminate persisted sessions.
|
|
23
|
-
* Main flow: process termination is an explicit cleanup action, not a default
|
|
24
|
-
* monitoring behavior, so restart recovery cannot be undone by auto-clean mode.
|
|
25
|
-
*/
|
|
13
|
+
|
|
26
14
|
export declare function shouldAutoCleanOrphanProcesses(env?: NodeJS.ProcessEnv): boolean;
|