codex

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 41 Imported by: ? 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.

README

Codex Bridge

The Codex bridge connects Beeper to a local Codex CLI runtime.

It fits setups where Codex stays on the machine that already has the checkout, credentials, and tools.

What it does

  • starts or connects to codex app-server
  • maps Codex conversations into Beeper rooms
  • streams replies into chat
  • carries approvals and tool activity through the same room

Login modes

The bridge supports:

  • ChatGPT login
  • OpenAI API key login
  • externally managed ChatGPT tokens
  • host-auth auto-detection when Codex is already logged in on the machine

Managed logins use an isolated CODEX_HOME per login. Host-auth uses the machine's existing Codex auth state.

Run

./tools/bridges run codex

Or:

./run.sh codex

Documentation

Index

Constants

View Source
const (
	FlowCodexAPIKey                = "codex_api_key"
	FlowCodexChatGPT               = "codex_chatgpt"
	FlowCodexChatGPTExternalTokens = "codex_chatgpt_external_tokens"
)
View Source
const (
	CodexAuthSourceManaged = "managed"
	CodexAuthSourceHost    = "host"
)
View Source
const AIAuthFailed status.BridgeStateErrorCode = "ai-auth-failed"
View Source
const ProviderCodex = "codex"

Variables

This section is empty.

Functions

This section is empty.

Types

type CodexClient

type CodexClient struct {
	agentremote.ClientBase
	UserLogin *bridgev2.UserLogin
	// contains filtered or unexported fields
}

func (*CodexClient) Connect

func (cc *CodexClient) Connect(ctx context.Context)

func (*CodexClient) Disconnect

func (cc *CodexClient) Disconnect()

func (*CodexClient) FetchMessages

func (*CodexClient) GetApprovalHandler

func (cc *CodexClient) GetApprovalHandler() agentremote.ApprovalReactionHandler

func (*CodexClient) GetCapabilities

func (cc *CodexClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *event.RoomFeatures

func (*CodexClient) GetChatInfo

func (cc *CodexClient) GetChatInfo(_ context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

func (*CodexClient) GetContactList

func (cc *CodexClient) GetContactList(ctx context.Context) ([]*bridgev2.ResolveIdentifierResponse, error)

func (*CodexClient) GetUserInfo

func (cc *CodexClient) GetUserInfo(_ context.Context, _ *bridgev2.Ghost) (*bridgev2.UserInfo, error)

func (*CodexClient) GetUserLogin

func (cc *CodexClient) GetUserLogin() *bridgev2.UserLogin

func (*CodexClient) HandleMatrixDeleteChat

func (cc *CodexClient) HandleMatrixDeleteChat(ctx context.Context, msg *bridgev2.MatrixDeleteChat) error

HandleMatrixDeleteChat best-effort archives the Codex thread and removes the temp cwd. The core bridge handles Matrix-side room cleanup separately.

func (*CodexClient) HandleMatrixMessage

func (cc *CodexClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (*bridgev2.MatrixMessageResponse, error)

func (*CodexClient) LogoutRemote

func (cc *CodexClient) LogoutRemote(ctx context.Context)

func (*CodexClient) ResolveIdentifier

func (cc *CodexClient) ResolveIdentifier(ctx context.Context, identifier string, createChat bool) (*bridgev2.ResolveIdentifierResponse, error)

func (*CodexClient) SetUserLogin

func (cc *CodexClient) SetUserLogin(login *bridgev2.UserLogin)

type CodexClientInfo

type CodexClientInfo struct {
	Name    string `yaml:"name"`
	Title   string `yaml:"title"`
	Version string `yaml:"version"`
}

type CodexConfig

type CodexConfig struct {
	Enabled       *bool            `yaml:"enabled"`
	Command       string           `yaml:"command"`
	Listen        string           `yaml:"listen"`
	HomeBaseDir   string           `yaml:"home_base_dir"`
	DefaultModel  string           `yaml:"default_model"`
	NetworkAccess *bool            `yaml:"network_access"`
	ClientInfo    *CodexClientInfo `yaml:"client_info"`
}

CodexConfig configures the Codex app-server integration.

type CodexConnector

type CodexConnector struct {
	*agentremote.ConnectorBase

	Config Config
	// contains filtered or unexported fields
}

CodexConnector runs the dedicated Codex bridge surface.

func NewConnector

func NewConnector() *CodexConnector

type CodexLogin

type CodexLogin struct {
	User      *bridgev2.User
	Connector *CodexConnector
	FlowID    string
	// contains filtered or unexported fields
}

CodexLogin provisions a provider=codex user login backed by a local `codex app-server` process. Tokens are persisted by Codex itself under an isolated CODEX_HOME per login.

func (*CodexLogin) Cancel

func (cl *CodexLogin) Cancel()

func (*CodexLogin) Start

func (cl *CodexLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error)

func (*CodexLogin) SubmitUserInput

func (cl *CodexLogin) SubmitUserInput(ctx context.Context, input map[string]string) (*bridgev2.LoginStep, error)

func (*CodexLogin) Wait

func (cl *CodexLogin) Wait(ctx context.Context) (*bridgev2.LoginStep, error)

type Config

type Config struct {
	Bridge             bridgeconfig.BridgeConfig `yaml:"bridge"`
	Codex              *CodexConfig              `yaml:"codex"`
	ModelCacheDuration time.Duration             `yaml:"model_cache_duration"`
}

type GhostMetadata

type GhostMetadata struct {
	LastSync jsontime.Unix `json:"last_sync,omitempty"`
}

type MessageMetadata

func (*MessageMetadata) CopyFrom

func (mm *MessageMetadata) CopyFrom(other any)

type PortalMetadata

type PortalMetadata struct {
	Title            string `json:"title,omitempty"`
	Slug             string `json:"slug,omitempty"`
	IsCodexRoom      bool   `json:"is_codex_room,omitempty"`
	CodexThreadID    string `json:"codex_thread_id,omitempty"`
	CodexCwd         string `json:"codex_cwd,omitempty"`
	ElevatedLevel    string `json:"elevated_level,omitempty"`
	AwaitingCwdSetup bool   `json:"awaiting_cwd_setup,omitempty"`
	ManagedImport    bool   `json:"managed_import,omitempty"`
}

type ToolCallMetadata

type ToolCallMetadata = agentremote.ToolCallMetadata

type UserLoginMetadata

type UserLoginMetadata struct {
	Provider          string   `json:"provider,omitempty"`
	CodexHome         string   `json:"codex_home,omitempty"`
	CodexAuthSource   string   `json:"codex_auth_source,omitempty"`
	CodexCommand      string   `json:"codex_command,omitempty"`
	CodexAuthMode     string   `json:"codex_auth_mode,omitempty"`
	CodexAccountEmail string   `json:"codex_account_email,omitempty"`
	ChatGPTAccountID  string   `json:"chatgpt_account_id,omitempty"`
	ChatGPTPlanType   string   `json:"chatgpt_plan_type,omitempty"`
	ChatsSynced       bool     `json:"chats_synced,omitempty"`
	ManagedPaths      []string `json:"managed_paths,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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