{ sec, inputs, ... }:
{
  imports = [
    inputs.nix-openclaw.homeManagerModules.openclaw
  ];

  programs.openclaw = {
    enable = true;
    installApp = false;
    systemd.enable = true;

    bundledPlugins = {
      summarize.enable = true;
    };

    instances.default = {
      enable = true;
      systemd.enable = true;

      config = {
        agents.defaults = {
          model.primary = "openrouter/qwen/qwen3-coder:free";
          sandbox.mode = "off";
        };

        gateway = {
          mode = "local";
          auth.token = sec."rus07tam/openclaw/gatewayToken".path;
        };

        channels.telegram = {
          tokenFile = sec."rus07tam/openclaw/telegramToken".path;
          allowFrom = [ 6146757977 ];
          groups = {
            "*" = {
              requireMention = true;
            };
          };
        };
      };
    };
  };
}
