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
4 changes: 2 additions & 2 deletions docs/protocol/draft/schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte
<ResponseField name="description" type={"string | null"} >
Optional description providing more details about this authentication method.
</ResponseField>
<ResponseField name="env" type={"object"} >
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
Additional environment variables to set when running the agent binary for terminal auth.
</ResponseField>
<ResponseField name="id" type={"string"} required>
Expand Down Expand Up @@ -2144,7 +2144,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte
<ResponseField name="description" type={"string | null"} >
Optional description providing more details about this authentication method.
</ResponseField>
<ResponseField name="env" type={"object"} >
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
Additional environment variables to set when running the agent binary for terminal auth.
</ResponseField>
<ResponseField name="id" type={"string"} required>
Expand Down
7 changes: 5 additions & 2 deletions docs/rfds/auth-methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@ This requires the client to be able to run an interactive terminal for the user
"description": "Setup Label",
"type": "terminal",
"args": ["--setup"],
"env": { "VAR1": "value1", "VAR2": "value2" }
"env": [
{ "name": "VAR1", "value": "value1" },
{ "name": "VAR2", "value": "value2" }
]
}
```

- `args` (optional, default `[]`): Additional arguments to pass when running the agent binary.
- `env` (optional, default `{}`): Additional environment variables to set.
- `env` (optional, default `[]`): Additional environment variables to set, as an array of objects with `name` and `value` fields.

The `command` cannot be specified, the client will invoke the exact same binary with the exact same setup. The agent can supply additional arguments and environment variables as necessary. These will be supplied in **addition** to any args/env supplied by default when the server is started. So agents will need to have a way to kickoff their interactive login flow even if normal acp commands/arguments are supplied as well.

Expand Down
26 changes: 10 additions & 16 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

use std::{path::PathBuf, sync::Arc};

#[cfg(feature = "unstable_auth_methods")]
use std::collections::HashMap;

use derive_more::{Display, From};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -823,8 +820,8 @@ pub struct AuthMethodTerminal {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub args: Vec<String>,
/// Additional environment variables to set when running the agent binary for terminal auth.
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
pub env: HashMap<String, String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub env: Vec<EnvVariable>,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
Expand All @@ -843,7 +840,7 @@ impl AuthMethodTerminal {
name: name.into(),
description: None,
args: Vec::new(),
env: HashMap::new(),
env: Vec::new(),
meta: None,
}
}
Expand All @@ -857,7 +854,7 @@ impl AuthMethodTerminal {

/// Additional environment variables to set when running the agent binary for terminal auth.
#[must_use]
pub fn env(mut self, env: HashMap<String, String>) -> Self {
pub fn env(mut self, env: Vec<EnvVariable>) -> Self {
self.env = env;
self
}
Expand Down Expand Up @@ -4497,11 +4494,7 @@ mod test_serialization {
#[cfg(feature = "unstable_auth_methods")]
#[test]
fn test_auth_method_terminal_with_args_and_env_serialization() {
use std::collections::HashMap;

let mut env = HashMap::new();
env.insert("TERM".to_string(), "xterm-256color".to_string());

let env = vec![EnvVariable::new("TERM", "xterm-256color")];
let method = AuthMethod::Terminal(
AuthMethodTerminal::new("tui-auth", "Terminal Auth")
.args(vec!["--interactive".to_string(), "--color".to_string()])
Expand All @@ -4516,9 +4509,9 @@ mod test_serialization {
"name": "Terminal Auth",
"type": "terminal",
"args": ["--interactive", "--color"],
"env": {
"TERM": "xterm-256color"
}
"env": [
{ "name": "TERM", "value": "xterm-256color" }
]
})
);

Expand All @@ -4527,7 +4520,8 @@ mod test_serialization {
AuthMethod::Terminal(AuthMethodTerminal { args, env, .. }) => {
assert_eq!(args, vec!["--interactive", "--color"]);
assert_eq!(env.len(), 1);
assert_eq!(env.get("TERM").unwrap(), "xterm-256color");
assert_eq!(env[0].name, "TERM");
assert_eq!(env[0].value, "xterm-256color");
}
_ => panic!("Expected Terminal variant"),
}
Expand Down