ito

package module
v0.0.0-...-b409587 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 Imported by: 0

README

ito

WebSocket protocol definition between Shutter Agent and Loom Backend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(kind MessageKind, payload any) ([]byte, error)

func GenerateNodeID

func GenerateNodeID(appPrefix string) (string, error)

Types

type CPUMetrics

type CPUMetrics struct {
	UsedPercent float64   `json:"used_percent"`
	PerCPU      []float64 `json:"per_cpu"`
}

type Capability

type Capability struct {
	Kind      string   `json:"kind"`
	Version   string   `json:"version"`
	Platforms []string `json:"platforms"`

	Risk              RiskLevel `json:"risk"`
	RequiresElevation bool      `json:"requires_elevation"`
	Warning           string    `json:"warning,omitempty"`
}

type DiskMetrics

type DiskMetrics struct {
	Partitions []DiskPartition `json:"partitions"`
}

type DiskPartition

type DiskPartition struct {
	Mountpoint  string  `json:"mountpoint"`
	Total       uint64  `json:"total"`
	Used        uint64  `json:"used"`
	Free        uint64  `json:"free"`
	UsedPercent float64 `json:"used_percent"`
}

type Envelope

type Envelope struct {
	Kind    MessageKind     `json:"kind"`
	Payload json.RawMessage `json:"payload"`
}

func Decode

func Decode(data []byte) (*Envelope, error)

type ExecutorRegisteredResult

type ExecutorRegisteredResult struct {
	CorrelationID string `json:"correlation_id,omitempty"`
	Success       bool   `json:"success"`
	Error         string `json:"error,omitempty"`
}

ExecutorRegisteredResult is the response payload for KindExecutorRegistered.

type ExecutorRegistration

type ExecutorRegistration struct {
	Kind              string    `json:"kind"`
	Version           string    `json:"version"`
	Runtime           string    `json:"runtime"` // bash | python | powershell
	Script            string    `json:"script"`
	Platforms         []string  `json:"platforms"`
	Risk              RiskLevel `json:"risk"`
	RequiresElevation bool      `json:"requires_elevation"`
	Warning           string    `json:"warning,omitempty"`
	CorrelationID     string    `json:"correlation_id,omitempty"`
}

type JoinPacket

type JoinPacket struct {
	NodeID   string `json:"node_id"`
	Hostname string `json:"hostname"`

	OS   string `json:"os"`
	Arch string `json:"arch"`

	TaskManifest map[string]Capability `json:"task_manifest"`

	Version string   `json:"version"`
	Tags    []string `json:"tags"`
}

type LoadMetrics

type LoadMetrics struct {
	Load1  float64 `json:"load1"`
	Load5  float64 `json:"load5"`
	Load15 float64 `json:"load15"`
}

type MemoryMetrics

type MemoryMetrics struct {
	Total       uint64  `json:"total"`
	Used        uint64  `json:"used"`
	Free        uint64  `json:"free"`
	UsedPercent float64 `json:"used_percent"`
}

type MessageKind

type MessageKind string
const (
	KindJoinAccepted       MessageKind = "join.accepted"
	KindTaskRequest        MessageKind = "task.request"
	KindTaskResult         MessageKind = "task.result"
	KindExecutorRegister   MessageKind = "executor.register"
	KindExecutorRegistered MessageKind = "executor.registered"
)

type NetworkInterface

type NetworkInterface struct {
	Name        string `json:"name"`
	BytesSent   uint64 `json:"bytes_sent"`
	BytesRecv   uint64 `json:"bytes_recv"`
	PacketsSent uint64 `json:"packets_sent"`
	PacketsRecv uint64 `json:"packets_recv"`
}

type NetworkMetrics

type NetworkMetrics struct {
	Interfaces []NetworkInterface `json:"interfaces"`
}

type RiskLevel

type RiskLevel int
const (
	RiskLow      RiskLevel = iota // 只读或无副作用
	RiskMedium                    // 可逆变更,如服务重启
	RiskHigh                      // 难以撤销,如关机、配置修改
	RiskCritical                  // 破坏性操作,如格式化、删除
)

type TaskRequest

type TaskRequest struct {
	TaskID string          `json:"task_id"`
	Kind   string          `json:"kind"`
	Params json.RawMessage `json:"params"`
}

type TaskResult

type TaskResult struct {
	TaskID  string          `json:"task_id"`
	Success bool            `json:"success"`
	Output  json.RawMessage `json:"output,omitempty"`
	Error   string          `json:"error,omitempty"`
}

type Telemetry

type Telemetry struct {
	NodeID    string `json:"node_id"`
	Timestamp int64  `json:"ts"`
	Type      string `json:"type"`
	Payload   any    `json:"payload"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL