SDKs & clients

Go SDK handbook

Use the Go REST/SSE SDK in application backends to create Tasks, answer input requests, observe progress and download verified artifacts. Requires Go 1.24+. The generator toolchain is separate from application dependencies. Check actual availability in the SDK center before installing:

sh
go get github.com/orbitmesh-official/orbitspace-go-sdk@v0.1.0

The public distribution repository contains only SDK source, tests, examples and contracts. It uses independent standard v0.x.y module tags. Control-plane api/v* and private source sdk-go/v* tags are not install versions. The public v0.1.0 module is available through the Go module proxy. pkg.go.dev provides the Go method reference.

Authentication and client

Prepare an authorized tenant, project, Workspace and Agent binding, or an authorized Agent service deployment. Native Tasks normally require tasks:read tasks:write; add artifacts:read for downloads. Scopes do not replace project policy. Provider model keys belong in platform configuration, not this SDK.

go
import (
    "context"
    "time"
    orbitspace "github.com/orbitmesh-official/orbitspace-go-sdk"
    "github.com/orbitmesh-official/orbitspace-go-sdk/api"
)

provider, err := orbitspace.NewClientCredentials(orbitspace.ClientCredentialsOptions{
    TokenURL: tokenEndpoint, // Use the configured issuer endpoint; do not guess.
    ClientID: clientID,
    ClientSecret: secretFromVault,
    Scope: "tasks:read tasks:write artifacts:read",
})
if err != nil { return err }
client, err := orbitspace.New(orbitspace.Options{
    BaseURL: "https://api.orbitspace.dev",
    TenantID: tenantID,
    TokenProvider: provider,
    Timeout: 30*time.Second,
    Retries: 2,
})
if err != nil { return err }

Alternatively supply Options.Token for an API Token; choose one authentication source. Client credentials default to client_secret_basic, with client_secret_post and private_key_jwt assertion callbacks also supported. Issuance is single-flight, uses early renewal, and does not cache indefinitely without expiry. Cancelling a waiter does not cancel other callers' issuance. Create a new provider after rotating its client secret; Invalidate() clears only its access-token cache. Providers are not implicitly shared across tenants or processes.

Use an established PKCE/OIDC library for browser/mobile login and supply short-lived tokens with TokenProviderFunc. Never ship confidential client secrets in an app. Token endpoints require HTTPS except for loopback test fixtures.

Create, wait and answer input

go
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
task, err := client.Tasks.Create(ctx, api.CreateTaskRequest{
    WorkspaceID: orbitspace.Ptr(workspaceID),
    WorkspaceAgentBindingID: orbitspace.Ptr(bindingID),
    Input: orbitspace.Ptr("Summarize the supplied document."),
    IdempotencyKey: orbitspace.Ptr(durableJobKey),
})
if err != nil { return err }
result, err := client.Tasks.Wait(ctx, *task.ID, orbitspace.ObserveOptions{})
if err != nil { return err }

Wait may return waiting_input, waiting_approval, paused or a terminal state; do not assume completion. Observe delivers authoritative REST snapshots through a callback, driven by SSE without periodic idle polling. Cancelling observation closes local connections without cancelling remote execution.

Fetch the latest request and state version with Tasks.InputRequests or Tasks.GetInput before answering:

go
_, err = client.Tasks.ReplyInput(ctx, inputRequestID, api.ReplyTaskInputRequestRequest{
    ExpectedStateVersion: orbitspace.Ptr(latestInputVersion),
    IdempotencyKey: orbitspace.Ptr(durableReplyKey),
    Response: orbitspace.Ptr[api.GoogleProtobufValue](map[string]any{"answer": "confirmed"}), // api.GoogleProtobufValue; ArtifactIDs can reference authorized artifacts.
})
if err != nil { return err }

Load a fresh Task before deciding whether to call Resume with its state_version. The SDK never automatically approves, answers, resumes or cancels. Persist separate stable keys for business jobs and replies. On uncertain admission, reconcile using the same key rather than creating a new business job. Decimal state versions, byte counts and cursors remain strings; do not convert them to floating point. See native Tasks and input and approval.

Events, recovery and errors

WatchTask, WatchInvocation, WatchGoal and Watch deliver raw SSE events synchronously. WatchOptions.After takes your committed cursor; reconnection sends Last-Event-ID. Streams require a cancellable Context. A received cursor is not a business acknowledgement: commit side effects and cursor in your own transaction before resuming from it. Missing history surfaces as an API error; apply the snapshot, paging and retention contract rather than pretending the gap is complete history.

Use errors.As for APIError (Status, Code, Message, RequestID), and errors.Is for cancellation/deadlines. OAuth errors do not echo provider bodies or secrets. REST defaults to a 30-second timeout; SSE uses the Context lifetime. Bounded automatic retries apply only to transient GET/HEAD failures and honor Retry-After. Writes are never replayed automatically, including keyed writes. API credentials remain confined to the configured origin/base path; redirects are disabled.

Verified downloads

go
receipt, err := client.Artifacts.DownloadFile(ctx, artifactID, destinationPath,
    orbitspace.DownloadOptions{MaxBytes: 32 << 20})
if err != nil { return err }
_ = receipt.SHA256

A fresh authorized receipt is fetched first, then bytes are requested without API authentication or tenant headers. The default destination is the API origin's /api/v1/artifact-downloads/ prefix. S3/CDN downloads require explicitly reviewed Destinations with exact origins and slash-bounded prefixes. Redirects, expiry, byte-limit violations, size mismatches and SHA-256 mismatches fail. A private staging file is verified before atomically replacing the destination; failures remove staging. See artifacts.

Complete API and qualification boundary

client.API exposes all 330 admitted typed operations. For example, client.API.TaskServiceGetTaskWithResponse(ctx, id) returns status-specific typed responses: check the HTTP status and Problem Details. Resource helpers normalize failures to APIError. Package api preserves wire fields and unknown string enum values. Skill management remains in the Registry operations under Workspaces and capabilities. See Tasks API and resources API.

The runnable backend example reads secrets, an existing Task ID or a durable business key from the environment without logging document contents or credentials. CI14 qualifies the minimum Go version, races, cancellation, SSE reconnection, full Task interaction and isolated source export against independent HTTP fixtures. This is not a claim that Smart-printer has completed production integration.

Application SDKs do not deploy sandboxes, enroll Worker/Host nodes, implement the A2A message binding or verify Webhook signatures; those remain separate contracts. See domain tools and Webhooks. Python is a follow-up, not a published SDK.