mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 08:03:46 +00:00
feat: add configuration for model, mode, and thought level (#205)
* feat: add configuration for model, mode, and thought level
* docs: document Claude effort-level filesystem config
* fix: prevent panic on empty modes/thoughtLevels in parse_agent_config
Use `.first()` with safe fallback instead of direct `[0]` index access,
which would panic if the Vec is empty and no default is set.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: harden session lifecycle and align cli.mdx example with claude.json
- destroySession: wrap session/cancel RPC in try/catch so local cleanup
always succeeds even when the agent is unreachable
- createSession/resumeOrCreateSession: clean up the remote session if
post-creation config calls (setMode/setModel/setThoughtLevel) fail,
preventing leaked orphan sessions
- cli.mdx: fix example output to match current claude.json (model name,
model order, and populated modes)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: harden session lifecycle and align config persistence logic
- resumeOrCreateSession: Remove destroy-on-error for the resume path. Config
errors now propagate without destroying a pre-existing session. The destroy
pattern remains in createSession (where the session is newly created and has
no prior state to preserve).
- setSessionMode fallback: When session/set_mode returns -32601 and the
fallback uses session/set_config_option, now keep modes.currentModeId
in sync with the updated currentValue. Prevents stale cached state in
getModes() when the fallback path is used.
- persistSessionStateFromMethod: Re-read the record from persistence instead
of using a stale pre-await snapshot. Prevents race conditions where
concurrent session/update events (processed by persistSessionStateFromEvent)
are silently overwritten by optimistic updates.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
* fix: correct doc examples with valid Codex modes and update stable API list
- Replace invalid Codex mode values ("plan", "build") with valid ones
("auto", "full-access") in agent-sessions.mdx and sdk-overview.mdx
- Update CLAUDE.md stable method enumerations to include new session
config methods (setSessionMode, setSessionModel, etc.)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: add OpenAPI annotations for process endpoints and fix config persistence race
Add summary/description to all process management endpoint specs and the
not_found error type. Fix hydrateSessionConfigOptions to re-read from
persistence after the network call, and sync mode-category configOptions
on session/update current_mode_update events.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e7343e14bd
commit
c91791f88d
18 changed files with 1675 additions and 70 deletions
|
|
@ -78,7 +78,7 @@ impl AgentId {
|
|||
|
||||
fn agent_process_registry_id(self) -> Option<&'static str> {
|
||||
match self {
|
||||
AgentId::Claude => Some("claude-code-acp"),
|
||||
AgentId::Claude => Some("claude-acp"),
|
||||
AgentId::Codex => Some("codex-acp"),
|
||||
AgentId::Opencode => Some("opencode"),
|
||||
AgentId::Amp => Some("amp-acp"),
|
||||
|
|
@ -90,7 +90,7 @@ impl AgentId {
|
|||
|
||||
fn agent_process_binary_hint(self) -> Option<&'static str> {
|
||||
match self {
|
||||
AgentId::Claude => Some("claude-code-acp"),
|
||||
AgentId::Claude => Some("claude-agent-acp"),
|
||||
AgentId::Codex => Some("codex-acp"),
|
||||
AgentId::Opencode => Some("opencode"),
|
||||
AgentId::Amp => Some("amp-acp"),
|
||||
|
|
@ -606,7 +606,7 @@ impl AgentManager {
|
|||
match agent {
|
||||
AgentId::Claude => {
|
||||
let package = fallback_npx_package(
|
||||
"@zed-industries/claude-code-acp",
|
||||
"@zed-industries/claude-agent-acp",
|
||||
options.agent_process_version.as_deref(),
|
||||
);
|
||||
write_npx_agent_process_launcher(&launcher, &package, &[], &HashMap::new())?;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command as ProcessCommand;
|
||||
|
|
@ -24,7 +24,7 @@ use sandbox_agent_agent_credentials::{
|
|||
ProviderCredentials,
|
||||
};
|
||||
use sandbox_agent_agent_management::agents::{AgentId, AgentManager, InstallOptions};
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use thiserror::Error;
|
||||
use tower_http::cors::{Any, CorsLayer};
|
||||
|
|
@ -220,6 +220,8 @@ pub struct AgentsArgs {
|
|||
pub enum AgentsCommand {
|
||||
/// List all agents and install status.
|
||||
List(ClientArgs),
|
||||
/// Emit JSON report of model/mode/thought options for all agents.
|
||||
Report(ClientArgs),
|
||||
/// Install or reinstall an agent.
|
||||
Install(ApiInstallAgentArgs),
|
||||
}
|
||||
|
|
@ -475,6 +477,7 @@ fn run_agents(command: &AgentsCommand, cli: &CliConfig) -> Result<(), CliError>
|
|||
let result = call_acp_extension(&ctx, ACP_EXTENSION_AGENT_LIST_METHOD, json!({}))?;
|
||||
write_stdout_line(&serde_json::to_string_pretty(&result)?)
|
||||
}
|
||||
AgentsCommand::Report(args) => run_agents_report(args, cli),
|
||||
AgentsCommand::Install(args) => {
|
||||
let ctx = ClientContext::new(cli, &args.client)?;
|
||||
let mut params = serde_json::Map::new();
|
||||
|
|
@ -498,6 +501,223 @@ fn run_agents(command: &AgentsCommand, cli: &CliConfig) -> Result<(), CliError>
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentListApiResponse {
|
||||
agents: Vec<AgentListApiAgent>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentListApiAgent {
|
||||
id: String,
|
||||
installed: bool,
|
||||
#[serde(default)]
|
||||
config_error: Option<String>,
|
||||
#[serde(default)]
|
||||
config_options: Option<Vec<Value>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RawConfigOption {
|
||||
#[serde(default)]
|
||||
id: Option<String>,
|
||||
#[serde(default)]
|
||||
category: Option<String>,
|
||||
#[serde(default)]
|
||||
current_value: Option<Value>,
|
||||
#[serde(default)]
|
||||
options: Vec<RawConfigOptionChoice>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RawConfigOptionChoice {
|
||||
#[serde(default)]
|
||||
value: Value,
|
||||
#[serde(default)]
|
||||
name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentConfigReport {
|
||||
generated_at_ms: u128,
|
||||
endpoint: String,
|
||||
agents: Vec<AgentConfigReportEntry>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentConfigReportEntry {
|
||||
id: String,
|
||||
installed: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
config_error: Option<String>,
|
||||
models: AgentConfigCategoryReport,
|
||||
modes: AgentConfigCategoryReport,
|
||||
thought_levels: AgentConfigCategoryReport,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Default, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentConfigCategoryReport {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
current_value: Option<String>,
|
||||
values: Vec<AgentConfigValueReport>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct AgentConfigValueReport {
|
||||
value: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum ConfigReportCategory {
|
||||
Model,
|
||||
Mode,
|
||||
ThoughtLevel,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct CategoryAccumulator {
|
||||
current_value: Option<String>,
|
||||
values: BTreeMap<String, Option<String>>,
|
||||
}
|
||||
|
||||
impl CategoryAccumulator {
|
||||
fn absorb(&mut self, option: &RawConfigOption) {
|
||||
if self.current_value.is_none() {
|
||||
self.current_value = config_value_to_string(option.current_value.as_ref());
|
||||
}
|
||||
|
||||
for candidate in &option.options {
|
||||
let Some(value) = config_value_to_string(Some(&candidate.value)) else {
|
||||
continue;
|
||||
};
|
||||
let name = candidate
|
||||
.name
|
||||
.as_ref()
|
||||
.map(|value| value.trim().to_string())
|
||||
.filter(|value| !value.is_empty());
|
||||
let entry = self.values.entry(value).or_insert(None);
|
||||
if entry.is_none() && name.is_some() {
|
||||
*entry = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn into_report(mut self) -> AgentConfigCategoryReport {
|
||||
if let Some(current) = self.current_value.clone() {
|
||||
self.values.entry(current).or_insert(None);
|
||||
}
|
||||
AgentConfigCategoryReport {
|
||||
current_value: self.current_value,
|
||||
values: self
|
||||
.values
|
||||
.into_iter()
|
||||
.map(|(value, name)| AgentConfigValueReport { value, name })
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run_agents_report(args: &ClientArgs, cli: &CliConfig) -> Result<(), CliError> {
|
||||
let ctx = ClientContext::new(cli, args)?;
|
||||
let response = ctx.get(&format!("{API_PREFIX}/agents?config=true"))?;
|
||||
let status = response.status();
|
||||
let text = response.text()?;
|
||||
|
||||
if !status.is_success() {
|
||||
print_error_body(&text)?;
|
||||
return Err(CliError::HttpStatus(status));
|
||||
}
|
||||
|
||||
let parsed: AgentListApiResponse = serde_json::from_str(&text)?;
|
||||
let report = build_agent_config_report(parsed, &ctx.endpoint);
|
||||
write_stdout_line(&serde_json::to_string_pretty(&report)?)
|
||||
}
|
||||
|
||||
fn build_agent_config_report(input: AgentListApiResponse, endpoint: &str) -> AgentConfigReport {
|
||||
let generated_at_ms = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|duration| duration.as_millis())
|
||||
.unwrap_or(0);
|
||||
|
||||
let agents = input
|
||||
.agents
|
||||
.into_iter()
|
||||
.map(|agent| {
|
||||
let mut model = CategoryAccumulator::default();
|
||||
let mut mode = CategoryAccumulator::default();
|
||||
let mut thought_level = CategoryAccumulator::default();
|
||||
|
||||
for option_value in agent.config_options.unwrap_or_default() {
|
||||
let Ok(option) = serde_json::from_value::<RawConfigOption>(option_value) else {
|
||||
continue;
|
||||
};
|
||||
let Some(category) = option
|
||||
.category
|
||||
.as_deref()
|
||||
.or(option.id.as_deref())
|
||||
.and_then(classify_report_category)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
match category {
|
||||
ConfigReportCategory::Model => model.absorb(&option),
|
||||
ConfigReportCategory::Mode => mode.absorb(&option),
|
||||
ConfigReportCategory::ThoughtLevel => thought_level.absorb(&option),
|
||||
}
|
||||
}
|
||||
|
||||
AgentConfigReportEntry {
|
||||
id: agent.id,
|
||||
installed: agent.installed,
|
||||
config_error: agent.config_error,
|
||||
models: model.into_report(),
|
||||
modes: mode.into_report(),
|
||||
thought_levels: thought_level.into_report(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
AgentConfigReport {
|
||||
generated_at_ms,
|
||||
endpoint: endpoint.to_string(),
|
||||
agents,
|
||||
}
|
||||
}
|
||||
|
||||
fn classify_report_category(raw: &str) -> Option<ConfigReportCategory> {
|
||||
let normalized = raw
|
||||
.trim()
|
||||
.to_ascii_lowercase()
|
||||
.replace('-', "_")
|
||||
.replace(' ', "_");
|
||||
|
||||
match normalized.as_str() {
|
||||
"model" | "model_id" => Some(ConfigReportCategory::Model),
|
||||
"mode" | "agent_mode" => Some(ConfigReportCategory::Mode),
|
||||
"thought" | "thoughtlevel" | "thought_level" | "thinking" | "thinking_level"
|
||||
| "reasoning" | "reasoning_effort" => Some(ConfigReportCategory::ThoughtLevel),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn config_value_to_string(value: Option<&Value>) -> Option<String> {
|
||||
match value {
|
||||
Some(Value::String(value)) => Some(value.clone()),
|
||||
Some(Value::Null) | None => None,
|
||||
Some(other) => Some(other.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn call_acp_extension(ctx: &ClientContext, method: &str, params: Value) -> Result<Value, CliError> {
|
||||
let server_id = unique_cli_server_id("cli-ext");
|
||||
let initialize_path = build_acp_server_path(&server_id, Some("mock"))?;
|
||||
|
|
@ -1219,4 +1439,96 @@ mod tests {
|
|||
.expect("build request");
|
||||
assert!(request.headers().get("last-event-id").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_report_category_supports_common_aliases() {
|
||||
assert!(matches!(
|
||||
classify_report_category("model"),
|
||||
Some(ConfigReportCategory::Model)
|
||||
));
|
||||
assert!(matches!(
|
||||
classify_report_category("mode"),
|
||||
Some(ConfigReportCategory::Mode)
|
||||
));
|
||||
assert!(matches!(
|
||||
classify_report_category("thought_level"),
|
||||
Some(ConfigReportCategory::ThoughtLevel)
|
||||
));
|
||||
assert!(matches!(
|
||||
classify_report_category("reasoning_effort"),
|
||||
Some(ConfigReportCategory::ThoughtLevel)
|
||||
));
|
||||
assert!(classify_report_category("arbitrary").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_agent_config_report_extracts_model_mode_and_thought() {
|
||||
let response = AgentListApiResponse {
|
||||
agents: vec![AgentListApiAgent {
|
||||
id: "codex".to_string(),
|
||||
installed: true,
|
||||
config_error: None,
|
||||
config_options: Some(vec![
|
||||
json!({
|
||||
"id": "model",
|
||||
"category": "model",
|
||||
"currentValue": "gpt-5",
|
||||
"options": [
|
||||
{"value": "gpt-5", "name": "GPT-5"},
|
||||
{"value": "gpt-5-mini", "name": "GPT-5 mini"}
|
||||
]
|
||||
}),
|
||||
json!({
|
||||
"id": "mode",
|
||||
"category": "mode",
|
||||
"currentValue": "default",
|
||||
"options": [
|
||||
{"value": "default", "name": "Default"},
|
||||
{"value": "plan", "name": "Plan"}
|
||||
]
|
||||
}),
|
||||
json!({
|
||||
"id": "thought",
|
||||
"category": "thought_level",
|
||||
"currentValue": "medium",
|
||||
"options": [
|
||||
{"value": "low", "name": "Low"},
|
||||
{"value": "medium", "name": "Medium"},
|
||||
{"value": "high", "name": "High"}
|
||||
]
|
||||
}),
|
||||
]),
|
||||
}],
|
||||
};
|
||||
|
||||
let report = build_agent_config_report(response, "http://127.0.0.1:2468");
|
||||
let agent = report.agents.first().expect("agent report");
|
||||
|
||||
assert_eq!(agent.id, "codex");
|
||||
assert_eq!(agent.models.current_value.as_deref(), Some("gpt-5"));
|
||||
assert_eq!(agent.modes.current_value.as_deref(), Some("default"));
|
||||
assert_eq!(
|
||||
agent.thought_levels.current_value.as_deref(),
|
||||
Some("medium")
|
||||
);
|
||||
|
||||
let model_values: Vec<&str> = agent
|
||||
.models
|
||||
.values
|
||||
.iter()
|
||||
.map(|item| item.value.as_str())
|
||||
.collect();
|
||||
assert!(model_values.contains(&"gpt-5"));
|
||||
assert!(model_values.contains(&"gpt-5-mini"));
|
||||
|
||||
let thought_values: Vec<&str> = agent
|
||||
.thought_levels
|
||||
.values
|
||||
.iter()
|
||||
.map(|item| item.value.as_str())
|
||||
.collect();
|
||||
assert!(thought_values.contains(&"low"));
|
||||
assert!(thought_values.contains(&"medium"));
|
||||
assert!(thought_values.contains(&"high"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ pub(super) fn fallback_config_options(agent: AgentId) -> Vec<Value> {
|
|||
AgentId::Codex => CODEX.clone(),
|
||||
AgentId::Opencode => OPENCODE.clone(),
|
||||
AgentId::Cursor => CURSOR.clone(),
|
||||
// Amp returns empty configOptions from session/new but exposes modes via
|
||||
// the `modes` field. The model is hardcoded. Modes discovered from ACP
|
||||
// session/new response (amp-acp v0.7.0).
|
||||
AgentId::Amp => vec![
|
||||
json!({
|
||||
"id": "model",
|
||||
|
|
@ -163,12 +166,10 @@ pub(super) fn fallback_config_options(agent: AgentId) -> Vec<Value> {
|
|||
"name": "Mode",
|
||||
"category": "mode",
|
||||
"type": "select",
|
||||
"currentValue": "smart",
|
||||
"currentValue": "default",
|
||||
"options": [
|
||||
{ "value": "smart", "name": "Smart" },
|
||||
{ "value": "deep", "name": "Deep" },
|
||||
{ "value": "free", "name": "Free" },
|
||||
{ "value": "rush", "name": "Rush" }
|
||||
{ "value": "default", "name": "Default" },
|
||||
{ "value": "bypass", "name": "Bypass" }
|
||||
]
|
||||
}),
|
||||
],
|
||||
|
|
@ -182,41 +183,76 @@ pub(super) fn fallback_config_options(agent: AgentId) -> Vec<Value> {
|
|||
{ "value": "default", "name": "Default" }
|
||||
]
|
||||
})],
|
||||
AgentId::Mock => vec![json!({
|
||||
"id": "model",
|
||||
"name": "Model",
|
||||
"category": "model",
|
||||
"type": "select",
|
||||
"currentValue": "mock",
|
||||
"options": [
|
||||
{ "value": "mock", "name": "Mock" }
|
||||
]
|
||||
})],
|
||||
AgentId::Mock => vec![
|
||||
json!({
|
||||
"id": "model",
|
||||
"name": "Model",
|
||||
"category": "model",
|
||||
"type": "select",
|
||||
"currentValue": "mock",
|
||||
"options": [
|
||||
{ "value": "mock", "name": "Mock" },
|
||||
{ "value": "mock-fast", "name": "Mock Fast" }
|
||||
]
|
||||
}),
|
||||
json!({
|
||||
"id": "mode",
|
||||
"name": "Mode",
|
||||
"category": "mode",
|
||||
"type": "select",
|
||||
"currentValue": "normal",
|
||||
"options": [
|
||||
{ "value": "normal", "name": "Normal" },
|
||||
{ "value": "plan", "name": "Plan" }
|
||||
]
|
||||
}),
|
||||
json!({
|
||||
"id": "thought_level",
|
||||
"name": "Thought Level",
|
||||
"category": "thought_level",
|
||||
"type": "select",
|
||||
"currentValue": "low",
|
||||
"options": [
|
||||
{ "value": "low", "name": "Low" },
|
||||
{ "value": "medium", "name": "Medium" },
|
||||
{ "value": "high", "name": "High" }
|
||||
]
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse an agent config JSON file (from `scripts/agent-configs/resources/`) into
|
||||
/// ACP `SessionConfigOption` values. The JSON format is:
|
||||
/// ```json
|
||||
/// { "defaultModel": "...", "models": [{id, name}], "defaultMode?": "...", "modes?": [{id, name}] }
|
||||
/// {
|
||||
/// "defaultModel": "...", "models": [{id, name}],
|
||||
/// "defaultMode?": "...", "modes?": [{id, name}],
|
||||
/// "defaultThoughtLevel?": "...", "thoughtLevels?": [{id, name}]
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Note: Claude and Codex don't report configOptions from `session/new`, so these
|
||||
/// JSON resource files are the source of truth for the capabilities report.
|
||||
/// Claude modes (plan, default) were discovered via manual ACP probing —
|
||||
/// `session/set_mode` works but `session/set_config_option` is not implemented.
|
||||
/// Codex modes/thought levels were discovered from its `session/new` response.
|
||||
fn parse_agent_config(json_str: &str) -> Vec<Value> {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct AgentConfig {
|
||||
#[serde(rename = "defaultModel")]
|
||||
default_model: String,
|
||||
models: Vec<ModelEntry>,
|
||||
models: Vec<ConfigEntry>,
|
||||
#[serde(rename = "defaultMode")]
|
||||
default_mode: Option<String>,
|
||||
modes: Option<Vec<ModeEntry>>,
|
||||
modes: Option<Vec<ConfigEntry>>,
|
||||
#[serde(rename = "defaultThoughtLevel")]
|
||||
default_thought_level: Option<String>,
|
||||
#[serde(rename = "thoughtLevels")]
|
||||
thought_levels: Option<Vec<ConfigEntry>>,
|
||||
}
|
||||
#[derive(serde::Deserialize)]
|
||||
struct ModelEntry {
|
||||
id: String,
|
||||
name: String,
|
||||
}
|
||||
#[derive(serde::Deserialize)]
|
||||
struct ModeEntry {
|
||||
struct ConfigEntry {
|
||||
id: String,
|
||||
name: String,
|
||||
}
|
||||
|
|
@ -242,7 +278,7 @@ fn parse_agent_config(json_str: &str) -> Vec<Value> {
|
|||
"name": "Mode",
|
||||
"category": "mode",
|
||||
"type": "select",
|
||||
"currentValue": config.default_mode.unwrap_or_else(|| modes[0].id.clone()),
|
||||
"currentValue": config.default_mode.or_else(|| modes.first().map(|m| m.id.clone())).unwrap_or_default(),
|
||||
"options": modes.iter().map(|m| json!({
|
||||
"value": m.id,
|
||||
"name": m.name,
|
||||
|
|
@ -250,6 +286,20 @@ fn parse_agent_config(json_str: &str) -> Vec<Value> {
|
|||
}));
|
||||
}
|
||||
|
||||
if let Some(thought_levels) = config.thought_levels {
|
||||
options.push(json!({
|
||||
"id": "thought_level",
|
||||
"name": "Thought Level",
|
||||
"category": "thought_level",
|
||||
"type": "select",
|
||||
"currentValue": config.default_thought_level.or_else(|| thought_levels.first().map(|t| t.id.clone())).unwrap_or_default(),
|
||||
"options": thought_levels.iter().map(|t| json!({
|
||||
"value": t.id,
|
||||
"name": t.name,
|
||||
})).collect::<Vec<_>>(),
|
||||
}));
|
||||
}
|
||||
|
||||
options
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue