daemonclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package daemonclient communicates with the local HTTP service; it never opens USB.

Index

Constants

View Source
const DefaultEndpoint = "http://127.0.0.1:8931"

Variables

This section is empty.

Functions

func ParseSequenceColorInput

func ParseSequenceColorInput(input string) (json.RawMessage, error)

ParseSequenceColorInput accepts a CLI color string or a JSON ColorInput. Color references are retained for the daemon to resolve when it saves.

func ValidSequenceColorName

func ValidSequenceColorName(name string) bool

func ValidateLightV2Progress

func ValidateLightV2Progress(previous, current control.FrameJob) error

ValidateLightV2Progress compares two individually validated snapshots from one original action. Callers retaining history must also bind immutable job timestamps and monotonic progress; a valid isolated snapshot is not enough.

func ValidatePatternV2Progress

func ValidatePatternV2Progress(previous, current control.PatternJobEnvelope) error

ValidatePatternV2Progress revalidates both mutable exported envelopes and requires identity, timestamps and progress to remain bound to one receipt.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(endpoint string) (*Client, error)

func (*Client) Cancel

func (c *Client) Cancel(ctx context.Context, id string) (out control.Job, err error)

func (*Client) CancelLightV2

func (c *Client) CancelLightV2(ctx context.Context, serial string, data []byte, receipt control.ReceiptRequest, jobID string) (LightV2CancelResult, error)

CancelLightV2 binds cancellation to the original high-level action and receipt before selecting a Job ID. It never submits a light action or retries a cancellation POST. The POST includes an instance precondition and requires the same instance in its response, then rechecks the original receipt.

func (*Client) CancelPatternV2Request

func (c *Client) CancelPatternV2Request(ctx context.Context, serial string, ref patternidentity.Ref, key control.ReceiptRequest, knownJobID, knownDigest string) (PatternCancelResultV2, error)

func (*Client) CancelSequenceJob

func (c *Client) CancelSequenceJob(ctx context.Context, id string) (control.SequenceJob, error)

func (*Client) Capabilities

func (c *Client) Capabilities(ctx context.Context) (control.CapabilityCatalog, error)

Capabilities returns the daemon's software compiler catalog, not hardware discovery. An older daemon is explicitly unsupported; no fallback is made.

func (*Client) Close

func (c *Client) Close()

func (*Client) Device

func (c *Client) Device(ctx context.Context, serial string) (out control.DeviceState, err error)

func (*Client) Devices

func (c *Client) Devices(ctx context.Context) (out []control.DeviceState, err error)

func (*Client) ExportPatterns

func (c *Client) ExportPatterns(ctx context.Context, id string) ([]byte, error)

ExportPatterns validates the complete canonical snapshot before returning bytes. id="" means the library. Returned path metadata is never opened.

func (*Client) ExportPatternsV2

func (c *Client) ExportPatternsV2(ctx context.Context, id string) ([]byte, error)

ExportPatternsV2 returns an integrity-checked canonical frozen snapshot. id="" selects the library. Valid unknown source/recipe records are preserved for read-only backup; returning them does not make them importable or runnable.

func (*Client) GetPattern

func (c *Client) GetPattern(ctx context.Context, id string) (patterns.Record, error)

func (*Client) GetPatternV2

func (c *Client) GetPatternV2(ctx context.Context, id string) (PatternRecordV2, error)

GetPatternV2 makes one bounded HTTP read and verifies identity, complete source/recipe integrity and the server's verification/digest metadata.

func (*Client) Health

func (c *Client) Health(ctx context.Context) (out Health, err error)

func (*Client) ImportPatterns

func (c *Client) ImportPatterns(ctx context.Context, data []byte) (patternstore.ImportResult, error)

ImportPatterns validates locally but sends the original authoring/snapshot bytes once. It never creates a Job, retries, or substitutes a different file.

func (*Client) ImportPatternsV2

