fix: create Codex account config directories

This commit is contained in:
zhoujun0601
2026-08-13 08:08:02 -04:00
parent 000cb0c53a
commit fa9d9bea8a
2 changed files with 51 additions and 0 deletions
+10
View File
@@ -41,6 +41,9 @@ func (c *Client) Start(ctx context.Context) error {
if c.connected {
return nil
}
if e := ensureConfigDir(c.configDir); e != nil {
return e
}
cmd := exec.CommandContext(ctx, "codex", "app-server")
cmd.Env = append(os.Environ(), "CODEX_HOME="+c.configDir)
out, e := cmd.StdoutPipe()
@@ -60,6 +63,13 @@ func (c *Client) Start(ctx context.Context) error {
go func() { _ = cmd.Wait(); c.failAll(cmd) }()
return nil
}
func ensureConfigDir(dir string) error {
if e := os.MkdirAll(dir, 0700); e != nil {
return fmt.Errorf("create CODEX_HOME %q: %w", dir, e)
}
return nil
}
func (c *Client) Initialize(ctx context.Context) error {
var out any
if e := c.Call(ctx, "initialize", map[string]any{"clientInfo": map[string]any{"name": "codex-helper", "title": "Codex Helper", "version": "0.1.0"}, "capabilities": map[string]any{}}, &out); e != nil {