Status: Private beta. The self-hosted client ships inside @allternit/platform and allternit-platform, which are not yet published to npm or PyPI. Install them from the repo (sdk/platform-ts, sdk/platform-python). The client is tested against a mock server; the real server is still being built.
Both SDKs have a SelfHostClient generated from selfhost-v1.yaml. It talks only to the server URL you give it.

TypeScript

Every API area is a property: client.server, client.agents, client.environments, client.environmentKeys, client.sessions, client.events, client.apiKeys, plus the worker routes client.work and client.toolCalls. The generated types are under the selfhost namespace (import { selfhost } from "@allternit/platform") or from @allternit/platform/selfhost. Each create call sends an Idempotency-Key. By default the SDK makes a new one for each call. After a network error or a 5xx answer before a response, it retries up to 2 times with the same key, so a retried message is not stored twice. To retry safely yourself, pass your own key and reuse it for the retry. The server replays the first answer and sets Idempotency-Replayed: true. See API reference. New error codes you can get: custom_tool_conflict (409, change the custom tool name; nothing was stored), idempotency_key_reuse (422, one key with two different bodies), idempotency_in_progress (409, retry shortly) and, in the event stream, server_restarted (resend the message). streamEvents yields typed events, skips keepalive comments and, after a dropped connection, reconnects with Last-Event-ID, so no event is missed or repeated. A full script is in sdk/platform-ts/examples/selfhost-session.ts.

Python

Attributes use snake case: client.environment_keys, client.tool_calls, client.api_keys. A full script is in sdk/platform-python/examples/selfhost_session.py.

Custom-tool worker

An agent tool with "type": "custom" is run by your code. The worker helper does the protocol work for you:
  1. Claims work for one environment with an environment key.
  2. Renews the lease every 20 seconds.
  3. Takes the session’s tool calls with the per-session secret.
  4. Runs your handler for each tool and posts the result, cut to 100 KiB.
A work item ends only when tool_calls/next answers 204 with X-Session-Closed: true; the helper then calls /complete. A plain 204 means the wait was empty, so it polls again and never completes after it. It sends X-Worker-Hostname and X-Worker-Version on claim, renew, complete and release (set the hostname with hostname, otherwise the machine’s). One worker serves one session at a time, so run as many workers as you want concurrent sessions. It answers a call that is handed out again (same tool_call_id) from memory instead of running it twice. When the lease turns stale it stops and posts nothing. When you stop it, it hands the item back with /release. A thrown error becomes an error result. A tool with no handler gets an error result.
Built-in sandbox tools (bash, file edits) are run by gizzi worker, not by this helper. Give agents whose tools your code runs their own environment, so the two kinds of worker don’t take each other’s work. The gizzi worker CLI runs custom tools that are commands, from a tools file. See Workers. Tools that need your own code run on SDK workers.

Regenerate

The clients are generated with the Platform SDK generator:
The internal loopback route (marked x-internal) is skipped.