DocsHarness SDK

BEEOS CLOUD / DEVELOPER REFERENCE

Identity and request signing

Ed25519 key pairs, signed request headers, and canonical hashing.

The harness owns an Ed25519 key pair. The SDK builds the exact signing preimage and the four X-Agent-* headers for Agent Gateway requests; the key never leaves your process.

AgentRequestIdentity

TypeScript @beeos-ai/cloud-harness-sdk · TypeScript only

A public key plus a signing function. The host keeps the private key; the SDK builds the exact signing preimage.

interface AgentRequestIdentity

Properties

NameTypeDescription
publicKeyUint8ArrayRaw 32-byte Ed25519 public key; it is sent base64-encoded in X-Agent-Public-Key.

sign

Signs a message and returns the raw Ed25519 signature. The private key stays inside this function.

sign(message: Uint8Array): Uint8Array

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
messageUint8ArrayyesThe exact bytes to sign.

Returns Uint8Array

agentAuthHeaders

TypeScript @beeos-ai/cloud-harness-sdk · Python beeos_cloud_harness_sdk.identity

Builds the four X-Agent-* headers for a request that you send yourself, for example a WebSocket upgrade.

function agentAuthHeaders(method: string, urlPath: string, keys: AgentKeyPair, body?: string | Uint8Array | null): Record<string, string>

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
methodstringyesHTTP method; it is upper-cased in the signing preimage.
urlPathstringyesDecoded request path that is signed. It must match the path the server sees and must not contain a query string.
keysAgentKeyPairyesThe harness key pair that signs the request.
bodystring | Uint8Array | nullnoExact request body; null or omitted means an empty body.

Returns Record<string, string>

Python · Parameters

ParameterTypeRequiredDefaultDescription
methodstryesHTTP method; it is upper-cased in the signing preimage.
url_pathstryesDecoded request path that is signed. It must match the path the server sees and must not contain a query string.
keysAgentKeyPairyesThe harness key pair that signs the request.
bodybytes | str | NonenoNoneExact request body; null or omitted means an empty body.

Returns dict[str, str]

agentIdentityFromKeyPair

TypeScript @beeos-ai/cloud-harness-sdk · TypeScript only

Wraps a key pair into an AgentRequestIdentity. Signed Gateway requests and registration proofs use it.

function agentIdentityFromKeyPair(keys: AgentKeyPair): AgentRequestIdentity

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
keysAgentKeyPairyesThe key pair whose private key signs.

Returns AgentRequestIdentity

agentRequestAuthHeaders

TypeScript @beeos-ai/cloud-harness-sdk · TypeScript only

Builds the four X-Agent-* headers for a request from an AgentRequestIdentity. The signed preimage is METHOD\|PATH\|\|bodyHash\|timestamp\|nonce.

function agentRequestAuthHeaders(method: string, path: string, identity: AgentRequestIdentity, body?: string | Uint8Array | null, now: () => number = Date.now, nonce: () => string = randomUUID): Record<string, string>

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
methodstringyesHTTP method; it is upper-cased in the signing preimage.
pathstringyesDecoded request path that is signed.
identityAgentRequestIdentityyesThe identity that signs the request.
bodystring | Uint8Array | nullnoExact request body; null or omitted means an empty body.
now() => numbernoDate.nowClock in milliseconds; replace it in tests. Defaults to Date.now.
nonce() => stringnorandomUUIDNonce generator; replace it in tests. Defaults to randomUUID.

Returns Record<string, string>

authenticatedAgentFetch

TypeScript @beeos-ai/cloud-harness-sdk · TypeScript only

Sends a signed fetch request. It signs the decoded URL path and the exact body, refuses redirects, and rejects when the response comes from another origin.

async function authenticatedAgentFetch(input: string | URL, identity: AgentRequestIdentity, init?: RequestInit): Promise<Response>

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
inputstring | URLyesAbsolute URL of the request.
identityAgentRequestIdentityyesThe identity that signs the request.
initRequestInitnoStandard fetch options. A body must be a string or a Uint8Array so that the signature covers the exact bytes.

Returns Promise<Response>

bodyHashHex

TypeScript @beeos-ai/cloud-harness-sdk · Python beeos_cloud_harness_sdk.identity

Returns the lowercase hexadecimal SHA-256 of a request body; an empty or missing body hashes to EMPTY_BODY_SHA256.

function bodyHashHex(body?: string | Uint8Array | null): string

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
bodystring | Uint8Array | nullnoRequest body; strings are hashed as UTF-8.

Returns string

Python · Parameters

ParameterTypeRequiredDefaultDescription
bodybytes | str | NonenoNoneRequest body; strings are hashed as UTF-8.

Returns str

canonicalize_jcs

Python beeos_cloud_harness_sdk.jcs · Python only

Serialises a JSON value to its canonical form (RFC 8785, JSON Canonicalization Scheme), the byte-exact text that is hashed for identity proofs.

