Skip to content

Commit e4403ff

Browse files
fix: 移除 RCS 按 machineName 复用 agent 记录的逻辑
多个同名 acp-link 实例注册到 RCS 时,REST 注册阶段按 machineName 去重导致不同实例共享同一条记录。改为每次注册都创建独立记录, 重连恢复由 WS identify 阶段按 environment_id 精确匹配。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 9e61e7a commit e4403ff

1 file changed

Lines changed: 0 additions & 33 deletions

File tree

  • packages/remote-control-server/src

packages/remote-control-server/src/store.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,6 @@ export function storeDeleteToken(token: string): boolean {
9898

9999
// ---------- Environment ----------
100100

101-
/** Find an active or offline environment by machineName (optionally filtered by workerType).
102-
* Includes "offline" so ACP agents can be reused on reconnect. */
103-
export function storeFindEnvironmentByMachineName(
104-
machineName: string,
105-
workerType?: string,
106-
): EnvironmentRecord | undefined {
107-
for (const rec of environments.values()) {
108-
if (rec.machineName === machineName && (rec.status === "active" || rec.status === "offline")) {
109-
if (!workerType || rec.workerType === workerType) {
110-
return rec;
111-
}
112-
}
113-
}
114-
return undefined;
115-
}
116-
117101
export function storeCreateEnvironment(req: {
118102
secret: string;
119103
machineName?: string;
@@ -126,23 +110,6 @@ export function storeCreateEnvironment(req: {
126110
username?: string;
127111
capabilities?: Record<string, unknown>;
128112
}): EnvironmentRecord {
129-
// ACP: reuse existing active record by machineName
130-
if (req.workerType === "acp" && req.machineName) {
131-
const existing = storeFindEnvironmentByMachineName(req.machineName, "acp");
132-
if (existing) {
133-
Object.assign(existing, {
134-
status: "active",
135-
lastPollAt: new Date(),
136-
updatedAt: new Date(),
137-
maxSessions: req.maxSessions ?? existing.maxSessions,
138-
bridgeId: req.bridgeId ?? existing.bridgeId,
139-
capabilities: req.capabilities ?? existing.capabilities,
140-
username: req.username ?? existing.username,
141-
});
142-
return existing;
143-
}
144-
}
145-
146113
const id = `env_${uuid().replace(/-/g, "")}`;
147114
const now = new Date();
148115
const record: EnvironmentRecord = {

0 commit comments

Comments
 (0)