feat: preempt active runs in interrupt queue mode
This commit is contained in:
@@ -132,6 +132,30 @@ export class SessionBridge {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request cancellation for the active operation in a session.
|
||||
* Returns true if at least one connection in the session is currently busy.
|
||||
*/
|
||||
cancelSession(sessionId: string): boolean {
|
||||
const clients = Array.from(this.clients.values()).filter((client) => client.sessionId === sessionId);
|
||||
if (clients.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const hasBusyClient = clients.some((client) => client.busy);
|
||||
if (!hasBusyClient) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const agent = this.agents.get(sessionId);
|
||||
if (!agent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
agent.cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Set onToolUse callback for a connection's agent. */
|
||||
setOnToolUse(connectionId: string, callback: ((event: ToolUseEvent) => void) | undefined): void {
|
||||
const client = this.clients.get(connectionId);
|
||||
|
||||
Reference in New Issue
Block a user