FFFF fix(min): name the Claude subscription token's service claude-code-oauth-token by agent-137 · Pull Request #4079 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions crates/boxes/src/core/services.rs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,7 @@ pub const SERVICE_LIBRARY: &[Service] = &[
header: "x-api-key",
prefix: None,
},
alternates: &["anthropic-oauth-token"],
},
// The OAuth token of a Claude subscription, which Claude Code reads
// from `CLAUDE_CODE_OAUTH_TOKEN` and sends as a bearer token (Karl's
// owner ruling of 2026-12-02 on spec 24's roster).
Service {
name: "anthropic-oauth-token",
env: Some("CLAUDE_CODE_OAUTH_TOKEN"),
hosts: &["api.anthropic.com"],
secret: ServiceSecret::Store {
authorities: &["api.anthropic.com"],
header: "Authorization",
prefix: Some("Bearer "),
},
alternates: &["anthropic-api-key"],
alternates: &["claude-code-oauth-token"],
},
// The claude.ai connectors' MCP proxy, with no secret. Its own entry,
// and opt-in, since a connector reaches the user's data in other
Expand All @@ -105,14 +91,28 @@ pub const SERVICE_LIBRARY: &[Service] = &[
// inference, account information and Remote Control to
// api.anthropic.com (Karl's owner ruling of 2026-12-03 on spec 24's
// roster, from the probes of a box on 0.8.0-dev.778). The secret comes
// from `anthropic-oauth-token` or `anthropic-api-key`.
// from `claude-code-oauth-token` or `anthropic-api-key`.
Service {
name: "claude-code",
env: None,
hosts: &["api.anthropic.com", "platform.claude.com"],
secret: ServiceSecret::None,
alternates: &[],
},
// The OAuth token of a Claude subscription, which Claude Code reads
// from `CLAUDE_CODE_OAUTH_TOKEN` and sends as a bearer token (Karl's
// owner ruling of 2026-12-02 on spec 24's roster).
Service {
name: "claude-code-oauth-token",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C1 · This entry holds a secret form (ServiceSecret::Store). architecture.md line 848 says such an entry is named for a provider and the form of its credential, never for a tool. claude-code is the tool's hosts-only entry. Name this entry anthropic-oauth-token and sort it back before claude-ai-connectors.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept: owner ruling (Karl, 2026-12-04, agreed with Norrie): the credential service is named for the token users know, claude-code-oauth-token (CLAUDE_CODE_OAUTH_TOKEN from claude setup-token). gominimal/arch#218 asks to amend architecture.md L848 to match.

env: Some("CLAUDE_CODE_OAUTH_TOKEN"),
hosts: &["api.anthropic.com"],
secret: ServiceSecret::Store {
authorities: &["api.anthropic.com"],
header: "Authorization",
prefix: Some("Bearer "),
},
alternates: &["anthropic-api-key"],
},
Service {
name: "cloudflare-api-token",
env: Some("CLOUDFLARE_API_TOKEN"),
Expand Down Expand Up @@ -324,14 +324,7 @@ mod tests {
Some("ANTHROPIC_API_KEY"),
&["api.anthropic.com"],
Some(("x-api-key", None)),
&["anthropic-oauth-token"],
),
(
"anthropic-oauth-token",
Some("CLAUDE_CODE_OAUTH_TOKEN"),
&["api.anthropic.com"],
Some(("Authorization", Some("Bearer "))),
&["anthropic-api-key"],
&["claude-code-oauth-token"],
),
(
"claude-ai-connectors",
Expand All @@ -347,6 +340,13 @@ mod tests {
None,
&[],
),
(
"claude-code-oauth-token",
Some("CLAUDE_CODE_OAUTH_TOKEN"),
&["api.anthropic.com"],
Some(("Authorization", Some("Bearer "))),
&["anthropic-api-key"],
),
(
"cloudflare-api-token",
Some("CLOUDFLARE_API_TOKEN"),
Expand Down
40 changes: 25 additions & 15 deletions crates/mfile/src/expand.rs
E90D
Original file line number Diff line number Diff line change
Expand Up @@ -6799,7 +6799,7 @@ mod tests {
fn uses_derives_one_grant_per_service_secret() {
let e = expand_uses(
"[sessions.dev]\nnetwork = { mode = \"own_ip\", uses = [\"github\", \
\"anthropic-oauth-token\", \"claude-code\"] }\n",
\"claude-code-oauth-token\", \"claude-code\"] }\n",
"dev",
)
.unwrap();
Expand All @@ -6820,7 +6820,7 @@ mod tests {
toml::Value::try_from(toml::toml! {
source = "store"
store = "keychain"
id = "anthropic-oauth-token"
id = "claude-code-oauth-token"
})
.unwrap()
);
Expand All @@ -6832,7 +6832,7 @@ mod tests {
.collect::<Vec<_>>(),
[
("GH_TOKEN", "github", false),
("CLAUDE_CODE_OAUTH_TOKEN", "anthropic-oauth-token", false)
("CLAUDE_CODE_OAUTH_TOKEN", "claude-code-oauth-token", false)
]
);
// A service sets no key of `network` but its hosts and grant.
Expand Down Expand Up @@ -6916,7 +6916,7 @@ mod tests {
// Two sealed grants of one name: the declared one stays and the
// report says so.
let e = expand_uses(
"[sessions.dev]\nnetwork = { mode = \"own_ip\", uses = [\"anthropic-oauth-token\"] }\n\
"[sessions.dev]\nnetwork = { mode = \"own_ip\", uses = [\"claude-code-oauth-token\"] }\n\
[sessions.dev.secrets.CLAUDE_CODE_OAUTH_TOKEN]\nsource = \"store\"\n\
store = \"keychain\"\nid = \"claude\"\n",
"dev",
Expand Down Expand Up @@ -7055,15 +7055,15 @@ mod tests {
let claude = || {
loadout(
"claude",
"[network]\nuses = [\"anthropic-oauth-token\", \"claude-code\"]\n",
"[network]\nuses = [\"claude-code-oauth-token\", \"claude-code\"]\n",
)
};
// Taken: the grant is derived as the box's own `uses` derives it, and
// a hosts-only service derives none.
let e = expand_with_loadouts(OPEN_BOX, vec![claude()], ServiceFacts::default()).unwrap();
assert_eq!(
e.spec["secrets"]["CLAUDE_CODE_OAUTH_TOKEN"]["id"].as_str(),
Some("anthropic-oauth-token")
Some("claude-code-oauth-token")
);
let summary: Vec<_> = e
.loadout_services
Expand All @@ -7074,7 +7074,7 @@ mod tests {
summary,
[
(
"anthropic-oauth-token",
"claude-code-oauth-token",
Some("CLAUDE_CODE_OAUTH_TOKEN"),
false
),
Expand All @@ -7097,7 +7097,12 @@ mod tests {

#[test]
fn loadout_grant_yields_to_layer_that_delivers_the_name() {
let claude = || loadout("claude", "[network]\nuses = [\"anthropic-oauth-token\"]\n");
let claude = || {
loadout(
"claude",
"[network]\nuses = [\"claude-code-oauth-token\"]\n",
)
};
for (file, how) in [
(
"[sessions.dev]\nloadout_mode = \"open\"\nnetwork = { mode = \"own_ip\" }\n\
Expand Down Expand Up @@ -7127,14 +7132,19 @@ mod tests {
.and_then(|s| s.get("CLAUDE_CODE_OAUTH_TOKEN"))
.and_then(|g| g.get("id"))
.and_then(toml::Value::as_str),
Some("anthropic-oauth-token")
Some("claude-code-oauth-token")
);
}
}

#[test]
fn loadout_service_left_out_where_host_cannot_carry_grant() {
let claude = || loadout("claude", "[network]\nuses = [\"anthropic-oauth-token\"]\n");
let claude = || {
loadout(
"claude",
"[network]\nuses = [\"claude-code-oauth-token\"]\n",
)
};
for facts in [
ServiceFacts {
proxy_serves: false,
Expand Down Expand Up @@ -7181,7 +7191,7 @@ mod tests {

#[test]
fn two_loadouts_naming_one_service_give_one_grant() {
let uses = "[network]\nuses = [\"anthropic-oauth-token\"]\n";
let uses = "[network]\nuses = [\"claude-code-oauth-token\"]\n";
let e = expand_with_loadouts(
OPEN_BOX,
vec![loadout("a", uses), loadout("b", uses)],
Expand Down Expand Up @@ -7337,7 +7347,7 @@ mod tests {
};
let own_ip = spec("own_ip");
assert_eq!(
fits(&own_ip, "anthropic-oauth-token", ServiceFacts::default()),
fits(&own_ip, "claude-code-oauth-token", ServiceFacts::default()),
Ok(())
);
assert_eq!(
Expand All @@ -7349,14 +7359,14 @@ mod tests {
..ServiceFacts::default()
};
assert_eq!(
fits(&own_ip, "anthropic-oauth-token", no_proxy),
fits(&own_ip, "claude-code-oauth-token", no_proxy),
Err(ServiceMisfit::NoProxy)
);
// A service with no grant needs no proxy.
assert_eq!(fits(&own_ip, "claude-code", no_proxy), Ok(()));
// The mode comes before the host's facts.
assert_eq!(
fits(&spec("none"), "anthropic-oauth-token", no_proxy),
fits(&spec("none"), "claude-code-oauth-token", no_proxy),
Err(ServiceMisfit::NoNetwork)
);
}
Expand Down Expand Up @@ -7408,7 +7418,7 @@ mod tests {
OPEN_BOX,
vec![loadout(
"tool",
"[network]\nuses = [\"anthropic-oauth-token\"]\n",
"[network]\nuses = [\"claude-code-oauth-token\"]\n",
)],
ServiceFacts::default(),
)
Expand Down
12 changes: 3 additions & 9 deletions crates/minimal/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2675,8 +2675,8 @@ fn service_long_help() -> String {
}

/// The parser of the retired `--preset`: it refuses every value, naming
/// `--service`, so clap exits 2. A preset whose rule a stored-secret service
/// gives as it was, under the same name or another, names that service. A
/// `--service`, so clap exits 2. A preset that names a stored-secret service
/// names that service. A
/// sign-in service names `min auth login`, as `--service` does. A service
/// that gives hosts only names `network.uses` and `--allow-service`, as
/// `--service` does. Any other
Expand All @@ -2685,13 +2685,7 @@ fn service_long_help() -> String {
/// an MCP host, and no service does.
fn refuse_preset(name: &str) -> Result<String, String> {
use boxes::core::services::{self, ServiceSecret};
// The old `anthropic` preset sent a bearer token, the form of a Claude
// subscription's OAuth token (Karl's owner ruling, 2026-12-02).
let lookup = if name == "anthropic" {
"anthropic-oauth-token"
} else {
name
};
let lookup = name;
Err(
match services::service(lookup).map(|service| service.secret) {
Some(ServiceSecret::Store { .. }) => format!(
Expand Down
Loading
Loading
0