func (c *Client) ImportPatternsV2(ctx context.Context, data []byte) (PatternWriteResultV2, error)

ImportPatternsV2 validates the complete verified snapshot before one POST. Original bytes are sent without a retry, redirect, authoring conversion or device operation. Unsupported read-only exports cannot be imported.

func (*Client) InspectNative

func (c *Client) InspectNative(ctx context.Context, serial string, request nativeinspection.Request) (nativeinspection.Result, error)

InspectNative performs one daemon GET, never preparation, retry, discovery or direct USB fallback. A request timeout does not forcibly cancel native I/O.

func (*Client) Instance

func (c *Client) Instance(ctx context.Context) (out control.InstanceInfo, err error)

func (*Client) Job

func (c *Client) Job(ctx context.Context, id string) (out control.Job, err error)

func (*Client) ListPatterns

func (c *Client) ListPatterns(ctx context.Context) (httpapi.PatternList, error)

func (*Client) ListPatternsV2

func (c *Client) ListPatternsV2(ctx context.Context) (PatternListV2, error)

ListPatternsV2 performs one bounded GET, without per-record fetches, tickets, preview, device work or local filesystem access. Unknown summaries stay visible and read-only; advertised verification is never promoted to execution consent.

func (*Client) LookupLightRequest

func (c *Client) LookupLightRequest(ctx context.Context, serial string, data []byte, receipt control.ReceiptRequest, jobID string) (control.Job, error)

LookupLightRequest reads the original receipt with a fixed accepted Job ID. A lookup failure never establishes that the original execution did not occur.

func (*Client) LookupLightV2Request

func (c *Client) LookupLightV2Request(ctx context.Context, serial string, data []byte, receipt control.ReceiptRequest, jobID string) (control.FrameJob, error)

LookupLightV2Request can recover a lost acceptance response without a Job ID. If a Job ID was already confirmed, require that same ID on every later read. Any failed lookup preserves uncertainty about the original accepted action.

func (*Client) LookupPatternRequest

func (c *Client) LookupPatternRequest(ctx context.Context, serial string, receipt control.ReceiptRequest, accepted control.Job) (control.Job, error)

LookupPatternRequest never resolves the library again. It binds only to the accepted Job's ID and frozen Program and the original receipt.

func (*Client) LookupPatternV2Request

func (c *Client) LookupPatternV2Request(ctx context.Context, serial string, ref patternidentity.Ref, key control.ReceiptRequest, knownJobID, knownDigest string) (control.PatternJobEnvelope, error)

LookupPatternV2Request reads only the exact original receipt. Optional known job/digest values constrain recovery; empty strings mean no extra constraint.

func (*Client) Prepare

func (c *Client) Prepare(ctx context.Context) (control.ReceiptRequest, error)

Prepare generates a binding without reserving a receipt or submitting a job.

func (*Client) Preview

Preview invokes the daemon's authoritative compiler exactly once. It never submits a Job, prepares a receipt, retries a POST or opens a device.

func (*Client) PreviewLight

func (c *Client) PreviewLight(ctx context.Context, data []byte, serial *string) (LightPreview, error)

PreviewLight sends original Action JSON, not the locally compiled Program. The shared compiler is used here only to bind the response to this input.

func (*Client) PreviewLightV2

func (c *Client) PreviewLightV2(ctx context.Context, data []byte, serial *string) (LightV2Preview, error)

PreviewLightV2 sends the original high-level action. Local compilation only verifies the returned deterministic recipe and never replaces its request.

func (*Client) PreviewPattern

func (c *Client) PreviewPattern(ctx context.Context, ref httpapi.PatternRef, serial *string) (httpapi.PatternPreview, error)

func (*Client) PreviewPatternDraftV2

func (c *Client) PreviewPatternDraftV2(ctx context.Context, data []byte) (PatternDraftPreviewV2, error)

