Rewst's lean, open-source command executor that fits right into your Rewst workflows. See community corner for more details.
Agent Smith runs as a system service on Windows, Linux, and macOS. Installation involves configuring the agent with your organization credentials and starting the service.
- A Rewst organization ID
- Configuration URL and secret from your Rewst platform
- Administrative/root privileges for service installation
- Download the appropriate binary for your platform from the releases page
- Configure the agent with your organization credentials:
Windows:
rewst_agent_config.win.exe --org-id YOUR_ORG_ID --config-url CONFIG_URL --config-secret CONFIG_SECRETLinux/macOS:
./rewst_agent_config.linux.bin --org-id YOUR_ORG_ID --config-url CONFIG_URL --config-secret CONFIG_SECRET
# or
./rewst_agent_config.mac-os.bin --org-id YOUR_ORG_ID --config-url CONFIG_URL --config-secret CONFIG_SECRET--logging-level: Set logging verbosity (info,warn,error,debug)--syslog: Write logs to system log instead of file (Linux/macOS)--disable-agent-postback: Disable agent postback--no-auto-updates: Disable auto updates
Example with optional parameters:
./rewst_agent_config --org-id YOUR_ORG_ID --config-url CONFIG_URL --config-secret CONFIG_SECRET --logging-level info --syslog --disable-agent-postback --no-auto-updatesOnce installed, the agent can be updated and configured using the config executable. The optional parameters are also available.
./rewst_agent_config --org-id YOUR_ORG_ID --update --logging-level info --syslog --disable-agent-postback --no-auto-updatesOnce configured, the agent can run in service mode using the generated configuration:
./rewst_agent_config --org-id YOUR_ORG_ID --config-file /path/to/config.json --log-file /path/to/agent.logTo remove Agent Smith from your system:
# Replace with your organization ID
./rewst_agent_config --org-id YOUR_ORG_ID --uninstallThis will stop the service, remove configuration files, and clean up system service registrations.
- Cross-platform: Runs on Windows, Linux, and macOS
- Secure: Uses Azure IoT Hub MQTT for encrypted communication
- Extensible: Plugin system for custom notifications and integrations
- Reliable: Automatic reconnection and error handling
- Lightweight: Minimal resource footprint
- Agent connects to your Rewst organization via Azure IoT Hub MQTT
- Receives command execution requests from Rewst workflows
- Executes commands using PowerShell (Windows) or Bash (Unix/Linux/macOS)
- Returns results back to the Rewst platform
- Supports system information collection and custom plugins
Required tools and packages:
-
commitizen: To use a standardized description of commits.
pipx ensurepath pipx install commitizen pipx upgrade commitizen -
go-winres: To embed icons and file versions to windows executables.
go install github.com/tc-hib/go-winres@latest
Run the following command using powershell or pwsh to build the binary:
./scripts/build.ps1
Agent Smith maintains high code quality through comprehensive testing with an 80% coverage threshold.
Run all tests:
go test ./...Run tests with verbose output:
go test ./... -vRun tests for a specific package:
go test ./cmd/agent_smith -v
go test ./internal/service -v
go test ./plugins -vRun a specific test:
go test ./cmd/agent_smith -v -run TestLoadConfigGenerate coverage report:
./scripts/coverage.ps1This script:
- Runs tests across all packages
- Generates coverage profiles
- Enforces 80% minimum coverage threshold
Note: When running tests locally on Linux, some tests write to
/tmp/rewst_remote_agent/scripts. If that directory was created byroot(e.g., viasudo), your user won't have write access. Fix it by running:sudo chmod -R o+w /tmp/rewst_remote_agent
Unit Tests: Test individual functions and components in isolation
- Message parsing and validation
- Configuration loading
- SAS token generation
- Path resolution
Integration Tests: Test component interactions
- MQTT message flow (with test broker)
- Service lifecycle (start/stop/restart)
- Plugin loading and notifications
- Command execution and postback
Platform-Specific Tests: Test OS-specific functionality
- Windows service management
- Linux systemd integration
- macOS launchd integration
- System information collection
When contributing new code, ensure:
- Test coverage: Aim for >80% coverage for new code
- Table-driven tests: Use for multiple test cases
tests := []struct { name string input string expected string }{ {"case1", "input1", "expected1"}, {"case2", "input2", "expected2"}, }
- Clean up resources: Use
t.TempDir()anddeferstatements - Avoid flaky tests: Use proper synchronization and timeouts
- Mock external dependencies: Don't rely on network or filesystem in unit tests
Tests run automatically on:
- Every pull request
- Every push to main branch
- Pre-release validation
GitHub Actions Workflows:
.github/workflows/test.yml- Runs test suite.github/workflows/coverage.yml- Validates coverage threshold
Pull requests must:
- ✅ Pass all tests
- ✅ Maintain ≥80% coverage
- ✅ Pass all linters
- ✅ Pass CodeQL security scanning
Agent Smith uses golangci-lint for strict security and code formatting enforcement.
See this guide to learn how to install golangci-lint on your local machine.
golangci-lint rungolangci-lint run --fixLinting runs automatically on:
- Every pull request
- Every push to main branch
Contributions are always welcome. Please submit a PR!
Please use commitizen to format the commit messages. After staging your changes, you can commit the changes with this command.
cz commit
Agent Smith is licensed under GNU GENERAL PUBLIC LICENSE. See license file for details.