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

native

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package native is the native host's durable state: the SQLite database that holds settings, credentials, model catalogs, sessions and Bridge documents, its one-time import from Pi-compatible files, and the per-conversation owner locks that keep one Orb process writing each conversation (DECISIONS.md "Native SQLite storage").

Index

Constants

This section is empty.

Variables

View Source
var ErrLegacyMigration = errors.New("legacy Orb data needs migration; close other Orb processes, then run orb storage migrate")

Functions

func DetachedProcAttr

func DetachedProcAttr() *syscall.SysProcAttr

DetachedProcAttr starts a daemon outside this process's session.

func Exec

func Exec(path string, argv, environment []string) error

Exec replaces this process with path.

func Migrated

func Migrated(ctx context.Context, agentDir string) (bool, error)

Migrated reports whether agentDir's state already lives in the database.

func Path

func Path(agentDir string) (string, error)

Path is the database file for agentDir: ORB_STATE_HOME, else beside an explicit agent dir or Bridge home, else ~/.orb/state.

func RequireOfflineMigration

func RequireOfflineMigration(ctx context.Context, agentDir string) error

RequireOfflineMigration refuses while another Orb process of this user selects the same agent directory, as a RunningError.

func StopLegacyWriters

func StopLegacyWriters(ctx context.Context, agentDir string, confirm func(pid int, command string) bool) error

StopLegacyWriters clears the way for the one-time migration. An Orb still running the previous version would keep writing files this one no longer reads, so confirm, given its pid and command line, decides whether to stop each; a nil confirm refuses.

Types

type RunningError

type RunningError struct{ PID int }

RunningError names another Orb still writing the data a migration moves.

func (RunningError) Error

func (e RunningError) Error() string

type State

type State struct {
	DB       *sqlite.DB
	AgentDir string
	// Files keeps settings.json and models.json in the agent dir
	// authoritative, as a deployed agent's mounted configuration is.
	Files bool
	// contains filtered or unexported fields
}

State is the open native database for one agent directory. A nil State is the file-backed fallback: every constructor then reads the Pi-compatible files under the agent directory.

func Open

func Open(ctx context.Context, agentDir string, migrate bool, credentials host.Document, sessionDirs ...string) (_ *State, err error)

Open opens agentDir's database, importing the legacy files and sessionDirs once when migrate is set; without it, pending legacy data is ErrLegacyMigration. credentials, when set, replaces auth.json.

func (*State) Accounts

func (state *State) Accounts(agentDir string, base auth.CredentialStore) *accounts.Store

func (*State) Auth

func (state *State) Auth(agentDir string) (*config.AuthStorage, error)

func (*State) BindSession

func (state *State) BindSession(manager *session.SessionManager) error

BindSession claims manager's conversation and keeps the claim.

func (*State) BridgeStore

func (state *State) BridgeStore(path string, quota int) (*nativebridge.Store, error)

func (*State) ChatNamespace

func (state *State) ChatNamespace(path string) string

ChatNamespace is the namespace of a chat gateway's data directory.

func (*State) ChildSession

func (state *State) ChildSession(cwd string) (*session.SessionManager, error)

ChildSession is a new session for an extension's child agent.

func (*State) ClaimSession

func (state *State) ClaimSession(manager *session.SessionManager) (func(), error)

ClaimSession takes manager's conversation for this state, refusing one another Orb process holds; the returned func releases the previous claim.

func (*State) Close

func (state *State) Close() error

func (*State) Conversation

func (state *State) Conversation() *State

Conversation shares this state's store with a claim of its own, for a process that keeps several conversations open at once (ACP).

func (*State) DeleteSession

func (state *State) DeleteSession(id string) error

DeleteSession deletes a stored conversation no Orb holds open.

func (*State) Document

func (state *State) Document(path string) host.Document

Document implements host.Store: kernel paths under the agent dir and the Bridge homes map to their namespaces, anything else is keyed by its path.

func (*State) Memory

func (state *State) Memory() memory.Store

func (*State) Models

func (state *State) Models(agentDir string, credentials auth.CredentialStore, offline bool) (*config.ModelRegistry, error)

func (*State) OwnerLock

func (state *State) OwnerLock(id string) (*flock.Flock, error)

OwnerLock is the lock an Orb process holds while it writes conversation id.

func (*State) PruneEmpty

func (state *State) PruneEmpty(ctx context.Context)

PruneEmpty drops the empty conversations earlier runs left behind. A minute of grace covers one that another Orb created but has not claimed yet.

func (*State) Read

func (state *State) Read(ctx context.Context, path string) ([]byte, error)

Read and Write fall back to private files without a database; an absent document reads as os.ErrNotExist, and writing nil deletes it.

func (*State) Release

func (state *State) Release()

Release drops the conversation claim, discarding a conversation left empty.

func (*State) Sessions

func (state *State) Sessions() *sqlite.Sessions

func (*State) Settings

func (state *State) Settings(cwd, agentDir string, options ...config.Option) (*config.SettingsManager, error)

func (*State) Trust

func (state *State) Trust(agentDir string) (*config.ProjectTrustStore, error)

func (*State) Write

func (state *State) Write(ctx context.Context, path string, data []byte) error

Directories

Path Synopsis
Package accounts backs the named-credential store with a private JSON file.
Package accounts backs the named-credential store with a private JSON file.
Package bridge supplies explicit filesystem and IPC adapters for Orb Bridge.
Package bridge supplies explicit filesystem and IPC adapters for Orb Bridge.
daemon
Package daemon is the native Bridge service: the process `orb bridge run` serves, reached over private IPC sockets in the profile directory, its peers over Tailcat and WebSocket, the machine-level calls it answers peers (host.*), and its installation as a systemd user service or on a server over SSH.
Package daemon is the native Bridge service: the process `orb bridge run` serves, reached over private IPC sockets in the profile directory, its peers over Tailcat and WebSocket, the machine-level calls it answers peers (host.*), and its installation as a systemd user service or on a server over SSH.
Package sandbox limits filesystem effects of child commands.
Package sandbox limits filesystem effects of child commands.
Package selfupdate replaces the running orb with a signed release: it fetches the same archive and checksums.txt that scripts/install.sh does, verifies the signature and sha256, and swaps the binary by atomic rename.
Package selfupdate replaces the running orb with a signed release: it fetches the same archive and checksums.txt that scripts/install.sh does, verifies the signature and sha256, and swaps the binary by atomic rename.
Package sqlite supplies explicitly opened native persistence.
Package sqlite supplies explicitly opened native persistence.
Package tailcat supplies stream transport only.
Package tailcat supplies stream transport only.
Package teamenv is the receiving side of a team agent's entrypoint contract (platforms/agent/harness): credentials on ORB_SECRETS_FD and ORB_AUTH_FD, never in the environment or files the agent's tools could open, and a process its same-user tools cannot inspect.
Package teamenv is the receiving side of a team agent's entrypoint contract (platforms/agent/harness): credentials on ORB_SECRETS_FD and ORB_AUTH_FD, never in the environment or files the agent's tools could open, and a process its same-user tools cannot inspect.

Jump to

Keyboard shortcuts

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