mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
fix: 移除 RCS 按 machineName 复用 agent 记录的逻辑
多个同名 acp-link 实例注册到 RCS 时,REST 注册阶段按 machineName 去重导致不同实例共享同一条记录。改为每次注册都创建独立记录, 重连恢复由 WS identify 阶段按 environment_id 精确匹配。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -98,22 +98,6 @@ export function storeDeleteToken(token: string): boolean {
|
|||||||
|
|
||||||
// ---------- Environment ----------
|
// ---------- Environment ----------
|
||||||
|
|
||||||
/** Find an active or offline environment by machineName (optionally filtered by workerType).
|
|
||||||
* Includes "offline" so ACP agents can be reused on reconnect. */
|
|
||||||
export function storeFindEnvironmentByMachineName(
|
|
||||||
machineName: string,
|
|
||||||
workerType?: string,
|
|
||||||
): EnvironmentRecord | undefined {
|
|
||||||
for (const rec of environments.values()) {
|
|
||||||
if (rec.machineName === machineName && (rec.status === "active" || rec.status === "offline")) {
|
|
||||||
if (!workerType || rec.workerType === workerType) {
|
|
||||||
return rec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function storeCreateEnvironment(req: {
|
export function storeCreateEnvironment(req: {
|
||||||
secret: string;
|
secret: string;
|
||||||
machineName?: string;
|
machineName?: string;
|
||||||
@@ -126,23 +110,6 @@ export function storeCreateEnvironment(req: {
|
|||||||
username?: string;
|
username?: string;
|
||||||
capabilities?: Record<string, unknown>;
|
capabilities?: Record<string, unknown>;
|
||||||
}): EnvironmentRecord {
|
}): EnvironmentRecord {
|
||||||
// ACP: reuse existing active record by machineName
|
|
||||||
if (req.workerType === "acp" && req.machineName) {
|
|
||||||
const existing = storeFindEnvironmentByMachineName(req.machineName, "acp");
|
|
||||||
if (existing) {
|
|
||||||
Object.assign(existing, {
|
|
||||||
status: "active",
|
|
||||||
lastPollAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
maxSessions: req.maxSessions ?? existing.maxSessions,
|
|
||||||
bridgeId: req.bridgeId ?? existing.bridgeId,
|
|
||||||
capabilities: req.capabilities ?? existing.capabilities,
|
|
||||||
username: req.username ?? existing.username,
|
|
||||||
});
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = `env_${uuid().replace(/-/g, "")}`;
|
const id = `env_${uuid().replace(/-/g, "")}`;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const record: EnvironmentRecord = {
|
const record: EnvironmentRecord = {
|
||||||
|
|||||||
Reference in New Issue
Block a user