def canonicalize_jcs(value: Any) -> str

Python · Parameters

ParameterTypeRequiredDefaultDescription
valueAnyyesA JSON-compatible value: dict, list, str, int, float, bool or None.

Returns str

generate_agent_key_pair

Python beeos_cloud_harness_sdk.identity · Python only

Generates a new Ed25519 key pair and writes it as JSON to save_to with mode 0600.

def generate_agent_key_pair(save_to: str | Path) -> AgentKeyPair

Python · Parameters

ParameterTypeRequiredDefaultDescription
save_tostr | PathyesPath of the key file; missing parent directories are created.

Returns AgentKeyPair

loadAgentKeyPair

TypeScript @beeos-ai/cloud-harness-sdk · Python beeos_cloud_harness_sdk.identity

Loads the key file. A missing file is created with a new key pair (mode 0600) in TypeScript; in Python it is created only when create_if_missing is set. A file holds JSON with publicKey and privateKey, or a bare base64 32-byte seed.

function loadAgentKeyPair(filePath: string): AgentKeyPair

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
filePathstringyesPath of the key file. It holds either JSON with base64 publicKey and privateKey, or a bare base64 32-byte seed.

Returns AgentKeyPair

Python · Parameters

ParameterTypeRequiredDefaultDescription
file_pathstr | PathyesPath of the key file. It holds either JSON with base64 publicKey and privateKey, or a bare base64 32-byte seed.
create_if_missingboolnoFalseWhen True, a missing file is created with a new key pair; otherwise FileNotFoundError is raised.

Returns AgentKeyPair

runtime_domain_hash

Python beeos_cloud_harness_sdk.jcs · Python only

Returns the SHA-256 (hexadecimal) of the domain string, a line feed, and the canonical JSON of the payload. It is the hash used in identity proofs.

def runtime_domain_hash(domain: str, payload: Any) -> str

Python · Parameters

ParameterTypeRequiredDefaultDescription
domainstryesDomain-separation string, for example REGISTRATION_HASH_DOMAIN.
payloadAnyyesJSON-compatible payload to hash.

Returns str

sha256_hex

Python beeos_cloud_harness_sdk.jcs · Python only

Returns the lowercase hexadecimal SHA-256 digest of the input.

def sha256_hex(data: str | bytes) -> str

Python · Parameters

ParameterTypeRequiredDefaultDescription
datastr | bytesyesText (hashed as UTF-8) or bytes.

Returns str

signAgentMessage

TypeScript @beeos-ai/cloud-harness-sdk · Python beeos_cloud_harness_sdk.identity

Signs a message with a raw Ed25519 private key and returns the 64-byte signature.

function signAgentMessage(message: string | Uint8Array, privateKey: Uint8Array): Uint8Array

TypeScript · Parameters

ParameterTypeRequiredDefaultDescription
messagestring | Uint8ArrayyesMessage to sign; strings are encoded as UTF-8.
privateKeyUint8ArrayyesRaw 32-byte Ed25519 seed (a PKCS#8 DER key is also accepted).

Returns Uint8Array

Python · Parameters

ParameterTypeRequiredDefaultDescription
messagestryesMessage to sign; strings are encoded as UTF-8.
private_keybytesyesRaw 32-byte Ed25519 seed (a PKCS#8 DER key is also accepted).

Returns bytes

signing_path_from_url

Python beeos_cloud_harness_sdk.identity · Python only

Returns the decoded path of a URL, which is the path to sign. Raises ValueError when the URL has a query string.

def signing_path_from_url(url: str) -> str

Python · Parameters

ParameterTypeRequiredDefaultDescription
urlstryesAbsolute URL; it must not contain a query string.

Returns str

AGENT_PROJECTION_HASH_DOMAIN

Python beeos_cloud_harness_sdk.jcs · Python only

Domain string beeos.runtime.agent-projection.v1 for the agent-projection hash.

AGENT_PROJECTION_HASH_DOMAIN = 'beeos.runtime.agent-projection.v1'

EMPTY_BODY_SHA256

TypeScript @beeos-ai/cloud-harness-sdk · Python beeos_cloud_harness_sdk.identity

SHA-256 of the empty body, in hexadecimal.

const EMPTY_BODY_SHA256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

HEARTBEAT_HASH_DOMAIN

Python beeos_cloud_harness_sdk.jcs · Python only

Domain string beeos.runtime.heartbeat.v1 for heartbeat identity proofs.

HEARTBEAT_HASH_DOMAIN = 'beeos.runtime.heartbeat.v1'

REGISTRATION_HASH_DOMAIN

Python beeos_cloud_harness_sdk.jcs · Python only

Domain string beeos.runtime.registration.v1 for registration identity proofs.

REGISTRATION_HASH_DOMAIN = 'beeos.runtime.registration.v1'