Package-level declarations

Types

Link copied to clipboard

Entry points for calling the suspending and Flow-returning parts of the ADK from Java, and for bridging a Flow to Reactive Streams.

Link copied to clipboard

Java-friendly base for implementing an ArtifactService. The engine's methods are suspend; a Java subclass returns CompletableFutures instead. Return each future promptly and do any blocking work inside it, not before returning it.

Link copied to clipboard

Java-friendly base for implementing a Classifier: a Java subclass overrides classifyAsync to return a CompletableFuture, which classify awaits. Canceling the calling coroutine cancels the future from classifyAsync; fail the future rather than cancel it when classification fails, since a canceled future raises CancellationException in classify.

Link copied to clipboard

Java-friendly base for implementing a LiveConnection: override the ...Async methods, which return a CompletableFuture, and receiveJava, which returns a Publisher of one model turn. The base maps these to LiveConnection's calls and also enforces two of its rules, one receive collector at a time and a closeSession that is safe to call again; apply its content rules yourself. Return a new future from each call, because the base cancels a send's future when its caller is cancelled, and a new publisher from each receiveJava call; return each promptly, with any blocking work inside it, and fail a future rather than cancel it.

Link copied to clipboard

Java-friendly base for implementing a MemoryService. The engine's methods are suspend; a Java subclass returns CompletableFutures instead. addEventsToMemoryAsync and addMemoryAsync are optional -- their default throws UnsupportedOperationException (as the engine does), so override them only if the service supports those writes. Return each future promptly and do any blocking work inside it, not before returning it.

Link copied to clipboard
abstract class BaseFuturePlugin(pluginName: String) : Plugin

Java-friendly base for implementing a Plugin -- the cross-cutting interception point. The engine's Plugin has 13 suspend callbacks plus close(), every one with a default body. This base final-overrides all 13 and re-exposes each as a CompletableFuture-returning hook whose result is the outcome; each default hook completes with the value that leaves execution unchanged. Return the future promptly and do any blocking work inside it, not before returning it.

Link copied to clipboard

Java-friendly base for implementing a SessionService. Every method of the engine interface is suspend; this base final-overrides each and asks the Java subclass for a CompletableFuture instead. Return each future promptly and do any blocking work inside it, not before returning it. The methods with default bodies (closeSession, appendEvent, flush) keep those defaults reachable: leave the hook unoverridden and the engine's own behaviour runs.

Link copied to clipboard

Java-friendly base for implementing a SkillSource: every engine method is a suspend returning a Result, and this base final-overrides each to await a CompletableFuture from the Java subclass, mapping a completed future to Result.success and any failure to a Result.failure of SkillSourceException. Return each future promptly and do any blocking work inside it. Complete the future exceptionally with a SkillSourceException to report a skill error whose message reaches the LLM.

Link copied to clipboard
abstract class BaseFutureTool @JvmOverloads constructor(name: String, description: String, isLongRunning: Boolean = false, customMetadata: Map<String, Any> = emptyMap()) : BaseTool

Java-friendly base for implementing a BaseTool asynchronously. A Java subclass overrides declaration and runAsync, which returns a CompletableFuture; this base awaits it to satisfy the suspend run contract that Java cannot express.

Link copied to clipboard
abstract class BaseFutureToolset : Toolset

Java-friendly base for implementing a Toolset -- a dynamically resolved group of tools. Both engine methods are suspend; a Java subclass returns CompletableFutures instead. Return each future promptly and do any blocking work inside it, not before returning it. processLlmRequest defaults to returning the request unchanged; override processLlmRequestAsync to rewrite it.

Link copied to clipboard

Java-friendly base for implementing a RetryPolicy. Java cannot return the Duration that nextRetryDelay needs, so a Java subclass implements shouldRetry and nextRetryDelayMillis instead. Like any RetryPolicy, it must be thread-safe and return quickly.

