export interface IRunsLock { lock(runId: string): Promise; release(runId: string): Promise; } export class InMemoryRunsLock implements IRunsLock { private locks: Record = {}; async lock(runId: string): Promise { if (this.locks[runId]) { return false; } this.locks[runId] = true; return true; } async release(runId: string): Promise { delete this.locks[runId]; } }