codex

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 25 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

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
	MCPBridgeSocket   string
	IntercomBin       string
	BrokerSocket      string
	BrokerBin         string
	New               bool
	AdoptThreadID     string
	ForkThreadID      string
	ReplaceBinding    bool
	ExecutionPolicy   ExecutionPolicy
	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 ExecutionPolicy added in v0.2.2

type ExecutionPolicy string

ExecutionPolicy is the launch-scoped command execution boundary for a managed Codex service. It is deliberately not persisted in ManagedState; omitting --yolo on a later launch returns the thread to workspace-write.

const (
	ExecutionWorkspaceWrite   ExecutionPolicy = "workspace-write"
	ExecutionDangerFullAccess ExecutionPolicy = "danger-full-access"
)

func (ExecutionPolicy) IsYolo added in v0.2.2

func (p ExecutionPolicy) IsYolo() bool

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"`
	ToolTransport       ToolTransport `json:"toolTransport"`
	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
	ExecutionPolicy ExecutionPolicy
}

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.

type ThreadLock added in v0.2.2

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

ThreadLock is a non-blocking process-lifetime advisory lock. It coordinates Intercom controllers; ordinary Codex processes do not honor it.

func AcquireThreadLock added in v0.2.2

func AcquireThreadLock(lockPath string) (*ThreadLock, error)

AcquireThreadLock prevents two Intercom peers from managing the same Codex thread concurrently.

func (*ThreadLock) Close added in v0.2.2

func (l *ThreadLock) Close() error

Close releases the thread lock.

type ToolTransport added in v0.2.2

type ToolTransport string

ToolTransport identifies how a managed Codex thread reaches Intercom's tools. Threads created by Intercom persist app-server dynamic tools in their rollout. Adopted and forked interactive threads receive an ephemeral MCP bridge configuration on every cold resume.

const (
	ToolTransportDynamic   ToolTransport = "dynamic"
	ToolTransportMCPBridge ToolTransport = "mcpBridge"
)

Jump to

Keyboard shortcuts

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