const AI_PENDING_ACTION_STATUSES = [
  "pending",
  "confirmed",
  "cancelled",
  "expired",
  "executing",
  "failed"
];
const AI_PENDING_ACTION_QUEUE_MODES = ["inline", "stack"];
const AI_PENDING_ACTION_ALLOWED_TRANSITIONS = {
  pending: ["confirmed", "cancelled", "expired"],
  confirmed: ["executing"],
  executing: ["confirmed", "failed"],
  cancelled: [],
  expired: [],
  failed: []
};
const AI_PENDING_ACTION_TERMINAL_STATUSES = [
  "confirmed",
  "cancelled",
  "expired",
  "failed"
];
class AiPendingActionStateError extends Error {
  constructor(from, to) {
    super(`Illegal AiPendingAction status transition: ${from} \u2192 ${to}`);
    this.from = from;
    this.to = to;
    this.code = "ai_pending_action_invalid_transition";
    this.name = "AiPendingActionStateError";
  }
}
function isAiPendingActionStatus(value) {
  return typeof value === "string" && AI_PENDING_ACTION_STATUSES.includes(value);
}
function isAiPendingActionQueueMode(value) {
  return typeof value === "string" && AI_PENDING_ACTION_QUEUE_MODES.includes(value);
}
function isTerminalAiPendingActionStatus(status) {
  return AI_PENDING_ACTION_TERMINAL_STATUSES.includes(status);
}
function isAllowedAiPendingActionTransition(from, to) {
  return (AI_PENDING_ACTION_ALLOWED_TRANSITIONS[from] ?? []).includes(to);
}
const AI_PENDING_ACTION_DEFAULT_TTL_SECONDS = 900;
const AI_PENDING_ACTION_TTL_ENV_VAR = "AI_PENDING_ACTION_TTL_SECONDS";
function resolveAiPendingActionTtlSeconds(env = process.env) {
  const raw = env[AI_PENDING_ACTION_TTL_ENV_VAR];
  if (raw == null) return AI_PENDING_ACTION_DEFAULT_TTL_SECONDS;
  const parsed = Number.parseInt(String(raw), 10);
  if (!Number.isFinite(parsed) || parsed <= 0) {
    return AI_PENDING_ACTION_DEFAULT_TTL_SECONDS;
  }
  return parsed;
}
export {
  AI_PENDING_ACTION_ALLOWED_TRANSITIONS,
  AI_PENDING_ACTION_DEFAULT_TTL_SECONDS,
  AI_PENDING_ACTION_QUEUE_MODES,
  AI_PENDING_ACTION_STATUSES,
  AI_PENDING_ACTION_TERMINAL_STATUSES,
  AI_PENDING_ACTION_TTL_ENV_VAR,
  AiPendingActionStateError,
  isAiPendingActionQueueMode,
  isAiPendingActionStatus,
  isAllowedAiPendingActionTransition,
  isTerminalAiPendingActionStatus,
  resolveAiPendingActionTtlSeconds
};
//# sourceMappingURL=pending-action-types.js.map
