This PR adds a central `AuthManager` struct that manages the auth information used across conversations and the MCP server. Prior to this, each conversation and the MCP server got their own private snapshots of the auth information, and changes to one (such as a logout or token refresh) were not seen by others. This is especially problematic when multiple instances of the CLI are run. For example, consider the case where you start CLI 1 and log in to ChatGPT account X and then start CLI 2 and log out and then log in to ChatGPT account Y. The conversation in CLI 1 is still using account X, but if you create a new conversation, it will suddenly (and unexpectedly) switch to account Y. With the `AuthManager`, auth information is read from disk at the time the `ConversationManager` is constructed, and it is cached in memory. All new conversations use this same auth information, as do any token refreshes. The `AuthManager` is also used by the MCP server's GetAuthStatus command, which now returns the auth method currently used by the MCP server. This PR also includes an enhancement to the GetAuthStatus command. It now accepts two new (optional) input parameters: `include_token` and `refresh_token`. Callers can use this to request the in-use auth token and can optionally request to refresh the token. The PR also adds tests for the login and auth APIs that I recently added to the MCP server.
51 lines
1.0 KiB
TOML
51 lines
1.0 KiB
TOML
[package]
|
|
edition = "2024"
|
|
name = "codex-exec"
|
|
version = { workspace = true }
|
|
|
|
[[bin]]
|
|
name = "codex-exec"
|
|
path = "src/main.rs"
|
|
|
|
[lib]
|
|
name = "codex_exec"
|
|
path = "src/lib.rs"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dependencies]
|
|
anyhow = "1"
|
|
chrono = "0.4.40"
|
|
clap = { version = "4", features = ["derive"] }
|
|
codex-arg0 = { path = "../arg0" }
|
|
codex-common = { path = "../common", features = [
|
|
"cli",
|
|
"elapsed",
|
|
"sandbox_summary",
|
|
] }
|
|
codex-core = { path = "../core" }
|
|
codex-login = { path = "../login" }
|
|
codex-ollama = { path = "../ollama" }
|
|
codex-protocol = { path = "../protocol" }
|
|
owo-colors = "4.2.0"
|
|
serde_json = "1"
|
|
shlex = "1.3.0"
|
|
tokio = { version = "1", features = [
|
|
"io-std",
|
|
"macros",
|
|
"process",
|
|
"rt-multi-thread",
|
|
"signal",
|
|
] }
|
|
tracing = { version = "0.1.41", features = ["log"] }
|
|
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
|
|
|
[dev-dependencies]
|
|
assert_cmd = "2"
|
|
core_test_support = { path = "../core/tests/common" }
|
|
libc = "0.2"
|
|
predicates = "3"
|
|
tempfile = "3.13.0"
|
|
wiremock = "0.6"
|