Java SDK
Run the Autohand agent loop on the JVM. The Java SDK exposes a builder-style API, sealed event types, and the same permission and streaming model as the other SDKs.
Install
<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.
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.
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
AgentOptionsandSDKConfig. - Stream callbacks over sealed event types in
Events. - Low-level
AutohandSDKaccess when you need direct runtime control. - Higher-level
Agentaccess for everyday application code.
Next steps
- Use Quickstart for the cross-language setup flow.
- Compare with the Go SDK or TypeScript SDK for the same patterns in other languages.