Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(computer): keep Codex MCP OAuth credentials out of the keyring
Dongdong Chen23295a3566cf
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex 61aed934..bae14b93 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -244,6 +244,13 @@ file, puts the snapshot back into the result and deletes the file, so the modelneed not call `browser_snapshot` again. Only links under `.linger/browser-output/`are replaced.+A Codex Context home receives these entries as URL servers in its projected+`config.toml`, together with `mcp_oauth_credentials_store = "file"`. Codex+otherwise reads the OAuth credentials of every URL server from the OS keyring,+and on Linux a session bus whose Secret Service never answers blocks the turn+until the Run times out. The managed servers never use OAuth, and the setting+applies only to that runtime home, not to the user's own Codex home.+The tool catalog is cached per Computer installation; an Operation's tool serviceexpires as soon as it closes. After connecting to the Runner Gateway, the Daemondiscovers the catalog once in the background so the first run does not wait. Ondiff --git a/apps/computer/local-daemon/internal/provider/native/codex_args.go b/apps/computer/local-daemon/internal/provider/native/codex_args.goindex 4663f373..af40a0c3 100644--- a/apps/computer/local-daemon/internal/provider/native/codex_args.go+++ b/apps/computer/local-daemon/internal/provider/native/codex_args.go@@ -52,7 +52,7 @@ func CodexAppServerArgs(version string, launchArgs ...string) []string {// NormalizeCodexLaunchArgs filters Computer args (extra) and Agent args// (custom) separately: --listen is adapter-owned, and the Daemon's MCP set-// owns every mcp_servers override.+// owns every mcp_servers override and the MCP OAuth credential store.func NormalizeCodexLaunchArgs(extra, custom []string, logger *slog.Logger) []string {if logger == nil {logger = slog.Default()@@ -62,7 +62,7 @@ func NormalizeCodexLaunchArgs(extra, custom []string, logger *slog.Logger) []strfor _, list := range [][]string{extra, custom} {filtered := filterAdapterArgs(logger, reserved, list)filtered = codexDropOverrides(logger, filtered, func(path []string) bool {- return len(path) > 0 && path[0] == "mcp_servers"+ return len(path) > 0 && (path[0] == "mcp_servers" || path[0] == codexOAuthStoreKey)})out = append(out, filtered...)}diff --git a/apps/computer/local-daemon/internal/provider/native/codex_fake_test.go b/apps/computer/local-daemon/internal/provider/native/codex_fake_test.goindex be9da322..8bfd1767 100644--- a/apps/computer/local-daemon/internal/provider/native/codex_fake_test.go+++ b/apps/computer/local-daemon/internal/provider/native/codex_fake_test.go@@ -17,6 +17,8 @@ import ("syscall""testing""time"++ "github.com/pelletier/go-toml/v2")// The test binary doubles as a fake Codex app-server when this variable is@@ -183,6 +185,7 @@ func (s *codexFakeServer) handle(line []byte) (int, bool) {s.result(request.ID, map[string]any{"thread": map[string]any{"id": s.thread}})case "thread/resume":switch {+ case s.keyringBlocks():case s.modes["reject_resume"]:s.reject(request.ID, -32600, "no rollout found for thread id "+request.Params["threadId"].(string))case s.modes["other_thread"]:@@ -243,6 +246,31 @@ func (s *codexFakeServer) handle(line []byte) (int, bool) {return 0, false}+// keyringBlocks models Codex on a Linux session bus whose Secret Service+// never answers (mode secret_service_unresponsive): unless config.toml+// selects the file credential store, Codex looks up the MCP OAuth+// credentials of every URL server in the keyring and blocks the turn and+// thread/resume on it.+func (s *codexFakeServer) keyringBlocks() bool {+ if !s.modes["secret_service_unresponsive"] {+ return false+ }+ data, _ := os.ReadFile(filepath.Join(os.Getenv("CODEX_HOME"), "config.toml"))+ var config struct {+ Store string `toml:"mcp_oauth_credentials_store"`+ Servers map[string]map[string]any `toml:"mcp_servers"`+ }+ if toml.Unmarshal(data, &config) != nil || config.Store == "file" {+ return false+ }+ for _, server := range config.Servers {+ if _, ok := server["url"]; ok {+ return true+ }+ }+ return false+}+func (s *codexFakeServer) turn(id json.RawMessage, compact bool) (int, bool) {s.count++script := codexFakeTurn{Status: "completed"}@@ -260,6 +288,9 @@ func (s *codexFakeServer) turn(id json.RawMessage, compact bool) (int, bool) {}s.result(id, ack)s.send(map[string]any{"method": "turn/started", "params": map[string]any{"threadId": s.thread, "turn": map[string]any{"id": s.current, "status": "inProgress"}}})+ if s.keyringBlocks() {+ return 0, false+ }for _, item := range script.Items {encoded, _ := json.Marshal(item)encoded = bytes.ReplaceAll(encoded, []byte("$THREAD"), []byte(s.thread))diff --git a/apps/computer/local-daemon/internal/provider/native/codex_home_config.go b/apps/computer/local-daemon/internal/provider/native/codex_home_config.goindex 76b6c873..e3505eed 100644--- a/apps/computer/local-daemon/internal/provider/native/codex_home_config.go+++ b/apps/computer/local-daemon/internal/provider/native/codex_home_config.go@@ -19,6 +19,8 @@ import (const (codexConfigName = "config.toml"codexConfigLimit = 32 << 20+ // codexOAuthStoreKey selects where Codex keeps MCP OAuth credentials.+ codexOAuthStoreKey = "mcp_oauth_credentials_store")var (@@ -27,8 +29,8 @@ var ()// codexProjectMCP writes the managed MCP set into <home>/config.toml,-// replacing the mcp_servers namespace and keeping every other key. All file-// access stays inside home.+// replacing the mcp_servers namespace and the MCP OAuth credential store and+// keeping every other key. All file access stays inside home.func codexProjectMCP(home string, raw json.RawMessage) error {raw = mcpNamespace(raw)if strings.TrimSpace(home) == "" {@@ -55,6 +57,11 @@ func codexProjectMCP(home string, raw json.RawMessage) error {}codexDropMCPServers(config)config["mcp_servers"] = servers+ // Every managed server carries its access in its URL or headers, never+ // OAuth. The default store asks the OS keyring for each URL server, and+ // on Linux a session bus whose Secret Service never answers blocks the+ // turn and thread/resume until the Run times out.+ config[codexOAuthStoreKey] = "file"encoded, err := toml.Marshal(config)if err != nil {return fmt.Errorf("encode Codex configuration: %w", err)diff --git a/apps/computer/local-daemon/internal/provider/native/codex_runtime_test.go b/apps/computer/local-daemon/internal/provider/native/codex_runtime_test.goindex c1657310..d99b4a74 100644--- a/apps/computer/local-daemon/internal/provider/native/codex_runtime_test.go+++ b/apps/computer/local-daemon/internal/provider/native/codex_runtime_test.go@@ -843,6 +843,29 @@ func TestCodexMCPFrontKeepsThreadAcrossURLChanges(t *testing.T) {}}+func TestCodexManagedMCPAvoidsTheKeyring(t *testing.T) {+ fake := newCodexFake(t, []codexFakeTurn{{Status: "completed", Items: []map[string]any{codexAgentMessage("m", "ok", nil)}}},+ map[string]string{"FAKE_MODES": "secret_service_unresponsive"})+ if err := os.WriteFile(filepath.Join(fake.home, "config.toml"), []byte("mcp_oauth_credentials_store = \"keyring\"\n"), 0o600); err != nil {+ t.Fatal(err)+ }+ spec := fake.spec()+ spec.FirstProgressBudget = time.Second+ spec.StartupBudget = 2 * time.Second+ spec.MCPServers = json.RawMessage(`{"mcpServers":{"browser":{"type":"http","url":"http://127.0.0.1:1/mcp/token/browser"}}}`)+ out, _ := codexDrain(t, fake.runtime(nil), "one", spec)+ if out.Status != statusCompleted || out.Output != "ok" {+ t.Fatalf("new thread = %+v", out)+ }+ if _, err := StopCodexHomeForMaintenance(fake.home); err != nil {+ t.Fatal(err)+ }+ spec.ResumeID = out.SessionID+ if out, _ = codexDrain(t, fake.runtime(nil), "two", spec); out.Status != statusCompleted || fake.count("thread/resume") != 1 {+ t.Fatalf("resumed thread = %+v methods = %v", out, fake.methods())+ }+}+func jsonText(value any) string {encoded, _ := json.Marshal(value)return string(encoded)diff --git a/apps/computer/local-daemon/internal/provider/native/codex_units_test.go b/apps/computer/local-daemon/internal/provider/native/codex_units_test.goindex 9be1179f..4e64b0b5 100644--- a/apps/computer/local-daemon/internal/provider/native/codex_units_test.go+++ b/apps/computer/local-daemon/internal/provider/native/codex_units_test.go@@ -68,7 +68,7 @@ func TestCodexPermissionHookVersions(t *testing.T) {func TestCodexOverrideFiltering(t *testing.T) {logger := slog.New(slog.DiscardHandler)got := NormalizeCodexLaunchArgs(- []string{"-c=mcp_servers.a.command=\"x\"", "-cmcp_servers.b.url=\"y\"", "--listen", "ws://x", "--model", "kept"},+ []string{"-c=mcp_servers.a.command=\"x\"", "-cmcp_servers.b.url=\"y\"", "-c", "mcp_oauth_credentials_store=\"keyring\"", "--listen", "ws://x", "--model", "kept"},[]string{"--config", `profiles."work".'mcp_servers'.c.command="z"`, "-c", "model=\"m\""},logger)if !slices.Equal(got, []string{"--model", "kept", "-c", `model="m"`}) {@@ -98,7 +98,7 @@ func TestCodexOverrideFiltering(t *testing.T) {func TestCodexManagedProjection(t *testing.T) {home := t.TempDir()config := filepath.Join(home, "config.toml")- if err := os.WriteFile(config, []byte("model = \"keep\"\n[mcp_servers.old]\ncommand = \"old\"\n[profiles.work]\nmodel = \"p\"\n[profiles.work.mcp_servers.x]\ncommand = \"x\"\n"), 0o644); err != nil {+ if err := os.WriteFile(config, []byte("model = \"keep\"\nmcp_oauth_credentials_store = \"keyring\"\n[mcp_servers.old]\ncommand = \"old\"\n[profiles.work]\nmodel = \"p\"\n[profiles.work.mcp_servers.x]\ncommand = \"x\"\n"), 0o644); err != nil {t.Fatal(err)}raw := json.RawMessage(`{"mcpServers":{"remote":{"type":"HTTP","url":"http://127.0.0.1:1/mcp","headers":{"Authorization":"Bearer t"},"tools":["a"]},"local":{"command":"bin","args":["-v"],"env":{"N":1.5}}}}`)@@ -112,7 +112,7 @@ func TestCodexManagedProjection(t *testing.T) {}servers := parsed["mcp_servers"].(map[string]any)remote := servers["remote"].(map[string]any)- if parsed["model"] != "keep" || servers["old"] != nil || remote["type"] != nil || remote["tools"] != nil || remote["headers"] != nil ||+ if parsed["model"] != "keep" || parsed[codexOAuthStoreKey] != "file" || servers["old"] != nil || remote["type"] != nil || remote["tools"] != nil || remote["headers"] != nil ||remote["http_headers"].(map[string]any)["Authorization"] != "Bearer t" || remote["experimental_use_rmcp_client"] != true {t.Fatalf("projected = %s", first)}