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,116 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 实现 Bridge 实例启动后自动向调度中心注册的功能
|
|
5
|
-
*
|
|
6
|
-
* 配置来源(优先级从高到低):
|
|
7
|
-
* 1. 环境变量
|
|
8
|
-
* 2. 用户目录下的 .aws-bridge/config.json 文件
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* 自动注册配置
|
|
12
|
-
*/
|
|
1
|
+
|
|
2
|
+
|
|
13
3
|
interface AutoRegisterConfig {
|
|
14
|
-
|
|
4
|
+
|
|
15
5
|
enabled: boolean;
|
|
16
|
-
|
|
6
|
+
|
|
17
7
|
serverUrl?: string;
|
|
18
|
-
|
|
8
|
+
|
|
19
9
|
tenantId?: string;
|
|
20
|
-
|
|
10
|
+
|
|
21
11
|
userKey: string;
|
|
22
|
-
|
|
12
|
+
|
|
23
13
|
connectionKey?: string;
|
|
24
|
-
|
|
14
|
+
|
|
25
15
|
instanceName?: string;
|
|
26
|
-
|
|
16
|
+
|
|
27
17
|
instanceId?: string;
|
|
28
|
-
|
|
18
|
+
|
|
29
19
|
projectName?: string;
|
|
30
|
-
|
|
20
|
+
|
|
31
21
|
roleName?: string;
|
|
32
|
-
|
|
22
|
+
|
|
33
23
|
workspacePath?: string;
|
|
34
|
-
|
|
35
|
-
* 注册地址(推荐)
|
|
36
|
-
* - 支持 `host:port`、纯 `host`(自动补 AWS_RUNTIME_BRIDGE_PORT)、完整 URL(`http://...` / `https://...`,原样使用)
|
|
37
|
-
* - 优先级高于 registerIp / virtualIp
|
|
38
|
-
*/
|
|
24
|
+
|
|
39
25
|
registerAddr?: string;
|
|
40
|
-
|
|
41
|
-
* 注册 IP(已废弃,仅做向后兼容回退)
|
|
42
|
-
* - 仅接受纯 IP/host,端口由 AWS_RUNTIME_BRIDGE_PORT 决定
|
|
43
|
-
* - 推荐迁移到 registerAddr
|
|
44
|
-
*/
|
|
26
|
+
|
|
45
27
|
registerIp?: string;
|
|
46
|
-
|
|
28
|
+
|
|
47
29
|
virtualIp?: string;
|
|
48
|
-
|
|
49
|
-
* 是否启用隧道模式(三态):
|
|
50
|
-
* - true:显式启用隧道模式,bridge 经 WebSocket 反向连出到 server,
|
|
51
|
-
* server 经 /tunnel/{instanceId}/ 虚拟路径反向调用 bridge。
|
|
52
|
-
* - false:显式禁用隧道模式,即使未填 registerAddr 也走直连(用于 loopback 场景)。
|
|
53
|
-
* - undefined(默认):未填 registerAddr/registerIp/virtualIp 时自动判定为隧道模式(向后兼容)。
|
|
54
|
-
*/
|
|
30
|
+
|
|
55
31
|
tunnel?: boolean;
|
|
56
|
-
|
|
32
|
+
|
|
57
33
|
preferSameLanIp?: boolean;
|
|
58
|
-
|
|
34
|
+
|
|
59
35
|
maxRetries?: number;
|
|
60
|
-
|
|
36
|
+
|
|
61
37
|
retryInterval?: number;
|
|
62
38
|
}
|
|
63
39
|
export declare function getConfiguredConnectionKeys(): string[];
|
|
64
|
-
|
|
40
|
+
|
|
65
41
|
export declare function cancelBackgroundRegisterRetries(): void;
|
|
66
|
-
|
|
67
|
-
* 配置文件路径
|
|
68
|
-
*
|
|
69
|
-
* 默认使用 os.homedir(),但 Windows 服务以 LocalSystem 身份运行时 homedir() 是
|
|
70
|
-
* System32\systemprofile,找不到用户配置 → 不注册 → 不建隧道。
|
|
71
|
-
* 因此优先读 AWS_RUNTIME_HOME_DIR 环境变量(与 getRuntimeHomeDir 一致),
|
|
72
|
-
* 让 `awsb service install` 把当前用户主目录注入到服务环境变量中。
|
|
73
|
-
*/
|
|
42
|
+
|
|
74
43
|
export declare function getAutoRegisterConfigFilePath(): string;
|
|
75
|
-
|
|
76
|
-
* 加载自动注册配置
|
|
77
|
-
*
|
|
78
|
-
* 优先级:环境变量 > 配置文件 > 默认值
|
|
79
|
-
*
|
|
80
|
-
* 如果没有配置文件且没有环境变量,则不启用自动注册
|
|
81
|
-
*/
|
|
44
|
+
|
|
82
45
|
export declare function loadConfig(): AutoRegisterConfig;
|
|
83
46
|
export declare function loadConfigs(): AutoRegisterConfig[];
|
|
84
47
|
export declare function isTunnelConfig(config?: AutoRegisterConfig): boolean;
|
|
85
48
|
export declare function loadPrimaryLifecycleConfig(): AutoRegisterConfig;
|
|
86
|
-
|
|
87
|
-
* 通过入站 runtime token 反查其所属调度中心地址。
|
|
88
|
-
*
|
|
89
|
-
* 场景:调度中心发起 /runtime/start 时,请求头 X-Runtime-Token 携带的是该 server
|
|
90
|
-
* 签发给本 bridge 的实例 token(RuntimeBridgeService.resolveRuntimeBridgeAuthToken)。
|
|
91
|
-
* bridge 本地 scoped token store(runtime-tokens.properties)按 serverUrl 存储这些
|
|
92
|
-
* 实例 token,因此匹配命中即可确定来源 server,避免多 autoRegisterTargets 时回退到
|
|
93
|
-
* DEFAULT_SCHEDULER_BASE_URL(localhost:8080)导致回调打错服务器。
|
|
94
|
-
*
|
|
95
|
-
* 候选来源:所有 autoRegisterTargets 的 serverUrl + binding.json 的 schedulerBaseUrl。
|
|
96
|
-
* 仅在 launch body 未显式携带 schedulerBaseUrl 时作为兜底使用。
|
|
97
|
-
*/
|
|
49
|
+
|
|
98
50
|
export declare function resolveSchedulerBaseUrlFromToken(token: unknown): string | undefined;
|
|
99
|
-
|
|
100
|
-
* 自动注册主函数
|
|
101
|
-
*
|
|
102
|
-
* 带重试机制的注册逻辑
|
|
103
|
-
*
|
|
104
|
-
* 配置来源(优先级从高到低):
|
|
105
|
-
* 1. 传入的 customConfig
|
|
106
|
-
* 2. 环境变量
|
|
107
|
-
* 3. ~/.aws-bridge/config.json 配置文件
|
|
108
|
-
* 4. 默认值
|
|
109
|
-
*/
|
|
51
|
+
|
|
110
52
|
export declare function autoRegister(customConfig?: Partial<AutoRegisterConfig>): Promise<boolean>;
|
|
111
|
-
|
|
112
|
-
* 注销实例
|
|
113
|
-
*/
|
|
53
|
+
|
|
114
54
|
export declare function requestRuntimeAccessTokenRefresh(): Promise<{
|
|
115
55
|
success: boolean;
|
|
116
56
|
runtimeAccessToken?: string;
|
|
@@ -124,9 +64,7 @@ export declare function requestRuntimeAccessTokenRefreshForServer(serverBaseUrl:
|
|
|
124
64
|
error?: string;
|
|
125
65
|
}>;
|
|
126
66
|
export declare function unregister(): Promise<boolean>;
|
|
127
|
-
|
|
128
|
-
* 获取注册状态
|
|
129
|
-
*/
|
|
67
|
+
|
|
130
68
|
export declare function getRegistrationState(): {
|
|
131
69
|
registered: boolean;
|
|
132
70
|
instanceId?: string;
|
|
@@ -134,26 +72,11 @@ export declare function getRegistrationState(): {
|
|
|
134
72
|
lastAttempt?: Date;
|
|
135
73
|
error?: string;
|
|
136
74
|
};
|
|
137
|
-
|
|
138
|
-
* 检查是否已注册
|
|
139
|
-
*/
|
|
75
|
+
|
|
140
76
|
export declare function isRegistered(): boolean;
|
|
141
|
-
|
|
142
|
-
* 获取实例 ID
|
|
143
|
-
*/
|
|
77
|
+
|
|
144
78
|
export declare function getInstanceId(): string | undefined;
|
|
145
|
-
|
|
146
|
-
* ★★★ Bridge 重启清理
|
|
147
|
-
*
|
|
148
|
-
* 当 aws-runtime-bridge 重启时调用,通知调度中心将该 bridge 关联的所有 Agent 设置为离线。
|
|
149
|
-
*
|
|
150
|
-
* 清理逻辑:
|
|
151
|
-
* 1. 调用调度中心的 /api/instances/bridge-restart-cleanup 接口
|
|
152
|
-
* 2. 传入 instanceId 或 runtimeBridgeBaseUrl
|
|
153
|
-
* 3. 调度中心会将关联的 Agent 设置为 is_online=false, runtime_status='stopped'
|
|
154
|
-
*
|
|
155
|
-
* @returns 清理结果
|
|
156
|
-
*/
|
|
79
|
+
|
|
157
80
|
export declare function bridgeRestartCleanup(): Promise<{
|
|
158
81
|
success: boolean;
|
|
159
82
|
agentCount?: number;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Bridge 包发布后通知服务
|
|
3
|
-
*
|
|
4
|
-
* 主干流程:读取 GitHub Actions 注入的 webhook URL 与密钥;两者均配置时,
|
|
5
|
-
* 读取当前包名/版本并发送带 HMAC 签名的 JSON 通知;任一配置缺失时安全跳过。
|
|
6
|
-
*/
|
|
1
|
+
|
|
7
2
|
import axios from "axios";
|
|
8
3
|
import { type Logger } from "../utils/logger.js";
|
|
9
4
|
export interface BridgePackageInfo {
|
|
@@ -27,21 +22,12 @@ interface NotifyOptions {
|
|
|
27
22
|
now?: () => Date;
|
|
28
23
|
post?: typeof axios.post;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
|
-
* 具体功能实现:读取 package.json 中用于通知服务识别包版本的最小信息。
|
|
32
|
-
*/
|
|
25
|
+
|
|
33
26
|
export declare function readBridgePackageInfo(): Promise<BridgePackageInfo>;
|
|
34
|
-
|
|
35
|
-
* 具体功能实现:构造稳定的发布通知负载,附带 GitHub Actions 上下文便于服务端审计。
|
|
36
|
-
*/
|
|
27
|
+
|
|
37
28
|
export declare function createBridgePackagePublishPayload(packageInfo: BridgePackageInfo, env?: NodeJS.ProcessEnv, now?: () => Date): BridgePackagePublishPayload;
|
|
38
|
-
|
|
39
|
-
* 具体功能实现:对实际发送的 JSON 字符串签名,保证服务端验签与请求体完全一致。
|
|
40
|
-
*/
|
|
29
|
+
|
|
41
30
|
export declare function createBridgePublishSignature(body: string, secret: string): string;
|
|
42
|
-
|
|
43
|
-
* 主逻辑:根据环境变量决定跳过或发送发布通知;已配置 webhook 时失败会抛出,
|
|
44
|
-
* 让 GitHub Actions 明确暴露“包已发布但通知失败”的状态。
|
|
45
|
-
*/
|
|
31
|
+
|
|
46
32
|
export declare function notifyBridgePackagePublished(options?: NotifyOptions): Promise<boolean>;
|
|
47
33
|
export {};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* CC-Switch SDK 包装层
|
|
3
|
-
*
|
|
4
|
-
* 负责创建 SDK 实例并注入 adapters。
|
|
5
|
-
* adapters 实现在 src/adapters/cc-switch/ 中。
|
|
6
|
-
*/
|
|
1
|
+
|
|
7
2
|
import { AiConfigService, CcSwitchSdk, type AppFlags } from '@cc-switch/sdk';
|
|
8
3
|
import type { CcSwitchAppPaths, AdapterResult, SdkApps } from '../types.js';
|
|
9
4
|
import { InstanceService } from './instance-service.js';
|
|
@@ -15,55 +15,34 @@ export interface CliCommandOptions {
|
|
|
15
15
|
stderr?: (message: string) => void;
|
|
16
16
|
runCommand?: (command: string, args: string[]) => CommandRunResult;
|
|
17
17
|
configure?: () => Promise<StartupConfigWizardResult>;
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
configureExample?: () => Promise<StartupConfigWizardResult>;
|
|
20
20
|
platform?: NodeJS.Platform;
|
|
21
21
|
serviceUnitPath?: string;
|
|
22
22
|
executablePath?: string;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
windowsServiceLogPath?: string;
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
windowsServiceManager?: WindowsServiceManager;
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
launchdPlistPath?: string;
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
launchdLogPath?: string;
|
|
31
|
-
|
|
32
|
-
* macOS launchd 域目标(默认 `gui/${process.getuid()}`)。
|
|
33
|
-
* service-target = `${domainTarget}/${LAUNCHD_LABEL}`,测试时可注入固定值避免依赖 getuid。
|
|
34
|
-
*/
|
|
31
|
+
|
|
35
32
|
launchdDomainTarget?: string;
|
|
36
|
-
|
|
33
|
+
|
|
37
34
|
findRunningBridgeProcesses?: (platform: NodeJS.Platform) => number[];
|
|
38
|
-
|
|
35
|
+
|
|
39
36
|
killBridgeProcess?: (pid: number, platform: NodeJS.Platform) => void;
|
|
40
|
-
|
|
37
|
+
|
|
41
38
|
prompt?: (question: string) => Promise<string>;
|
|
42
|
-
|
|
43
|
-
* 解析全局 node_modules 路径(默认执行 `npm root -g`)。
|
|
44
|
-
* 用于 update 前清理旧版残留目录,避免 macOS 专用 fsevents 在 Windows 上
|
|
45
|
-
* 触发 node-gyp 编译失败。
|
|
46
|
-
*/
|
|
39
|
+
|
|
47
40
|
globalModulePath?: () => string | null;
|
|
48
41
|
}
|
|
49
42
|
export declare function readPackageVersion(packageRoot?: string): string;
|
|
50
|
-
|
|
51
|
-
* 生成 systemd unit 内容,主流程是用当前 Node 可执行文件启动当前 CLI 入口。
|
|
52
|
-
*/
|
|
43
|
+
|
|
53
44
|
export declare function createSystemdUnitContent(executablePath: string): string;
|
|
54
|
-
|
|
55
|
-
* 生成 macOS launchd plist 内容。
|
|
56
|
-
*
|
|
57
|
-
* - Label:launchd 注册的服务标识,必须与 plist 文件名匹配;
|
|
58
|
-
* - ProgramArguments:用当前 Node 可执行文件启动 CLI 入口;
|
|
59
|
-
* - RunAtLoad=true:bootstrap 时立即启动;
|
|
60
|
-
* - KeepAlive=true:进程退出后自动拉起(对应 systemd Restart=always 语义;
|
|
61
|
-
* systemd 用 on-failure,launchd 没有细粒度条件时用 true 最稳);
|
|
62
|
-
* - StandardOutPath/StandardErrorPath:与 Windows 服务日志统一放在 ~/.aws-bridge/log/;
|
|
63
|
-
* - AWS_RUNTIME_HOME_DIR:注入当前用户主目录,避免 LaunchAgent 在某些上下文下
|
|
64
|
-
* 解析到错误 home 导致读不到 ~/.aws-bridge/config.json(与 Windows LocalSystem
|
|
65
|
-
* 场景同源,统一注入更稳)。
|
|
66
|
-
*/
|
|
45
|
+
|
|
67
46
|
export declare function createLaunchdPlistContent(executablePath: string, options?: {
|
|
68
47
|
userHomeDir?: string;
|
|
69
48
|
logPath?: string;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* 事件差量推送调度器
|
|
3
|
-
*
|
|
4
|
-
* 将 agent 事件缓冲区中的新事件差量推送到调度中心。
|
|
5
|
-
* 提供全局心跳调度和推送统计查询。
|
|
6
|
-
*/
|
|
1
|
+
|
|
7
2
|
import { type BridgeEventPayload } from "./agent-event-store.js";
|
|
8
3
|
import { type RingBufferEntry } from "./ring-buffer.js";
|
|
9
4
|
export interface RuntimeCallbackAuthOptions {
|
|
@@ -19,21 +14,11 @@ export interface PushStatEntry {
|
|
|
19
14
|
lastLatencyMs?: number;
|
|
20
15
|
lastError?: string;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
* 调度一次差量推送:将 agent 的新事件推送到调度中心。
|
|
24
|
-
* 暂以单次 push 模式实现,后续可按需改为批量/定时 flush。
|
|
25
|
-
*/
|
|
17
|
+
|
|
26
18
|
export declare function scheduleEventPush(agentId: string, _entry: RingBufferEntry<BridgeEventPayload>, authOptions?: RuntimeCallbackAuthOptions): Promise<void>;
|
|
27
|
-
|
|
28
|
-
* 启动全局心跳调度器。
|
|
29
|
-
* 每 30s 向调度中心发送空包,检测连接存活。
|
|
30
|
-
*/
|
|
19
|
+
|
|
31
20
|
export declare function startHeartbeatScheduler(): void;
|
|
32
|
-
|
|
33
|
-
* 停止全局心跳调度器。
|
|
34
|
-
*/
|
|
21
|
+
|
|
35
22
|
export declare function stopHeartbeatScheduler(): void;
|
|
36
|
-
|
|
37
|
-
* 返回所有 agent 的推送统计。
|
|
38
|
-
*/
|
|
23
|
+
|
|
39
24
|
export declare function getAllPushStats(): PushStatEntry[];
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* 文件快照存储服务
|
|
3
|
-
*
|
|
4
|
-
* 借鉴 Claude Code fileHistory 的确定性整文件覆盖方案,替代 git stash 实现稳定快照。
|
|
5
|
-
* - 快照 = 工作区那一刻所有文件的内容哈希副本 + index.json 映射
|
|
6
|
-
* - 还原 = "先清后写"整文件覆盖,零冲突,幂等
|
|
7
|
-
* - 内容哈希去重:相同文件内容跨快照共享一份物理副本
|
|
8
|
-
*/
|
|
1
|
+
|
|
9
2
|
export interface SnapshotIndexEntry {
|
|
10
|
-
|
|
3
|
+
|
|
11
4
|
backupName: string;
|
|
12
5
|
size: number;
|
|
13
6
|
mtime: number;
|
|
@@ -50,46 +43,25 @@ export interface SnapshotListItem {
|
|
|
50
43
|
fileCount: number;
|
|
51
44
|
totalBytes: number;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
* 创建工作区文件快照。
|
|
55
|
-
*
|
|
56
|
-
* 算法(借鉴 Claude Code fileHistoryMakeSnapshot):
|
|
57
|
-
* 1. 遍历工作区收集所有文件
|
|
58
|
-
* 2. 对每个文件计算内容哈希,拷贝到快照目录(去重)
|
|
59
|
-
* 3. 写入 index.json 和 meta.json
|
|
60
|
-
*/
|
|
46
|
+
|
|
61
47
|
export declare function createSnapshot(params: {
|
|
62
48
|
workspacePath: string;
|
|
63
49
|
snapshotId?: string;
|
|
64
50
|
snapshotName?: string;
|
|
65
51
|
triggerType?: string;
|
|
66
52
|
}): Promise<CreateSnapshotResult>;
|
|
67
|
-
|
|
68
|
-
* 还原工作区到快照状态。
|
|
69
|
-
*
|
|
70
|
-
* 算法(借鉴 Claude Code applySnapshot):
|
|
71
|
-
* 1. 可选:还原前自动创建安全网快照(preRestoreBackup)
|
|
72
|
-
* 2. 读取目标快照 index.json
|
|
73
|
-
* 3. 删除工作区中"快照后新增"的文件
|
|
74
|
-
* 4. 从备份逐文件覆盖,内容相同则跳过
|
|
75
|
-
*/
|
|
53
|
+
|
|
76
54
|
export declare function restoreSnapshot(params: {
|
|
77
55
|
workspacePath: string;
|
|
78
56
|
snapshotKey: string;
|
|
79
57
|
preRestoreBackup?: boolean;
|
|
80
58
|
}): Promise<RestoreSnapshotResult>;
|
|
81
|
-
|
|
82
|
-
* 列出指定工作区的所有快照
|
|
83
|
-
*/
|
|
59
|
+
|
|
84
60
|
export declare function listSnapshots(workspacePath: string): Promise<SnapshotListItem[]>;
|
|
85
|
-
|
|
86
|
-
* 删除指定快照
|
|
87
|
-
*/
|
|
61
|
+
|
|
88
62
|
export declare function deleteSnapshot(snapshotKey: string): Promise<{
|
|
89
63
|
ok: boolean;
|
|
90
64
|
error?: string;
|
|
91
65
|
}>;
|
|
92
|
-
|
|
93
|
-
* 获取快照根目录(供诊断/调试使用)
|
|
94
|
-
*/
|
|
66
|
+
|
|
95
67
|
export declare function getSnapshotRootPath(): string;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AI 配置服务
|
|
3
|
-
*
|
|
4
|
-
* 管理 ACode 实例的 AI provider 配置(model/baseURL/apiKey)。
|
|
5
|
-
* 支持三层来源(api > env > file)仲裁,deep-merge 后写入
|
|
6
|
-
* per-instance acode.json 供 ACode runtime 加载。
|
|
7
|
-
*/
|
|
1
|
+
|
|
8
2
|
export interface AdapterInstanceAiConfig {
|
|
9
3
|
model?: string;
|
|
10
4
|
baseURL?: string;
|
|
@@ -12,7 +6,7 @@ export interface AdapterInstanceAiConfig {
|
|
|
12
6
|
effort?: string;
|
|
13
7
|
}
|
|
14
8
|
interface PrepareOptions {
|
|
15
|
-
|
|
9
|
+
|
|
16
10
|
apiOverrides?: AdapterInstanceAiConfig;
|
|
17
11
|
agentId: string;
|
|
18
12
|
sessionId?: string;
|
|
@@ -30,19 +24,8 @@ interface PrepareResult {
|
|
|
30
24
|
};
|
|
31
25
|
perInstanceConfigPath: string;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
|
-
* 脱敏日志中的敏感字段(apiKey / secret / token / password)。
|
|
35
|
-
* 返回新对象,不修改原对象。
|
|
36
|
-
*/
|
|
27
|
+
|
|
37
28
|
export declare function redactForLog(obj: Record<string, unknown>): Record<string, unknown>;
|
|
38
|
-
|
|
39
|
-
* 准备 ACode 实例配置。
|
|
40
|
-
*
|
|
41
|
-
* 主流程:
|
|
42
|
-
* 1. 从 apiOverrides(请求体)、env(环境变量)、file(acode.json)三层收集配置
|
|
43
|
-
* 2. 按 api > env > file 优先级仲裁每个字段
|
|
44
|
-
* 3. 将仲裁结果 deep-merge 写入 per-instance acode.json
|
|
45
|
-
* 4. 返回合并后的 config 和 per-instance 文件路径
|
|
46
|
-
*/
|
|
29
|
+
|
|
47
30
|
export declare function prepareAcodeInstanceConfig(options: PrepareOptions): Promise<PrepareResult>;
|
|
48
31
|
export {};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* InstanceService - Agent 实例初始化服务
|
|
3
|
-
*
|
|
4
|
-
* 负责 Agent 实例的生命周期管理:
|
|
5
|
-
* - 实例根目录、workspace 路径管理
|
|
6
|
-
* - 实例状态持久化
|
|
7
|
-
* - Skill/MCP 包安装流程
|
|
8
|
-
*
|
|
9
|
-
* 注意:此服务属于 Agent 运行时层,不属于 cc-switch-sdk 配置管理层
|
|
10
|
-
*/
|
|
1
|
+
|
|
11
2
|
import type { AppId, InstalledSkill, McpServer } from '@cc-switch/sdk';
|
|
12
3
|
import { CcSwitchSdk } from '@cc-switch/sdk';
|
|
13
4
|
export interface SkillPackage {
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* 实例状态持久化服务
|
|
3
|
-
*
|
|
4
|
-
* 管理 Agent 实例的初始化状态持久化
|
|
5
|
-
*/
|
|
1
|
+
|
|
6
2
|
import type { InstanceState } from '../types.js';
|
|
7
|
-
|
|
8
|
-
* 获取实例状态文件路径
|
|
9
|
-
*
|
|
10
|
-
* @param agentId - Agent ID
|
|
11
|
-
* @returns 状态文件路径
|
|
12
|
-
*/
|
|
3
|
+
|
|
13
4
|
export declare function getInstanceStateFile(agentId: string): string;
|
|
14
|
-
|
|
15
|
-
* 加载实例状态
|
|
16
|
-
*
|
|
17
|
-
* @param agentId - Agent ID
|
|
18
|
-
* @returns 实例状态
|
|
19
|
-
*/
|
|
5
|
+
|
|
20
6
|
export declare function loadInstanceState(agentId: string): Promise<InstanceState>;
|
|
21
|
-
|
|
22
|
-
* 保存实例状态
|
|
23
|
-
*
|
|
24
|
-
* @param agentId - Agent ID
|
|
25
|
-
* @param state - 部分实例状态
|
|
26
|
-
* @returns 完整的实例状态
|
|
27
|
-
*/
|
|
7
|
+
|
|
28
8
|
export declare function saveInstanceState(agentId: string, state: Partial<InstanceState>): Promise<InstanceState>;
|
|
29
|
-
|
|
30
|
-
* 获取 Agent 初始化根目录
|
|
31
|
-
*
|
|
32
|
-
* @param agentId - Agent ID
|
|
33
|
-
* @returns 初始化根目录路径
|
|
34
|
-
*/
|
|
9
|
+
|
|
35
10
|
export declare function getAgentInitRoot(agentId: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
export declare function migrateOldPathsOnStartup(): void;
|
|
@@ -22,8 +22,5 @@ export declare function createBridgeLifecycleOperation(input: {
|
|
|
22
22
|
}): BridgeLifecycleOperation;
|
|
23
23
|
export declare function upsertBridgeLifecycleOperation(operation: BridgeLifecycleOperation): Promise<void>;
|
|
24
24
|
export declare function removeBridgeLifecycleOperation(operationId: string): Promise<void>;
|
|
25
|
-
|
|
26
|
-
* 投递 Bridge 生命周期通知。
|
|
27
|
-
* 主流程:把已完成操作回调调度中心;已接收的操作从本地状态移除,失败则保留待下次启动重试。
|
|
28
|
-
*/
|
|
25
|
+
|
|
29
26
|
export declare function deliverPendingBridgeLifecycleNotifications(): Promise<void>;
|
|
@@ -31,16 +31,10 @@ export interface McpLaunchBindingClaimRequest {
|
|
|
31
31
|
export declare function enqueueMcpLaunchBinding(input: McpLaunchBindingInput): McpLaunchBinding | null;
|
|
32
32
|
export declare function claimMcpLaunchBinding(request: McpLaunchBindingClaimRequest): ClaimedMcpLaunchBinding | null;
|
|
33
33
|
export declare function getMcpLaunchQueueSize(workspacePath: unknown): number;
|
|
34
|
-
|
|
35
|
-
* 主流程:按启动绑定 ID 移除尚未被 MCP node 认领的绑定。
|
|
36
|
-
* 具体逻辑:启动流程失败时调用;若绑定已被认领或 ID 不存在则返回 false,保持幂等。
|
|
37
|
-
*/
|
|
34
|
+
|
|
38
35
|
export declare function removeMcpLaunchBinding(bindingId: string): boolean;
|
|
39
36
|
export declare function clearMcpLaunchBindingQueues(): void;
|
|
40
|
-
|
|
41
|
-
* 获取指定 agent 的最新 MCP session token。
|
|
42
|
-
* 供 MCP node 在 401 后向 bridge 查询最新 token 使用。
|
|
43
|
-
*/
|
|
37
|
+
|
|
44
38
|
export declare function getLatestAgentToken(agentId: string): {
|
|
45
39
|
runtimeAccessToken: string;
|
|
46
40
|
} | null;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 定期扫描和检测孤儿进程,支持自动清理和告警
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 孤儿进程事件类型
|
|
8
|
-
*/
|
|
1
|
+
|
|
2
|
+
|
|
9
3
|
export type OrphanEventType = 'orphan_detected' | 'orphan_cleaned' | 'process_unresponsive' | 'process_high_cpu' | 'process_high_memory' | 'health_check';
|
|
10
|
-
|
|
11
|
-
* 孤儿进程事件
|
|
12
|
-
*/
|
|
4
|
+
|
|
13
5
|
export interface OrphanEvent {
|
|
14
6
|
type: OrphanEventType;
|
|
15
7
|
agentId: string;
|
|
@@ -18,81 +10,46 @@ export interface OrphanEvent {
|
|
|
18
10
|
timestamp: Date;
|
|
19
11
|
details?: Record<string, unknown>;
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
* 孤儿进程监控器
|
|
23
|
-
*/
|
|
13
|
+
|
|
24
14
|
export declare class OrphanMonitor {
|
|
25
15
|
private intervalId;
|
|
26
16
|
private lastScanTime;
|
|
27
17
|
private eventListeners;
|
|
28
18
|
private stopped;
|
|
29
|
-
|
|
30
|
-
* 启动监控器
|
|
31
|
-
*/
|
|
19
|
+
|
|
32
20
|
start(): Promise<void>;
|
|
33
|
-
|
|
34
|
-
* 停止监控器
|
|
35
|
-
*/
|
|
21
|
+
|
|
36
22
|
stop(): void;
|
|
37
|
-
|
|
38
|
-
* 执行一次扫描
|
|
39
|
-
*/
|
|
23
|
+
|
|
40
24
|
scan(): Promise<void>;
|
|
41
|
-
|
|
42
|
-
* 处理检测到的孤儿进程
|
|
43
|
-
*/
|
|
25
|
+
|
|
44
26
|
private handleOrphanDetected;
|
|
45
|
-
|
|
46
|
-
* 处理健康异常
|
|
47
|
-
*/
|
|
27
|
+
|
|
48
28
|
private handleHealthIssue;
|
|
49
|
-
|
|
50
|
-
* 自动清理孤儿进程
|
|
51
|
-
*/
|
|
29
|
+
|
|
52
30
|
private autoCleanOrphan;
|
|
53
|
-
|
|
54
|
-
* 清理已死亡的会话记录
|
|
55
|
-
*/
|
|
31
|
+
|
|
56
32
|
private cleanupDeadSessions;
|
|
57
|
-
|
|
58
|
-
* 向 server 查询 agent 是否仍然存在。
|
|
59
|
-
* 返回 true=存在, false=已删除, null=无法确认(网络错误/认证失败等)。
|
|
60
|
-
*/
|
|
33
|
+
|
|
61
34
|
private checkAgentExistsOnServer;
|
|
62
|
-
|
|
63
|
-
* 上报事件到调度中心
|
|
64
|
-
*/
|
|
35
|
+
|
|
65
36
|
private reportToScheduler;
|
|
66
|
-
|
|
67
|
-
* 注册事件监听器
|
|
68
|
-
*/
|
|
37
|
+
|
|
69
38
|
onEvent(listener: (event: OrphanEvent) => void): void;
|
|
70
|
-
|
|
71
|
-
* 移除事件监听器
|
|
72
|
-
*/
|
|
39
|
+
|
|
73
40
|
offEvent(listener: (event: OrphanEvent) => void): void;
|
|
74
|
-
|
|
75
|
-
* 触发事件
|
|
76
|
-
*/
|
|
41
|
+
|
|
77
42
|
private emit;
|
|
78
|
-
|
|
79
|
-
* 获取监控状态
|
|
80
|
-
*/
|
|
43
|
+
|
|
81
44
|
getStatus(): {
|
|
82
45
|
running: boolean;
|
|
83
46
|
lastScanTime: Date | null;
|
|
84
47
|
mode: string;
|
|
85
48
|
};
|
|
86
49
|
}
|
|
87
|
-
|
|
88
|
-
* 获取孤儿进程监控器实例
|
|
89
|
-
*/
|
|
50
|
+
|
|
90
51
|
export declare function getOrphanMonitor(): OrphanMonitor;
|
|
91
|
-
|
|
92
|
-
* 启动孤儿进程监控
|
|
93
|
-
*/
|
|
52
|
+
|
|
94
53
|
export declare function startOrphanMonitor(): Promise<void>;
|
|
95
|
-
|
|
96
|
-
* 停止孤儿进程监控
|
|
97
|
-
*/
|
|
54
|
+
|
|
98
55
|
export declare function stopOrphanMonitor(): void;
|