Skip to content

Commit 0f0ca5d

Browse files
committed
koog kmp updates
1 parent 4e48db3 commit 0f0ca5d

File tree

31 files changed

+729
-209
lines changed

31 files changed

+729
-209
lines changed

agents/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
dependencies {
66
implementation(libs.mcp.kotlin)
77
implementation(libs.koin.core)
8-
implementation(libs.koog.agents)
98
//implementation("org.slf4j:slf4j-simple:2.0.17")
109
implementation(libs.google.adk)
1110
implementation(libs.google.adk.dev)

agents/src/main/kotlin/koog/ClimateTraceTool.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

agents/src/main/kotlin/koog/koog_agent.kt

Lines changed: 0 additions & 88 deletions
This file was deleted.

composeApp/build.gradle.kts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
@file:OptIn(ExperimentalWasmDsl::class)
2+
13
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
24
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
3-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
5+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
46
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
57

68
plugins {
@@ -29,7 +31,6 @@ kotlin {
2931
androidTarget {
3032
@OptIn(ExperimentalKotlinGradlePluginApi::class)
3133
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
32-
3334
}
3435

3536

@@ -46,10 +47,6 @@ kotlin {
4647
}
4748
}
4849

49-
compilerOptions {
50-
languageVersion.set(KOTLIN_2_0)
51-
}
52-
5350
sourceSets {
5451
all {
5552
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
@@ -84,6 +81,10 @@ kotlin {
8481
implementation("dev.carlsen.flagkit:flagkit:1.1.0")
8582
api(libs.compose.adaptive)
8683
api(libs.compose.adaptive.layout)
84+
85+
implementation(libs.markdown.renderer)
86+
87+
implementation(libs.koog.agents)
8788
}
8889

8990
commonTest.dependencies {
@@ -159,9 +160,9 @@ android {
159160
sourceCompatibility = JavaVersion.VERSION_17
160161
targetCompatibility = JavaVersion.VERSION_17
161162
}
162-
dependencies {
163-
debugImplementation(libs.compose.ui.tooling)
164-
}
163+
// dependencies {
164+
// debugImplementation(libs.compose.ui.tooling)
165+
// }
165166

166167
testOptions {
167168
unitTests {
@@ -184,15 +185,26 @@ compose.desktop {
184185
}
185186
}
186187

187-
compose.experimental {
188-
web.application {}
189-
}
188+
//compose.experimental {
189+
// web.application {}
190+
//}
190191

191192

192193
kotlin.sourceSets.all {
193194
languageSettings.optIn("kotlin.experimental.ExperimentalObjCName")
194195
}
195196

196-
configurations.configureEach {
197-
exclude("androidx.window.core", "window-core")
197+
//configurations.configureEach {
198+
// exclude("androidx.window.core", "window-core")
199+
//}
200+
//
201+
configurations.all {
202+
// FIXME exclude netty from Koog dependencies?
203+
exclude(group = "io.netty", module = "*")
204+
}
205+
206+
// Explicitly exclude Ktor CIO engine on iOS/apple targets to avoid bringing non-supported engine
207+
// can be removed once https://github.com/JetBrains/koog/pull/869 is merged
208+
configurations.matching { it.name.contains("ios", ignoreCase = true) || it.name.contains("apple", ignoreCase = true) }.all {
209+
exclude(group = "io.ktor", module = "ktor-client-cio")
198210
}

composeApp/src/androidMain/kotlin/dev/johnoreilly/climatetrace/MainActivity.kt

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,28 @@ import android.os.Bundle
66
import androidx.activity.ComponentActivity
77
import androidx.activity.compose.setContent
88
import androidx.activity.enableEdgeToEdge
9+
import androidx.compose.foundation.layout.Column
10+
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.material.icons.Icons
12+
import androidx.compose.material.icons.filled.AccountTree
13+
import androidx.compose.material.icons.filled.Public
914
import androidx.compose.material3.ExperimentalMaterial3Api
15+
import androidx.compose.material3.Icon
1016
import androidx.compose.material3.MaterialTheme
17+
import androidx.compose.material3.NavigationBar
18+
import androidx.compose.material3.NavigationBarItem
19+
import androidx.compose.material3.Scaffold
20+
import androidx.compose.material3.Text
1121
import androidx.compose.runtime.Composable
22+
import androidx.compose.runtime.getValue
23+
import androidx.compose.runtime.mutableIntStateOf
24+
import androidx.compose.runtime.remember
25+
import androidx.compose.runtime.setValue
26+
import androidx.compose.ui.Modifier
1227
import cafe.adriel.voyager.navigator.Navigator
1328
import dev.johnoreilly.climatetrace.di.initKoin
14-
import dev.johnoreilly.climatetrace.ui.CountryListScreen
29+
import dev.johnoreilly.climatetrace.ui.AgentsScreen
30+
import dev.johnoreilly.climatetrace.ui.ClimateTraceScreen
1531
import dev.johnoreilly.wordmaster.androidApp.theme.ClimateTraceTheme
1632

1733
class MainActivity : ComponentActivity() {
@@ -32,5 +48,31 @@ class MainActivity : ComponentActivity() {
3248

3349
@Composable
3450
fun AndroidApp() {
35-
Navigator(screen = CountryListScreen())
51+
var selectedIndex by remember { mutableIntStateOf(0) }
52+
53+
Scaffold(
54+
bottomBar = {
55+
NavigationBar {
56+
NavigationBarItem(
57+
selected = selectedIndex == 0,
58+
onClick = { selectedIndex = 0 },
59+
icon = { Icon(Icons.Default.Public, contentDescription = "Climate") },
60+
label = { Text("Climate") }
61+
)
62+
NavigationBarItem(
63+
selected = selectedIndex == 1,
64+
onClick = { selectedIndex = 1 },
65+
icon = { Icon(Icons.Default.AccountTree, contentDescription = "Agents") },
66+
label = { Text("Agent") }
67+
)
68+
}
69+
}
70+
) { paddingValues ->
71+
Column(modifier = Modifier.padding(paddingValues)) {
72+
when (selectedIndex) {
73+
0 -> Navigator(screen = ClimateTraceScreen())
74+
else -> AgentsScreen()
75+
}
76+
}
77+
}
3678
}

composeApp/src/androidMain/kotlin/dev/johnoreilly/climatetrace/di/Koin.android.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.content.Context
44
import dev.johnoreilly.climatetrace.remote.Country
55
import io.github.xxfast.kstore.KStore
66
import io.github.xxfast.kstore.file.storeOf
7+
import io.ktor.client.engine.HttpClientEngine
8+
import io.ktor.client.engine.android.Android
79
import kotlinx.io.files.Path
810
import org.koin.android.ext.koin.androidContext
911
import org.koin.core.module.Module
@@ -19,3 +21,7 @@ actual fun dataModule(): Module = module {
1921
storeOf(file = Path(path = "$filesDir/countries.json"), default = emptyList())
2022
}
2123
}
24+
25+
actual fun createHttpClientEngine(): HttpClientEngine {
26+
return Android.create()
27+
}

composeApp/src/commonMain/kotlin/App.kt

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
import androidx.compose.foundation.layout.Column
2+
import androidx.compose.foundation.layout.padding
3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.filled.AccountTree
5+
import androidx.compose.material.icons.filled.Public
6+
import androidx.compose.material3.Icon
17
import androidx.compose.material3.MaterialTheme
8+
import androidx.compose.material3.NavigationBar
9+
import androidx.compose.material3.NavigationBarItem
10+
import androidx.compose.material3.Scaffold
11+
import androidx.compose.material3.Text
212
import androidx.compose.runtime.Composable
13+
import androidx.compose.runtime.getValue
14+
import androidx.compose.runtime.mutableIntStateOf
15+
import androidx.compose.runtime.remember
16+
import androidx.compose.runtime.setValue
17+
import androidx.compose.ui.Modifier
318
import cafe.adriel.voyager.navigator.Navigator
419
import dev.johnoreilly.climatetrace.di.commonModule
20+
import dev.johnoreilly.climatetrace.ui.AgentsScreen
521
import dev.johnoreilly.climatetrace.ui.ClimateTraceScreen
622
import org.jetbrains.compose.ui.tooling.preview.Preview
723
import org.koin.compose.KoinApplication
@@ -14,7 +30,33 @@ fun App() {
1430
modules(commonModule())
1531
}) {
1632
MaterialTheme {
17-
Navigator(screen = ClimateTraceScreen())
33+
var selectedIndex by remember { mutableIntStateOf(0) }
34+
35+
Scaffold(
36+
bottomBar = {
37+
NavigationBar {
38+
NavigationBarItem(
39+
selected = selectedIndex == 0,
40+
onClick = { selectedIndex = 0 },
41+
icon = { Icon(Icons.Default.Public, contentDescription = "Climate") },
42+
label = { Text("Climate") }
43+
)
44+
NavigationBarItem(
45+
selected = selectedIndex == 1,
46+
onClick = { selectedIndex = 1 },
47+
icon = { Icon(Icons.Default.AccountTree, contentDescription = "Agents") },
48+
label = { Text("Agent") }
49+
)
50+
}
51+
}
52+
) { paddingValues ->
53+
Column(Modifier.padding(paddingValues)) {
54+
when (selectedIndex) {
55+
0 -> Navigator(screen = ClimateTraceScreen())
56+
else -> AgentsScreen()
57+
}
58+
}
59+
}
1860
}
1961
}
2062
}

0 commit comments

Comments
 (0)