Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

487 B
Raw Blame
export async function stopIdleLocalVm(deps: {
  keepRunning(): boolean;
  status(): Promise<{ container: string; managed: boolean }>;
  stop(): Promise<{ stopped_at?: string | null }>;
  record(stoppedAt: string | null | undefined): void;
}): Promise<void | "busy"> {
  const status = await deps.status();
  if (deps.keepRunning()) return "busy";
  if (status.container === "running" && status.managed) {
    const stopped = await deps.stop();
    deps.record(stopped.stopped_at);
  }
}