Install

Maven

<dependency>
    <groupId>ai.autohand</groupId>
    <artifactId>agent-sdk-java</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

API shape

The Java wrapper mirrors the same runtime ideas as the TypeScript and Go SDKs: create an agent, send a prompt, stream events, then close the session.

Java

import ai.autohand.sdk.sdk.Agent;
import ai.autohand.sdk.sdk.AgentOptions;
import ai.autohand.sdk.sdk.RunResult;
import ai.autohand.sdk.types.Events;
import ai.autohand.sdk.types.PermissionMode;

Agent agent = Agent.create(AgentOptions.builder()
    .cwd(".")
    .instructions("Review code with concise release-readiness notes.")
    .permissionMode(PermissionMode.INTERACTIVE)
    .build());

var run = agent.send("Review the repository for release risks.");
run.stream(event -> {
    if (event instanceof Events.MessageUpdateEvent mue) {
        System.out.print(mue.delta());
    }
});

RunResult result = run.waitForResult();
System.out.println(result.text());
agent.close();

Permissions

Permission events follow the same pattern as the other wrappers.

Java

import ai.autohand.sdk.sdk.AutohandSDK;
import ai.autohand.sdk.types.DecisionScope;
import ai.autohand.sdk.types.Events;
import ai.autohand.sdk.types.PromptParams;
import ai.autohand.sdk.types.SDKConfig;

AutohandSDK sdk = new AutohandSDK(new SDKConfig(
    ".",
    null,
    false,
    300000
));

sdk.start();
sdk.streamPrompt(new PromptParams("Run the test suite and summarize failures."), event -> {
    if (event instanceof Events.PermissionRequestEvent pre) {
        sdk.allowPermission(pre.requestId(), DecisionScope.ONCE);
    }
});
sdk.stop();

What to expect

  • Builder-based configuration via `AgentOptions` and `SDKConfig`.
  • Stream callbacks over sealed event types in `Events`.
  • Low-level `AutohandSDK` access when you need direct runtime control.
  • Higher-level `Agent` access for everyday application code.

Next steps

  • Use [Quickstart](/docs/agent-sdk/quickstart.html) for the cross-language setup flow.
  • Compare with the Go SDK or TypeScript SDK for the same patterns in other languages.