Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import com.google.adk.kt.serialization.adkJson
import com.google.adk.kt.sessions.SessionService
import com.google.adk.kt.telemetry.TelemetryConfig
import com.google.adk.kt.webserver.AdkWebServer.StatusAwareLogger
import com.google.adk.kt.webserver.dev.routes.debugRoutes
import com.google.adk.kt.webserver.dev.routes.evalRoutes
import com.google.adk.kt.webserver.dev.routes.graphRoutes
import com.google.adk.kt.webserver.loaders.AgentLoader
import com.google.adk.kt.webserver.models.VersionInfo
import com.google.adk.kt.webserver.routes.appRoutes
import com.google.adk.kt.webserver.routes.artifactRoutes
import com.google.adk.kt.webserver.routes.debugRoutes
import com.google.adk.kt.webserver.routes.evalRoutes
import com.google.adk.kt.webserver.routes.graphRoutes
import com.google.adk.kt.webserver.routes.runRoutes
import com.google.adk.kt.webserver.routes.sessionRoutes
import com.google.adk.kt.webserver.routes.staticRoutes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.adk.kt.webserver

/** Kept so callers of the previous package keep compiling; use the `dev` package instead. */
@Deprecated(
"Moved to the development-only package.",
ReplaceWith("AgentGraphGenerator", "com.google.adk.kt.webserver.dev.AgentGraphGenerator"),
)
typealias AgentGraphGenerator = com.google.adk.kt.webserver.dev.AgentGraphGenerator
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.adk.kt.webserver
package com.google.adk.kt.webserver.dev

import com.google.adk.kt.agents.BaseAgent
import com.google.adk.kt.agents.LlmAgent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.adk.kt.webserver.routes
package com.google.adk.kt.webserver.dev.routes

import com.google.adk.kt.webserver.telemetry.ApiServerSpanExporter
import io.ktor.http.HttpStatusCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.adk.kt.webserver.routes
package com.google.adk.kt.webserver.dev.routes

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package com.google.adk.kt.webserver.routes
package com.google.adk.kt.webserver.dev.routes

import com.google.adk.kt.sessions.SessionKey
import com.google.adk.kt.sessions.SessionService
import com.google.adk.kt.webserver.AgentGraphGenerator
import com.google.adk.kt.webserver.dev.AgentGraphGenerator
import com.google.adk.kt.webserver.loaders.AgentLoader
import io.ktor.http.HttpStatusCode
import io.ktor.http.Parameters
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.adk.kt.webserver.routes

import com.google.adk.kt.sessions.SessionService
import com.google.adk.kt.webserver.dev.routes.debugRoutes as devDebugRoutes
import com.google.adk.kt.webserver.dev.routes.evalRoutes as devEvalRoutes
import com.google.adk.kt.webserver.dev.routes.graphRoutes as devGraphRoutes
import com.google.adk.kt.webserver.loaders.AgentLoader
import com.google.adk.kt.webserver.telemetry.ApiServerSpanExporter
import io.ktor.server.routing.Route

/** Kept so callers of the previous package keep compiling; use the `dev` package instead. */
@Deprecated(
"Moved to the development-only package.",
ReplaceWith("debugRoutes(exporter)", "com.google.adk.kt.webserver.dev.routes.debugRoutes"),
)
fun Route.debugRoutes(exporter: ApiServerSpanExporter) = devDebugRoutes(exporter)

/** Kept so callers of the previous package keep compiling; use the `dev` package instead. */
@Deprecated(
"Moved to the development-only package.",
ReplaceWith("evalRoutes()", "com.google.adk.kt.webserver.dev.routes.evalRoutes"),
)
fun Route.evalRoutes() = devEvalRoutes()

/** Kept so callers of the previous package keep compiling; use the `dev` package instead. */
@Deprecated(
"Moved to the development-only package.",
ReplaceWith(
"graphRoutes(agentLoader, sessionService)",
"com.google.adk.kt.webserver.dev.routes.graphRoutes",
),
)
fun Route.graphRoutes(agentLoader: AgentLoader, sessionService: SessionService) =
devGraphRoutes(agentLoader, sessionService)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.adk.kt.webserver

import com.google.adk.kt.webserver.routes.staticRoutes
import com.google.common.truth.Truth.assertThat
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
import io.ktor.server.routing.routing
import io.ktor.server.testing.testApplication
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

/** The server resolves the Development UI from `browser/` on the classpath. */
@RunWith(JUnit4::class)
class DevUiAssetsTest {

@Test
fun devUi_index_isServedFromClasspath() = withoutWebUiDir {
testApplication {
application { routing { staticRoutes(this@application) } }

val response = client.get("/dev-ui/index.html")

assertThat(response.status).isEqualTo(HttpStatusCode.OK)
assertThat(response.bodyAsText()).contains("<html")
}
}

@Test
fun devUi_nestedAsset_isServedFromClasspath() = withoutWebUiDir {
testApplication {
application { routing { staticRoutes(this@application) } }

// A nested path proves the whole asset tree is packaged, not just the entry point.
assertThat(client.get("/dev-ui/assets/audio-processor.js").status)
.isEqualTo(HttpStatusCode.OK)
}
}

/** Runs [body] with the `adk.web.ui.dir` system property cleared. */
private fun withoutWebUiDir(body: () -> Unit) {
val previous: String? = System.getProperty(WEB_UI_DIR_PROPERTY)
System.clearProperty(WEB_UI_DIR_PROPERTY)
try {
body()
} finally {
if (previous != null) System.setProperty(WEB_UI_DIR_PROPERTY, previous)
}
}

private companion object {
const val WEB_UI_DIR_PROPERTY = "adk.web.ui.dir"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.adk.kt.webserver.routes
package com.google.adk.kt.webserver.dev.routes

import com.google.adk.kt.annotations.FrameworkInternalApi
import com.google.adk.kt.serialization.adkJson
Expand Down
Loading