diff --git a/api/src/commonMain/kotlin/run/ostrom/core/api/models/Cloud.kt b/api/src/commonMain/kotlin/run/ostrom/core/api/models/Cloud.kt index 2898746..b790109 100644 --- a/api/src/commonMain/kotlin/run/ostrom/core/api/models/Cloud.kt +++ b/api/src/commonMain/kotlin/run/ostrom/core/api/models/Cloud.kt @@ -194,7 +194,10 @@ public data class CloudSetup( val start: List = emptyList(), ) -/** The agent a cloud session starts; `shell` is a plain shell, to prepare a workspace or debug an image. */ +/** + * The agents a cloud session is known to start, the values of [CreateCloudSessionRequest.agent] and [CloudSession.agent] + * this version names; `shell` is a plain shell, to prepare a workspace or debug an image. The list is open. + */ @Serializable(with = CloudAgentKind.Serializer::class) public enum class CloudAgentKind( /** The JSON value. */ @@ -223,6 +226,8 @@ public enum class CloudAgentKind( * The cloud session to start (`POST /api/v1/cloud/sessions`). Give either the legacy single [repo] (with [ref]) or an * [environment] recipe, which a server without `runners.cloud.environment.v1` ignores. * + * @property agent The agent to start: a [CloudAgentKind] value, or another agent the server knows. The list is open, so + * any name is sent as is and the server decides. * @property prompt The agent's first message, up to 20,000 characters; an interactive agent when null. * @property profileId The organization's cloud profile (`runners.cloud.profiles.v1`, planned). * @property image An image instead of the profile's (planned). @@ -245,7 +250,7 @@ public enum class CloudAgentKind( */ @Serializable public data class CreateCloudSessionRequest( - val agent: CloudAgentKind, + val agent: String, val model: String? = null, val repo: String? = null, val ref: String? = null, diff --git a/api/src/commonTest/kotlin/run/ostrom/core/api/RemoteModelsTest.kt b/api/src/commonTest/kotlin/run/ostrom/core/api/RemoteModelsTest.kt index 807da99..c4a260b 100644 --- a/api/src/commonTest/kotlin/run/ostrom/core/api/RemoteModelsTest.kt +++ b/api/src/commonTest/kotlin/run/ostrom/core/api/RemoteModelsTest.kt @@ -85,14 +85,22 @@ class RemoteModelsTest { assertNull(session.host) val device = OstromJson.decodeFromString(Device.serializer(), """{"id":"d1","name":"Laptop"}""") assertNull(device.daemon) - val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE) + val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE.value) val create = OstromJson.encodeToString(CreateCloudSessionRequest.serializer(), request) assertEquals("""{"agent":"claude"}""", create) } + @Test + fun anAgentThisVersionDoesNotNameIsSentAsIs() { + val request = CreateCloudSessionRequest("grok", kind = CloudSessionKinds.LOCAL) + val create = OstromJson.encodeToString(CreateCloudSessionRequest.serializer(), request) + assertEquals("""{"agent":"grok","kind":"local"}""", create) + } + @Test fun aLocalSessionCarriesItsLaunch() { - val request = CreateCloudSessionRequest(CloudAgentKind.CODEX, kind = CloudSessionKinds.LOCAL, launchId = "l1") + val request = + CreateCloudSessionRequest(CloudAgentKind.CODEX.value, kind = CloudSessionKinds.LOCAL, launchId = "l1") val create = OstromJson.encodeToString(CreateCloudSessionRequest.serializer(), request) assertEquals("""{"agent":"codex","kind":"local","launchId":"l1"}""", create) val session = OstromJson.decodeFromString( diff --git a/client/src/commonTest/kotlin/run/ostrom/core/client/CloudSessionCreateTest.kt b/client/src/commonTest/kotlin/run/ostrom/core/client/CloudSessionCreateTest.kt index 03cf1db..4b3faa5 100644 --- a/client/src/commonTest/kotlin/run/ostrom/core/client/CloudSessionCreateTest.kt +++ b/client/src/commonTest/kotlin/run/ostrom/core/client/CloudSessionCreateTest.kt @@ -29,7 +29,7 @@ class CloudSessionCreateTest { val server = ScriptedServer { json(cloudSession, HttpStatusCode.Accepted, listOf(Idempotency.REPLAYED_HEADER to "true")) } - val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE, prompt = "Fix it") + val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE.value, prompt = "Fix it") server.client().use { client -> val key = Idempotency.newKey() assertEquals("cs_1", client.cloudSessions.create(request, idempotencyKey = key).id) @@ -45,7 +45,7 @@ class CloudSessionCreateTest { @Test fun aWriteOnBehalfOfAMemberNamesThemAndAMalformedNameIsRefusedBeforeAnyRequest() = runTest { val server = ScriptedServer { json(cloudSession, HttpStatusCode.Created) } - val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE) + val request = CreateCloudSessionRequest(CloudAgentKind.CLAUDE.value) server.client().use { client -> client.cloudSessions.create(request, onBehalfOf = "ada") client.cloudSessions.pause("cs_1", onBehalfOf = "ada") diff --git a/client/src/commonTest/kotlin/run/ostrom/core/client/ResourceClientsTest.kt b/client/src/commonTest/kotlin/run/ostrom/core/client/ResourceClientsTest.kt index 2b32667..b2548eb 100644 --- a/client/src/commonTest/kotlin/run/ostrom/core/client/ResourceClientsTest.kt +++ b/client/src/commonTest/kotlin/run/ostrom/core/client/ResourceClientsTest.kt @@ -600,7 +600,7 @@ class ResourceClientsTest { server.client().use { client -> client.cloudSessions.create( CreateCloudSessionRequest( - agent = CloudAgentKind.CLAUDE, + agent = CloudAgentKind.CLAUDE.value, prompt = "Fix it", environment = CloudEnvironment( repositories = listOf( @@ -615,7 +615,7 @@ class ResourceClientsTest { ), ) client.cloudSessions.create( - CreateCloudSessionRequest(CloudAgentKind.SHELL, repo = "https://github.com/o/r", ref = "dev"), + CreateCloudSessionRequest(CloudAgentKind.SHELL.value, repo = "https://github.com/o/r", ref = "dev"), ) client.cloudSessions.pause("cs_1") client.cloudSessions.resume("cs_1")