Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(host): let Cursor bots choose a model's effort and fast mode

leepokaid94e08cd661d
diff --git a/apps/desktop/src/renderer/views/bots/AgentModelPicker.tsx b/apps/desktop/src/renderer/views/bots/AgentModelPicker.tsx
index 6b556f2d..017f035a 100644
--- a/apps/desktop/src/renderer/views/bots/AgentModelPicker.tsx
+++ b/apps/desktop/src/renderer/views/bots/AgentModelPicker.tsx
@@ -4,14 +4,28 @@ import { font } from '../../lib/fonts'
import { useStore } from '../../store/context'
import { errorText } from './drafts'
+/** A model's own setting (effort, fast…) and the values the agent accepts. */
+interface ModelOption {
+ id: string
+ name: string
+ values: { id: string; name: string }[]
+ default?: string | null
+}
+
/** Model identifiers and display names advertised by the selected computer's ACP agent. */
interface AgentModels {
- models: { id: string; name: string; description?: string | null }[]
+ models: { id: string; name: string; description?: string | null; options?: ModelOption[] }[]
currentModelId?: string | null
}
/** Models come from the selected computer's agent, never a bundled provider list. */
-export function AgentModelPicker({ backend, selection, onChange }: { backend: string; selection: string | null | undefined; onChange: (model: string | null) => void }) {
+export function AgentModelPicker({ backend, selection, onChange, options: chosen, onOptionsChange }: {
+ backend: string
+ selection: string | null | undefined
+ onChange: (model: string | null) => void
+ options: Record<string, string>
+ onOptionsChange: (options: Record<string, string>) => void
+}) {
const store = useStore()
const online = store.connection.kind === 'online'
const [catalog, setCatalog] = useState<AgentModels | null>(null)
@@ -65,6 +79,11 @@ export function AgentModelPicker({ backend, selection, onChange }: { backend: st
const value = selection === agentDefault?.id ? '' : (selection ?? '')
const set = (v: string) => onChange(v ? v : null)
const empty = catalog?.models.length === 0
+ const modelOptions = available.find((m) => m.id === value)?.options ?? []
+ const setOption = (id: string, v: string) => {
+ const { [id]: _, ...rest } = chosen
+ onOptionsChange(v ? { ...rest, [id]: v } : rest)
+ }
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
@@ -96,6 +115,17 @@ export function AgentModelPicker({ backend, selection, onChange }: { backend: st
)}
</div>
</div>
+ {modelOptions.map((o) => {
+ const fallback = o.values.find((v) => v.id === o.default)?.name
+ const choices = [{ id: '', label: fallback ? `Default · ${fallback}` : 'Default' }, ...o.values.map((v) => ({ id: v.id, label: v.name }))]
+ return (
+ <div key={o.id} className="fade-in" style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
+ <span style={{ color: 'var(--text)', whiteSpace: 'nowrap' }}>{o.name}</span>
+ <span style={{ flex: 1 }} />
+ <ChoicePicker selection={chosen[o.id] ?? ''} options={choices} onChange={(v) => setOption(o.id, v)} />
+ </div>
+ )
+ })}
{!custom && !loading && failure ? (
<span style={{ ...font('caption'), color: 'var(--warning)' }}>{failure}</span>
) : !custom && !loading && empty ? (
diff --git a/apps/desktop/src/renderer/views/bots/BotEditorView.tsx b/apps/desktop/src/renderer/views/bots/BotEditorView.tsx
index fe9b25b2..00a96772 100644
--- a/apps/desktop/src/renderer/views/bots/BotEditorView.tsx
+++ b/apps/desktop/src/renderer/views/bots/BotEditorView.tsx
@@ -101,7 +101,9 @@ function BotSettingsForm({ draft, onChange, error, plugins }: {
const [viewingSkill, setViewingSkill] = useState<SkillRef | null>(null)
const avatarRef = useRef<HTMLButtonElement>(null)
const set = <K extends keyof BotDraft>(key: K, value: BotDraft[K]) => onChange((d) => ({ ...d, [key]: value }))
- const setModel = useCallback((model: string | null) => onChange((d) => ({ ...d, model })), [onChange])
+ // Options belong to one model.
+ const setModel = useCallback((model: string | null) => onChange((d) => (d.model === model ? d : { ...d, model, modelOptions: {} })), [onChange])
+ const setModelOptions = useCallback((modelOptions: Record<string, string>) => onChange((d) => ({ ...d, modelOptions })), [onChange])
const backends = store.hello?.backends ?? []
const backend = backends.find((b) => b.id === draft.backend)
@@ -158,7 +160,7 @@ function BotSettingsForm({ draft, onChange, error, plugins }: {
/>
) : null}
</div>
- <AgentModelPicker backend={draft.backend} selection={draft.model} onChange={setModel} />
+ <AgentModelPicker backend={draft.backend} selection={draft.model} onChange={setModel} options={draft.modelOptions ?? {}} onOptionsChange={setModelOptions} />
<ValueRow
label="Workspace"
detail={
diff --git a/apps/desktop/src/shared/models.ts b/apps/desktop/src/shared/models.ts
index 9da26d40..c6f7728a 100644
--- a/apps/desktop/src/shared/models.ts
+++ b/apps/desktop/src/shared/models.ts
@@ -20,6 +20,8 @@ export interface Bot {
/** `ask` or `auto`. */
permission: string
model?: string | null
+ /** The model's own settings (effort, fast…): agent option id → value. */
+ modelOptions: Record<string, string>
pinned: boolean
/** Where the user dragged it, lowest first (after pinned bots); ties sort by recent activity. */
position: number
@@ -59,6 +61,7 @@ export function normalizeBot(raw: Partial<Bot> & { id: string }): Bot {
managedWorkspace: raw.managedWorkspace ?? false,
permission: raw.permission ?? 'auto',
model: raw.model ?? null,
+ modelOptions: raw.modelOptions ?? {},
pinned: raw.pinned ?? false,
position: raw.position ?? 0,
hidden: raw.hidden ?? false,
@@ -405,6 +408,7 @@ export interface BotDraft {
cwd: string
permission: string
model?: string | null
+ modelOptions?: Record<string, string>
pinned?: boolean
hidden?: boolean
notify?: boolean | null
@@ -425,6 +429,7 @@ export function draftOf(bot: Bot): BotDraft {
cwd: bot.managedWorkspace ? '' : bot.cwd,
permission: bot.permission,
model: bot.model ?? null,
+ modelOptions: bot.modelOptions,
pinned: bot.pinned,
hidden: bot.hidden,
notify: bot.notify ?? null,
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/AgentModels.swift b/apps/ios/Kit/Sources/CodyncKit/Models/AgentModels.swift
index 7f79f6d9..30d96674 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Models/AgentModels.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/AgentModels.swift
@@ -6,6 +6,21 @@ public struct AgentModels: Decodable, Sendable {
public let id: String
public let name: String
public let description: String?
+ /// The model's own settings (effort, fast…); absent from hosts that don't list them.
+ public let options: [Option]?
+ }
+
+ /// A model setting and the values the agent accepts.
+ public struct Option: Decodable, Identifiable, Sendable {
+ public struct Value: Decodable, Sendable {
+ public let id: String
+ public let name: String
+ }
+
+ public let id: String
+ public let name: String
+ public let values: [Value]
+ public let `default`: String?
}
public let models: [Model]
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/Models.swift b/apps/ios/Kit/Sources/CodyncKit/Models/Models.swift
index ebeeb15c..2afce11d 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Models/Models.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/Models.swift
@@ -21,6 +21,8 @@ public struct Bot: Codable, Identifiable, Hashable, Sendable {
/// `ask` or `auto`.
public var permission: String
public var model: String?
+ /// The model's own settings (effort, fast…): agent option id → value.
+ public var modelOptions: [String: String] = [:]
public var pinned: Bool
/// Where the user dragged it, lowest first (after pinned bots); ties sort by recent activity.
public var position: Int = 0
@@ -338,6 +340,7 @@ public struct BotDraft: Codable, Hashable, Sendable {
public var cwd: String
public var permission: String
public var model: String?
+ public var modelOptions: [String: String] = [:]
public var pinned: Bool?
public var hidden: Bool?
public var notify: Bool?
@@ -368,6 +371,7 @@ public struct BotDraft: Codable, Hashable, Sendable {
cwd = bot.managedWorkspace ? "" : bot.cwd
permission = bot.permission
model = bot.model
+ modelOptions = bot.modelOptions
pinned = bot.pinned
hidden = bot.hidden
notify = bot.notify
@@ -398,6 +402,7 @@ extension Bot {
managedWorkspace = try c.decodeIfPresent(Bool.self, forKey: .managedWorkspace) ?? false
permission = try c.decodeIfPresent(String.self, forKey: .permission) ?? "auto"
model = try c.decodeIfPresent(String.self, forKey: .model)
+ modelOptions = try c.decodeIfPresent([String: String].self, forKey: .modelOptions) ?? [:]
pinned = try c.decodeIfPresent(Bool.self, forKey: .pinned) ?? false
position = try c.decodeIfPresent(Int.self, forKey: .position) ?? 0
hidden = try c.decodeIfPresent(Bool.self, forKey: .hidden) ?? false
diff --git a/apps/ios/Kit/Sources/CodyncUI/Bots/AgentModelPicker.swift b/apps/ios/Kit/Sources/CodyncUI/Bots/AgentModelPicker.swift
index 9a6deb4b..412bdc78 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Bots/AgentModelPicker.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Bots/AgentModelPicker.swift
@@ -5,6 +5,8 @@ import SwiftUI
struct AgentModelPicker: View {
let backend: String
@Binding var selection: String?
+ /// The selected model's settings (effort, fast…); they belong to one model.
+ @Binding var options: [String: String]
@Environment(BotStore.self) private var store
@State private var catalog: AgentModels?
@State private var catalogScope: String?
@@ -23,7 +25,7 @@ struct AgentModelPicker: View {
catalog?.models.first { $0.name.lowercased().hasPrefix("default") }
}
- private var options: [(String, String)] {
+ private var modelChoices: [(String, String)] {
let available = (catalog?.models ?? []).filter { $0.id != agentDefault?.id }
let current = available.first { $0.id == catalog?.currentModelId }?.name
var result = [("", agentDefault?.name ?? current.map { "Default · \($0)" } ?? "Default")]
@@ -38,10 +40,29 @@ struct AgentModelPicker: View {
private var value: Binding<String> {
Binding(
get: { selection == agentDefault?.id ? "" : selection ?? "" },
- set: { selection = $0.isEmpty ? nil : $0 }
+ set: {
+ let model = $0.isEmpty ? nil : $0
+ guard model != selection else { return }
+ selection = model
+ options = [:]
+ }
)
}
+ /// Settings the selected model offers.
+ private var modelOptions: [AgentModels.Option] {
+ catalog?.models.first { $0.id == value.wrappedValue }?.options ?? []
+ }
+
+ private func optionValue(_ id: String) -> Binding<String> {
+ Binding(get: { options[id] ?? "" }, set: { options[id] = $0.isEmpty ? nil : $0 })
+ }
+
+ private func choices(_ option: AgentModels.Option) -> [(String, String)] {
+ let fallback = option.values.first { $0.id == option.default }?.name
+ return [("", fallback.map { "Default · \($0)" } ?? "Default")] + option.values.map { ($0.id, $0.name) }
+ }
+
var body: some View {
VStack(alignment: .leading, spacing: 6) {
HStack(spacing: 8) {
@@ -59,10 +80,20 @@ struct AgentModelPicker: View {
.frame(minWidth: 0, maxWidth: 180)
.outlinedPill()
} else {
- ChoicePicker(selection: value, options: options, fitsAvailableWidth: true)
+ ChoicePicker(selection: value, options: modelChoices, fitsAvailableWidth: true)
}
}
}
+ ForEach(modelOptions) { option in
+ HStack(spacing: 8) {
+ Text(option.name)
+ .foregroundStyle(Palette.text)
+ .fixedSize()
+ Spacer(minLength: 0)
+ ChoicePicker(selection: optionValue(option.id), options: choices(option), fitsAvailableWidth: true)
+ }
+ .transition(.opacity)
+ }
if backend != "custom", !loading {
if let failure {
Text(failure)
@@ -78,7 +109,11 @@ struct AgentModelPicker: View {
.font(.caption)
.foregroundStyle(Palette.secondary)
}
- .onChange(of: backend) { _, _ in selection = nil }
+ .onChange(of: backend) { _, _ in
+ selection = nil
+ options = [:]
+ }
+ .animation(Motion.reduced(Motion.fade, reduceMotion), value: modelOptions.map(\.id))
.task(id: requestKey) { await load() }
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Bots/BotEditorView.swift b/apps/ios/Kit/Sources/CodyncUI/Bots/BotEditorView.swift
index 45a3fef0..127aa142 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Bots/BotEditorView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Bots/BotEditorView.swift
@@ -49,6 +49,7 @@ public struct BotEditorView: View {
// Folders, models and connectors belong to the old computer.
draft.cwd = ""
draft.model = nil
+ draft.modelOptions = [:]
draft.connectors = nil
draft.skills = nil
model.fillDefaults(&draft)
@@ -139,7 +140,7 @@ struct BotSettingsForm: View {
.fieldBox()
}
}
- AgentModelPicker(backend: draft.backend, selection: $draft.model)
+ AgentModelPicker(backend: draft.backend, selection: $draft.model, options: $draft.modelOptions)
ValueRow("Workspace", detail: draft.cwd.isEmpty
? "This bot has its own space for files. It can work in other folders when you ask."
: "This project is the default starting folder. The bot can work elsewhere when you ask.") {
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/AgentModelsTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/AgentModelsTests.swift
index 04f0c720..2e69b802 100644
--- a/apps/ios/Kit/Tests/CodyncKitTests/AgentModelsTests.swift
+++ b/apps/ios/Kit/Tests/CodyncKitTests/AgentModelsTests.swift
@@ -22,3 +22,14 @@ import Testing
let selected = try #require(JSONSerialization.jsonObject(with: JSONEncoder().encode(BotUpdate(draft: draft))) as? [String: Any])
#expect(selected["model"] as? String == "agent-model")
}
+
+@Test func modelOptionsDecodeAndRoundTripThroughDrafts() throws {
+ let data = Data(#"{"models":[{"id":"grok-4.7","name":"Grok 4.7","options":[{"id":"fast","name":"Fast","default":"true","values":[{"id":"false","name":"Off"},{"id":"true","name":"On"}]}]},{"id":"old","name":"Old host"}]}"#.utf8)
+ let catalog = try JSONDecoder().decode(AgentModels.self, from: data)
+ #expect(catalog.models.first?.options?.first?.values.map(\.name) == ["Off", "On"])
+ #expect(catalog.models.last?.options == nil)
+ let bot = try JSONDecoder().decode(Bot.self, from: Data(#"{"id":"b","modelOptions":{"fast":"false"}}"#.utf8))
+ #expect(bot.modelOptions == ["fast": "false"])
+ let body = try #require(JSONSerialization.jsonObject(with: JSONEncoder().encode(BotUpdate(draft: BotDraft(bot)))) as? [String: Any])
+ #expect(body["modelOptions"] as? [String: String] == ["fast": "false"])
+}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 861d7705..f8dedf63 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -11,8 +11,10 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
- 電腦上沒有 Node.js 時,Extensions 會標出需要它的 agent,按一下就能讓 Codync 幫那台電腦加上。
- Windows 電腦上的 Claude Code、Codex 等 agent 現在可以正常啟動了。
+- Cursor bot 可以替模型選擇推理強度、快速模式等設定,不再只能用每個模型的預設組合。
### en-US
- When your computer doesn't have Node.js, Extensions shows which agents need it, and one tap has Codync add it.
- Claude Code, Codex and other agents now start on Windows computers.
+- Cursor bots can now choose a model's settings, such as reasoning effort and fast mode, instead of only its default variant.
diff --git a/docs/features/marketplace.md b/docs/features/marketplace.md
index c67ee638..f7795fd3 100644
--- a/docs/features/marketplace.md
+++ b/docs/features/marketplace.md
@@ -48,11 +48,13 @@ See [file structure](../architecture/file-structure.md), [bot collaboration](bot
## Model selection
-The shared bot editor requests `agentModels {backend}` from the selected computer. The host starts an isolated ACP session under its probe directory with saved agent credentials, no MCP servers and no prompt, then closes the process. The response is `{models: [{id, name, description}], currentModelId}`.
+The shared bot editor requests `agentModels {backend}` from the selected computer. The host starts an isolated ACP session under its probe directory with saved agent credentials, no MCP servers and no prompt, then closes the process. The response is `{models: [{id, name, description, options}], currentModelId}`.
Discovery prefers ACP `configOptions` with category `model` (including grouped options), with conventional `model`/`models` IDs as a compatibility fallback. Older agents may expose `models.availableModels`. Model names and IDs come from the agent; Codync does not bundle a provider catalog. See the [ACP config option contract](https://agentclientprotocol.com/protocol/v1/session-config-options).
-The editor keeps Default, shows available models in a dropdown, and resets the selected model when changing agents. Errors are visible and retryable. Custom commands and agents without model discovery retain manual ID entry; an existing unlisted ID is preserved. The probe uses an isolated directory, so project-specific agent configuration can differ from the real bot session. Changing the model restarts the bot's agent sessions with fresh model context and preserves the stored chat history. The agent remains responsible for validating availability when a session starts.
+A model's `options` are its own settings, such as reasoning effort or fast mode: `[{id, name, values: [{id, name}], default}]`. Every `initialize` sends `clientCapabilities._meta.parameterizedModelPicker: true`; Cursor then lists plain models and, on `cursor/list_available_models` (asked only of the Cursor backend), each model's settings as ACP select config options. Without the flag Cursor offers one fixed variant per model (`grok-4.7[reasoning_effort=high,fast=true]`) and rejects every other. The bot stores the picks as `modelOptions` (option id → value; an absent id means the agent's default). After choosing the model with `session/set_config_option`, the host sets each option the same way, on new sessions and again after `session/load`, because Cursor resumes a session on its last-used model. A bot saved with a variant ID keeps working: when the agent lists the plain model instead, the bracket's `key=value` pairs become options. Changing the model or agent clears the options; the host also clears them when an app that predates them changes the model.
+
+The editor keeps Default, shows available models in a dropdown, and resets the selected model when changing agents. Under the model it shows one picker per option (iPhone and desktop: a row each, named by the agent, with Default first; terminal UI: an Options row, ←→ to move, space to change). Errors are visible and retryable. Custom commands and agents without model discovery retain manual ID entry; an existing unlisted ID is preserved. The probe uses an isolated directory, so project-specific agent configuration can differ from the real bot session. Changing the model restarts the bot's agent sessions with fresh model context and preserves the stored chat history. The agent remains responsible for validating availability when a session starts.
## Secure connection setup
diff --git a/host/src/agent/auth.rs b/host/src/agent/auth.rs
index bab466aa..0293da3a 100644
--- a/host/src/agent/auth.rs
+++ b/host/src/agent/auth.rs
@@ -113,9 +113,9 @@ pub async fn models(store: &Store, backend: &str) -> Result<Value> {
let result = tokio::time::timeout(Duration::from_secs(60), async {
let request = acp.request("session/new", json!({"cwd": probe_dir(), "mcpServers": []}));
tokio::pin!(request);
- loop {
+ let session = loop {
tokio::select! {
- result = &mut request => break result,
+ result = &mut request => break result?,
incoming = inbox.recv() => match incoming {
Some(Incoming::Request { id, .. }) => {
acp.respond_error(id, -32601, "not supported during model discovery").await?;
@@ -124,12 +124,19 @@ pub async fn models(store: &Store, backend: &str) -> Result<Value> {
Some(Incoming::Closed { .. }) | None => bail!("agent closed during model discovery"),
}
}
- }
+ };
+ // Cursor lists each model's options (effort, fast…) only through its own method.
+ let options = if backend == "cursor" {
+ acp.request("cursor/list_available_models", json!({})).await.unwrap_or_default()
+ } else {
+ Value::Null
+ };
+ Ok((session, options))
})
.await;
acp.kill().await;
- let session = result.context("the agent's model list timed out")??;
- Ok(model_catalog(&session))
+ let (session, options) = result.context("the agent's model list timed out")??;
+ Ok(model_catalog(&session, &options))
}
/// IDs are agent-defined: use the category, with legacy conventional IDs as a fallback.
@@ -143,7 +150,15 @@ pub(crate) fn model_config(session: &Value) -> Option<&Value> {
.or_else(|| options.iter().filter(is_select).find(|v| v["id"] == "model" || v["id"] == "models"))
}
-fn model_catalog(session: &Value) -> Value {
+/// The model ids the agent lists, in its order.
+pub(crate) fn model_ids(session: &Value) -> Vec<String> {
+ let catalog = model_catalog(session, &Value::Null);
+ catalog["models"].as_array().into_iter().flatten().filter_map(|m| text(&m["id"])).collect()
+}
+
+/// `{models: [{id, name, description, options}], currentModelId}`; `options` is Cursor's
+/// `cursor/list_available_models` answer (`Null` for other agents).
+fn model_catalog(session: &Value, options: &Value) -> Value {
fn collect(options: &Value, out: &mut Vec<Value>) {
for option in options.as_array().into_iter().flatten() {
if option["options"].is_array() {
@@ -171,9 +186,37 @@ fn model_catalog(session: &Value) -> Value {
}
text(&session["models"]["currentModelId"])
};
+ for model in &mut models {
+ model["options"] = json!(model_options(options, model["id"].as_str().unwrap_or_default()));
+ }
json!({"models": models, "currentModelId": current})
}
+/// One model's options as `[{id, name, values: [{id, name}], default}]`, from Cursor's
+/// `{models: [{value, configOptions}]}` (ACP select config options).
+fn model_options(options: &Value, model: &str) -> Vec<Value> {
+ let entry = options["models"].as_array().into_iter().flatten().find(|m| m["value"] == model);
+ entry
+ .and_then(|m| m["configOptions"].as_array())
+ .into_iter()
+ .flatten()
+ .filter(|o| o["type"] == "select")
+ .filter_map(|o| {
+ let id = text(&o["id"])?;
+ let values: Vec<Value> = o["options"]
+ .as_array()?
+ .iter()
+ .filter_map(|v| {
+ let value = text(&v["value"])?;
+ Some(json!({"id": value, "name": text(&v["name"]).unwrap_or(value)}))
+ })
+ .collect();
+ Some(json!({"id": id, "name": text(&o["name"]).unwrap_or(id), "values": values,
+ "default": text(&o["currentValue"])}))
+ })
+ .collect()
+}
+
async fn probe(store: &Store, backend: &str) -> Result<Status> {
let (acp, _inbox, init, cmd) = start(store, backend).await?;
let methods = methods(backend, &init, &cmd);
@@ -228,9 +271,10 @@ async fn start(store: &Store, backend: &str) -> Result<Started> {
"clientCapabilities": {
"fs": {"readTextFile": false, "writeTextFile": false},
"terminal": false,
- // Ask for terminal sign-in methods (spec field and the older `_meta` flag).
+ // Ask for terminal sign-in methods (spec field and the older `_meta` flag),
+ // and for plain models with options, as bot sessions do (`bot::start_agent`).
"auth": {"terminal": true},
- "_meta": {"terminal-auth": true},
+ "_meta": {"terminal-auth": true, "parameterizedModelPicker": true},
},
"clientInfo": {"name": "codync", "title": "Codync", "version": env!("CARGO_PKG_VERSION")},
}),
@@ -378,24 +422,52 @@ mod tests {
]}]
}], "models": {"availableModels": [{"modelId": "legacy", "name": "Legacy"}]}});
assert_eq!(model_config(&session).unwrap()["id"], "provider-model");
- let result = model_catalog(&session);
+ let result = model_catalog(&session, &Value::Null);
assert_eq!(result["currentModelId"], "m2");
assert_eq!(result["models"].as_array().unwrap().len(), 2);
assert_eq!(result["models"][0]["id"], "m1");
assert_eq!(result["models"][1]["name"], "Second");
+ assert_eq!(result["models"][1]["options"], json!([]));
+ assert_eq!(model_ids(&session), ["m1", "m2"]);
}
#[test]
fn model_catalog_reads_legacy_and_missing_lists() {
- let result = model_catalog(&json!({"models": {
- "currentModelId": "a", "availableModels": [
- {"modelId": "a", "name": "Agent model", "description": "Available here"},
- {"name": "No ID"}
- ]
- }}));
+ let result = model_catalog(
+ &json!({"models": {
+ "currentModelId": "a", "availableModels": [
+ {"modelId": "a", "name": "Agent model", "description": "Available here"},
+ {"name": "No ID"}
+ ]
+ }}),
+ &Value::Null,
+ );
assert_eq!(result["models"].as_array().unwrap().len(), 1);
assert_eq!(result["models"][0]["description"], "Available here");
- assert_eq!(model_catalog(&json!({})), json!({"models": [], "currentModelId": null}));
+ assert_eq!(model_catalog(&json!({}), &Value::Null), json!({"models": [], "currentModelId": null}));
+ }
+
+ #[test]
+ fn model_catalog_adds_cursor_model_options() {
+ let session = json!({"configOptions": [{"id": "model", "category": "model", "type": "select",
+ "currentValue": "grok-4.7", "options": [{"value": "grok-4.7", "name": "Grok 4.7"}, {"value": "auto"}]}]});
+ let listed = json!({"models": [{"value": "grok-4.7", "name": "Grok 4.7", "configOptions": [
+ {"id": "reasoning_effort", "name": "Reasoning", "category": "thought_level", "type": "select",
+ "currentValue": "high", "options": [{"value": "medium", "name": "Medium"}, {"value": "high", "name": "High"}]},
+ {"id": "fast", "type": "select", "currentValue": "true", "options": [{"value": "false", "name": "Off"}, {"value": "true"}]},
+ {"id": "verbose", "type": "boolean"}
+ ]}]});
+ let result = model_catalog(&session, &listed);
+ assert_eq!(
+ result["models"][0]["options"],
+ json!([
+ {"id": "reasoning_effort", "name": "Reasoning", "default": "high",
+ "values": [{"id": "medium", "name": "Medium"}, {"id": "high", "name": "High"}]},
+ {"id": "fast", "name": "fast", "default": "true",
+ "values": [{"id": "false", "name": "Off"}, {"id": "true", "name": "true"}]}
+ ])
+ );
+ assert_eq!(result["models"][1]["options"], json!([]));
}
#[test]
diff --git a/host/src/agent/bot/queue.rs b/host/src/agent/bot/queue.rs
index 0cb760e7..5310c9c2 100644
--- a/host/src/agent/bot/queue.rs
+++ b/host/src/agent/bot/queue.rs
@@ -78,7 +78,8 @@ impl Actor {
let restart = cfg.backend != self.cfg.backend
|| cfg.command != self.cfg.command
|| cfg.cwd != self.cfg.cwd
- || cfg.model != self.cfg.model;
+ || cfg.model != self.cfg.model
+ || cfg.model_options != self.cfg.model_options;
self.tools_changed |= cfg.connectors != self.cfg.connectors || cfg.computer != self.cfg.computer;
// Name, description and skill changes reach the agent as a profile update
// on the next message (see `context`).
diff --git a/host/src/agent/bot/session.rs b/host/src/agent/bot/session.rs
index 87720fb8..2971cccf 100644
--- a/host/src/agent/bot/session.rs
+++ b/host/src/agent/bot/session.rs
@@ -242,7 +242,12 @@ impl Actor {
}
}
match res {
- Ok(_) => {
+ Ok(res) => {
+ // A resumed session can come back on the agent's last-used model (Cursor
+ // keeps one for all its sessions), so the bot's own is set again.
+ if res.get("configOptions").is_some() || res.get("models").is_some() {
+ select_model(&conn.acp, &res, &sid, &self.cfg).await?;
+ }
conn.loaded.insert(sid.clone());
if let Some(s) = snapshot {
// Its system prompt now names the bot as rendered.
@@ -336,23 +341,45 @@ pub(crate) async fn launch_commands(cfg: &BotConfig, progress: impl Fn(&str)) ->
})
}
-/// Switches a new session (`session/new` answered `res`) to the bot's chosen model.
+/// Switches a session (`session/new` or `session/load` answered `res`) to the bot's
+/// chosen model, then sets that model's options (effort, fast…).
pub(crate) async fn select_model(acp: &Acp, res: &Value, sid: &str, cfg: &BotConfig) -> Result<()> {
let Some(model) = cfg.model.as_deref().filter(|m| !m.is_empty()) else { return Ok(()) };
- let r = match crate::agent::auth::model_config(res).and_then(|c| c["id"].as_str()) {
- Some(config_id) => {
- acp.request("session/set_config_option", json!({"sessionId": sid, "configId": config_id, "value": model}))
- .await
- }
- None => acp.request("session/set_model", json!({"sessionId": sid, "modelId": model})).await,
+ let Some(config_id) = crate::agent::auth::model_config(res).and_then(|c| c["id"].as_str()) else {
+ let r = acp.request("session/set_model", json!({"sessionId": sid, "modelId": model})).await;
+ return r.map(drop).map_err(|e| model_error(model, &e));
};
- if let Err(e) = r {
- tracing::warn!(model, error = format!("{e:#}"), "couldn't set model");
- bail!("Couldn't select model {model}: {e:#}");
+ let (model, mut options) = split_variant(res, model);
+ options.extend(cfg.model_options.iter().map(|(k, v)| (k.as_str(), v.as_str())));
+ let set = |id: &str, value: &str| {
+ acp.request("session/set_config_option", json!({"sessionId": sid, "configId": id, "value": value}))
+ };
+ set(config_id, model).await.map_err(|e| model_error(model, &e))?;
+ for (id, value) in options {
+ set(id, value).await.map_err(|e| model_error(&format!("{model} with {id}={value}"), &e))?;
}
Ok(())
}
+fn model_error(model: &str, e: &anyhow::Error) -> anyhow::Error {
+ tracing::warn!(model, error = format!("{e:#}"), "couldn't set model");
+ anyhow!("Couldn't select model {model}: {e:#}")
+}
+
+/// Cursor names a model variant `grok-4.7[reasoning_effort=high,fast=true]`. When the agent
+/// lists plain models instead, the bracket becomes options of the plain model.
+fn split_variant<'a>(res: &Value, model: &'a str) -> (&'a str, Vec<(&'a str, &'a str)>) {
+ let listed = |id: &str| crate::agent::auth::model_ids(res).iter().any(|m| m == id);
+ if let Some((name, params)) = model.strip_suffix(']').and_then(|m| m.split_once('['))
+ && let Some(params) = params.split(',').map(|p| p.split_once('=')).collect::<Option<Vec<_>>>()
+ && !listed(model)
+ && listed(name)
+ {
+ return (name, params);
+ }
+ (model, Vec::new())
+}
+
/// Spawns an ACP agent and completes the `initialize` handshake.
pub(crate) async fn start_agent(command: &str, cwd: &str, env: &[(String, String)], budget: Duration) -> Result<Conn> {
let (acp, rx) = Acp::spawn(command, cwd, env)?;
@@ -363,10 +390,13 @@ pub(crate) async fn start_agent(command: &str, cwd: &str, env: &[(String, String
json!({
"protocolVersion": 1,
// `session.compaction`: tell us when the agent summarizes its context.
+ // `parameterizedModelPicker`: Cursor lists plain models with their options
+ // (effort, fast…) instead of one fixed variant each; model discovery asks the same.
"clientCapabilities": {
"fs": {"readTextFile": false, "writeTextFile": false},
"terminal": false,
"session": {"compaction": {}},
+ "_meta": {"parameterizedModelPicker": true},
},
"clientInfo": {"name": "codync", "title": "Codync", "version": env!("CARGO_PKG_VERSION")},
}),
@@ -391,3 +421,26 @@ pub(crate) async fn start_agent(command: &str, cwd: &str, env: &[(String, String
let claude = init["agentCapabilities"]["_meta"]["claudeCode"].is_object();
Ok(Conn { acp, rx, sessions, claude, loaded: HashSet::new() })
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn variant_ids_become_options_only_when_the_agent_lists_plain_models() {
+ let plain = json!({"configOptions": [{"id": "model", "category": "model", "type": "select",
+ "options": [{"value": "grok-4.7"}]}]});
+ let variant = "grok-4.7[context=256k,reasoning_effort=medium,fast=false]";
+ assert_eq!(
+ split_variant(&plain, variant),
+ ("grok-4.7", vec![("context", "256k"), ("reasoning_effort", "medium"), ("fast", "false")])
+ );
+ assert_eq!(split_variant(&plain, "grok-4.7"), ("grok-4.7", vec![]));
+ let variants = json!({"configOptions": [{"id": "model", "category": "model", "type": "select",
+ "options": [{"value": variant}]}]});
+ assert_eq!(split_variant(&variants, variant), (variant, vec![]));
+ assert_eq!(split_variant(&plain, "other[x=1]"), ("other[x=1]", vec![]));
+ // Claude's `opus[1m]` is a model id of its own, not a variant.
+ assert_eq!(split_variant(&json!({"models": {"availableModels": [{"modelId": "opus"}]}}), "opus[1m]").1, vec![]);
+ }
+}
diff --git a/host/src/hub.rs b/host/src/hub.rs
index 2538eabd..6d240e30 100644
--- a/host/src/hub.rs
+++ b/host/src/hub.rs
@@ -229,6 +229,10 @@ impl Hub {
if cfg.name != row.config.name && patch.get("autoName").is_none() {
cfg.auto_name = false;
}
+ // Options belong to one model; an app that doesn't know them can't clear them itself.
+ if (cfg.model != row.config.model || cfg.backend != row.config.backend) && patch.get("modelOptions").is_none() {
+ cfg.model_options.clear();
+ }
if cfg.kind != row.config.kind {
bail!("a bot can't become a group, or a group a bot");
}
diff --git a/host/src/store/bots.rs b/host/src/store/bots.rs
index 6c7ec171..b805c43a 100644
--- a/host/src/store/bots.rs
+++ b/host/src/store/bots.rs
@@ -214,6 +214,7 @@ mod tests {
cwd: "/tmp".into(),
permission: Permission::Ask,
model: None,
+ model_options: std::collections::BTreeMap::new(),
pinned: false,
position: 0,
hidden: false,
diff --git a/host/src/store/model.rs b/host/src/store/model.rs
index 91e6fd0b..dec7b63e 100644
--- a/host/src/store/model.rs
+++ b/host/src/store/model.rs
@@ -2,6 +2,7 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;
+use std::collections::BTreeMap;
/// How a bot handles the agent's permission requests (wire values `ask` / `auto`).
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -80,6 +81,9 @@ pub struct BotConfig {
pub permission: Permission,
#[serde(default)]
pub model: Option<String>,
+ /// The model's own settings (effort, fast…): ACP config option id → value.
+ #[serde(default)]
+ pub model_options: BTreeMap<String, String>,
#[serde(default)]
pub pinned: bool,
/// Place in the roster, lowest first (after pinned bots). All 0 until the user drags one:
diff --git a/host/src/tui/app/forms.rs b/host/src/tui/app/forms.rs
index 69537689..33531e4f 100644
--- a/host/src/tui/app/forms.rs
+++ b/host/src/tui/app/forms.rs
@@ -2,6 +2,7 @@
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use serde_json::{Value, json};
+use std::collections::BTreeMap;
use super::{
After, AgentPicker, App, Bot, COLORS, Editor, FIELDS, Field, Form, GroupField, GroupForm, Overlay, SHAPES, Toggle,
@@ -127,6 +128,7 @@ impl App {
instructions: Editor::with(&b.description),
backend: b.backend.clone(),
model: Editor::with(b.model.as_deref().unwrap_or_default()),
+ model_options: (b.model.clone().unwrap_or_default(), b.model_options.clone()),
cwd: if b.managed_workspace { String::new() } else { b.cwd.clone() },
auto: b.auto,
notify: b.notify,
@@ -161,6 +163,7 @@ impl App {
instructions: Editor::default(),
backend,
model: Editor::default(),
+ model_options: (String::new(), BTreeMap::new()),
cwd: String::new(),
auto: true,
notify: true,
@@ -246,6 +249,7 @@ impl App {
| Field::Computer
| Field::Color
| Field::Shape
+ | Field::ModelOptions
| Field::Connectors
| Field::Skills
) =>
@@ -269,6 +273,27 @@ impl App {
Field::Computer => f.computer = !f.computer,
Field::Color if !space => f.color = cycle(f.color, d, COLORS.len()),
Field::Shape if !space => f.shape = cycle(f.shape, d, SHAPES.len()),
+ Field::ModelOptions => {
+ let model = f.model.text.trim().to_owned();
+ let offered = self.model_settings(&f.backend, &model);
+ if !space {
+ f.sub = cycle(f.sub, d, offered.len().max(1));
+ } else if let Some(o) = offered.get(f.sub) {
+ if f.model_options.0 != model {
+ f.model_options = (model, BTreeMap::new());
+ }
+ // Default, then each value.
+ let ids: Vec<&str> =
+ std::iter::once("").chain(o.values.iter().map(|(id, _)| id.as_str())).collect();
+ let now = f.model_options.1.get(&o.id).map_or("", String::as_str);
+ let next = ids[cycle(ids.iter().position(|i| *i == now).unwrap_or(0), 1, ids.len())];
+ if next.is_empty() {
+ f.model_options.1.remove(&o.id);
+ } else {
+ f.model_options.1.insert(o.id.clone(), next.to_owned());
+ }
+ }
+ }
Field::Connectors | Field::Skills => {
let list = if field == Field::Connectors { &mut f.connectors } else { &mut f.skills };
if space {
@@ -313,6 +338,7 @@ impl App {
"cwd": f.cwd,
"permission": if f.auto { "auto" } else { "ask" },
"model": if model.is_empty() { Value::Null } else { model.into() },
+ "modelOptions": f.model_options().cloned().unwrap_or_default(),
"notify": f.notify,
"computer": f.computer,
"avatarColor": COLORS[f.color],
@@ -336,3 +362,30 @@ const NAMES: [&str; 24] = [
"Ada", "Rex", "Mia", "Sol", "Kit", "Oli", "Ivy", "Max", "Zoe", "Leo", "Ari", "Bea", "Cal", "Dot", "Eli", "Fay",
"Gus", "Hal", "Ida", "Jin", "Kai", "Lux", "Nia", "Otto",
];
+
+#[cfg(test)]
+mod tests {
+ use super::super::{AgentModel, test_app};
+ use super::*;
+
+ #[tokio::test]
+ async fn model_options_cycle_and_belong_to_their_model() {
+ let mut app = test_app();
+ let grok = json!({"id": "grok", "name": "Grok", "options": [
+ {"id": "fast", "name": "Fast", "values": [{"id": "false", "name": "Off"}, {"id": "true", "name": "On"}]}]});
+ app.models.insert("cursor".into(), Some(AgentModel::parse(&grok).into_iter().collect()));
+ let bot = json!({"id": "b", "backend": "cursor", "model": "grok", "modelOptions": {"fast": "false"}});
+ app.bots.insert("b".into(), Bot::parse(&bot).expect("a bot"));
+ app.selected = Some("b".into());
+ app.edit_bot();
+ let Some(Overlay::Form(mut f)) = app.overlays.pop() else { panic!("the editor opens") };
+ f.field = FIELDS.iter().position(|x| *x == Field::ModelOptions).expect("an options field");
+ let space = KeyEvent::from(KeyCode::Char(' '));
+ let Some(Overlay::Form(f)) = app.form_key(f, space) else { panic!("the editor stays") };
+ assert_eq!(f.model_options().and_then(|o| o.get("fast")).map(String::as_str), Some("true"));
+ let Some(Overlay::Form(mut f)) = app.form_key(f, space) else { panic!("the editor stays") };
+ assert!(f.model_options().is_some_and(BTreeMap::is_empty), "back to the agent's default");
+ f.model = Editor::with("other");
+ assert!(f.model_options().is_none(), "another model starts without settings");
+ }
+}
diff --git a/host/src/tui/app/mod.rs b/host/src/tui/app/mod.rs
index 4e804dd6..cbfcb085 100644
--- a/host/src/tui/app/mod.rs
+++ b/host/src/tui/app/mod.rs
@@ -14,7 +14,7 @@ mod ui;
pub use editor::Editor;
pub use exchange::{ConversationRow, Exchange, Item, Outcome, conversation, group, rows};
-pub use model::{After, Bot, Entry, Kind, Mark, Msg, Status};
+pub use model::{After, AgentModel, Bot, Entry, Kind, Mark, ModelOption, Msg, Status};
pub use ui::{
ACTIONS, Action, AgentPicker, COLORS, Click, Confirm, ConfirmAct, Dir, FIELDS, FILTERS, Field, Focus, FolderPicker,
Form, Goto, GotoItem, GroupField, GroupForm, Hits, NEW_GROUP, Overlay, SHAPES, Toast, Toggle, TraceMode, Width,
@@ -88,7 +88,7 @@ pub struct App {
/// Installed connectors and skills as the host lists them.
pub plugins: (Vec<Value>, Vec<Value>),
/// Models each agent offers (`None` while loading).
- pub models: HashMap<String, Option<Vec<(String, String)>>>,
+ pub models: HashMap<String, Option<Vec<AgentModel>>>,
/// A setup terminal holding the screen.
pub shell: Option<Shell>,
/// Chats and threads (`bot` / `bot/root`) marked read since their bot's unread count last changed.
diff --git a/host/src/tui/app/model.rs b/host/src/tui/app/model.rs
index 007e0c20..77243e1e 100644
--- a/host/src/tui/app/model.rs
+++ b/host/src/tui/app/model.rs
@@ -1,6 +1,7 @@
//! What the host sends: bots, transcript entries, and the messages that carry them.
use serde_json::Value;
+use std::collections::BTreeMap;
use super::super::manage::Reply;
use super::tilde;
@@ -93,6 +94,8 @@ pub struct Bot {
pub managed_workspace: bool,
pub auto: bool,
pub model: Option<String>,
+ /// The model's own settings (effort, fast…): option id → value.
+ pub model_options: BTreeMap<String, String>,
pub pinned: bool,
/// Where the user dragged it (see `App::roster`).
pub position: i64,
@@ -119,6 +122,36 @@ fn strs(v: &Value) -> Vec<String> {
v.as_array().into_iter().flatten().filter_map(Value::as_str).map(str::to_owned).collect()
}
+/// A model an agent offers (`agentModels`), with its own settings.
+pub struct AgentModel {
+ pub id: String,
+ pub name: String,
+ pub options: Vec<ModelOption>,
+}
+
+/// A model setting (effort, fast…) and its values as `(id, name)`.
+pub struct ModelOption {
+ pub id: String,
+ pub name: String,
+ pub values: Vec<(String, String)>,
+}
+
+impl AgentModel {
+ pub fn parse(v: &Value) -> Option<Self> {
+ let pair = |v: &Value| {
+ let id = v["id"].as_str()?.to_owned();
+ Some((v["name"].as_str().unwrap_or(&id).to_owned(), id))
+ };
+ let (name, id) = pair(v)?;
+ let options = v["options"].as_array().into_iter().flatten().filter_map(|o| {
+ let (name, id) = pair(o)?;
+ let values = o["values"].as_array()?.iter().filter_map(|v| pair(v).map(|(n, i)| (i, n))).collect();
+ Some(ModelOption { id, name, values })
+ });
+ Some(Self { id, name, options: options.collect() })
+ }
+}
+
impl Bot {
/// Where it works, as the header shows it.
pub fn folder(&self, home: &str) -> String {
@@ -138,6 +171,12 @@ impl Bot {
managed_workspace: v["managedWorkspace"] == true,
auto: v["permission"] == "auto",
model: v["model"].as_str().filter(|m| !m.is_empty()).map(str::to_owned),
+ model_options: v["modelOptions"]
+ .as_object()
+ .into_iter()
+ .flatten()
+ .filter_map(|(k, v)| Some((k.clone(), v.as_str()?.to_owned())))
+ .collect(),
pinned: v["pinned"].as_bool().unwrap_or(false),
position: v["position"].as_i64().unwrap_or(0),
hidden: v["hidden"].as_bool().unwrap_or(false),
diff --git a/host/src/tui/app/ui.rs b/host/src/tui/app/ui.rs
index eff5c933..08c8f2b7 100644
--- a/host/src/tui/app/ui.rs
+++ b/host/src/tui/app/ui.rs
@@ -1,6 +1,7 @@
//! The screen's state: panes, overlays and their forms, and where clicks land.
use ratatui::layout::Rect;
+use std::collections::BTreeMap;
use std::time::Instant;
use super::super::manage::{
@@ -134,6 +135,7 @@ pub enum Field {
Instructions,
Agent,
Model,
+ ModelOptions,
Folder,
Approvals,
Notify,
@@ -144,11 +146,12 @@ pub enum Field {
Skills,
}
-pub const FIELDS: [Field; 12] = [
+pub const FIELDS: [Field; 13] = [
Field::Name,
Field::Instructions,
Field::Agent,
Field::Model,
+ Field::ModelOptions,
Field::Folder,
Field::Approvals,
Field::Notify,
@@ -172,6 +175,8 @@ pub struct Form {
pub instructions: Editor,
pub backend: String,
pub model: Editor,
+ /// Model settings (effort, fast…) and the model they were picked for.
+ pub model_options: (String, BTreeMap<String, String>),
pub cwd: String,
pub auto: bool,
pub notify: bool,
@@ -191,6 +196,11 @@ impl Form {
pub fn current(&self) -> Field {
FIELDS[self.field]
}
+
+ /// The settings picked for the model now in the field; another model has none yet.
+ pub fn model_options(&self) -> Option<&BTreeMap<String, String>> {
+ (self.model_options.0 == self.model.text.trim()).then_some(&self.model_options.1)
+ }
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
diff --git a/host/src/tui/manage/mod.rs b/host/src/tui/manage/mod.rs
index b953a657..2203b1a1 100644
--- a/host/src/tui/manage/mod.rs
+++ b/host/src/tui/manage/mod.rs
@@ -274,10 +274,16 @@ impl App {
pub(super) fn cycle_model(&self, backend: &str, current: &str, d: isize) -> Option<String> {
let list = self.models.get(backend)?.as_ref()?;
let mut ids = vec![String::new()];
- ids.extend(list.iter().map(|(id, _)| id.clone()));
+ ids.extend(list.iter().map(|m| m.id.clone()));
let i = ids.iter().position(|x| x == current).unwrap_or(0);
Some(ids[super::app::cycle(i, d, ids.len())].clone())
}
+
+ /// The settings (effort, fast…) `backend`'s `model` offers.
+ pub(crate) fn model_settings(&self, backend: &str, model: &str) -> &[super::app::ModelOption] {
+ let list = self.models.get(backend).and_then(Option::as_ref);
+ list.and_then(|l| l.iter().find(|m| m.id == model)).map_or(&[], |m| &m.options)
+ }
}
/// Opens `url` in this computer's browser, when the host is this computer.
diff --git a/host/src/tui/manage/replies.rs b/host/src/tui/manage/replies.rs
index 9606a2f6..276b13df 100644
--- a/host/src/tui/manage/replies.rs
+++ b/host/src/tui/manage/replies.rs
@@ -2,7 +2,7 @@
use serde_json::{Value, json};
-use super::super::app::{After, App, Entry, Overlay, Toggle};
+use super::super::app::{After, AgentModel, App, Entry, Overlay, Toggle};
use super::{MemoryMode, Reply, Shell, open_browser, s};
impl App {
@@ -198,15 +198,7 @@ impl App {
}
}
Reply::Models(backend) => {
- let list = v["models"]
- .as_array()
- .into_iter()
- .flatten()
- .filter_map(|m| {
- let id = m["id"].as_str()?.to_owned();
- Some((id.clone(), m["name"].as_str().unwrap_or(&id).to_owned()))
- })
- .collect();
+ let list = v["models"].as_array().into_iter().flatten().filter_map(AgentModel::parse).collect();
self.models.insert(backend, Some(list));
}
Reply::Downloaded => {
diff --git a/host/src/tui/view/forms.rs b/host/src/tui/view/forms.rs
index 6d6ac6f1..6aebe4ce 100644
--- a/host/src/tui/view/forms.rs
+++ b/host/src/tui/view/forms.rs
@@ -14,7 +14,7 @@ use super::style::{FACE, avatar, bot_color, face_style, theme};
pub(super) fn form_view(buf: &mut Buffer, area: Rect, app: &App, f: &Form) {
let t = theme();
- let r = centered(area, 88, 30);
+ let r = centered(area, 88, 32);
let title = match &f.bot_id {
Some(_) => format!("Edit {}", f.name.text),
None => "New bot · 2/2 name and looks".into(),
@@ -48,6 +48,7 @@ pub(super) fn form_view(buf: &mut Buffer, area: Rect, app: &App, f: &Form) {
Field::Instructions => "Instructions",
Field::Agent => "Agent",
Field::Model => "Model",
+ Field::ModelOptions => "Options",
Field::Folder => "Workspace",
Field::Approvals => "Approvals",
Field::Notify => "Notify",
@@ -95,8 +96,8 @@ pub(super) fn form_view(buf: &mut Buffer, area: Rect, app: &App, f: &Form) {
Some(Some(list)) if !list.is_empty() => {
let id = f.model.text.trim();
list.iter()
- .find(|(m, _)| m == id)
- .map_or_else(|| format!("‹ › {} models", list.len()), |(_, name)| format!("‹ {name} ›"))
+ .find(|m| m.id == id)
+ .map_or_else(|| format!("‹ › {} models", list.len()), |m| format!("‹ {} ›", m.name))
}
_ => String::new(),
};
@@ -104,6 +105,26 @@ pub(super) fn form_view(buf: &mut Buffer, area: Rect, app: &App, f: &Form) {
rput(buf, inner.right(), y, &hint, t.dim.patch(base));
}
}
+ Field::ModelOptions => {
+ let offered = app.model_settings(&f.backend, f.model.text.trim());
+ if offered.is_empty() {
+ put(buf, vx, y, vw, "none for this model", t.dim.patch(base));
+ }
+ let mut x = vx;
+ for (j, o) in offered.iter().enumerate() {
+ let picked = f.model_options().and_then(|p| p.get(&o.id));
+ let value = picked.map_or("default", |v| {
+ o.values.iter().find(|(id, _)| id == v).map_or(v.as_str(), |(_, name)| name.as_str())
+ });
+ let item = format!("{} ‹{value}›", o.name);
+ let s = if active && j == f.sub { t.bold.add_modifier(Modifier::UNDERLINED) } else { t.text };
+ if x + u(w(&item)) >= inner.right() {
+ put(buf, x, y, 2, "…", t.dim.patch(base));
+ break;
+ }
+ x = put(buf, x, y, u(w(&item)), &item, s.patch(base)) + 2;
+ }
+ }
Field::Agent => {
put(buf, vx, y, vw, &format!("‹ {agent_name} ›"), t.text.patch(base));
}
@@ -195,6 +216,7 @@ pub(super) fn form_view(buf: &mut Buffer, area: Rect, app: &App, f: &Form) {
let hint = match f.current() {
Field::Folder => "↵ project folder · backspace personal · tab next field",
Field::Connectors => "←→ move · space toggle · tab next",
+ Field::ModelOptions => "←→ move · space change · tab next",
Field::Skills => "←→ move · space toggle · i details · tab next",
Field::Agent => "←→ change · ↵ install / sign in · tab next",
Field::Model => "←→ pick a model · or type its id",
diff --git a/host/tests/fixtures/wire-shape.json b/host/tests/fixtures/wire-shape.json
index 42bfcd1c..9cbe51b8 100644
--- a/host/tests/fixtures/wire-shape.json
+++ b/host/tests/fixtures/wire-shape.json
@@ -23,6 +23,7 @@
"event:bot.bot.managedWorkspace": "bool",
"event:bot.bot.members": "array",
"event:bot.bot.model": "null",
+ "event:bot.bot.modelOptions": "object",
"event:bot.bot.name": "string",
"event:bot.bot.notify": "null",
"event:bot.bot.permission": "string",