const PENDING_ACTION_CLEANUP_SCHEDULE_ID = "ai_assistant:pending-action-cleanup";
const TOKEN_USAGE_PRUNE_SCHEDULE_ID = "ai_assistant:token-usage-prune";
async function ensurePendingActionCleanupSchedule(container) {
  if (!container) return;
  let schedulerService;
  try {
    schedulerService = container.resolve("schedulerService");
  } catch {
    schedulerService = void 0;
  }
  if (!schedulerService) return;
  try {
    await schedulerService.register({
      id: PENDING_ACTION_CLEANUP_SCHEDULE_ID,
      name: "AI pending-action cleanup",
      description: "Sweep pending AI mutation approvals whose TTL elapsed without confirm/cancel and flip them to expired.",
      scopeType: "system",
      scheduleType: "interval",
      scheduleValue: "5m",
      timezone: "UTC",
      targetType: "queue",
      targetQueue: "ai-pending-action-cleanup",
      targetPayload: {},
      sourceType: "module",
      sourceModule: "ai_assistant",
      isEnabled: true
    });
  } catch (error) {
    console.warn(
      "[ai_assistant] Failed to register pending-action cleanup schedule:",
      error instanceof Error ? error.message : error
    );
  }
}
async function ensureTokenUsagePruneSchedule(container) {
  if (!container) return;
  let schedulerService;
  try {
    schedulerService = container.resolve("schedulerService");
  } catch {
    schedulerService = void 0;
  }
  if (!schedulerService) return;
  try {
    await schedulerService.register({
      id: TOKEN_USAGE_PRUNE_SCHEDULE_ID,
      name: "AI token-usage prune",
      description: "Delete ai_token_usage_events rows older than AI_TOKEN_USAGE_EVENTS_RETENTION_DAYS (default 90) and reconcile session_count on the daily rollup.",
      scopeType: "system",
      scheduleType: "interval",
      scheduleValue: "24h",
      timezone: "UTC",
      targetType: "queue",
      targetQueue: "ai-token-usage-prune",
      targetPayload: {},
      sourceType: "module",
      sourceModule: "ai_assistant",
      isEnabled: true
    });
  } catch (error) {
    console.warn(
      "[ai_assistant] Failed to register token-usage prune schedule:",
      error instanceof Error ? error.message : error
    );
  }
}
const setup = {
  defaultRoleFeatures: {
    admin: [
      "ai_assistant.view",
      "ai_assistant.settings.manage",
      "ai_assistant.conversations.manage",
      "ai_assistant.conversations.share",
      "ai_assistant.mcp.serve",
      "ai_assistant.tools.list",
      "ai_assistant.mcp_servers.view",
      "ai_assistant.mcp_servers.manage"
    ],
    employee: ["ai_assistant.view", "ai_assistant.conversations.share"]
  },
  async seedDefaults({ container }) {
    await ensurePendingActionCleanupSchedule(container);
    await ensureTokenUsagePruneSchedule(container);
  }
};
var setup_default = setup;
export {
  setup_default as default,
  setup
};
//# sourceMappingURL=setup.js.map
