Documentation
¶
Overview ¶
Package config loads and validates agentgate.yaml.
Index ¶
- Constants
- Variables
- func BuiltinRedactionPatterns() []string
- func BuiltinRedactors() []*regexp.Regexp
- func ExpandEnv(s string) string
- func ExpandPath(p string) (string, error)
- func ParseDuration(s string) (time.Duration, error)
- type Approval
- type Audit
- type Config
- type Duration
- type Honeypot
- type Honeypots
- type Notify
- type Upstream
- type Webhook
Constants ¶
const ( DefaultPrefixSeparator = "__" DefaultCallTimeout = 120 * time.Second DefaultApprovalTimeout = 60 * time.Second DefaultRetention = 30 * 24 * time.Hour DefaultMaxResultBytes = 256 * 1024 DefaultAuditPath = "~/.agentgate/audit.db" DefaultUIAddr = "127.0.0.1:7777" )
Defaults that apply when the config file leaves a field out.
const ( EventDeny = "deny" EventAsk = "ask" EventHoneypot = "honeypot" EventFreeze = "freeze" EventError = "error" EventShadow = "shadow" )
Event names a webhook can subscribe to.
Variables ¶
var DefaultWebhookEvents = []string{EventDeny, EventAsk, EventHoneypot, EventFreeze}
DefaultWebhookEvents are sent when a webhook does not say which it wants.
Functions ¶
func BuiltinRedactionPatterns ¶
func BuiltinRedactionPatterns() []string
BuiltinRedactionPatterns returns the source of the built-in patterns, for documentation and for the web UI.
func BuiltinRedactors ¶
BuiltinRedactors returns the patterns agentgate redacts out of the box.
func ExpandEnv ¶
ExpandEnv replaces ${VAR} and $VAR with the value from the environment. Unset variables expand to the empty string, matching how MCP host configs behave.
func ExpandPath ¶
ExpandPath expands ${ENV} and a leading ~ in a filesystem path.
Types ¶
type Approval ¶
type Approval struct {
// Mode is auto, tty, ui or deny.
//
// auto use the web UI when it is running, else the TTY, else deny
// tty prompt on the agentgate terminal only
// ui wait for an approval in the web UI only
// deny never ask, deny every "ask" decision
Mode string `yaml:"mode"`
Timeout Duration `yaml:"timeout"`
}
Approval configures what happens to calls a rule marked "ask".
type Audit ¶
type Audit struct {
// Enabled defaults to true; set it to false to run without an audit trail.
Enabled *bool `yaml:"enabled"`
Path string `yaml:"path"`
Retention Duration `yaml:"retention"`
// Redact holds regexes applied to arguments and results before they are
// written. They are added to the built-in patterns unless BuiltinRedaction
// is false.
Redact []string `yaml:"redact"`
BuiltinRedaction *bool `yaml:"builtin_redaction"`
// MaxResultBytes caps how much of a result is stored. Larger results are
// truncated and flagged.
MaxResultBytes int `yaml:"max_result_bytes"`
// contains filtered or unexported fields
}
Audit configures the SQLite audit store.
type Config ¶
type Config struct {
Version int `yaml:"version"`
// PrefixSeparator joins the upstream name and the tool name. It defaults to
// "__" because some MCP hosts reject dots in tool names; policy rules may
// still be written with a dot either way.
PrefixSeparator string `yaml:"prefix_separator"`
CallTimeout Duration `yaml:"call_timeout"`
Approval Approval `yaml:"approval"`
Audit Audit `yaml:"audit"`
Upstreams []Upstream `yaml:"upstreams"`
Policy policy.Policy `yaml:"policy"`
Honeypots Honeypots `yaml:"honeypots"`
Notify Notify `yaml:"notify"`
// Path is the file the config was read from. It is not part of the file.
Path string `yaml:"-"`
}
Config is the whole of agentgate.yaml.
func Parse ¶
Parse decodes and validates config bytes. Unknown fields are an error, so a misspelled key is caught by "agentgate policy validate" rather than silently ignored at run time.
func (*Config) AuditEnabled ¶
AuditEnabled reports whether calls should be recorded.
func (*Config) FreezeFile ¶
FreezeFile is the path of the kill-switch marker. It sits next to the audit database so that every agentgate process reading the same config agrees on it, and so that `agentgate freeze` works with no proxy running at all.
type Duration ¶
Duration is a time.Duration that also understands the day and week suffixes used in the config file ("30d", "2w"), which time.ParseDuration rejects.
type Honeypot ¶
type Honeypot struct {
// Name is the exact name the host sees. Give it a prefix that matches a
// real upstream if you want it to blend in ("fs__delete_everything").
Name string `yaml:"name"`
Description string `yaml:"description"`
}
Honeypot is one decoy tool.
type Honeypots ¶
type Honeypots struct {
// Action is what tripping a honeypot does beyond denying the call:
// "deny" (the default) or "freeze", which also throws the kill switch.
Action string `yaml:"action"`
// Tools are the decoys. Each needs a name; a description makes it more
// convincing, and the whole point is to be convincing.
Tools []Honeypot `yaml:"tools"`
}
Honeypots are tools that do not exist. They are advertised to the host like any other tool, and a call to one is proof that the agent is acting on instructions you did not give it — a prompt injection, a hallucinated capability, or a model that has decided to be creative. Nothing is ever forwarded; the call is denied, recorded and, if you say so, freezes the gateway.
type Notify ¶
type Notify struct {
Webhooks []Webhook `yaml:"webhooks"`
}
Notify sends events to the outside world.
type Upstream ¶
type Upstream struct {
Name string `yaml:"name"`
// Stdio is the command and arguments to run, for a stdio server.
Stdio []string `yaml:"stdio"`
// HTTP is the endpoint of a Streamable HTTP server.
HTTP string `yaml:"http"`
// Env is added to the environment of a stdio server. Values may reference
// the agentgate process environment with ${VAR}.
Env map[string]string `yaml:"env"`
// Cwd is the working directory of a stdio server.
Cwd string `yaml:"cwd"`
// Headers are sent with every request to an HTTP server.
Headers map[string]string `yaml:"headers"`
// Prefix controls whether this upstream's tools are exposed with a
// "<name><sep>" prefix. It defaults to true when more than one upstream is
// configured and to false for a single upstream.
Prefix *bool `yaml:"prefix"`
Timeout Duration `yaml:"timeout"`
}
Upstream is one real MCP server agentgate connects to.
type Webhook ¶
type Webhook struct {
URL string `yaml:"url"`
// Events is the subset to send: deny, ask, honeypot, freeze, error,
// shadow. Empty means deny, ask, honeypot and freeze.
Events []string `yaml:"events"`
// Format shapes the body: "json" (the default, agentgate's own event
// object), "slack", "discord" or "ntfy". The named ones post a message
// the service renders as-is, so a webhook URL from any of them works
// with no glue in between.
Format string `yaml:"format"`
Headers map[string]string `yaml:"headers"`
}
Webhook is one HTTP endpoint that wants to hear about events.