PreviewPatternDraftV2 sends the author's exact bytes once. Local pure compilation only binds the response; no record is saved and no job is made.

func (*Client) PreviewPatternRefV2

func (c *Client) PreviewPatternRefV2(ctx context.Context, ref patternidentity.Ref, serial *string) (PatternRefPreviewV2, error)

func (*Client) PreviewSequence

func (c *Client) PreviewSequence(ctx context.Context, input SequenceInput, serial string) (SequencePreview, error)

func (*Client) Request

func (c *Client) Request(ctx context.Context, serial string, receipt control.ReceiptRequest) (out control.Job, err error)

func (*Client) ResolveColor

func (c *Client) ResolveColor(ctx context.Context, color json.RawMessage) (colorinput.Result, error)

ResolveColor computes a color through the daemon exactly once. Input and response use the shared software contract; no device or execution API is used.

func (*Client) SavePatternV2

func (c *Client) SavePatternV2(ctx context.Context, data []byte) (PatternWriteResultV2, error)

SavePatternV2 validates confirmation against the complete candidate, sends the exact bytes once and accepts only the original saved record. Publication uncertainty is separate from execution: this method never creates a job.

func (*Client) SaveSequenceColor

func (c *Client) SaveSequenceColor(ctx context.Context, name string, color json.RawMessage) (SequenceColor, error)

func (*Client) SaveSequencePattern

func (c *Client) SaveSequencePattern(ctx context.Context, id string, input SequenceInput, title string) (SequencePattern, error)

func (*Client) SequenceColors

func (c *Client) SequenceColors(ctx context.Context) ([]SequenceColor, error)

func (*Client) SequenceJob

func (c *Client) SequenceJob(ctx context.Context, id string) (control.SequenceJob, error)

func (*Client) SequencePattern

func (c *Client) SequencePattern(ctx context.Context, id string) (SequencePattern, error)

func (*Client) SequencePatterns

func (c *Client) SequencePatterns(ctx context.Context) ([]SequencePatternSummary, error)

func (*Client) Submit

func (c *Client) Submit(ctx context.Context, serial string, program control.Program, policy string) (out control.Job, err error)

func (*Client) SubmitEffect

func (c *Client) SubmitEffect(ctx context.Context, serial string, effect control.Effect, policy string) (out control.Job, err error)

SubmitEffect sends the high-level intent to the daemon's authoritative compiler; this HTTP adapter does not maintain a second effect compiler.

func (*Client) SubmitEffectWithReceipt

func (c *Client) SubmitEffectWithReceipt(ctx context.Context, serial string, effect control.Effect, policy string, receipt control.ReceiptRequest) (out control.ReceiptResult, err error)

func (*Client) SubmitLightV2WithReceipt

func (c *Client) SubmitLightV2WithReceipt(ctx context.Context, serial string, data []byte, receipt control.ReceiptRequest) (control.FrameReceiptResult, error)

SubmitLightV2WithReceipt issues one high-level POST with the original ticket. It never prepares a replacement, falls back to low-level frames, or retries.

func (*Client) SubmitLightWithReceipt

func (c *Client) SubmitLightWithReceipt(ctx context.Context, serial string, data []byte, receipt control.ReceiptRequest) (control.ReceiptResult, error)

SubmitLightWithReceipt makes exactly one bound POST with policy reject. It never prepares a replacement ticket, retries, or falls back to /jobs/direct.

func (*Client) SubmitPatternV2WithReceipt

func (c *Client) SubmitPatternV2WithReceipt(ctx context.Context, serial string, ref patternidentity.Ref, policy string, key control.ReceiptRequest) (control.PatternReceiptResult, error)

SubmitPatternV2WithReceipt sends exactly one execution POST. It neither prepares a ticket nor resolves/previews a library first: accepted receipts must replay even when the source library later disappears.

func (*Client) SubmitPatternWithReceipt

