Compare commits
3
Commits
2128390f99
...
d50de7c06a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d50de7c06a
|
||
|
|
0956f08791
|
||
|
|
087d0c320c
|
@@ -305,6 +305,29 @@ async fn handle_escalated(ctx: &RequestContext, action: &str, args: &Value) -> R
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_options(args: &Value) -> Result<Vec<String>> {
|
||||
let raw = args
|
||||
.get("options")
|
||||
.ok_or_else(|| anyhow!("'options' is required and must be an array of strings"))?;
|
||||
|
||||
let arr: Vec<Value> = match raw {
|
||||
Value::Array(arr) => arr.clone(),
|
||||
Value::String(s) => serde_json::from_str::<Vec<Value>>(s).map_err(|_| {
|
||||
anyhow!(
|
||||
"'options' was a string but did not parse as a JSON array. \
|
||||
Pass options as a native JSON array, e.g. [\"yes\", \"no\"]."
|
||||
)
|
||||
})?,
|
||||
_ => bail!("'options' is required and must be an array of strings"),
|
||||
};
|
||||
|
||||
Ok(arr
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.map(String::from)
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -329,26 +352,3 @@ mod tests {
|
||||
assert_eq!(v["options"], json!([]));
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_options(args: &Value) -> Result<Vec<String>> {
|
||||
let raw = args
|
||||
.get("options")
|
||||
.ok_or_else(|| anyhow!("'options' is required and must be an array of strings"))?;
|
||||
|
||||
let arr: Vec<Value> = match raw {
|
||||
Value::Array(arr) => arr.clone(),
|
||||
Value::String(s) => serde_json::from_str::<Vec<Value>>(s).map_err(|_| {
|
||||
anyhow!(
|
||||
"'options' was a string but did not parse as a JSON array. \
|
||||
Pass options as a native JSON array, e.g. [\"yes\", \"no\"]."
|
||||
)
|
||||
})?,
|
||||
_ => bail!("'options' is required and must be an array of strings"),
|
||||
};
|
||||
|
||||
Ok(arr
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.map(String::from)
|
||||
.collect())
|
||||
}
|
||||
|
||||
+5
-8
@@ -236,14 +236,6 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
if cli.acp_server {
|
||||
ctx.render_mode = RenderMode::Silent;
|
||||
}
|
||||
|
||||
if cli.acp_server {
|
||||
return acp::run_acp_server(ctx, abort_signal).await;
|
||||
}
|
||||
|
||||
if let Err(err) = run(ctx, cli, text, abort_signal).await {
|
||||
render_error(err);
|
||||
process::exit(1);
|
||||
@@ -505,6 +497,11 @@ async fn run(
|
||||
ctx.load_skill_repl(name, abort_signal.clone()).await?;
|
||||
}
|
||||
|
||||
if cli.acp_server {
|
||||
ctx.render_mode = RenderMode::Silent;
|
||||
return acp::run_acp_server(ctx, abort_signal).await;
|
||||
}
|
||||
|
||||
match is_repl {
|
||||
false => {
|
||||
let mut input = create_input(&ctx, text, &cli.file, abort_signal.clone()).await?;
|
||||
|
||||
Reference in New Issue
Block a user