Skip to main content

Self-hosted SRE investigation copilot with YAML tools, SSH execution, SSE streaming, and secret redaction.

Project description

ops-copilot

CI PyPI Downloads License: MIT Python

Self-hosted SRE investigation copilot for production systems.

ops-copilot lets an LLM call tools defined in YAML, execute safe remote commands over SSH, redact secrets from outputs, and stream investigation events through LangGraph or an optional FastAPI SSE server.

Architecture

User question -> InvestigationGraph -> LLM -> YAML tools -> SSH host
                                      <- redacted tool output <- command result

The package is intentionally generic. You can start with shell tools from YAML, then inject custom Python RemoteTool classes for richer workflows.

Install

uv add ops-copilot

Optional extras:

uv add 'ops-copilot[server]'
uv add 'ops-copilot[openai]'
uv add 'ops-copilot[ollama]'

YAML tools

tools:
  - name: disk_usage
    type: shell
    description: Show filesystem usage.
    command: df -h

  - name: journalctl_service
    type: shell
    description: Show recent logs for a systemd service.
    command: journalctl -u {service} --since '{since}' --no-pager
    parameters:
      service:
        type: string
      since:
        type: string
        required: false
        default: "30 minutes ago"

Minimal usage

from ops_copilot import InvestigationGraph, SSHClient, ToolRegistry

ssh = SSHClient(host="server.example.com", user="deploy", key_path="~/.ssh/id_ed25519")
tools = ToolRegistry(ssh, config_path="tools.yaml").load()

graph = InvestigationGraph(
    llm=your_langchain_chat_model,
    tools=tools,
    system_prompt="You are an SRE copilot. Investigate safely and report evidence.",
)

async for event in graph.stream("The API is slow. What should I check?"):
    print(event)

Streaming events

InvestigationGraph.stream() yields dictionaries with these event names:

Event Meaning
token streamed model text
tool_start tool call started with input and step id
tool_end tool call finished with redacted output
error graph or stream error
done investigation complete

Optional FastAPI server

The ops_copilot.server.create_app() helper exposes:

  • POST /investigate
  • POST /investigate/stream

If OPS_COPILOT_API_KEY is set, clients must send X-API-Key.

Security notes

This project executes commands on servers you control. Treat tools.yaml as privileged code.

Recommendations:

  • Use SSH key auth with least-privilege users.
  • Review every command template before exposing it to an LLM.
  • Avoid destructive commands in YAML.
  • Keep parameterized commands narrow.
  • Store no secrets in YAML or prompts.
  • Rely on built-in redaction as a safety net, not as your only control.

Built-in redaction covers env-style secret lines, Bearer tokens, OpenAI-style keys, JWTs, long hex runs, and inline image data URLs.

Documentation and examples

  • docs/security-model.md documents threat boundaries and deployment controls.
  • docs/writing-tools.md explains YAML and custom Python tools.
  • docs/server.md covers the optional FastAPI/SSE integration.
  • docs/maintenance-workflows.md describes maintainer workflows and review checklists.
  • examples/local_demo.py runs without a real SSH host using fake outputs.
  • examples/custom_tool.py shows how to inject a custom RemoteTool class.

Roadmap

  • Command allowlist validation for shell tools.
  • Built-in Docker and systemd tool packs.
  • Persistent investigation sessions.
  • Audit log export.
  • More fake incident fixtures for regression tests.

Development

uv sync --dev
uv run ruff check .
uv run pytest
uv run python scripts/smoke.py

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ops_copilot-0.1.2.tar.gz (201.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ops_copilot-0.1.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file ops_copilot-0.1.2.tar.gz.

File metadata

  • Download URL: ops_copilot-0.1.2.tar.gz
  • Upload date:
  • Size: 201.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ops_copilot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4cea0c3af5d9e689db1f69c9481866b882c05689c3ad96bd79347248d901fb69
MD5 dadfeefc8ae6727e43ca46ea557288b8
BLAKE2b-256 a5c1b866e97d8b2113a6dffcd06fb2e63176f2c368cc79c91a6e3839712c675b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ops_copilot-0.1.2.tar.gz:

Publisher: publish.yml on BenjaminJornet/ops-copilot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ops_copilot-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ops_copilot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ops_copilot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 58715a8a2bd573cc367a8b30232965b5868af796db7e1f494b904f264ab5937b
MD5 b64e1ee7345079a3cebcab4bc6c4bb87
BLAKE2b-256 a659324638ab088f90ed15322b0f84c9b3e00ba5a3e2b8ff4130f1e6054709bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ops_copilot-0.1.2-py3-none-any.whl:

Publisher: publish.yml on BenjaminJornet/ops-copilot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page