codexhome

package
v0.62.8 Latest Latest
Warning

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

Go to latest
Published: May 20, 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 AgentServerMCP added in v0.51.0

type AgentServerMCP struct {
	CodexBin              string // absolute path to codex-app-gateway binary
	WorkspaceID           string
	ExecGatewayURL        string // ws base URL; env-mcp appends /<exe_id>
	AppGatewayInternalURL string // http base for /internal/connected loopback
	WorkspaceToken        string // workspace-scoped cap token (env-injected)
	LoopbackToken         string // per-spawn loopback token (env-injected)
	// ExecGatewayInternalURL is the http base for codex-exec-gateway's
	// internal API (NOT the ws bridge URL). When non-empty (and
	// ExecGatewayInternalSecret is set), env-mcp's copy_path tool can
	// mint relay tickets and use the HTTP relay path. Empty → omit the
	// flag and secret; copy_path falls back to ws cat-pump.
	ExecGatewayInternalURL    string
	ExecGatewayInternalSecret string // written verbatim into env-mcp's env block
}

AgentServerMCP carries everything codexhome needs to emit one fixed `[mcp_servers.agentserver]` block per the 2026-05-16 redesign. One env-mcp child per codex app-server handles every executor in the workspace via env_id routing — no per-executor sections.

type ConfigInput

type ConfigInput struct {
	ModelProvider       string
	Model               string
	ModelProviders      map[string]ModelProvider
	AgentServer         AgentServerMCP
	ProjectTrustedPaths []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 string) (string, error)

NewTmpDir creates `<root>/<workspaceID>/` with mode 0700. Idempotent.

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 CODEX_HOME tree.

func NewS3Backend

func NewS3Backend(store ObjectStore, workspaceID 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 object key. New layout: codex-app-gateway/<workspace>.tar.gz.

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