Skip to content

Commit 4cda0d4

Browse files
committed
feat(sdk-ts): add raw escape hatch for uncurated gateway RPCs
The curated sub-clients reduce proto messages to ergonomic subsets (for example get() drops created_at_ms, the full spec, conditions, runtime endpoints, and current_policy_version), and not every gateway RPC has a typed helper yet. Rather than ship methods that exist but throw, expose a generated client for the full surface. OpenShellClient.raw and SandboxClient.raw are generated clients covering every gateway RPC, returning the verbatim wire messages so proto distinctions the curated types smooth over are preserved. .transport exposes the shared connection for building extra clients over one socket. Generated request/response types are published at the new @nvidia/openshell-sdk/raw subpath. Curated methods stay the default; raw is the always-available floor. Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
1 parent 35b6afd commit 4cda0d4

5 files changed

Lines changed: 91 additions & 0 deletions

File tree

‎sdk/typescript/README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,35 @@ await client.sandbox.setSetting(name, 'feature.enabled', { value: { case: 'boolV
116116

117117
Sandbox-scoped `setPolicy` may only change `networkPolicies`; static fields (`filesystem`, `landlock`, `process`) must match the create-time policy. Sandbox-scoped setting deletes are rejected by the gateway, so only upsert (`setSetting`) is exposed here.
118118

119+
## Surface and roadmap
120+
121+
The SDK's goal is agent parity: anything the OpenShell gateway can do should be reachable from typed code, not only the CLI. The API is organized as scoped sub-clients over one shared connection, mirroring the CLI's verbs.
122+
123+
- `client.sandbox` (`SandboxClient`) is available today: sandbox lifecycle, exec, forward, SSH, sandbox-scoped providers, config, and policy.
124+
- `client.gateway` (`GatewayClient`) is planned: gateway-scoped config and settings, health, and cluster status.
125+
- `client.providers` (`ProviderClient`) is planned: gateway-scoped provider CRUD and profiles.
126+
127+
`health()` lives at the root today and will move under `client.gateway` (with a root alias) when that lands.
128+
129+
Curated methods are added deliberately, so some gateway RPCs are not yet wrapped in a typed helper. Rather than ship methods that exist but throw, the SDK omits what it has not curated and gives you the raw escape hatch below to reach the full gateway surface today. Omission means "not yet ergonomic," never "impossible."
130+
131+
### Advanced: raw escape hatch
132+
133+
`client.raw` is a generated client for every gateway RPC, including surface the curated sub-clients do not wrap yet (gateway config, provider CRUD, policy status, watch, logs, and the full observed `Sandbox`). `client.transport` is the shared connection, so extra clients reuse one socket. Generated request and response types live at `@nvidia/openshell-sdk/raw`.
134+
135+
```ts
136+
import { OpenShellClient } from '@nvidia/openshell-sdk'
137+
import type { GetGatewayConfigResponse } from '@nvidia/openshell-sdk/raw'
138+
139+
const client = await OpenShellClient.connect({ gateway, oidcToken })
140+
141+
// Reach RPCs the curated surface does not wrap yet:
142+
const cfg: GetGatewayConfigResponse = await client.raw.getGatewayConfig({})
143+
const status = await client.raw.getSandboxPolicyStatus({ name: 'my-sandbox', version: 0, global: false })
144+
```
145+
146+
The raw layer returns the generated wire messages verbatim, preserving proto distinctions (an omitted optional versus an explicitly empty map) that the curated types may smooth over. As curated sub-clients land, prefer them; `raw` stays as the always-available floor.
147+
119148
## Boundaries
120149

121150
The SDK ships primitives, not the CLI's terminal experience. Some things are intentionally out of scope:

‎sdk/typescript/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
".": {
2020
"types": "./dist/index.d.ts",
2121
"import": "./dist/index.js"
22+
},
23+
"./raw": {
24+
"types": "./dist/raw.d.ts",
25+
"import": "./dist/raw.js"
2226
}
2327
},
2428
"files": [

‎sdk/typescript/src/client.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,25 @@ describe('enum name maps', () => {
760760
});
761761
}
762762
});
763+
764+
describe('raw escape hatch', () => {
765+
it('reaches uncurated RPCs and returns generated wire messages', async () => {
766+
const sandbox = client({
767+
getSandbox: () => readySandbox('sb', 'sb-id-1'),
768+
getGatewayConfig: () => ({ settings: {}, settingsRevision: 42n }),
769+
});
770+
771+
// An RPC with no curated wrapper is still reachable through raw.
772+
const cfg = await sandbox.raw.getGatewayConfig({});
773+
expect(cfg.settingsRevision).toBe(42n);
774+
775+
// raw returns the full generated message: the enum stays numeric, where the
776+
// curated get() would lowercase status.phase to 'ready'.
777+
const resp = await sandbox.raw.getSandbox({ name: 'sb' });
778+
expect(resp.sandbox?.status?.phase).toBe(SandboxPhase.READY);
779+
expect(resp.sandbox?.metadata?.name).toBe('sb');
780+
781+
// The shared transport is exposed for building extra clients.
782+
expect(sandbox.transport).toBeDefined();
783+
});
784+
});

