@ravi-os/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @ravi-os/sdk
2
+
3
+ Type-safe TypeScript client for the Ravi gateway. The `RaviClient` surface is
4
+ generated 1:1 from `getRegistry()`, so every CLI command becomes a typed method
5
+ on the client.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add @ravi-os/sdk
11
+ # or
12
+ npm install @ravi-os/sdk
13
+ ```
14
+
15
+ ## HTTP transport (browser- or node-compatible)
16
+
17
+ ```ts
18
+ import { RaviClient } from "@ravi-os/sdk/client";
19
+ import { createHttpTransport } from "@ravi-os/sdk/transport/http";
20
+
21
+ const client = new RaviClient(
22
+ createHttpTransport({
23
+ baseUrl: "http://127.0.0.1:7777",
24
+ contextKey: process.env.RAVI_CONTEXT_KEY!,
25
+ }),
26
+ );
27
+
28
+ const result = await client.artifacts.show("art_xyz");
29
+ ```
30
+
31
+ `createHttpTransport` only depends on the global `fetch`, so it runs in any
32
+ modern browser, Node 18+, Bun, Deno, or edge runtime.
33
+
34
+ ## In-process transport (server-side only)
35
+
36
+ ```ts
37
+ import { RaviClient } from "@ravi-os/sdk/client";
38
+ import { createInProcessTransport } from "@ravi-os/sdk/transport/in-process";
39
+ import { getRegistry } from "ravi.bot/cli/registry-snapshot";
40
+
41
+ const client = new RaviClient(
42
+ createInProcessTransport({
43
+ registry: getRegistry(),
44
+ scopeContext: { agentId: "agent-orquestrador" },
45
+ }),
46
+ );
47
+ ```
48
+
49
+ The in-process transport reuses the same dispatcher pipeline that the HTTP
50
+ gateway runs (validation, scope checks, audit), without HTTP overhead. It only
51
+ runs in Node — the package exports map this entry as `null` for non-node
52
+ conditions.
53
+
54
+ ## Generated artifacts
55
+
56
+ `client.ts`, `schemas.ts`, `types.ts`, and `version.ts` are produced by
57
+ `ravi sdk client generate` and committed as the canonical surface. Drift is
58
+ caught by `ravi sdk client check` (used in CI).
59
+
60
+ ## Errors
61
+
62
+ Every transport throws strongly-typed errors:
63
+
64
+ - `RaviAuthError` — 401, missing/invalid context key
65
+ - `RaviPermissionError` — 403, scope denied
66
+ - `RaviValidationError` — 4xx body validation, exposes `issues[]`
67
+ - `RaviInternalError` — 5xx from the gateway
68
+ - `RaviTransportError` — network / timeout / unexpected shape
69
+
70
+ All inherit from `RaviError`, so `catch (e: unknown) { if (e instanceof RaviError) ... }` works.