func (c *Client) SubmitPatternWithReceipt(ctx context.Context, serial string, ref httpapi.PatternRef, receipt control.ReceiptRequest) (control.ReceiptResult, error)

SubmitPatternWithReceipt performs one target preview and at most one bound jobs POST. The preview's independent frozen Program binds the accepted Job.

func (*Client) SubmitSequence

func (c *Client) SubmitSequence(ctx context.Context, input SequenceInput, serial, id string) (control.SequenceJob, error)

func (*Client) SubmitWithReceipt

func (c *Client) SubmitWithReceipt(ctx context.Context, serial string, program control.Program, policy string, receipt control.ReceiptRequest) (out control.ReceiptResult, err error)

type DecodeError

type DecodeError struct {
	Status int
	Err    error
}

DecodeError means an HTTP response arrived but its body could not be decoded. It is distinct from an API rejection: callers cannot infer a submission's outcome from malformed response data.

func (*DecodeError) Error

func (e *DecodeError) Error() string

func (*DecodeError) Unwrap

func (e *DecodeError) Unwrap() error

type Error

type Error struct {
	Status        int
	Code, Message string
}

func (*Error) Error

func (e *Error) Error() string

type Health

type Health struct {
	Status     string `json:"status"`
	APIVersion string `json:"api_version"`
}

Health describes the HTTP service only; it does not prove a device is online.

type InspectionError

type InspectionError struct {
	Result nativeinspection.Result
}

InspectionError means a valid collection envelope arrived but the requested native observation is incomplete. Result retains partial data and errors; this is not a malformed response or an API admission rejection.

func (*InspectionError) Error

func (e *InspectionError) Error() string

type LightPreview

type LightPreview struct {
	Result  lightaction.Result    `json:"result"`
	Preview control.PreviewResult `json:"preview"`
}

LightPreview preserves both the authoring result and the device-aware Program preview. Every field is checked against the original request.

type LightV2CancelResult

type LightV2CancelResult struct {
	Job              control.FrameJob
	DaemonInstanceID string
	CancelAttempted  bool
	AlreadyTerminal  bool
	// Only transport/server uncertainty permits further receipt-only polling.
	// Integrity errors must not be hidden by a subsequent plausible response.
	QueryRecoveryAllowed bool
	// A validated POST snapshot also constrains recovery if its confirming GET
	// failed. Job remains the last fully receipt-confirmed display snapshot.
	RecoveryAnchor *control.FrameJob
}

LightV2CancelResult retains the last receipt-verified Job even when the cancellation response is lost or inconsistent. Attempted does not mean the request reached the daemon, or that cancellation/cleanup has completed.

type LightV2FramePreview

type LightV2FramePreview struct {
	Contract             string                             `json:"contract"`
	Program              control.FrameProgram               `json:"program"`
	TotalFrames          int                                `json:"total_frames"`
	StoredTargetWrites   int                                `json:"stored_target_writes"`
	PlannedTargetWrites  int                                `json:"planned_target_writes"`
	CycleDurationMS      int64                              `json:"cycle_duration_ms"`
	NominalInitialMS     int64                              `json:"nominal_initial_ms"`
	NominalTailMS        int64                              `json:"nominal_tail_ms"`
	NominalDurationMS    int64                              `json:"nominal_duration_ms"`
	TimingBasis          string                             `json:"timing_basis"`
	RequiredCapabilities []string                           `json:"required_capabilities"`
	Execution            control.FrameExecutionAvailability `json:"execution"`
	Device               *LightV2PreviewDevice              `json:"device,omitempty"`
}

Keep this wire type flat: the strict JSON checker deliberately does not flatten anonymous embedded structs when collecting permitted JSON fields.

type LightV2Preview

type LightV2Preview struct {
	Result  lightactionv2.Result `json:"result"`
	Preview LightV2FramePreview  `json:"preview"`
}

func LocalLightV2Preview

