Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# OpenRouter (shared LLM backend for hermes-agent and freebuff BYOK)
OPENROUTER_API_KEY=

# Codebuff backend (freebuff default LLM proxy)
CODEBUFF_API_KEY=

# Optional: override OpenRouter base URL (default https://openrouter.ai/api/v1)
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ scripts/identity/out/
# Ad creative projects (Remotion, npm-only, not Bun workspaces): renders and deps stay local
ad-creatives/*/out/
ad-creatives/*/node_modules/

# Local contact data holds real phone numbers (PII). Root-anchored so it never
# matches a nested project's own data/ directory.
/data/

# Reference clone of a third-party repo kept locally for reading; never part of
# this project's source.
/OpenWA/
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,43 @@ See the [Contributing Guide](./CONTRIBUTING.md), [development guide](./docs/deve

Freebuff is built on [Codebuff](https://codebuff.com), the open multi-agent framework that powers its orchestration, tools, and SDK. To create custom agents or embed them in another application, see the [Codebuff documentation](https://codebuff.com/docs) and [`@codebuff/sdk`](https://www.npmjs.com/package/@codebuff/sdk).

## Unified multi-function agent

This repository also bundles a unified agent entrypoint (`agent.py`) that combines:

- **code** — Freebuff coding agent (TypeScript CLI, LLM via OpenRouter/Codebuff)
- **chat/hermes** — Hermes Agent (general-purpose agent, OpenRouter-backed)
- **scan/osint** — User Scanner (OSINT username/email scanner)
- **gateway** — Hermes gateway (Telegram/Discord/Slack/etc.)

Run any capability:

```bash
python3 agent.py setup # once: bootstrap Hermes' pm env (stages uv + Python 3.14)
python3 agent.py code --help # Freebuff coding CLI (bun)
python3 agent.py chat # Hermes interactive agent (OpenRouter)
python3 agent.py scan --help # User Scanner
python3 agent.py gateway --help # Hermes messaging gateway (python -m gateway.run)
```

Set `OPENROUTER_API_KEY` (and optionally `CODEBUFF_API_KEY`) in a `.env` file at the repo root. See `.env.example`.

Hermes' core dependencies are gated on Python >= 3.14, so the system Python
(3.12) cannot run it. `python3 agent.py setup` runs
`vendor/hermes-agent/setup-hermes.sh`, which stages a pinned `uv` and a
Python 3.14 interpreter under `~/.hermes/tools/` and installs the hash-verified
dependency set. `agent.py` then auto-detects that interpreter for
`chat`/`hermes`/`gateway`. If the launcher step prints
"launcher publication failed", the tools are still usable through `agent.py`.

Notes:
- Hermes still needs a model provider: set `OPENROUTER_API_KEY` (or run
`hermes model` / `hermes auth add` inside its env) before `chat`/`gateway`.
- Bundled `cua-driver` (computer-use) is optional and needs `libX11`; it is
skipped on headless machines without affecting the rest.
- The `hermes` shell command refuses to run when the checkout is reached
through a symlinked path; `agent.py` invokes `cli.py` directly instead.

## Links

- [Website](https://freebuff.com)
Expand Down
139 changes: 139 additions & 0 deletions agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env python3
"""Unified multi-function coding agent.

Combines three capabilities into one entrypoint:
- code : Freebuff coding agent (TypeScript CLI, LLM via OpenRouter/Codebuff)
- chat : Hermes Agent (general-purpose agent, OpenRouter-backed)
- scan : User Scanner (OSINT username/email scanner)
- gateway: Hermes gateway (Telegram/Discord/Slack/etc.)

OpenRouter is the shared LLM backend. Set OPENROUTER_API_KEY (and optionally
CODEBUFF_API_KEY) in the environment or in a .env file at the repo root.
"""
import os
import sys
import subprocess
from pathlib import Path

ROOT = Path(__file__).resolve().parent
HERMES_DIR = ROOT / "vendor" / "hermes-agent"
SCANNER_DIR = ROOT / "vendor" / "user-scanner"
FREEBUFF_DIR = ROOT # freebuff cli lives at cli/

# Load .env if present (simple, no dependency)
env_file = ROOT / ".env"
if env_file.exists():
for line in env_file.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, _, val = line.partition("=")
key = key.strip()
val = val.strip().strip('"').strip("'")
os.environ.setdefault(key, val)

# Default OpenRouter base URL
os.environ.setdefault("OPENROUTER_BASE_URL", "https://openrouter.ai/api/v1")

# Defaults so freebuff CLI boots without a full web .env (mirrors sdk/test/setup-env.ts)
_DEFAULTS = {
"NEXT_PUBLIC_CB_ENVIRONMENT": "dev",
"NEXT_PUBLIC_CODEBUFF_APP_URL": "http://localhost:3000",
"NEXT_PUBLIC_SUPPORT_EMAIL": "support@freebuff.com",
"NEXT_PUBLIC_POSTHOG_API_KEY": "test-posthog-key",
"NEXT_PUBLIC_POSTHOG_HOST_URL": "https://us.i.posthog.com",
"NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY": "pk_test_placeholder",
"NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL": "https://billing.stripe.com/p/login/test_placeholder",
"NEXT_PUBLIC_WEB_PORT": "3000",
"FREEBUFF_MODE": "true",
}
for _k, _v in _DEFAULTS.items():
os.environ.setdefault(_k, _v)


def run(cmd, cwd=None, env=None):
merged = dict(os.environ)
if env:
merged.update(env)
return subprocess.run(cmd, cwd=cwd, env=merged)


def cmd_code(argv):
bun = os.path.expanduser("~/.bun/bin/bun")
if not os.path.exists(bun):
bun = "bun"
# freebuff cli dev
return run([bun, "--cwd", str(ROOT / "cli"), "dev", *argv])


def _pm_python():
"""Return the Python 3.14 interpreter staged by hermes' pm bootstrap.

Hermes' deps are gated on python_version >= '3.14', so the system Python
(3.12 here) cannot run it. `./agent.py setup` installs the pm interpreter
under ~/.hermes/tools/python-3.14*/bin/python3.
"""
import glob
candidates = sorted(glob.glob(os.path.expanduser("~/.hermes/tools/python-3.14*/bin/python3")))
return candidates[0] if candidates else sys.executable


def cmd_chat(argv):
# hermes cli (needs the pm-managed Python 3.14)
env = {"PYTHONPATH": str(HERMES_DIR)}
return run([_pm_python(), str(HERMES_DIR / "cli.py"), *argv], cwd=str(HERMES_DIR), env=env)


def cmd_hermes(argv):
env = {"PYTHONPATH": str(HERMES_DIR)}
return run([_pm_python(), str(HERMES_DIR / "cli.py"), *argv], cwd=str(HERMES_DIR), env=env)


def cmd_scan(argv):
env = {"PYTHONPATH": str(SCANNER_DIR)}
return run([sys.executable, "-m", "user_scanner", *argv], cwd=str(SCANNER_DIR), env=env)


def cmd_setup(argv):
# Bootstrap hermes-agent's pm-managed Python environment
setup = HERMES_DIR / "setup-hermes.sh"
if not setup.exists():
print("setup-hermes.sh not found")
return subprocess.run(["false"])
return run(["bash", str(setup), *argv], cwd=str(HERMES_DIR))


def cmd_gateway(argv):
# gateway runner entry point: `python -m gateway.run`
env = {"PYTHONPATH": str(HERMES_DIR)}
return run([_pm_python(), "-m", "gateway.run", *argv], cwd=str(HERMES_DIR), env=env)


COMMANDS = {
"setup": cmd_setup,
"code": cmd_code,
"chat": cmd_chat,
"hermes": cmd_hermes,
"scan": cmd_scan,
"osint": cmd_scan,
"gateway": cmd_gateway,
}


def main():
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
print(__doc__)
print("Usage: ./agent.py <command> [args...]")
print("Commands:", ", ".join(sorted(COMMANDS)))
sys.exit(0)
name = sys.argv[1]
if name not in COMMANDS:
print(f"Unknown command: {name}")
print("Available:", ", ".join(sorted(COMMANDS)))
sys.exit(2)
rc = COMMANDS[name](sys.argv[2:])
sys.exit(rc.returncode if rc is not None else 0)


if __name__ == "__main__":
main()
18 changes: 18 additions & 0 deletions vendor/hermes-agent/.coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CodeRabbit configuration.
#
# Auto-review is DISABLED repo-wide: the app was enabled at the org level on
# 2026-08-14 and immediately began reviewing every opened PR. This repo's
# merge gate is CI ("All required checks pass (v2)") plus maintainer review —
# CodeRabbit reviews carry no merge weight (protect-main ruleset requires
# 0 approving reviews), so auto-firing on the full PR firehose adds comment
# noise without gating value.
#
# The bot stays installed and summonable on demand: comment
# `@coderabbitai review` on any PR to request a one-off review, or
# `@coderabbitai ignore` to mute it on a PR it has already joined.
#
# To re-enable auto-review, flip `enabled: true` below (or delete this file —
# the app default is on).
reviews:
auto_review:
enabled: false
152 changes: 152 additions & 0 deletions vendor/hermes-agent/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Git
.git
.gitignore
.gitmodules

# Python
__pycache__
*.py[cod]
*$py.class
*.so
.Python
*.egg-info/
dist/
build/
!scripts/build/
!scripts/build/**

# Virtual environments
venv/
env/
ENV/

# Dependencies
node_modules
**/node_modules
.venv
**/.venv
.notebooklm-cli-venv/
.notebooklm-playwright/
.pip-cache/
.uv-cache/
.cache/
.build/

# Built artifacts that are regenerated inside the image. Excluded so local
# rebuilds on the developer's machine don't invalidate the dependency-install layer
# that now depends on the full ui-tui/packages/hermes-ink/ tree being present.
ui-tui/dist/
ui-tui/packages/hermes-ink/dist/

# CI/CD
.github
# written into the workspace by useblacksmith/setup-docker-builder
/buildkitd.toml
/docker-container-buildkitd.toml

# Environment files
.env
.env.*
# ...but keep the template: docker/stage2-hook.sh seeds $HERMES_HOME/.env from
# /opt/hermes/.env.example on first boot (OOF-285 — excluding it silently broke
# first-boot .env seeding and the API_SERVER_KEY generation that depends on it).
!.env.example

# IDE
.vscode/
.idea/
*.swp
*.swo

# Testing
.pytest_cache/
.coverage
htmlcov/

# Documentation
*.md
!skills/**/*.md
!optional-skills/**/*.md

# Runtime data (bind-mounted at /opt/data; must not leak into build context)
data/
.hermes-docker/
.notebooklm-home/

# Compose/profile runtime state (bind-mounted; avoid ownership/secret issues)
hermes-config/
runtime/

# ---------- Not needed inside the Docker image ----------

# Desktop app source (Tauri/Electron); the app is never installed in the container.
# apps/shared is the dashboard↔desktop websocket helper and is linked from
# web/package.json as a workspace:* dep — keep it in the build context.
# apps/desktop is the Webapp renderer's build input (webapp_build stage); its
# local build outputs stay out.
apps/
!apps/shared/
!apps/shared/**
!apps/desktop/
!apps/desktop/**
apps/desktop/dist/
apps/desktop/dist-webapp/
apps/desktop/build/
apps/desktop/release/
# The negations above override the global dependency and secret rules.
apps/**/node_modules
apps/desktop/**/.env
apps/desktop/**/.env.*
apps/desktop/**/.vite
apps/desktop/**/.cache
apps/desktop/**/coverage
apps/desktop/**/playwright-report
apps/desktop/**/test-results
apps/desktop/**/*.p12
apps/desktop/**/*.pfx
apps/desktop/**/*.pem
apps/desktop/**/*.key

# Test suite — not shipped in production images
tests/

# Documentation site (Docusaurus)
website/

# Keep the source artwork needed by web's icon-generation prebuild.
assets/
!assets/
assets/*
!assets/nous-girl-black.svg
!assets/nous-girl-white.svg
!assets/dmg-volume.png
!assets/backgrounds/
!assets/backgrounds/**
infographic/

# Plugin-level docs (hermes-achievements ships docs/ but the runtime doesn't read them)
plugins/hermes-achievements/docs/

# Nix / Homebrew / AUR packaging metadata — irrelevant to Docker
nix/
flake.nix
flake.lock
packaging/

# Design and planning documents
plans/
.plans/
.hermes/

# Repo-level dotfiles that are git-only or dev-tooling config
.envrc
.gitattributes
.hadolint.yaml
.mailmap

# Debug/export artifacts — must never reach image layers (COPY . .)
/log.txt
/sqlite_leak_fix.png
/*.png.bak
*.tar.gz
*.tgz
Loading
Loading