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:
parent
fd17e4b174
commit
5238d5a668
8 changed files with 63 additions and 0 deletions
21
android/backend/api/build.gradle.kts
Normal file
21
android/backend/api/build.gradle.kts
Normal 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)
|
||||
}
|
||||
2
android/backend/api/src/main/AndroidManifest.xml
Normal file
2
android/backend/api/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package io.clawdroid.backend.api
|
||||
|
||||
enum class BackendState { STOPPED, STARTING, RUNNING, ERROR }
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package io.clawdroid.backend.api
|
||||
|
||||
data class GatewaySettings(
|
||||
val wsPort: Int = 18793,
|
||||
val httpPort: Int = 18790,
|
||||
val apiKey: String = "",
|
||||
)
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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() {}
|
||||
}
|
||||
|
|
@ -18,3 +18,4 @@ include(":feature:chat")
|
|||
include(":core:domain")
|
||||
include(":core:data")
|
||||
include(":core:ui")
|
||||
include(":backend:api")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue