Java SDK handbook
A Java 17+ backend client for REST, OAuth, Task input replies, resumable SSE and verified downloads. dev.orbitspace:orbitspace-sdk:0.1.0 is published to Maven Central. Visit the SDK center for installation and version-specific references.
Install
Add this dependency to your Maven pom.xml. No additional repository configuration is needed:
<dependency>
<groupId>dev.orbitspace</groupId>
<artifactId>orbitspace-sdk</artifactId>
<version>0.1.0</version>
</dependency>Gradle Kotlin DSL:
repositories { mavenCentral() }
dependencies { implementation("dev.orbitspace:orbitspace-sdk:0.1.0") }Consumers need JDK 17+, without a generator, Buf, protobuf or Spring. This is a backend SDK, not an Android SDK.
Build from source
The public orbitspace-java-sdk repository contains only SDK source, public contracts, tests, examples and build files. Use JDK 17+ and Maven 3.8.7+:
git clone --branch v0.1.0 https://github.com/orbitmesh-official/orbitspace-java-sdk.git
cd orbitspace-java-sdk
mvn verifyRun mvn install only when using a locally modified SDK. Normal integrations resolve the published dependency from Maven Central.
Credentials and client
Prepare an authorized tenant, project, Workspace and Agent binding. Native Tasks usually need tasks:read tasks:write; add artifacts:read for downloads. Scopes do not replace project authorization. The SDK receives an application credential, never a model-provider Key.
import dev.orbitspace.sdk.*;
import dev.orbitspace.sdk.model.*;
import java.time.Duration;
OrbitSpaceClient client = OrbitSpaceClient.builder()
.tenantId(tenantId)
.token(apiTokenFromSecretStore)
.build();For OAuth client credentials, configure the issuer's actual token endpoint:
ClientCredentials provider = ClientCredentials.builder(tokenEndpoint, clientId)
.secret(secretFromVault)
.scope("tasks:read tasks:write artifacts:read")
.build();
OrbitSpaceClient client = OrbitSpaceClient.builder()
.tenantId(tenantId).tokenProvider(provider).build();Choose exactly one of token or tokenProvider. OAuth defaults to client_secret_basic, also supporting client_secret_post and private_key_jwt. Use .assertion(audience -> signedAssertion) with your signer; the audience is the validated token endpoint. Keep credentials and assertions out of logs.
The provider coalesces concurrent issuance and renews early. Missing expiry is not cached long-term. Cancelling one waiter does not cancel other callers' issuance. invalidate() clears the access-token cache; construct a new provider when client credentials rotate. Providers are not implicitly shared across tenants. Use TokenProvider with your existing OIDC/PKCE token manager; established authentication libraries handle interactive login.
Create, answer input and continue
Task task = client.tasks().create(new CreateTaskRequest()
.workspaceId(workspaceId)
.workspaceAgentBindingId(bindingId)
.input("Summarize the supplied document.")
.idempotencyKey(durableBusinessJobKey));
try (Cancellation cancellation = Cancellation.after(Duration.ofMinutes(10))) {
var result = client.tasks().waitFor(task.getId(), cancellation);
// Inspect result.state().
}waitFor can return waiting_input, waiting_approval, paused or a terminal state; a return is not always success. observe reads authoritative REST snapshots in response to events, with a minimum 500ms interval and no idle polling. Closing local Cancellation does not cancel a remote Task.
Fetch the latest input with tasks().inputRequests(taskId) or getInput(inputRequestId), then explicitly reply:
client.tasks().replyInput(inputRequestId, new ReplyTaskInputRequestRequest()
.expectedStateVersion(latestInputVersion)
.idempotencyKey(durableReplyKey)
.response(java.util.Map.of("answer", "confirmed")));Use a fresh Task snapshot to decide whether to resume, passing its state_version. The SDK never approves, answers, resumes or cancels automatically. Persist separate idempotency keys for the business job and reply; reuse the original key when submission is uncertain. Keep versions and cursors as strings. See native Tasks and interactive input.
Events and recovery
tasks().watch, invocations().watch and goals().watch deliver raw events and require a bounded Cancellation. In SseStream.Options(after, committedCursor, maxReconnects, maxEventBytes), the committed-cursor supplier reads your durable business cursor. Reconnection sends Last-Event-ID.
Observation is not a business acknowledgement. Commit effects and cursor in the same transaction before recovering from that cursor. Without a supplier, reconnect reuses the initial cursor, so tolerate duplicate events. EOF discards incomplete frames without advancing their IDs. History gaps remain explicit errors; recover using the execution contract instead of silently skipping to live events. Returning false stops only local consumption.
Errors and downloads
ApiError exposes status(), code() and requestId() without raw error bodies in its message. Generated operations share HTTP error normalization; transport/decoding errors use native ApiException. REST defaults to a 30-second deadline, including streamed response bodies in generated operations. Bounded retries cover only transient GET/HEAD failures; writes are never automatically replayed. Credentials stay within the configured API origin and path. Redirects, cookies and implicit HTTP authentication are disabled.
try (Cancellation cancellation = Cancellation.after(Duration.ofMinutes(2))) {
var result = client.artifacts().downloadFile(artifactId, destination,
Artifacts.DownloadOptions.apiOnly(32L << 20), cancellation);
}A separate request without API Token or tenant headers checks expiry, byte limits, exact size and SHA-256 before atomic replacement. Failures clean private staging files and preserve existing destinations. The API's /api/v1/artifact-downloads/ prefix is allowed by default; S3/CDN origins require explicit Destination origins and prefixes. Default error chains redact signed URLs; callers opting into DownloadTransportException.diagnostics() control sensitive diagnostic retention. See artifacts and files.
Complete API
import dev.orbitspace.sdk.api.TaskServiceApi;
Task task = client.api(TaskServiceApi.class).taskServiceGetTask(taskId);api(...) exposes all 330 admitted typed operations, including Skill management through Registry. Models preserve unknown string enums and decimal-string fields, and the JAR embeds the public contract. Browse Task APIs and Workspace and capability APIs.
Application SDKs do not deploy Runtimes/sandboxes, enroll nodes, bind A2A messages or verify Webhook signatures. Use the separate domain-tool kit for executor integration and authentication and access for OAuth and scopes.