Documentation
¶
Overview ¶
Package gateway decides whether an AI tool call may run, needs approval, or is denied, and audits every decision. It must not import core.
Index ¶
Constants ¶
const ( SourceWit = "wit" SourceSkill = "skill" SourcePlugin = "plugin" SourceMCP = "mcp" SourceHook = "hook" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Call ¶
type Call struct {
Source, Extension, Tool, CallID string
Write bool
Egress []string
TargetKind string
TargetID int64
}
Call is one tool call. Egress lists the destinations of a network tool. Extension is the plugin name or MCP server ID of an extension's tool.
type Entry ¶
type Entry struct {
Source, Extension, Tool, CallID string
TargetKind string
TargetID int64
Destinations []string
Decision, Reason string
}
Entry is one audit_log row. Destinations are reduced to host[:port] (see Host); no URL, query, credential or body is ever stored.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
func New ¶
New is a gateway writing to db; redact (nil: none) cleans every string an audit row stores, such as secret values in a destination.
func (*Gateway) Check ¶
Check decides c under scope and writes one structured audit_log row. If the row cannot be written the call is denied. A nil scope has read no mail.
func (*Gateway) Record ¶
Record writes one audit_log row, such as for a host-initiated event that is not a tool call, like a skill run (decision "run").
func (*Gateway) Wrap ¶
func (g *Gateway) Wrap(scope *Scope, c Call, t ai.ToolSpec, egress func(*Scope) []string) ai.ToolSpec
Wrap routes t through the gateway as c (Source, Extension, Write); every tool handed to ai.Run goes through it. Its Gate decides every call when it happens, with egress(scope) as its destinations: a scope tainted mid-run makes later egress calls interrupt for approval. The gateway decides first and a deny wins; then t's own NeedsApproval or Gate can only make it stricter. The final decision is audited with the call ID.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope is one run's data provenance. The Service rebuilds it from runs.snapshot when a run resumes. Safe for concurrent use.
func (*Scope) MarkReadMail ¶
func (s *Scope) MarkReadMail()
MarkReadMail records that mail content entered this run.