feat: add :backend:api module with interfaces and models (Step 2)

Add the backend API module skeleton with BackendLifecycle interface,
BackendState enum, NoopBackendLifecycle, GatewaySettings, and
GatewaySettingsStore for the dual-flavor architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kohei 2026-02-26 19:05:00 +09:00
parent fd17e4b174
commit 5238d5a668
8 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,21 @@
plugins {
alias(libs.plugins.android.library)
}
android {
namespace = "io.clawdroid.backend.api"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
dependencies {
implementation(libs.coroutines.android)
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />

View file

@ -0,0 +1,10 @@
package io.clawdroid.backend.api
import kotlinx.coroutines.flow.StateFlow
interface BackendLifecycle {
val state: StateFlow<BackendState>
val isManaged: Boolean
suspend fun start()
suspend fun stop()
}

View file

@ -0,0 +1,3 @@
package io.clawdroid.backend.api
enum class BackendState { STOPPED, STARTING, RUNNING, ERROR }

View file

@ -0,0 +1,7 @@
package io.clawdroid.backend.api
data class GatewaySettings(
val wsPort: Int = 18793,
val httpPort: Int = 18790,
val apiKey: String = "",
)

View file

@ -0,0 +1,8 @@
package io.clawdroid.backend.api
import kotlinx.coroutines.flow.StateFlow
interface GatewaySettingsStore {
val settings: StateFlow<GatewaySettings>
suspend fun update(settings: GatewaySettings)
}

View file

@ -0,0 +1,11 @@
package io.clawdroid.backend.api
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class NoopBackendLifecycle : BackendLifecycle {
override val state: StateFlow<BackendState> = MutableStateFlow(BackendState.RUNNING)
override val isManaged: Boolean = false
override suspend fun start() {}
override suspend fun stop() {}
}

View file

@ -18,3 +18,4 @@ include(":feature:chat")
include(":core:domain") include(":core:domain")
include(":core:data") include(":core:data")
include(":core:ui") include(":core:ui")
include(":backend:api")