Make model and permission choices provider-specific
This commit is contained in:
1 parent
6a0202b1b5
commit
7ee88dfd9c
10 files changed
+269
-60
No files matched your search
@@ -330,7 +330,13 @@ fun deleteSubagents(settings: ServerSettings, sessionId: String, subagentIds: Li
|
||||
//
|
||||
// One list rather than two. A provider only exists on a machine that has it installed, so offering
|
||||
// machines and providers as independent choices would offer pairs that cannot work.
|
||||
data class Provider(val name: String, val kind: String, val models: List<String>)
|
||||
data class Provider(
|
||||
val name: String,
|
||||
val kind: String,
|
||||
val models: List<String>,
|
||||
val permissionModes: List<String>,
|
||||
val defaultPermissionMode: String?,
|
||||
)
|
||||
|
||||
/**
|
||||
* A machine, and what it can run. [address] is absent for the backend itself.
|
||||
@@ -345,13 +351,17 @@ data class Setup(
|
||||
val providers: List<Provider>,
|
||||
)
|
||||
|
||||
private fun parseProvider(provider: JSONObject) =
|
||||
Provider(
|
||||
private fun parseProvider(provider: JSONObject): Provider {
|
||||
val kind = provider.getString("kind")
|
||||
return Provider(
|
||||
name = provider.getString("name"),
|
||||
kind = provider.getString("kind"),
|
||||
kind = kind,
|
||||
// Omitted entirely when the provider offers none.
|
||||
models = provider.optJSONArray("models")?.strings().orEmpty(),
|
||||
permissionModes = provider.optJSONArray("permissionModes")?.strings().orEmpty(),
|
||||
defaultPermissionMode = provider.optString("defaultPermissionMode").ifEmpty { null },
|
||||
)
|
||||
}
|
||||
|
||||
private fun parseSetup(setup: JSONObject) =
|
||||
Setup(
|
||||
@@ -1083,16 +1093,6 @@ fun setSessionModel(settings: ServerSettings, sessionId: String, model: String)
|
||||
) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common permission intents, in the order they give up asking. Each coding CLI maps these onto its
|
||||
* own flags: "manual" asks, "acceptEdits" and "auto" allow ordinary work, "bypassPermissions"
|
||||
* accepts everything, and "plan" makes no changes.
|
||||
*
|
||||
* One list for every screen that offers them -- spawn, import, and the session's own picker --
|
||||
* because three copies had already drifted: the import screen was missing "plan".
|
||||
*/
|
||||
val PERMISSION_MODES = listOf("manual", "acceptEdits", "auto", "bypassPermissions", "plan")
|
||||
|
||||
/**
|
||||
* What a new session's thinking level is when nothing chose one, or null for the CLI's own.
|
||||
*
|
||||
@@ -1294,6 +1294,19 @@ fun fetchSetupModels(settings: ServerSettings, setupId: String): List<LocalModel
|
||||
}
|
||||
}
|
||||
|
||||
/** The current model catalog for one CLI provider on the machine where it runs. */
|
||||
fun fetchProviderModels(
|
||||
settings: ServerSettings,
|
||||
setupId: String,
|
||||
provider: String,
|
||||
): List<String> =
|
||||
requestFromServer(
|
||||
settings,
|
||||
"/setups/${setupId.urlEncoded()}/providers/${provider.urlEncoded()}/models",
|
||||
) { connection ->
|
||||
JSONArray(connection.inputStream.bufferedReader().readText()).strings()
|
||||
}
|
||||
|
||||
fun fetchModels(settings: ServerSettings): Models =
|
||||
requestFromServer(settings, "/models") { connection ->
|
||||
val body = JSONObject(connection.inputStream.bufferedReader().readText())
|
||||
|
||||
Reference in new issue
Block a user