Help us shape the future of Go! Take the 2026 Go Developer Survey

machine

package
v0.4.23 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ContractVersion = "v1"
View Source
const ExecutionContractVersion = "v1"
View Source
const StreamContractVersion = "v1"

Variables

View Source
var ErrJSONObject = errors.New("invalid or ambiguous machine JSON object")

Functions

func CapabilitySpecifications

func CapabilitySpecifications() []string

func ExecutionCorrelation added in v0.4.23

func ExecutionCorrelation(ctx context.Context) string

func MCPTools added in v0.4.15

func MCPTools() []string

func MachineHTTPBindings added in v0.4.23

func MachineHTTPBindings() map[string]HTTPBinding

func ValidateJSONObject added in v0.4.23

func ValidateJSONObject(data []byte, maxBytes int) error

ValidateJSONObject rejects duplicate keys at every depth before typed decoding. The entire object, including trailing whitespace, must fit the caller's bound. Error text never contains untrusted keys, values or parser diagnostics.

func WithExecutionCorrelation added in v0.4.23

func WithExecutionCorrelation(ctx context.Context, id string) context.Context

WithExecutionCorrelation carries the authoritative execution identity to typed transport and provider boundaries. It contains no actor credential.

Types

type ActorRef added in v0.4.22

type ActorRef struct {
	Mode      string   `json:"mode"`
	Issuer    string   `json:"issuer,omitempty"`
	Subject   string   `json:"subject,omitempty"`
	Assurance string   `json:"assurance,omitempty"`
	Methods   []string `json:"authentication_methods,omitempty"`
}

type ApplicationListResult added in v0.4.23

type ApplicationListResult struct {
	ContractVersion string              `json:"contract_version"`
	Deployments     []DeploymentSummary `json:"deployments"`
	Warnings        []string            `json:"warnings,omitempty"`
}

type DeploymentSummary added in v0.4.23

type DeploymentSummary struct {
	ContractVersion string `json:"contract_version"`
	DeploymentID    string `json:"deployment_id"`
	ApplicationID   string `json:"application_id"`
	Target          string `json:"target"`
	Application     string `json:"application"`
	Environment     string `json:"environment"`
	RuntimeProvider string `json:"runtime_provider,omitempty"`
	State           string `json:"state,omitempty"`
	Ready           bool   `json:"ready"`
	SourceKind      string `json:"source_kind,omitempty"`
	SourceAvailable bool   `json:"source_available"`
}

Navigation results are shared by CLI JSON, MCP and protected HTTP. These records describe Core observations; they do not imply live health.

type Discovery added in v0.4.22

type Discovery struct {
	HTTP             map[string]HTTPBinding `json:"http,omitempty"`
	ContractVersion  string                 `json:"contract_version"`
	ExecutionVersion string                 `json:"execution_version"`
	Operations       []Operation            `json:"operations"`
	Capabilities     []string               `json:"capabilities,omitempty"`
}

func MachineDiscovery added in v0.4.22

func MachineDiscovery() Discovery

type Error

type Error struct {
	Code        ErrorCode `json:"code"`
	Message     string    `json:"message"`
	CauseCode   string    `json:"cause,omitempty"`
	Retryable   bool      `json:"retryable,omitempty"`
	Next        string    `json:"next,omitempty"`
	Resource    string    `json:"resource,omitempty"`
	Remediation string    `json:"remediation_class,omitempty"`
	Cause       error     `json:"-"`
}

func Classify

func Classify(err error) *Error

func NewError

func NewError(code ErrorCode, message, next string, retryable bool) *Error

func Wrap

func Wrap(code ErrorCode, err error, next string, retryable bool) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCode

type ErrorCode string
const (
	ErrorValidationFailed         ErrorCode = "validation_failed"
	ErrorNotFound                 ErrorCode = "not_found"
	ErrorPortConflict             ErrorCode = "port_conflict"
	ErrorRequiredSecretMissing    ErrorCode = "required_secret_missing"
	ErrorSourceMissing            ErrorCode = "source_missing"
	ErrorApprovalRequired         ErrorCode = "approval_required"
	ErrorWorkloadStartFailed      ErrorCode = "workload_start_failed"
	ErrorImagePullFailed          ErrorCode = "image_pull_failed"
	ErrorAuthenticationFailed     ErrorCode = "authentication_failed"
	ErrorInvalidWorkload          ErrorCode = "invalid_workload"
	ErrorCapabilityMissing        ErrorCode = "capability_missing"
	ErrorPolicyDenied             ErrorCode = "policy_denied"
	ErrorConflict                 ErrorCode = "conflict"
	ErrorOwnershipAmbiguous       ErrorCode = "ownership_ambiguous"
	ErrorProviderUnavailable      ErrorCode = "provider_unavailable"
	ErrorRuntimeUnavailable       ErrorCode = "runtime_unavailable"
	ErrorHostResourceInsufficient ErrorCode = "host_resource_insufficient"
	ErrorTimeout                  ErrorCode = "timeout"
	ErrorVerificationFailed       ErrorCode = "verification_failed"
	ErrorUnsupported              ErrorCode = "unsupported_operation"
	ErrorInternal                 ErrorCode = "internal_error"
)

