Skip to main content

API Spec

1. Transport Layer Map​

TransportEndpointAuthImplementation
REST/JSON/api/v1/*JWT (Firebase or Internal)src/api/Routes.ts, CommandAPI.ts, FirmwareRoutes.ts, SessionRoutes.ts
GraphQL/graphqlJWTsrc/api/graphql/Schema.ts + Resolvers.ts (Mercurius)
WebSocket/ws/stateJWT query paramsrc/api/Websocket.ts
MCP (SSE)/mcpRoute-levelsrc/api/mcp/McpServer.ts (19 registered tools)
MQTThxtp/+/+/+HMAC-SHA256 per-messagesrc/mqtt/Router.ts, src/mqtt/Client.ts
gRPC:50051Internal (no TLS, bridged network)hx47-core/src/hx47_core/runtime.py

2. MCP Tool Registry (Complete)​

All 19 tools registered in McpServer.ts:

CategoryTool NamePurpose
Observabilityget_device_stateFetch device connectivity/battery status
get_device_capabilitiesList device capability array
get_device_command_historyPaginated command history
get_command_statusSingle command status lookup
Discoverylist_devicesAll devices for tenant
get_device_detailFull device metadata
list_homesAll homes for tenant
list_roomsRooms in a home
list_groupsDevice groups for tenant
Command Dispatchexecute_hxtp_commandFull command dispatch with SafetyGateway (device/room/group targets)
confirm_hxtp_commandConfirm a dry-run token for CRITICAL actions
Provisioningprovision_deviceRegister new device (MOCKED in current implementation)
decommission_deviceRevoke device via Repo.RevokeDevice()
Managementsetup_homeCreate home entity
create_device_groupCreate logical group
add_devices_to_groupAdd devices to group
Firmwarecheck_firmware_updateQuery for available OTA
get_manifest_capabilitiesGlobal capability definitions
get_device_capability_schemaExact JSON parameter schema from manifest
AI Nativeexecute_planMulti-step plan execution with rollback
get_plan_statusPlan execution progress
get_state_verificationPost-command state verification lookup
write_agent_memoryPersist agent observation/preference/routine
get_agent_memoriesQuery agent long-term memory
whoamiUser identity lookup

3. HxTP/3.1 Protocol Canonical Framing​

The canonical string used for Ed25519 signing consists of exactly 11 pipe-separated fields, in this specific order:

version|device_id|tenant_id|client_id|message_id|request_id|sequence_number|timestamp|nonce|message_type|payload_hash

Critical constraints:

  • Strict Order: The pipe-separated sequence is immutable.
  • Protocol version: Must be HxTP/3.1.
  • Tenant ID: Must be present to prevent cross-tenant replay attacks.
  • Client ID: Contains the short-lived MQTT session token (Layer 1 Auth).
  • Payload Hash: SHA-256 hex digest of the canonical stringified payload.

4. gRPC Protocol Definition (hx47_runtime.proto)​

service CognitiveRuntime {
rpc Orchestrate(stream RuntimeEvent) returns (stream CognitionProposal);
}

TS → Python Events (RuntimeEvent):

VariantPurpose
PerceptionUpdateWorld state hash + active contexts
ObservationOutcomePhysical action result (command_id, success, device_state)
InterruptSignalCancellation or preemption
CapabilitySyncUpdated OpenAI-compatible tool schemas
GraphStateUpdateNode state transition in the DAG

Python → TS Proposals (CognitionProposal):

VariantPurpose
GraphNodeProposalNew node to add to the runtime DAG
SuspendCognitionYield — waiting for physical observations
CompleteCognitionGoal achieved, final state
RuntimeErrorUnrecoverable sidecar error

5. MQTT Topic Structure​

Pattern: hxtp/{tenant_id}/device/{device_id}/{channel}

ChannelDirectionHandlerPurpose
heartbeatDevice → CloudHandleHeartbeatConnectivity monitoring
cmd_ackDevice → CloudHandleCommandAckRPC confirmation
stateDevice → CloudHandleStateEchoDigital twin sync
helloDevice → CloudHandleHelloHandshake (v3.1)
cmdCloud → DeviceN/ASubscribed by device

6. Device Provisioning Protocol (ClaimService.ts)​