File size: 784 Bytes
3144483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { resetGatewayWorkAdmission } from "./gateway-work-admission.js";

type CommandQueueStateShape = {
  lanes: Map<unknown, unknown>;
  nextTaskId: number;
  nextQueueSequence?: number;
  laneGroups?: Map<unknown, unknown>;
  laneGroupByLane?: Map<unknown, unknown>;
};

/** Hard-reset the process-global command queue between isolated tests. */
export function resetCommandQueueStateForTest(): void {
  resetGatewayWorkAdmission();
  const key = Symbol.for("openclaw.commandQueueState");
  const state = (globalThis as Record<PropertyKey, unknown>)[key] as
    | CommandQueueStateShape
    | undefined;
  if (!state) {
    return;
  }

  state.lanes.clear();
  state.laneGroups?.clear();
  state.laneGroupByLane?.clear();
  state.nextTaskId = 1;
  state.nextQueueSequence = 1;
}