type ErrorResult

type ErrorResult struct {
	ContractVersion string `json:"contract_version"`
	Error           *Error `json:"error"`
}

func ResultError

func ResultError(err error) ErrorResult

type EventKind added in v0.4.22

type EventKind string
const (
	EventOperationStarted   EventKind = "operation.started"
	EventOperationProgress  EventKind = "operation.progress"
	EventOperationSucceeded EventKind = "operation.succeeded"
	EventOperationFailed    EventKind = "operation.failed"
	EventOperationCancelled EventKind = "operation.cancelled"
	EventApplicationState   EventKind = "application.state"
	EventProviderState      EventKind = "provider.state"
	EventTargetState        EventKind = "target.state"
	EventRuntimeResource    EventKind = "runtime.resource"
)

type Execution added in v0.4.22

type Execution struct {
	ContractVersion string             `json:"contract_version"`
	ExecutionID     string             `json:"execution_id"`
	OperationID     string             `json:"operation_id"`
	Actor           ActorRef           `json:"actor"`
	Context         OperationContext   `json:"context"`
	State           ExecutionState     `json:"state"`
	StartedAt       *time.Time         `json:"started_at,omitempty"`
	FinishedAt      *time.Time         `json:"finished_at,omitempty"`
	Progress        *OperationProgress `json:"progress,omitempty"`
	Result          json.RawMessage    `json:"result,omitempty"`
	Error           *Error             `json:"error,omitempty"`
}

func (Execution) Validate added in v0.4.22

func (e Execution) Validate() error

type ExecutionState added in v0.4.22

type ExecutionState string
const (
	ExecutionPending   ExecutionState = "pending"
	ExecutionRunning   ExecutionState = "running"
	ExecutionSucceeded ExecutionState = "succeeded"
	ExecutionFailed    ExecutionState = "failed"
	ExecutionCancelled ExecutionState = "cancelled"
)

type HTTPBinding added in v0.4.23

type HTTPBinding struct {
	Href     string `json:"href"`
	Method   string `json:"method"`
	Protocol string `json:"protocol,omitempty"`
}

HTTPBinding is the canonical browser endpoint, including named resource placeholders. Clients pin the Core origin and substitute validated IDs only.

type MachineEvent added in v0.4.22

type MachineEvent struct {
	ContractVersion string             `json:"contract_version"`
	Sequence        uint64             `json:"sequence"`
	OccurredAt      time.Time          `json:"occurred_at"`
	Kind            EventKind          `json:"kind"`
	ExecutionID     string             `json:"execution_id,omitempty"`
	OperationID     string             `json:"operation_id,omitempty"`
	Actor           *ActorRef          `json:"actor,omitempty"`
	Context         *OperationContext  `json:"context,omitempty"`
	State           ExecutionState     `json:"state,omitempty"`
	Progress        *OperationProgress `json:"progress,omitempty"`
	Result          json.RawMessage    `json:"result,omitempty"`
	Error           *Error             `json:"error,omitempty"`
	ResourceKind    string             `json:"resource_kind,omitempty"`
	ResourceID      string             `json:"resource_id,omitempty"`
}

type Operation

type Operation struct {
	ID                   string      `json:"id"`
	Description          string      `json:"description"`
	Safety               SafetyClass `json:"safety"`
	ConfirmationRequired bool        `json:"confirmation_required"`
	PolicyRequired       bool        `json:"policy_required"`
	ContractVersion      string      `json:"contract_version"`
	MCPTool              string      `json:"mcp_tool,omitempty"`
}

func OperationByID added in v0.4.15

func OperationByID(id string) (Operation, bool)

func Operations

func Operations() []Operation

type OperationContext added in v0.4.22

