codexhome

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package codexhome owns per-thread CODEX_HOME tmpdirs: creation, destruction, and the rendering of the config.toml fragment we plant inside each one before spawning `codex app-server`.

Index

Constants

This section is empty.

Variables

View Source
var ErrObjectNotFound = errors.New("codexhome: object not found")

ErrObjectNotFound is returned by ObjectStore.Get when a key is absent.

Functions

func RenderConfigTOML

func RenderConfigTOML(cfg ConfigInput) (string, error)

RenderConfigTOML produces the TOML body. Pure function so tests can assert exact substrings without filesystem.

Types

type ConfigInput

type ConfigInput struct {
	ModelProvider       string
	Model               string
	ModelProviders      map[string]ModelProvider
	Executors           []ExecutorEntry
	ProjectTrustedPaths []string
}

type ExecutorEntry

type ExecutorEntry struct {
	ID        string
	BridgeURL string
	TokenEnv  string
	TokenVal  string // injected via env, not written to TOML
	Desc      string
	CodexBin  string // path to codex-app-gateway binary (for `env-mcp` subcommand)
	TurnID    string
}

type Manager

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

Manager creates per-thread CODEX_HOME tmpdirs under root.

func NewManager

func NewManager(root string) *Manager

func (*Manager) NewTmpDir

func (m *Manager) NewTmpDir(workspaceID, threadID string) (string, error)

NewTmpDir creates `<root>/<workspaceID>/<threadID>/` with mode 0700. Idempotent: returns the existing path if already present.

func (*Manager) RemoveTmpDir

func (m *Manager) RemoveTmpDir(path string) error

RemoveTmpDir removes a previously-created tmpdir tree, but refuses to remove anything outside the manager's root.

func (*Manager) WriteConfig

func (m *Manager) WriteConfig(codexHome string, cfg ConfigInput) error

WriteConfig renders `config.toml` into the given CODEX_HOME dir.

type ModelProvider

type ModelProvider struct {
	Name    string
	BaseURL string
	EnvKey  string
	WireAPI string
}

type ObjectStore

type ObjectStore interface {
	Put(ctx context.Context, key string, data []byte) error
	Get(ctx context.Context, key string) ([]byte, error)
	Delete(ctx context.Context, key string) error
}

ObjectStore is the seam between codexhome and the S3 client. Real callers wire in a thin wrapper around aws-sdk-go-v2; tests use a map-backed fake.

type S3Backend

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

S3Backend round-trips a single (workspace, thread) CODEX_HOME tree.

func NewS3Backend

func NewS3Backend(store ObjectStore, workspaceID, threadID string) *S3Backend

func (*S3Backend) Download

func (b *S3Backend) Download(ctx context.Context, dst string) error

Download fetches the tarball and untars into dst (which must exist and be owned by the caller).

func (*S3Backend) Key

func (b *S3Backend) Key() string

Key is the S3 key. Exposed so callers (and tests) can introspect.

func (*S3Backend) Upload

func (b *S3Backend) Upload(ctx context.Context, src string) error

Upload tars+gzips the directory tree at src and writes it to S3.

Jump to

Keyboard shortcuts

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