// src/state.ts
function getRuntime() {
  const g = globalThis;
  if (!g.__caRuntime) {
    g.__caRuntime = {
      inFlightRuns: /* @__PURE__ */ new Map(),
      pendingUserInputs: /* @__PURE__ */ new Map()
    };
  }
  return g.__caRuntime;
}
function pushPendingUserInput(input) {
  const rt = getRuntime();
  const list = rt.pendingUserInputs.get(input.sessionId) ?? [];
  list.push(input.input);
  rt.pendingUserInputs.set(input.sessionId, list);
}
function drainPendingUserInputs(sessionId) {
  const rt = getRuntime();
  const list = rt.pendingUserInputs.get(sessionId) ?? [];
  rt.pendingUserInputs.delete(sessionId);
  return list;
}

export {
  getRuntime,
  pushPendingUserInput,
  drainPendingUserInputs
};