type OperationContext struct {
	Application string `json:"application,omitempty"`
	Environment string `json:"environment,omitempty"`
	Target      string `json:"target,omitempty"`
	Workspace   string `json:"workspace,omitempty"`
	Resource    string `json:"resource,omitempty"`
}

type OperationProgress added in v0.4.22

type OperationProgress struct {
	Stage   string  `json:"stage,omitempty"`
	Message string  `json:"message,omitempty"`
	Current int64   `json:"current,omitempty"`
	Total   int64   `json:"total,omitempty"`
	Percent float64 `json:"percent,omitempty"`
}

type SafetyClass

type SafetyClass string
const (
	SafetyReadOnly    SafetyClass = "read_only"
	SafetyMutating    SafetyClass = "mutating"
	SafetyDestructive SafetyClass = "destructive"
)

type StreamDescriptor added in v0.4.22

type StreamDescriptor struct {
	ContractVersion string           `json:"contract_version"`
	StreamID        string           `json:"stream_id"`
	Kind            StreamKind       `json:"kind"`
	Actor           ActorRef         `json:"actor"`
	Context         OperationContext `json:"context"`
	ResourceKind    string           `json:"resource_kind"`
	ResourceID      string           `json:"resource_id"`
	CreatedAt       time.Time        `json:"created_at"`
}

type StreamKind added in v0.4.22

type StreamKind string
const (
	StreamLogs StreamKind = "logs"
	StreamExec StreamKind = "exec"
)

type StreamRequest added in v0.4.22

type StreamRequest struct {
	ContractVersion string           `json:"contract_version"`
	Kind            StreamKind       `json:"kind"`
	Context         OperationContext `json:"context"`
	ResourceKind    string           `json:"resource_kind"`
	ResourceID      string           `json:"resource_id"`
	Since           *time.Time       `json:"since,omitempty"`
	Tail            int              `json:"tail,omitempty"`
	Follow          bool             `json:"follow,omitempty"`
	Command         []string         `json:"command,omitempty"`
	Rows            int              `json:"rows,omitempty"`
	Columns         int              `json:"columns,omitempty"`
	TTY             bool             `json:"tty,omitempty"`
}

func (StreamRequest) Validate added in v0.4.22

func (r StreamRequest) Validate() error

type TargetListResult added in v0.4.23

type TargetListResult struct {
	ContractVersion string          `json:"contract_version"`
	Targets         []TargetSummary `json:"targets"`
}

type TargetSummary added in v0.4.23

type TargetSummary struct {
	ContractVersion string `json:"contract_version"`
	Name            string `json:"name"`
	RuntimeProvider string `json:"runtime_provider"`
	AccessReference string `json:"access_reference"`
	Scope           string `json:"scope,omitempty"`
	Implicit        bool   `json:"implicit,omitempty"`
	Default         bool   `json:"default,omitempty"`
	Active          bool   `json:"active,omitempty"`
	Effective       bool   `json:"effective,omitempty"`
}

type TerminalEvent added in v0.4.23

type TerminalEvent struct {
	ContractVersion string    `json:"contract_version"`
	StreamID        string    `json:"stream_id"`
	Sequence        uint64    `json:"sequence"`
	Kind            string    `json:"kind"`
	OccurredAt      time.Time `json:"occurred_at"`
	Data            []byte    `json:"data,omitempty"`
	ExitCode        *int      `json:"exit_code,omitempty"`
}

TerminalEvent carries binary PTY output as JSON base64; replay is forbidden.

type TerminalInput added in v0.4.23

type TerminalInput struct {
	ContractVersion string `json:"contract_version"`
	Sequence        uint64 `json:"sequence"`
	Kind            string `json:"kind"`
	Data            []byte `json:"data,omitempty"`
	Rows            int    `json:"rows,omitempty"`
	Columns         int    `json:"columns,omitempty"`
}

type WorkspaceListResult added in v0.4.23

type WorkspaceListResult struct {
	ContractVersion string             `json:"contract_version"`
	Workspaces      []WorkspaceSummary `json:"workspaces"`
	Warnings        []string           `json:"warnings,omitempty"`
}

type WorkspaceSummary added in v0.4.23

type WorkspaceSummary struct {
	ContractVersion string            `json:"contract_version"`
	Application     string            `json:"application"`
	Manifest        string            `json:"manifest"`
	SourceCount     int               `json:"source_count"`
	Sources         map[string]string `json:"sources,omitempty"`
}

Jump to

Keyboard shortcuts

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