Link copied to clipboard
abstract class BasePublisherAgent @JvmOverloads constructor(name: String, description: String = "", subAgents: List<BaseAgent> = emptyList(), beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), afterAgentCallbacks: List<AfterAgentCallback> = emptyList(), disallowTransferToParent: Boolean = false, disallowTransferToPeers: Boolean = false) : BaseAgent

Java-friendly base for implementing a BaseAgent. A Java subclass overrides runAsyncImplJava, which returns a Reactive Streams Publisher of the turn's events; this base adapts it to the Flow-returning runAsyncImpl contract that Java cannot express. The publisher is subscribed to lazily and asked for one event at a time, the next only after the runner has processed the previous one, so later events see the state and history that earlier ones changed.

Link copied to clipboard
abstract class BasePublisherModel(val name: String) : Model

Java-friendly base for implementing a Model. A Java subclass overrides generateContentJava, which returns a Reactive Streams Publisher; this base adapts it to the Flow-returning generateContent contract that Java cannot express. Both the unary and streaming cases flow through that one method, exactly as they do for a Kotlin Model; a subclass that supports live connections also overrides connectAsync.

Link copied to clipboard
abstract class BasePublisherNode @JvmOverloads constructor(name: String, description: String = "", rerunOnResume: Boolean = false, waitForOutput: Boolean = false, config: NodeConfig = NodeConfig(), inputSchema: Schema? = null, outputSchema: Schema? = null, stateSchema: Schema? = null) : BaseNode

Java-friendly base for implementing a workflow node. A Java subclass overrides runNodeJava to set routes or state on the context and return a Reactive Streams Publisher of node outputs, which this base adapts to the Flow-returning runNode. To run other nodes from runNodeJava, pass rerunOnResume = true and use InteropContextView.runNode.

Link copied to clipboard
abstract class BasePublisherTool @JvmOverloads constructor(name: String, description: String, customMetadata: Map<String, Any> = emptyMap()) : BaseTool

Java-friendly base for a BaseTool whose result is a Reactive Streams Publisher. A Java subclass overrides declaration and runPublisher, whose values a connected live run streams; anywhere else the call fails, as BaseTool.run describes for a Flow. A live run declares the tool non-blocking on its own, so the model can keep the conversation going while results arrive.

Link copied to clipboard
object Choices

Java factories for the sealed CallbackChoice.

Link copied to clipboard

Java-friendly wrapper around an ArtifactService that it owns: each method calls the suspend method of the same name and returns a CompletableFuture of its result, so Java callers never pass a Continuation. Each call runs in the caller's OpenTelemetry context and in the coroutineContext passed to it, such as MDCContext() from kotlinx-coroutines-slf4j to carry the caller's MDC. Canceling a future cancels its call, a Job in coroutineContext is ignored, and close cancels every call in flight, then closes the service if it is AutoCloseable.

Link copied to clipboard

Java-friendly wrapper around a Classifier that it owns: classify calls Classifier.classify in the caller's OpenTelemetry context and the passed coroutineContext, returning a CompletableFuture of the result. Canceling a future cancels its call, and a Job in coroutineContext is ignored.

Link copied to clipboard

Java-friendly wrapper around a MemoryService that it owns: each method calls the suspend method of the same name and returns a CompletableFuture of its result, so Java callers never pass a Continuation. Each call runs in the caller's OpenTelemetry context and in the coroutineContext passed to it, such as MDCContext() from kotlinx-coroutines-slf4j to carry the caller's MDC. Canceling a future cancels its call, a Job in coroutineContext is ignored, and close cancels every call in flight, then closes the service if it is AutoCloseable.

Link copied to clipboard

Java-friendly wrapper around a SessionService that it owns: each method calls the suspend method of the same name and returns a CompletableFuture of its result, so Java callers never pass a Continuation. Each call runs in the caller's OpenTelemetry context and in the coroutineContext passed to it, such as MDCContext() from kotlinx-coroutines-slf4j to carry the caller's MDC. Canceling a future cancels its call, a Job in coroutineContext is ignored, and close cancels every call in flight, then closes the service if it is AutoCloseable.

