localstate

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneRoots added in v1.2.1

func CloneRoots(sourcePath, targetPath string) error

CloneRoots prepares a state database for a new cloud identity without carrying over task, command or workspace identifiers owned by the old one.

func DefaultDir

func DefaultDir() (string, error)

func SaveConfig

func SaveConfig(path string, cfg Config) error

Types

type CommandRecord

type CommandRecord struct {
	Status    string          `json:"status"`
	Result    json.RawMessage `json:"result,omitempty"`
	Error     string          `json:"error,omitempty"`
	UpdatedAt time.Time       `json:"updatedAt"`
}

type CommandSnapshot

type CommandSnapshot struct {
	CommandID uuid.UUID `json:"commandId"`
	CommandRecord
}

type Config

type Config struct {
	ServerURL string    `json:"serverUrl"`
	RunnerID  uuid.UUID `json:"runnerId"`
	NodeID    string    `json:"nodeId"`
	Name      string    `json:"name"`
	StatePath string    `json:"statePath"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

type CredentialStore

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

func OpenCredentialStore

func OpenCredentialStore(dir string) (*CredentialStore, error)

func (*CredentialStore) Delete

func (s *CredentialStore) Delete() error

func (*CredentialStore) Get

func (s *CredentialStore) Get() (string, error)

func (*CredentialStore) Set

func (s *CredentialStore) Set(credential string) error

type RequestRecord

type RequestRecord struct {
	Key       string          `json:"key"`
	TaskID    uuid.UUID       `json:"taskId"`
	Method    string          `json:"method"`
	RequestID json.RawMessage `json:"requestId"`
	Params    json.RawMessage `json:"params,omitempty"`
	CreatedAt time.Time       `json:"createdAt"`
}

RequestRecord is intentionally Runner-local. In particular, the raw Codex JSON-RPC request id must never be copied to the Control Plane database.

type State

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

func Open

func Open(path string) (*State, error)

func (*State) AddRoot

func (s *State) AddRoot(path string) error

func (*State) Close

func (s *State) Close() error

func (*State) Command

func (s *State) Command(id uuid.UUID) (CommandRecord, bool, error)

func (*State) Commands

func (s *State) Commands(limit int) ([]CommandSnapshot, error)

Commands returns the newest durable command records. UUIDv7 command keys sort chronologically, so walking the bucket backwards gives a bounded reconnect snapshot without allowing this message to grow forever.

func (*State) CompleteCommand

func (s *State) CompleteCommand(id uuid.UUID, result json.RawMessage, errorMessage string) error

func (*State) DeleteRequest

func (s *State) DeleteRequest(key string) error

func (*State) MarkReceived

func (s *State) MarkReceived(id uuid.UUID) (CommandRecord, bool, error)

func (*State) PutRequest

func (s *State) PutRequest(record RequestRecord) error

func (*State) PutTask

func (s *State) PutTask(record TaskRecord) error

func (*State) PutWorkspace

func (s *State) PutWorkspace(record WorkspaceRecord) error

func (*State) ReconcileIdentity added in v1.2.1

func (s *State) ReconcileIdentity(keepCommandID uuid.UUID, workspaceIDs []uuid.UUID) error

ReconcileIdentity removes stale runtime records after the user explicitly merges old Runner installations. Authorized roots and selected workspaces remain available; only the current reconcile command survives for ack/result.

func (*State) Request

func (s *State) Request(key string) (RequestRecord, bool, error)

func (*State) Roots

func (s *State) Roots() ([]string, error)

func (*State) Task

func (s *State) Task(id uuid.UUID) (TaskRecord, bool, error)

func (*State) TaskByThread

func (s *State) TaskByThread(threadID string) (TaskRecord, bool, error)

func (*State) Tasks

func (s *State) Tasks() ([]TaskRecord, error)

func (*State) Workspace

func (s *State) Workspace(id uuid.UUID) (WorkspaceRecord, bool, error)

func (*State) Workspaces

func (s *State) Workspaces() ([]WorkspaceRecord, error)

type TaskRecord

type TaskRecord struct {
	TaskID       uuid.UUID `json:"taskId"`
	ThreadID     string    `json:"threadId"`
	ActiveTurnID string    `json:"activeTurnId,omitempty"`
	RelayTurnID  uuid.UUID `json:"relayTurnId,omitempty"`
	WorkspaceID  uuid.UUID `json:"workspaceId"`
	Workspace    string    `json:"workspace"`
	BaselineDiff string    `json:"baselineDiff,omitempty"`
	UpdatedAt    time.Time `json:"updatedAt"`
}

type WorkspaceRecord

type WorkspaceRecord struct {
	ID            uuid.UUID `json:"id"`
	CanonicalPath string    `json:"canonicalPath"`
	Name          string    `json:"name"`
	UpdatedAt     time.Time `json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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