This commit is contained in:
@ -745,11 +745,18 @@ export class MockAgentGateway implements AgentGateway {
|
||||
};
|
||||
throw err;
|
||||
}
|
||||
// Singleton invariant: refuse a launch when the agent is already live in a
|
||||
// *different* cell (mirrors the backend `AGENT_ALREADY_RUNNING`). The same
|
||||
// node is allowed (idempotent re-launch of the very same cell).
|
||||
// Singleton invariant for the human native TUI surface: refuse a launch when
|
||||
// the agent already has a PTY in a different cell. Structured/headless
|
||||
// sessions are separate surfaces and must not make the human TUI look
|
||||
// "already active elsewhere" (#169/#170).
|
||||
const liveNode = this.liveByAgent.get(agentId);
|
||||
if (liveNode !== undefined && options.nodeId && liveNode !== options.nodeId) {
|
||||
const liveKind = this.liveKindByAgent.get(agentId) ?? "pty";
|
||||
if (
|
||||
liveNode !== undefined &&
|
||||
liveKind === "pty" &&
|
||||
options.nodeId &&
|
||||
liveNode !== options.nodeId
|
||||
) {
|
||||
const err: GatewayError = {
|
||||
code: "AGENT_ALREADY_RUNNING",
|
||||
message: `agent ${agentId} is already running in cell ${liveNode}`,
|
||||
@ -814,7 +821,13 @@ export class MockAgentGateway implements AgentGateway {
|
||||
} as GatewayError;
|
||||
}
|
||||
const liveNode = this.liveByAgent.get(agentId);
|
||||
if (liveNode !== undefined && options.nodeId && liveNode !== options.nodeId) {
|
||||
const liveKind = this.liveKindByAgent.get(agentId) ?? "pty";
|
||||
if (
|
||||
liveNode !== undefined &&
|
||||
liveKind === "pty" &&
|
||||
options.nodeId &&
|
||||
liveNode !== options.nodeId
|
||||
) {
|
||||
throw {
|
||||
code: "AGENT_ALREADY_RUNNING",
|
||||
message: `agent ${agentId} is already running in cell ${liveNode}`,
|
||||
|
||||
Reference in New Issue
Block a user