func LocalLightV2Preview(data []byte) (LightV2Preview, error)

LocalLightV2Preview performs pure compilation only; execution remains unchecked. Neither this helper nor the compiler opens a device or a socket.

type LightV2PreviewDevice

type LightV2PreviewDevice struct {
	Serial     string `json:"serial"`
	Connection string `json:"connection"`
}

type PatternCancelResultV2

type PatternCancelResultV2 struct {
	Job              *control.PatternJobEnvelope `json:"job,omitempty"`
	DaemonInstanceID string                      `json:"daemon_instance_id,omitempty"`
	CancelAttempted  bool                        `json:"cancel_attempted"`
	AlreadyTerminal  bool                        `json:"already_terminal"`
}

PatternCancelResultV2 retains the last trusted snapshot on every later failure. CancelAttempted only records the one POST attempt, not delivery or completed cleanup. No failed POST is followed by a good GET to hide failure.

type PatternDraftPreviewV2

type PatternDraftPreviewV2 struct {
	SchemaVersion    int                            `json:"schema_version"`
	Contract         string                         `json:"contract"`
	Record           json.RawMessage                `json:"record"`
	Verification     patternsv2.Support             `json:"verification"`
	ExecutionDigest  string                         `json:"execution_digest"`
	Preview          patternsv2.PreviewFacts        `json:"preview"`
	PatternExecution PatternExecutionAvailabilityV2 `json:"pattern_execution"`
}

Keep this wire type flat for the common strict JSON field checker.

type PatternExecutionAvailabilityV2

type PatternExecutionAvailabilityV2 struct {
	Available bool   `json:"available"`
	Reason    string `json:"reason"`
}

type PatternImportError

type PatternImportError struct {
	Err                error
	PublicationUnknown bool
}

PatternImportError is about publication, never execution. A lost or malformed response may follow a successful import; inspect the original IDs/revisions.

func (*PatternImportError) Error

func (e *PatternImportError) Error() string

func (*PatternImportError) Unwrap

func (e *PatternImportError) Unwrap() error

type PatternLibraryInfoV2

type PatternLibraryInfoV2 struct {
	Path            string `json:"path"`
	State           string `json:"state"`
	CreateOnly      bool   `json:"create_only"`
	MaxRecords      int    `json:"max_records"`
	MaxPackageBytes int    `json:"max_package_bytes"`
	RecordContract  string `json:"record_contract"`
	SnapshotKind    string `json:"snapshot_kind"`
}

PatternLibraryInfoV2 describes the daemon's selected library. Path is display metadata only, including when the daemon runs on a different OS.

type PatternListV2

type PatternListV2 struct {
	SchemaVersion    int                            `json:"schema_version"`
	Contract         string                         `json:"contract"`
	Library          PatternLibraryInfoV2           `json:"library"`
	PatternExecution PatternExecutionAvailabilityV2 `json:"pattern_execution"`
	Patterns         []PatternSummaryV2             `json:"patterns"`
}

type PatternRecordV2

type PatternRecordV2 struct {
	SchemaVersion   int                `json:"schema_version"`
	Contract        string             `json:"contract"`
	Record          json.RawMessage    `json:"record"`
	Verification    patternsv2.Support `json:"verification"`
	ExecutionDigest string             `json:"execution_digest"`
}

PatternRecordV2 keeps the complete original record as JSON. InspectRecord validates its typed execution without losing valid future source/recipe data. A successful read does not grant permission to execute an unknown recipe.

type PatternRefPreviewV2

type PatternRefPreviewV2 struct {
	SchemaVersion    int                            `json:"schema_version"`
	Contract         string                         `json:"contract"`
	PatternRef       patternidentity.Ref            `json:"pattern_ref"`
	ExecutionDigest  string                         `json:"execution_digest"`
	Execution        json.RawMessage                `json:"execution"`
	Preview          json.RawMessage                `json:"preview"`
	PatternExecution PatternExecutionAvailabilityV2 `json:"pattern_execution"`
}

