Overview
Ravi exposes a typed SDK gateway under/api/v1/*. The gateway is generated from
the decorated CLI registry, so SDK clients mirror Ravi commands without
hand-maintained API wrappers.
The current SDK surfaces are:
- TypeScript package:
packages/ravi-os-sdk - Swift package:
packages/ravi-os-swift-sdk - OpenAPI snapshot:
docs/openapi.json
src/cli/registry-snapshot.ts. OpenAPI, TypeScript, and
Swift are deterministic projections of that registry.
Start the Gateway
The SDK gateway is mounted on Ravi’s webhook HTTP server. The daemon starts that server only when an HTTP port is configured:RAVI_HTTP_HOST is not loopback, Ravi refuses to start unless
RAVI_GATEWAY_NETWORK_AUTHORIZED=1 is set. This keeps the SDK gateway private
by default even when bearer auth is configured.
Set RAVI_SDK_GATEWAY_DISABLE=1 to disable SDK routes while leaving the HTTP
server available for webhook handlers.
Context Keys
Non-open SDK routes require a runtime context key (rctx_*) in the bearer auth
header. Bootstrap the first admin key on the daemon host:
--allow format is:
view:system:eventsfor the events streamview:system:tasksfor the tasks streamview:system:auditfor the audit streamaccess:session:ravi-webfor one session stream
TypeScript Client
Install:daemon init-admin-key becomes client.daemon.initAdminKey().
Wire Contract
Every command call is a POST:{ "args": ..., "options": ... } wrappers.
The HTTP transport sends:
Authorization: Bearer <rctx_key>x-ravi-sdk-versionx-ravi-registry-hash
Streaming
Use@ravi-os/sdk/streaming for server-sent event streams:
Streams always require a valid context key, even when ordinary open commands do
not.
Binary Responses
Commands marked with@Returns.binary() return a raw Response on successful
2xx calls. Error responses still map to typed SDK errors.
Error Handling
All transports throw the same error hierarchy:RaviAuthErrorfor 401 responsesRaviPermissionErrorfor 403 responsesRaviValidationErrorfor 4xx validation failures, withissues[]RaviInternalErrorfor 5xx responsesRaviTransportErrorfor network, timeout, or transport failures
Codegen
Regenerate the TypeScript client from the live registry:packages/ravi-os-sdk/src:
client.tsschemas.tstypes.tsversion.ts
Published Exports
The published TypeScript package exports:packages/ravi-os-sdk/src/transport/in-process.ts, but it is monorepo-internal
and is not exported by the published package.