11# openshell-sdk
22
33` openshell-sdk ` is the shared async Rust client for OpenShell gateways. It owns
4- the gRPC transport and auth stack so the CLI, the TUI, and language bindings
5- share one implementation of channel setup, TLS, OIDC refresh, and the
6- Cloudflare Access tunnel.
7-
8- Designed in [ RFC 0008] ( ../../rfc/0008-shared-sdk-core-and-ts-binding/README.md ) .
4+ gRPC channel setup, TLS, OIDC refresh, and the Cloudflare Access tunnel so the
5+ CLI, the TUI, and language bindings share one client implementation. Callers
6+ pass an explicit bearer token; the SDK does no filesystem access and no
7+ gateway-name resolution.
98
109## Two layers
1110
@@ -15,54 +14,38 @@ Designed in [RFC 0008](../../rfc/0008-shared-sdk-core-and-ts-binding/README.md).
1514 surface doesn't yet cover (inference, providers, policy, logs, settings, SSH,
1615 forwarding).
1716
18- The curated surface drives OIDC refresh automatically (proactively before a
19- request and reactively on ` Unauthenticated ` ). The plain ` raw_grpc ` /
20- ` raw_inference ` accessors do not: they return a client bound to the current
21- token. When a refresher is wired, use ` raw_grpc_fresh ` /` raw_inference_fresh `
22- for a proactive refresh before the call, and ` force_refresh ` to recover after
23- a raw RPC returns ` Unauthenticated ` .
24-
25- ## Responsibilities
26-
27- - Construct the gRPC channel and select the transport (plaintext vs TLS).
28- - Load TLS material and set up mTLS channels.
29- - Attach edge-auth bearer tokens and refresh OIDC tokens, with single-flight
30- coalescing so only one refresh is in flight at a time.
31- - Proxy connections through the Cloudflare Access tunnel for hosted gateways.
32- - Map transport and gateway failures to a typed ` SdkError ` with a discriminable
33- kind.
17+ ## Auth and refresh
3418
35- ## Non-responsibilities
19+ The curated surface drives OIDC refresh automatically: proactively before a
20+ request and reactively on ` Unauthenticated ` . Refreshes are single-flight, so
21+ only one is in flight at a time.
3622
37- - Gateway-name resolution, default config-path lookups, and the OIDC browser
38- flow. These are user-facing concerns owned by ` openshell-cli ` ; the SDK
39- consumes a ` Refresh ` trait the CLI implements.
40- - Reading tokens from disk. Callers pass an explicit token; the SDK performs no
41- filesystem access.
42- - Defining the gRPC contract. The protos and generated types are owned by
43- ` openshell-core ` .
23+ The plain ` raw_grpc ` /` raw_inference ` accessors do not refresh; they return a
24+ client bound to the current token. When a refresher is wired, use
25+ ` raw_grpc_fresh ` /` raw_inference_fresh ` to refresh before the call, and
26+ ` force_refresh ` to recover after a raw RPC returns ` Unauthenticated ` .
4427
45- ## Transport and auth modes
28+ The SDK consumes a ` Refresh ` trait that the caller implements; it does not run
29+ the OIDC browser flow itself.
4630
47- Covers the connectivity modes the CLI exercises in production, except mTLS:
31+ ## Transport modes
4832
4933- Plaintext (local development)
50- - Server-authenticated TLS over HTTPS (system roots, or a pinned private CA via ` ca_cert ` )
34+ - Server-authenticated TLS (system roots, or a pinned private CA via ` ca_cert ` )
5135- OIDC bearer over HTTPS (gateways behind an OAuth2/OIDC IdP)
5236- Cloudflare Access tunnel (hosted gateways)
5337- Insecure TLS (development/debug; certificate verification disabled)
5438
55- mTLS (client certificates) is intentionally out of scope; gateways that require
56- it continue to use ` openshell-cli ` 's legacy mTLS path until that auth method is
57- retired.
39+ mTLS (client certificates) is not supported.
5840
5941## Public surface
6042
6143` OpenShellClient::connect(ClientConfig) ` returns a connected client exposing
6244` health ` , ` create_sandbox ` , ` get_sandbox ` , ` list_sandboxes ` , ` delete_sandbox ` ,
6345` wait_ready ` , ` wait_deleted ` , and ` exec ` . Curated types (` SandboxSpec ` ,
6446` SandboxRef ` , ` Health ` , ` ListOptions ` , ` ExecOptions ` , ` SandboxPhase ` ) use
65- SDK-shaped enums rather than raw proto integers.
47+ SDK-shaped enums rather than raw proto integers. Failures map to a typed
48+ ` SdkError ` with a discriminable kind.
6649
6750## Modules
6851
@@ -79,14 +62,8 @@ SDK-shaped enums rather than raw proto integers.
7962| ` types ` | Curated request/response types and proto conversions. |
8063| ` raw ` | Escape hatch re-exporting the generated tonic clients. |
8164
82- ## Consumers
83-
84- ` openshell-cli ` , ` openshell-tui ` , and ` openshell-sdk-node ` (published as
85- ` @openshell/sdk ` ).
86-
8765## Notes
8866
8967- Async-only. Tonic is async-native; callers needing a blocking call can wrap
9068 with their own runtime.
91- - The surface is alpha and will grow as more RPCs graduate from ` raw ` into the
92- curated client.
69+ - The curated surface will grow as more RPCs graduate from ` raw ` .
0 commit comments