import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk/channel-lifecycle";

type StoppableMonitor = {
  stop: () => void;
};

export async function runStoppablePassiveMonitor<TMonitor extends StoppableMonitor>(params: {
  abortSignal: AbortSignal;
  start: () => Promise<TMonitor>;
}): Promise<void> {
  await runPassiveAccountLifecycle({
    abortSignal: params.abortSignal,
    start: params.start,
    stop: async (monitor) => {
      monitor.stop();
    },
  });
}