PatternRefPreviewV2 preserves the exact frozen execution and pure preview wire JSON after validating both against closed typed core data. It verifies an execution digest, not the server's original source compiler or hardware.

type PatternSnapshotImportErrorV2

type PatternSnapshotImportErrorV2 struct {
	Err error
	// contains filtered or unexported fields
}

PatternSnapshotImportErrorV2 retains the exact import input and requested references after an uncertain or rejected publication. It is not an execution receipt. Errors.As can still find the underlying PatternImportError.

func (*PatternSnapshotImportErrorV2) Error

func (*PatternSnapshotImportErrorV2) OriginalSnapshotJSON

func (e *PatternSnapshotImportErrorV2) OriginalSnapshotJSON() []byte

func (*PatternSnapshotImportErrorV2) RequestedRefs

func (e *PatternSnapshotImportErrorV2) RequestedRefs() []patternidentity.Ref

func (*PatternSnapshotImportErrorV2) Unwrap

func (e *PatternSnapshotImportErrorV2) Unwrap() error

type PatternSummaryV2

type PatternSummaryV2 struct {
	PatternRef        patternidentity.Ref `json:"pattern_ref"`
	Title             string              `json:"title"`
	SourceContract    string              `json:"source_contract"`
	ExecutionKind     string              `json:"execution_kind"`
	ExecutionContract string              `json:"execution_contract"`
	Verification      patternsv2.Support  `json:"verification"`
	ExecutionDigest   string              `json:"execution_digest"`
}

PatternSummaryV2 contains advertised metadata, not a complete verified Record. Use GetPatternV2 for independent source/recipe/revision/digest verification.

type PatternWriteResultV2

type PatternWriteResultV2 struct {
	SchemaVersion int               `json:"schema_version"`
	Contract      string            `json:"contract"`
	Records       []json.RawMessage `json:"records"`
	Created       []string          `json:"created"`
	Existing      []string          `json:"existing"`
	Total         int               `json:"total"`
}

type ReceiptError

type ReceiptError struct {
	Err            error
	Receipt        control.ReceiptRequest
	OutcomeUnknown bool
}

ReceiptError preserves the binding after an uncertain submission or lookup. Expiry/instance changes cannot establish whether the original intent ran.

func (*ReceiptError) Error

func (e *ReceiptError) Error() string

func (*ReceiptError) Unwrap

func (e *ReceiptError) Unwrap() error

type SequenceColor

type SequenceColor struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

type SequenceDeviceCheck

type SequenceDeviceCheck struct {
	Status string `json:"status"`
	Reason string `json:"reason,omitempty"`
}

type SequenceInput

type SequenceInput struct {
	Action    json.RawMessage `json:"action,omitempty"`
	Sequence  json.RawMessage `json:"sequence,omitempty"`
	PatternID *string         `json:"pattern_id,omitempty"`
}

SequenceInput retains the original author input used to identify a Job.

func DecodeSequenceInput

func DecodeSequenceInput(data []byte) (SequenceInput, error)

type SequencePattern

type SequencePattern struct {
	ID       string            `json:"id"`
	Title    string            `json:"title,omitempty"`
	Sequence sequence.Sequence `json:"sequence"`
}

type SequencePatternSummary

type SequencePatternSummary struct {
	ID    string `json:"id"`
	Title string `json:"title,omitempty"`
}

type SequencePreview

type SequencePreview struct {
	Sequence             sequence.Sequence   `json:"sequence"`
	TotalSteps           int                 `json:"total_steps"`
	NominalDurationMS    int64               `json:"nominal_duration_ms"`
	RequiredCapabilities []string            `json:"required_capabilities"`
	DeviceCheck          SequenceDeviceCheck `json:"device_check"`
}

Jump to

Keyboard shortcuts

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