diff --git a/deps.edn b/deps.edn index fb2ff8a20..896c1be6c 100644 --- a/deps.edn +++ b/deps.edn @@ -1,5 +1,5 @@ {:paths ["libtmux-clojure/src/main/clojure"] - :deps {org.clojure/clojure {:mvn/version "1.12.6"} + :deps {org.clojure/clojure {:mvn/version "1.12.7"} io.github.libtmux/libtmux {:mvn/version "0.1.2-SNAPSHOT"}} :aliases {:test diff --git a/examples/api/clojure/deps.edn b/examples/api/clojure/deps.edn index 03fe2032f..b95236dec 100644 --- a/examples/api/clojure/deps.edn +++ b/examples/api/clojure/deps.edn @@ -1,6 +1,6 @@ {:paths ["src/main/clojure"] :mvn/local-repo "m2" - :deps {org.clojure/clojure {:mvn/version "1.12.6"} + :deps {org.clojure/clojure {:mvn/version "1.12.7"} io.github.libtmux/libtmux-clojure {:mvn/version "0.1.2-SNAPSHOT"}} :aliases {:core-async diff --git a/examples/src/test/scala/io/github/libtmux/scaladsl/examples/RunnableExamplesSuite.scala b/examples/src/test/scala/io/github/libtmux/scaladsl/examples/RunnableExamplesSuite.scala index 9e9f417f9..8c5d92d29 100644 --- a/examples/src/test/scala/io/github/libtmux/scaladsl/examples/RunnableExamplesSuite.scala +++ b/examples/src/test/scala/io/github/libtmux/scaladsl/examples/RunnableExamplesSuite.scala @@ -6,8 +6,12 @@ import io.github.libtmux.scaladsl.fixture.OwnedTmux import java.lang.reflect.InvocationTargetException import java.nio.charset.StandardCharsets import java.nio.file.{Files, Path} -import java.util.concurrent.{CountDownLatch, TimeUnit} -import java.util.concurrent.atomic.AtomicReference +import java.util.concurrent.{ + ExecutionException, + FutureTask, + TimeUnit, + TimeoutException +} import munit.FunSuite import scala.jdk.CollectionConverters._ import scala.jdk.OptionConverters._ @@ -140,24 +144,23 @@ object RunnableExamplesSuite { * A daemon, so a body that never returns cannot hold the JVM either. */ def run(name: String, body: () => Unit, deadlineMillis: Long): Unit = { - val failure = new AtomicReference[Throwable]() - val finished = new CountDownLatch(1) - val runner: Runnable = () => - try body() - catch { - case thrown: InvocationTargetException => failure.set(thrown.getCause) - case thrown: Throwable => failure.set(thrown) - } finally finished.countDown() + val runner = new FutureTask[Unit](() => body()) val thread = new Thread(runner, "example-" + name) thread.setDaemon(true) thread.start() - if (!finished.await(deadlineMillis, TimeUnit.MILLISECONDS)) { - thread.interrupt() - throw new AssertionError( - s"$name did not return within $deadlineMillis ms" - ) + try runner.get(deadlineMillis, TimeUnit.MILLISECONDS) + catch { + case _: TimeoutException => + thread.interrupt() + throw new AssertionError( + s"$name did not return within $deadlineMillis ms" + ) + case failure: ExecutionException => + failure.getCause match { + case wrapped: InvocationTargetException => throw wrapped.getCause + case cause => throw cause + } } - Option(failure.get).foreach(thrown => throw thrown) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cfb634adb..9fb273f65 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,35 +4,36 @@ kotlin = "2.4.21" coroutines = "1.11.0" junit = "6.1.3" jackson = "2.23.0" -mcp = "2.1.0" +mcp = "2.2.0" +reactor = "3.9.0" re2j = "1.8" slf4j = "2.0.20" tomlj = "2.2.0" jsr305 = "3.0.2" -errorprone = "2.52.0" -nullaway = "0.14.3" +errorprone = "2.53.0" +nullaway = "0.14.4" errorprone-plugin = "5.2.0" -spotless = "8.11.0" +spotless = "8.12.0" maven-publish-plugin = "0.37.0" palantir-format = "2.97.0" -cyclonedx-plugin = "3.5.1" +cyclonedx-plugin = "3.6.1" japicmp = "0.27.0" -clojure = "1.12.6" +clojure = "1.12.7" core-async = "1.9.865" manifold = "0.5.0" picocli = "4.7.7" reactive-streams = "1.0.4" snakeyaml = "2.7" testng-engine = "1.1.0" -javapoet = "0.22.0" +javapoet = "0.23.0" kotlinpoet = "2.4.0" dokka = "2.3.0" -scala = "3.10.0" +scala = "3.10.1" scalafmt = "3.11.5" munit = "1.3.6" cats-effect = "3.7.1" -fs2 = "3.14.0" -ox = "1.1.0" +fs2 = "3.16.0" +ox = "1.1.1" [libraries] jspecify = { module = "org.jspecify:jspecify", version.ref = "jspecify" } @@ -46,6 +47,7 @@ jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", ver jackson-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" } mcp-core = { module = "io.modelcontextprotocol.sdk:mcp-core", version.ref = "mcp" } mcp-json-jackson2 = { module = "io.modelcontextprotocol.sdk:mcp-json-jackson2", version.ref = "mcp" } +reactor-core = { module = "io.projectreactor:reactor-core", version.ref = "reactor" } re2j = { module = "com.google.re2j:re2j", version.ref = "re2j" } slf4j-nop = { module = "org.slf4j:slf4j-nop", version.ref = "slf4j" } tomlj = { module = "org.tomlj:tomlj", version.ref = "tomlj" } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index f8c58761f..541f21ac6 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -29,6 +29,14 @@ + + + + + + + + @@ -79,6 +87,11 @@ + + + + + @@ -100,6 +113,14 @@ + + + + + + + + @@ -124,6 +145,14 @@ + + + + + + + + @@ -148,6 +177,14 @@ + + + + + + + + @@ -281,6 +318,11 @@ + + + + + @@ -326,6 +368,11 @@ + + + + + @@ -465,6 +512,14 @@ + + + + + + + + @@ -530,6 +585,14 @@ + + + + + + + + @@ -576,6 +639,14 @@ + + + + + + + + @@ -624,6 +695,14 @@ + + + + + + + + @@ -666,6 +745,11 @@ + + + + + @@ -1004,6 +1088,14 @@ + + + + + + + + @@ -1084,6 +1176,14 @@ + + + + + + + + @@ -1108,6 +1208,14 @@ + + + + + + + + @@ -1132,6 +1240,14 @@ + + + + + + + + @@ -1182,6 +1298,11 @@ + + + + + @@ -1335,6 +1456,14 @@ + + + + + + + + @@ -1385,6 +1514,11 @@ + + + + + @@ -1540,6 +1674,14 @@ + + + + + + + + @@ -1572,6 +1714,14 @@ + + + + + + + + @@ -1601,6 +1751,14 @@ + + + + + + + + @@ -1789,6 +1947,14 @@ + + + + + + + + @@ -1842,6 +2008,14 @@ + + + + + + + + @@ -2168,6 +2342,14 @@ + + + + + + + + @@ -2184,6 +2366,14 @@ + + + + + + + + @@ -2205,6 +2395,17 @@ + + + + + + + + + + + @@ -2950,6 +3151,14 @@ + + + + + + + + @@ -3273,6 +3482,14 @@ + + + + + + + + @@ -3289,6 +3506,14 @@ + + + + + + + + @@ -3320,6 +3545,14 @@ + + + + + + + + @@ -3330,6 +3563,11 @@ + + + + + @@ -5049,6 +5287,9 @@ + + + @@ -5408,6 +5649,14 @@ + + + + + + + + @@ -5416,6 +5665,14 @@ + + + + + + + + @@ -5424,6 +5681,14 @@ + + + + + + + + @@ -5432,6 +5697,14 @@ + + + + + + + + @@ -5544,6 +5817,14 @@ + + + + + + + + @@ -5576,6 +5857,14 @@ + + + + + + + + @@ -5592,6 +5881,14 @@ + + + + + + + + @@ -5608,6 +5905,14 @@ + + + + + + + + @@ -5624,6 +5929,14 @@ + + + + + + + + @@ -5640,6 +5953,14 @@ + + + + + + + + @@ -5656,6 +5977,14 @@ + + + + + + + + @@ -5672,6 +6001,14 @@ + + + + + + + + @@ -5744,6 +6081,14 @@ + + + + + + + + @@ -5800,6 +6145,14 @@ + + + + + + + + @@ -6333,6 +6686,11 @@ + + + + + @@ -6343,6 +6701,11 @@ + + + + + @@ -6359,6 +6722,14 @@ + + + + + + + + @@ -6375,6 +6746,14 @@ + + + + + + + + @@ -6391,6 +6770,14 @@ + + + + + + + + @@ -6401,6 +6788,11 @@ + + + + + diff --git a/integration-tests/src/test/scala/io/github/libtmux/scaladsl/BatchChainSuite.scala b/integration-tests/src/test/scala/io/github/libtmux/scaladsl/BatchChainSuite.scala index e956535c7..c4904c187 100644 --- a/integration-tests/src/test/scala/io/github/libtmux/scaladsl/BatchChainSuite.scala +++ b/integration-tests/src/test/scala/io/github/libtmux/scaladsl/BatchChainSuite.scala @@ -18,7 +18,7 @@ import io.github.libtmux.transport.{ } import java.nio.file.Files import java.time.Duration -import java.util.concurrent.{CompletableFuture, ExecutionException, TimeUnit} +import java.util.concurrent.{ExecutionException, FutureTask, TimeUnit} import java.util.concurrent.atomic.AtomicInteger import munit.FunSuite import scala.jdk.CollectionConverters._ @@ -479,17 +479,8 @@ final class BatchChainSuite extends FunSuite { private def shell(text: String): String = "'" + text.replace("'", "'\"'\"'") + "'" - private def start[A](body: => A): (Thread, CompletableFuture[A]) = { - val result = new CompletableFuture[A]() - val worker = Thread - .ofPlatform() - .start(() => { - try result.complete(body) - catch { - case failure: Throwable => result.completeExceptionally(failure) - } - () - }) - (worker, result) + private def start[A](body: => A): (Thread, FutureTask[A]) = { + val result = new FutureTask[A](() => body) + (Thread.ofPlatform().start(result), result) } } diff --git a/integration-tests/src/test/scala/io/github/libtmux/scaladsl/OldDaemonControlSuite.scala b/integration-tests/src/test/scala/io/github/libtmux/scaladsl/OldDaemonControlSuite.scala index ee430dc9f..cc6a21c1b 100644 --- a/integration-tests/src/test/scala/io/github/libtmux/scaladsl/OldDaemonControlSuite.scala +++ b/integration-tests/src/test/scala/io/github/libtmux/scaladsl/OldDaemonControlSuite.scala @@ -8,6 +8,7 @@ import io.github.libtmux.scaladsl.cats.Control import java.nio.file.{Files, Path} import java.time.Duration import munit.FunSuite +import scala.annotation.nowarn import scala.concurrent.duration._ /** Attaching a Cats control client to a real daemon below the floor is refused @@ -69,8 +70,9 @@ final class OldDaemonControlSuite extends FunSuite { } } } finally { - try raw(daemon, socket, "kill-server") - catch { case _: Throwable => () } + // A failing kill-server assertion must still allow socket cleanup. + (try raw(daemon, socket, "kill-server") + catch { case _: Throwable => () }): @nowarn("id=E235") Files.deleteIfExists(socket) Files.deleteIfExists(root) } diff --git a/integration-tests/src/testFixtures/scala/io/github/libtmux/scaladsl/fixture/OwnedTmux.scala b/integration-tests/src/testFixtures/scala/io/github/libtmux/scaladsl/fixture/OwnedTmux.scala index 30dd0cc51..c52118ad3 100644 --- a/integration-tests/src/testFixtures/scala/io/github/libtmux/scaladsl/fixture/OwnedTmux.scala +++ b/integration-tests/src/testFixtures/scala/io/github/libtmux/scaladsl/fixture/OwnedTmux.scala @@ -11,6 +11,7 @@ import io.github.libtmux.junit5.NamedServerFixture import java.nio.file.{Files, LinkOption, Path} import java.time.Duration import java.util.concurrent.TimeUnit +import scala.annotation.nowarn import scala.collection.mutable.ArrayBuffer import scala.jdk.CollectionConverters._ import scala.util.Using @@ -60,6 +61,8 @@ private[scaladsl] final class OwnedTmux private ( val descendants = process.toVector.flatMap(OwnedTmux.descendants) var endpointReleased = false var failure: Throwable = null + // Release every owned handle before rethrowing the first failure. + @nowarn("id=E235") def attempt(body: => Unit): Unit = try body catch { @@ -139,6 +142,8 @@ private[scaladsl] object OwnedTmux { acquire(binary)(_ => ()) } + // Even a failed assertion can leave a daemon or a temporary directory. + @nowarn("id=E235") def acquire(binary: String)(afterAcquired: OwnedTmux => Unit): OwnedTmux = { require( !sys.env.contains("TMUX") && !sys.env.contains("TMUX_PANE"), diff --git a/libtmux-clojure/CHANGELOG.md b/libtmux-clojure/CHANGELOG.md index 274d9683d..b42b3e787 100644 --- a/libtmux-clojure/CHANGELOG.md +++ b/libtmux-clojure/CHANGELOG.md @@ -12,6 +12,11 @@ CI, and release tooling, are in the [main changelog](../CHANGELOG.md). ## Unreleased +### Changed + +- **The facade uses Clojure 1.12.7.** The runtime rejects Java serialization + and deserialization of Clojure functions by default. + ### Added - **`libtmux-clojure` adds Clojure APIs over the Java engine.** Use captured diff --git a/libtmux-clojure/README.md b/libtmux-clojure/README.md index 21322084c..77182b553 100644 --- a/libtmux-clojure/README.md +++ b/libtmux-clojure/README.md @@ -116,7 +116,7 @@ not settled: any release may change or remove exported identifiers, and the changelog marks each break. Pin an exact version to avoid one. Only the newest release is supported, with no backports. The Clojure façade -is currently pre-release; CI tests Clojure 1.12.6 on JDK 25 and 27 against +is currently pre-release; CI tests Clojure 1.12.7 on JDK 25 and 27 against the supported tmux endpoints, 3.3a and 3.8. [Report a defect][contributing] with the tmux version, endpoint choice, and the smallest reproducer. diff --git a/libtmux-mcp/CHANGELOG.md b/libtmux-mcp/CHANGELOG.md index cbd9751bb..6ac826cfb 100644 --- a/libtmux-mcp/CHANGELOG.md +++ b/libtmux-mcp/CHANGELOG.md @@ -14,6 +14,12 @@ changelog](../CHANGELOG.md). ## Unreleased +### Changed + +- **`libtmux-mcp` and its stdio launcher use MCP Java SDK 2.2.0 and Reactor + Core 3.9.0.** Applications embedding the server get the same Reactor release + on their compile and runtime classpaths, up from 3.7.0. + ### Fixed - **`run_shell_command` waits for the shell of a pane created a moment ago.** diff --git a/libtmux-mcp/build.gradle.kts b/libtmux-mcp/build.gradle.kts index 0d5abad53..1f22fefbd 100644 --- a/libtmux-mcp/build.gradle.kts +++ b/libtmux-mcp/build.gradle.kts @@ -28,6 +28,8 @@ dependencies { // On this module's own signature: serving() takes a transport provider and every entry point // returns the SDK's server, so compiling against this module means compiling against the SDK. api(libs.mcp.core) + // Callers implement the SDK transport with Reactor's Mono, which the server wrappers also use. + api(libs.reactor.core) implementation(libs.mcp.json.jackson2) implementation(libs.jackson.databind) @@ -35,8 +37,7 @@ dependencies { add(launcherRuntime.name, libs.slf4j.nop) - // Only to let javac fully resolve the JSR-305 annotations reactor-core's own Nullable class - // carries; io.projectreactor:reactor-core is a transitive runtime dependency of libs.mcp.core. + // Let javac resolve the JSR-305 annotations on Reactor's Nullable class. compileOnly(libs.jsr305) testCompileOnly(libs.jsr305) diff --git a/libtmux-mcp/src/main/java/io/github/libtmux/mcp/TmuxMcpServer.java b/libtmux-mcp/src/main/java/io/github/libtmux/mcp/TmuxMcpServer.java index b28292d66..954331dc0 100644 --- a/libtmux-mcp/src/main/java/io/github/libtmux/mcp/TmuxMcpServer.java +++ b/libtmux-mcp/src/main/java/io/github/libtmux/mcp/TmuxMcpServer.java @@ -126,14 +126,17 @@ private static McpSyncServer serving( } private static McpSyncServer build(Connection connection, McpServerTransportProvider transport) { + // Session-based clients can still negotiate logging during initialization. + @SuppressWarnings("deprecation") + var capabilities = McpSchema.ServerCapabilities.builder() + .tools(false) + .resources(false, false) + .logging() + .build(); var specification = McpServer.sync(new SerializedTransportProvider(transport)) .serverInfo("libtmux", version()) .instructions(Instructions.forServer(connection)) - .capabilities(McpSchema.ServerCapabilities.builder() - .tools(false) - .resources(false, false) - .logging() - .build()) + .capabilities(capabilities) .resources(Resources.fixed(connection)); for (ToolSpec tool : connection.surface().tools().values()) { diff --git a/module-tests/sbt/build.sbt b/module-tests/sbt/build.sbt index 994d95b60..19a61fb97 100644 --- a/module-tests/sbt/build.sbt +++ b/module-tests/sbt/build.sbt @@ -5,7 +5,7 @@ val libtmuxVersion = sys.props.getOrElse("libtmux.version", sys.error("pass -Dlibtmux.version=")) val staging = file(sys.props.getOrElse("libtmux.staging", "../../build/staging-repository")) -ThisBuild / scalaVersion := "3.10.0" +ThisBuild / scalaVersion := "3.10.1" ThisBuild / scalacOptions ++= Seq("-release:25", "-deprecation", "-feature", "-Werror") ThisBuild / resolvers += "libtmux staging" at staging.getAbsoluteFile.toURI.toString