Documentation
¶
Overview ¶
Package bridge defines the agent-to-agent protocol that allows OK instances to discover each other and share tasks. Multiple OK agents on a local network (or same machine) can form an ad-hoc team without any central server — pure peer-to-peer.
Discovery: mDNS (Bonjour/avahi) on port 9463. Each agent announces its name, capabilities, and current load. Discovery is zero-config.
Communication: HTTP/JSON over the same port. Agents RPC each other with task requests, returning results as streaming NDJSON.
Security: local-network only (bind 127.0.0.1 or LAN interface). Shared secret (from ~/.ok/agent-secret) prevents unauthorized peers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadOrCreateSecret ¶
func LoadOrCreateSecret() string
LoadOrCreateSecret returns the agent's shared secret (for peer auth). Creates one on first run. Errors are logged to stderr; a best-effort secret is always returned (bridge is optional, so startup is never blocked by a missing secret).
Types ¶
type AgentInfo ¶
type AgentInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Model string `json:"model"`
Load int `json:"load"` // 0-100
Tags []string `json:"tags"` // desktop, server, coding, personal
Addr string `json:"addr"` // ip:port
LastSeen time.Time `json:"-"`
}
AgentInfo describes an agent on the network.
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge manages agent-to-agent connections.
func NewBridge ¶
func NewBridge(secret string, port int, onTask func(ctx context.Context, task string) (<-chan string, error)) *Bridge
NewBridge creates an agent bridge. If port is 0, the system picks a random available port (read via ListenerAddr after Start). Default port is 9463.
type TaskRequest ¶
type TaskRequest struct {
From string `json:"from"`
Task string `json:"task"`
Timeout int `json:"timeout_sec"`
}
TaskRequest is sent from one agent to another.