Documentation
¶
Overview ¶
Package bridges hosts INBOUND bridge installers — wiring foreign AI coding agents to use clawtool as their MCP server. The OUTBOUND equivalents (clawtool → foreign-CLI install recipes) live in internal/setup/recipes/bridges; their hermes-bridge there is the outbound surface (verify `hermes` binary on PATH so SendMessage can dispatch to it). This package handles the reverse direction: editing the foreign agent's own config so it dials clawtool.
Currently Hermes-only — Codex / Gemini / OpenCode use the generic mcp_host adapter in internal/agents which shells out to `<bin> mcp add`. Hermes has no `hermes mcp add` subcommand, so the bridge edits ~/.hermes/config.yaml directly. New foreign agents without an `mcp add` surface land here too.
Index ¶
Constants ¶
const MCPServerName = "clawtool"
MCPServerName is the canonical name the inbound MCP server entry uses across every host. Matches internal/agents.MCPServerName so `clawtool` is the identifier the operator sees in every host's config — kept duplicated here rather than imported to avoid an import cycle (internal/bridges → internal/agents → internal/cli → internal/bridges).
Variables ¶
This section is empty.
Functions ¶
func HermesBinaryOnPATH ¶
func HermesBinaryOnPATH() bool
HermesBinaryOnPATH reports whether `hermes` is on PATH. Used by bridge add to surface a useful warning when the operator installs the inbound entry on a host without Hermes.
func HermesConfigPath ¶
func HermesConfigPath() string
HermesConfigPath returns the path Hermes's config.yaml lives at — $HOME/.hermes/config.yaml in production, or the test override. Exposed for tests + diagnostic output.
func HermesEntryPresent ¶
HermesEntryPresent reports whether the clawtool entry exists in ~/.hermes/config.yaml. Used by `bridge list` to render status.
func SetHermesConfigPath ¶
func SetHermesConfigPath(p string)
SetHermesConfigPath redirects the inbound bridge to a custom config path. Tests use it; production should never call it.
func SetHermesExecutable ¶
SetHermesExecutable redirects the resolver used to find the clawtool binary. Tests use it to pin a deterministic value.
Types ¶
type HermesAddOptions ¶
type HermesAddOptions struct {
// Upgrade overwrites an existing entry instead of skipping with
// AlreadyPresent.
Upgrade bool
// ExecutablePath, when non-empty, is used in place of resolving
// the running binary. Tests + autodev paths set this so a
// deterministic path is recorded in the entry's `command:`.
ExecutablePath string
}
HermesAddOptions tunes the InstallHermes call.
type HermesAddResult ¶
type HermesAddResult struct {
ConfigPath string // path written (or that would have been written)
ExecutablePath string // clawtool binary referenced in the entry
Installed bool // entry written this call
AlreadyPresent bool // entry already matched the desired shape, no-op
}
HermesAddResult reports what InstallHermes did. The CLI surfaces this via the structured `bridge add --json` path so automation can branch on AlreadyPresent vs Installed.
func InstallHermes ¶
func InstallHermes(opts HermesAddOptions) (HermesAddResult, error)
InstallHermes adds an `mcp_servers.clawtool` entry to Hermes's config.yaml that wires clawtool as an MCP server. Idempotent: if the entry already exists with the right shape the call is a no-op and AlreadyPresent=true. With Upgrade=true the entry is rewritten even when present.
The file is atomically rewritten via temp+rename. Comments and ordering on keys we don't touch are preserved (yaml.v3 round-trip).
type HermesRemoveResult ¶
type HermesRemoveResult struct {
ConfigPath string
Removed bool // entry existed and was deleted
Missing bool // entry wasn't present; call was a noop
}
HermesRemoveResult reports the outcome of RemoveHermes.
func RemoveHermes ¶
func RemoveHermes() (HermesRemoveResult, error)
RemoveHermes deletes the `mcp_servers.clawtool` entry from config.yaml. Idempotent: a missing entry returns Missing=true with no error. Unrelated keys in the file are preserved.