{"version":3,"file":"idlePolicy-DZ8ZuRp7.cjs","names":[],"sources":["../src/constants/idlePolicy.ts","../src/services/idlePolicy/index.ts"],"sourcesContent":["export const DEFAULT_AUTO_STOP_DELAYS = {\n  cooldownMs: 5_000,\n  recheckMs: 100,\n};\n\nexport const AUTO_STOP_ACTION = {\n  /** The session has nothing left to do and can exit. */\n  shutdown: 'shutdown',\n  /** Look again after the returned delay. */\n  recheck: 'recheck',\n  /** The user is back; stop watching until the agent settles again. */\n  standDown: 'stand-down',\n} as const;\n\n/** Telemetry events that explain an auto-stop decision after the fact. */\nexport const AUTO_STOP_EVENT = {\n  /** Idle, but background work is still listed; carries what it is. */\n  waitingOnBackgroundWork: 'doom_autostop.waiting_on_background_work',\n  /** A message was queued, so the watch stopped until the agent settles again. */\n  stoodDown: 'doom_autostop.stood_down',\n  /** Everything was clear and shutdown was requested. */\n  shutdownRequested: 'doom_autostop.shutdown_requested',\n} as const;\n\n/** How often a long wait on background work is reported again. */\nexport const AUTO_STOP_REPORT_INTERVAL_MS = 60_000;\n/** Longest the session waits for telemetry to flush on its way out. */\nexport const AUTO_STOP_TELEMETRY_FLUSH_MS = 2_000;\n/** Longest list of work items or errors carried on one event. */\nexport const AUTO_STOP_DETAIL_MAX_LENGTH = 500;\n\n/**\n * The only background work that keeps a settled session open: background\n * runners (`doom-runner`) and running subagents (`team-direct-runs`,\n * `doom-task`). Workflow runs are left out on purpose; a workflow step never\n * launches another workflow, so a run a session started must not hold it open.\n */\nexport const AUTO_STOP_BLOCKING_PROVIDERS: readonly string[] = ['doom-runner', 'team-direct-runs', 'doom-task'];\n\n/**\n * A runner holds the session only while it is working. The runner keeps a\n * finished one listed (completed or failed) until its exit message is sent,\n * and that must not delay the stop.\n */\nexport const AUTO_STOP_RUNNER_PROVIDER = 'doom-runner';\nexport const AUTO_STOP_RUNNER_WORKING_STATUS = 'running';\n","import { AUTO_STOP_ACTION } from '../../constants/idlePolicy';\nimport type { AutoStopDecision, AutoStopDelays, SessionActivity } from './type';\n/**\n * Taken when the agent reports it has settled.\n *\n * Settling is not enough on its own: a queued message means the session is\n * about to run again, and even an empty queue gets the cooldown so a user\n * typing their next prompt is not cut off mid-word.\n */\nexport function decideOnSettled(activity: SessionActivity, delays: AutoStopDelays): AutoStopDecision {\n  if (activity.hasPendingMessages) return { action: AUTO_STOP_ACTION.standDown };\n  return { action: AUTO_STOP_ACTION.recheck, delayMs: delays.cooldownMs };\n}\n\n/**\n * Taken when a scheduled look comes due.\n *\n * The agent can still be streaming after it settled, so a session that is not\n * yet idle is polled rather than stopped.\n */\nexport function decideOnRecheck(activity: SessionActivity, delays: AutoStopDelays): AutoStopDecision {\n  if (activity.hasPendingMessages) return { action: AUTO_STOP_ACTION.standDown };\n  if (activity.isIdle) return { action: AUTO_STOP_ACTION.shutdown };\n  return { action: AUTO_STOP_ACTION.recheck, delayMs: delays.recheckMs };\n}\n"],"mappings":";AAAA,MAAa,2BAA2B;CACtC,YAAY;CACZ,WAAW;AACb;AAEA,MAAa,mBAAmB;;CAE9B,UAAU;;CAEV,SAAS;;CAET,WAAW;AACb;;AAGA,MAAa,kBAAkB;;CAE7B,yBAAyB;;CAEzB,WAAW;;CAEX,mBAAmB;AACrB;;AAGA,MAAa,+BAA+B;;AAE5C,MAAa,+BAA+B;;;;;;;AAU5C,MAAa,+BAAkD;CAAC;CAAe;CAAoB;AAAW;;;;;;AAO9G,MAAa,4BAA4B;AACzC,MAAa,kCAAkC;;;;;;;;;;ACpC/C,SAAgB,gBAAgB,UAA2B,QAA0C;CACnG,IAAI,SAAS,oBAAoB,OAAO,EAAE,QAAQ,iBAAiB,UAAU;CAC7E,OAAO;EAAE,QAAQ,iBAAiB;EAAS,SAAS,OAAO;CAAW;AACxE;;;;;;;AAQA,SAAgB,gBAAgB,UAA2B,QAA0C;CACnG,IAAI,SAAS,oBAAoB,OAAO,EAAE,QAAQ,iBAAiB,UAAU;CAC7E,IAAI,SAAS,QAAQ,OAAO,EAAE,QAAQ,iBAAiB,SAAS;CAChE,OAAO;EAAE,QAAQ,iBAAiB;EAAS,SAAS,OAAO;CAAU;AACvE"}