const MAX_AGE_MS = 5 * 60 * 1e3;
const pendingRequests = /* @__PURE__ */ new Map();
function cleanup(maxAgeMs = MAX_AGE_MS) {
  const now = Date.now();
  for (const [id, entry] of pendingRequests.entries()) {
    if (now - entry.createdAt > maxAgeMs) {
      pendingRequests.delete(id);
    }
  }
}
function createPendingRequest(requestId, data) {
  cleanup();
  pendingRequests.set(requestId, {
    createdAt: Date.now(),
    decidedAt: null,
    decision: null,
    sessionId: data.sessionId,
    toolInput: data.toolInput,
    toolName: data.toolName
  });
}
function getDecision(requestId) {
  const entry = pendingRequests.get(requestId);
  if (!entry) {
    return { status: "not_found" };
  }
  if (entry.decision) {
    pendingRequests.delete(requestId);
    return { decision: entry.decision, status: "decided" };
  }
  return { status: "pending" };
}
function setDecision(requestId, decision) {
  const entry = pendingRequests.get(requestId);
  if (!entry) {
    return false;
  }
  entry.decision = decision;
  entry.decidedAt = Date.now();
  return true;
}

export { cleanup as a, createPendingRequest as c, getDecision as g, setDecision as s };
//# sourceMappingURL=pending-requests-D8UiTw7L.js.map