Link copied to clipboard

Creates FunctionNodes from Java with a type per port. Jackson reads each input into its declared type and writes each output as JSON, so records and POJOs work as ports, and a port typed this way infers the schema of that JSON form, or none for a type with no fixed shape or an input Jackson reads as another class through @JsonDeserialize(as = ...) or a builder; Object.class leaves a port untyped, a Content or Event port passes values unchanged, and a String port reads a message as its text, passes null through, rejects any other non-text value, and infers a string schema. An edge into a typed port must fit its schema as between Kotlin ports: the source may write only keys the port type reads, or keys the port type itself writes, with a JSON type that fits (an integer also fits a number), and null only where the port type takes it, such as into a String port or a field marked @Nullable. So a bean fits its own input, even one whose getter and setter names differ by a typo, which then reads null; a creator property that a type never writes fails its own edge, as its reader would get null. A port writes a value as its own class, so a subclass value may write keys its declared type does not; a typed successor skips them, but an explicit input schema with additionalProperties: false rejects them at run time. To run a node on each item of a list, wrap it with FunctionNode.parallelOf.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Java-friendly adapters for the engine's callback interfaces.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Java-friendly view of a Context: each method except emit and runNodeBlocking calls the suspend method of the same name and returns a CompletableFuture of its result, so Java callers never pass a Continuation; those two instead block and work only in a Java FunctionNode body, and emit ignores the coroutine context given to of. Each future-returning call runs in the caller's OpenTelemetry context, on the calling thread until it first suspends (so runNode children get their run IDs in call order) and then on Dispatchers.IO, as PublisherRunner runs agents. Each future-returning call is canceled with its future and with the Job given to of, if any, or otherwise when the node run that owns the context, if any, ends, so await each call before the node finishes.

Link copied to clipboard
actual typealias JavaClass<T> = Class<T>
typealias JavaClass<T> = Class<T>

On JVM and Android, a Java class object is java.lang.Class.

expect class JavaClass<T>

A Java class object, so that common code can offer Java callers methods that take or return Class, such as RetryConfig.Builder.exceptionJavaClasses. On JVM and Android it is a typealias for java.lang.Class; Kotlin code uses KClass instead.

Link copied to clipboard

Java-friendly wrapper around a Runner. A run is exposed as a Reactive Streams Publisher of events, so Java callers never touch Flow; collect it with AsyncJavaHelpers.collect/forEach or any Reactive Streams consumer. Session management is not a runner concern: to call the session service from Java, create it wrapped in a CompletableFutureSessionService and build the runner with the wrapper's asKotlinSessionService().

Link copied to clipboard

Builds a BaseTool from a Tool-annotated Java method, on the JVM only, for javac-only modules; prefer the KSP @Tool path whenever the code is built with the Kotlin compiler, which processes .java sources too. It reads the same Tool/Param annotations, including Tool.requireConfirmation, relying on Param.name/Param.required because Java retains neither parameter names nor nullability; every parameter needs Param except one Context or ToolContext and one experimental Publisher<LiveRequest> (or Publisher<? extends LiveRequest>), which carries ToolContext.liveRequests. Like a KSP tool, the method runs in the calling coroutine and keeps its context (such as MDC), so run blocking methods on a dispatcher meant for blocking work, such as PublisherRunner.runAsync's default; a returned Reactive Streams Publisher acts as a returned Flow does (see BaseTool.run).

Link copied to clipboard
data class RunNodeConfig(val runId: String? = null, val useAsOutput: Boolean = false, val useSubBranch: Boolean = false, val overrideBranch: String? = null, val overrideIsolationScope: String? = null, val raiseOnWait: Boolean = false)

Options for InteropContextView.runNode and InteropContextView.runNodeBlocking. Each property has the default and meaning of the Context.runNode argument with the same name.