Documentation
¶
Index ¶
- Variables
- func SaveConfig(config *Config, path string) error
- func SignPayload(payload *JobPayload, secret string) (string, error)
- func ValidateSignature(job *SignedJob, secret string) error
- func ValidateTTL(payload *JobPayload) error
- type AgentError
- type Config
- type Job
- type JobExecutor
- type JobPayload
- type JobResult
- type JobSignature
- type JobStatus
- type LogFrame
- type Server
- type SignedJob
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSignature = &AgentError{Code: "INVALID_SIGNATURE", Message: "Invalid job signature"} ErrJobExpired = &AgentError{Code: "JOB_EXPIRED", Message: "Job has expired (TTL exceeded)"} ErrJobTooOld = &AgentError{Code: "JOB_TOO_OLD", Message: "Job timestamp too old (possible replay attack)"} ErrInsufficientScopes = &AgentError{Code: "INSUFFICIENT_SCOPES", Message: "Insufficient scopes for job execution"} )
Errors
Functions ¶
func SaveConfig ¶
SaveConfig saves configuration to a YAML file
func SignPayload ¶
func SignPayload(payload *JobPayload, secret string) (string, error)
SignPayload creates an HMAC signature for a job payload
func ValidateSignature ¶
ValidateSignature verifies the HMAC signature of a job
func ValidateTTL ¶
func ValidateTTL(payload *JobPayload) error
ValidateTTL checks if the job has expired
Types ¶
type AgentError ¶
AgentError represents an agent-specific error
func (*AgentError) Error ¶
func (e *AgentError) Error() string
type Config ¶
type Config struct {
// Server settings
Port int `yaml:"port"`
TLSCertFile string `yaml:"tls_cert_file"`
TLSKeyFile string `yaml:"tls_key_file"`
// Authentication
HMACSecret string `yaml:"hmac_secret"`
AllowedControllers []string `yaml:"allowed_controllers"`
// Execution settings
MaxConcurrentJobs int `yaml:"max_concurrent_jobs"`
AllowedImages []string `yaml:"allowed_images"`
DefaultImage string `yaml:"default_image"`
// Security
RunAsUser string `yaml:"run_as_user"`
RunAsGroup string `yaml:"run_as_group"`
// Sandbox defaults
DefaultCPULimit float64 `yaml:"default_cpu_limit"`
DefaultMemoryLimit int64 `yaml:"default_memory_limit"`
DefaultTimeout int `yaml:"default_timeout_seconds"`
// Audit
AuditDBPath string `yaml:"audit_db_path"`
}
Config represents the agent configuration
func LoadConfig ¶
LoadConfig loads configuration from a YAML file
type Job ¶
type Job struct {
Payload *JobPayload
Status JobStatus
Result *JobResult
LogChan chan *LogFrame
CancelFunc context.CancelFunc
CreatedAt time.Time
}
Job represents a job being executed
type JobExecutor ¶
type JobExecutor struct {
// contains filtered or unexported fields
}
JobExecutor executes jobs using the sandbox runner
func NewJobExecutor ¶
func NewJobExecutor(config *Config) (*JobExecutor, error)
NewJobExecutor creates a new job executor
func (*JobExecutor) Execute ¶
func (e *JobExecutor) Execute(ctx context.Context, payload *JobPayload, logChan chan<- *LogFrame) (*JobResult, error)
Execute executes a job and streams logs
type JobPayload ¶
type JobPayload struct {
JobID string `json:"job_id"`
Prompt string `json:"prompt"`
Command string `json:"command"`
CandidateMetadata map[string]interface{} `json:"candidate_metadata"`
PluginMetadata map[string]interface{} `json:"plugin_metadata"`
RequiredScopes []string `json:"required_scopes"`
SnapshotMetadata string `json:"snapshot_metadata"` // JSON-encoded
TTL int64 `json:"ttl"` // Unix timestamp
Timestamp int64 `json:"timestamp"` // Unix timestamp
ControllerID string `json:"controller_id"`
}
JobPayload represents a signed job request from the controller
type JobResult ¶
type JobResult struct {
JobID string `json:"job_id"`
Status JobStatus `json:"status"`
SandboxID string `json:"sandbox_id"`
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
DurationMs int64 `json:"duration_ms"`
Error string `json:"error,omitempty"`
Snapshot string `json:"snapshot,omitempty"` // JSON-encoded snapshot metadata
}
JobResult contains the execution result
type JobSignature ¶
type JobSignature struct {
Signature string `json:"signature"`
Algorithm string `json:"algorithm"` // "HMAC-SHA256"
}
JobSignature contains the HMAC signature for a job payload
type LogFrame ¶
type LogFrame struct {
JobID string `json:"job_id"`
Timestamp time.Time `json:"timestamp"`
Stream string `json:"stream"` // "stdout" or "stderr"
Data string `json:"data"`
Final bool `json:"final"` // True for the last frame
}
LogFrame represents a single log message during streaming
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the agent HTTP server
type SignedJob ¶
type SignedJob struct {
Payload JobPayload `json:"payload"`
Signature JobSignature `json:"signature"`
}
SignedJob combines payload and signature