codex

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateSchemaVersion  = 1
	ToolContractVersion = 1
)

Variables

This section is empty.

Functions

func Run

func Run(parent context.Context, cfg Config) error

Run connects one externally supervised app-server thread to the Intercom broker and blocks until cancellation or a fatal lifecycle error.

Types

type Config

type Config struct {
	Name              string
	Version           string
	CWD               string
	AppServerEndpoint string
	ClientEndpoint    string
	BrokerSocket      string
	BrokerBin         string
	New               bool
	Logger            *slog.Logger

	QueueSize       int
	StartupTimeout  time.Duration
	ControlTimeout  time.Duration
	ReverseTimeout  time.Duration
	ActivityTimeout time.Duration
	StatePath       string
	LockPath        string
	OnReady         func(ReadyInfo) error
	OnStopping      func() error
	// contains filtered or unexported fields
}

type ManagedState

type ManagedState struct {
	SchemaVersion       int    `json:"schemaVersion"`
	Peer                string `json:"peer"`
	ThreadID            string `json:"threadId"`
	CWD                 string `json:"cwd"`
	CodexHome           string `json:"codexHome"`
	ServerUserAgent     string `json:"serverUserAgent"`
	CodexVersion        string `json:"codexVersion"`
	ToolContractVersion int    `json:"toolContractVersion"`
	Materialized        bool   `json:"materialized"`
}

ManagedState binds an Intercom peer to the Codex thread it exclusively manages. Conversation data remains in CODEX_HOME; this record contains only binding identity, compatibility metadata, and last-validated runtime diagnostics.

func (ManagedState) Validate

func (s ManagedState) Validate() error

type ReadyInfo

type ReadyInfo struct {
	Name           string
	CWD            string
	ThreadID       string
	ClientEndpoint string
	CodexVersion   string
}

ReadyInfo describes the live managed thread after the broker and optional TUI proxy are ready. OnReady runs synchronously before Run enters its main service loop.

type StateStore

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

StateStore owns the non-blocking lifetime lock for one peer and provides atomic state reads and writes.

func AcquireStateStore

func AcquireStateStore(statePath, lockPath string) (*StateStore, error)

AcquireStateStore acquires lockPath without waiting. The returned store must be closed for the process lifetime of the managed peer.

func (*StateStore) Close

func (s *StateStore) Close() error

func (*StateStore) Load

func (s *StateStore) Load() (*ManagedState, error)

Load returns nil, nil when no binding exists.

func (*StateStore) Remove

func (s *StateStore) Remove() error

func (*StateStore) Save

func (s *StateStore) Save(state ManagedState) error

Save durably and atomically replaces the state file with mode 0600.

Jump to

Keyboard shortcuts

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