Skip to content

Commit 3970185

Browse files
viadezo1erclaudeAbhiPrasad
authored
TTY fallback for bt setup and agent detection (#109)
Self-contained infra changes that the wizard depends on. - `tty_term()` function in `src/ui/select.rs` (`/dev/tty` fallback) - `fuzzy_select` using `interact_on(&term)` - `detect_runnable_agents()` (PATH-only check) - `detect_agents` simplification (drop config-dir heuristics) - `resolve_unambiguous_instrument_agent` - `/dev/tty` stdin fallback in `run_agent_invocation` for interactive mode Cursor skill path detection, global quiet mode are fixed in the [3rd PR](#110). PATH only detection of the agent seem ok, I don't think people would want to install skills/mcp without having the agent. Part 2 of #94 --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Abhijeet Prasad <abhijeet@braintrustdata.com>
1 parent 9743cd6 commit 3970185

6 files changed

Lines changed: 241 additions & 162 deletions

File tree

src/eval.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct DevServerState {
181181
struct DevAuthContext {
182182
token: String,
183183
org_name: String,
184+
api_url: Option<String>,
184185
}
185186

186187
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
@@ -1093,26 +1094,33 @@ async fn authenticate_dev_request(
10931094

10941095
let payload = response.json::<Value>().await.unwrap_or(Value::Null);
10951096
if let Some(orgs) = payload.get("org_info").and_then(|value| value.as_array()) {
1096-
let matched = orgs.iter().any(|org| {
1097+
let matched_org = orgs.iter().find(|org| {
10971098
org.get("name")
10981099
.and_then(|name| name.as_str())
10991100
.map(|name| name == org_name)
11001101
.unwrap_or(false)
11011102
});
1102-
if !matched {
1103+
let Some(matched_org) = matched_org else {
11031104
return Err(json_error_response(
11041105
actix_web::http::StatusCode::UNAUTHORIZED,
11051106
"Unauthorized",
11061107
));
1107-
}
1108+
};
1109+
let api_url = matched_org
1110+
.get("api_url")
1111+
.and_then(|value| value.as_str())
1112+
.map(str::to_string);
1113+
Ok(DevAuthContext {
1114+
token,
1115+
org_name,
1116+
api_url,
1117+
})
11081118
} else {
1109-
return Err(json_error_response(
1119+
Err(json_error_response(
11101120
actix_web::http::StatusCode::UNAUTHORIZED,
11111121
"Unauthorized",
1112-
));
1122+
))
11131123
}
1114-
1115-
Ok(DevAuthContext { token, org_name })
11161124
}
11171125

11181126
async fn resolve_dataset_ref_for_eval_request(
@@ -1227,6 +1235,9 @@ fn make_dev_mode_env(
12271235
("BRAINTRUST_APP_URL".to_string(), state.app_url.clone()),
12281236
("BT_EVAL_DEV_MODE".to_string(), dev_mode.to_string()),
12291237
];
1238+
if let Some(api_url) = auth.api_url.as_ref() {
1239+
env.push(("BRAINTRUST_API_URL".to_string(), api_url.clone()));
1240+
}
12301241
if let Some(request) = request {
12311242
let serialized =
12321243
serde_json::to_string(request).context("failed to serialize eval request payload")?;

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ Flags
8383
--json Output as JSON
8484
-q, --quiet Reduce interactive UI output [env: BRAINTRUST_QUIET=]
8585
--no-color Disable ANSI color output
86-
--no-input Disable all interactive prompts
8786
--api-url <URL> Override API URL [env: BRAINTRUST_API_URL]
8887
--app-url <URL> Override app URL [env: BRAINTRUST_APP_URL]
8988
--env-file <PATH> Path to a .env file to load

0 commit comments

Comments
 (0)