‎sdk/typescript/src/client.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,22 @@ class Pushable<T> implements AsyncIterable<T> {
490490
export class SandboxClient {
491491
private readonly grpc: Client<typeof OpenShell>;
492492

493+
/**
494+
* Advanced escape hatch: a generated client for every gateway RPC, including
495+
* surface the curated methods do not wrap yet. Request/response types are the
496+
* generated wire messages (import them from '@nvidia/openshell-sdk/raw').
497+
*/
498+
readonly raw: Client<typeof OpenShell>;
499+
/** The shared Connect transport, for building extra clients over the same connection. */
500+
readonly transport: Transport;
501+
493502
// Takes a transport rather than options so OpenShellClient can compose
494503
// several scoped clients over a single connection. For standalone use,
495504
// prefer the SandboxClient.connect() factory below.
496505
constructor(transport: Transport) {
506+
this.transport = transport;
497507
this.grpc = createClient(OpenShell, transport);
508+
this.raw = this.grpc;
498509
}
499510

500511
static async connect(options: ConnectOptions): Promise<SandboxClient> {
@@ -1072,11 +1083,23 @@ export class OpenShellClient {
10721083
/** Sandbox lifecycle + exec: create/get/list/delete, waitReady/waitDeleted, exec. */
10731084
readonly sandbox: SandboxClient;
10741085

1086+
/**
1087+
* Advanced escape hatch: a generated client for every gateway RPC, including
1088+
* surface the curated sub-clients do not wrap yet (gateway config, provider
1089+
* CRUD, policy status, watch, logs, and the full observed Sandbox). See
1090+
* '@nvidia/openshell-sdk/raw' for the generated request/response types.
1091+
*/
1092+
readonly raw: Client<typeof OpenShell>;
1093+
/** The shared Connect transport, for building extra clients over the same connection. */
1094+
readonly transport: Transport;
1095+
10751096
private readonly grpc: Client<typeof OpenShell>;
10761097

10771098
private constructor(transport: Transport) {
10781099
// One transport (one connection) shared across every scoped client.
1100+
this.transport = transport;
10791101
this.grpc = createClient(OpenShell, transport);
1102+
this.raw = this.grpc;
10801103
this.sandbox = new SandboxClient(transport);
10811104
}
10821105

‎sdk/typescript/src/raw.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export * from './gen/datamodel_pb.js';
5+
// Advanced surface: the full generated protobuf types (messages, enums, and the
6+
// OpenShell service descriptor) for callers using the raw escape hatch on
7+
// OpenShellClient / SandboxClient (`.raw` and `.transport`). These are the
8+
// uncurated wire types; import them from '@nvidia/openshell-sdk/raw'. The
9+
// curated entry point stays free of generated types so its surface does not
10+
// shift when the proto regenerates. The three generated modules export disjoint
11+
// symbol names, so a flat re-export is unambiguous.
12+
export * from './gen/openshell_pb.js';
13+
export * from './gen/sandbox_pb.js';

0 commit comments

Comments
 (0)