@onecli-sh/sdk
View on npm
Requirements
| SDK version | Node.js version |
|---|---|
| >= 0.1.0 | >= 20 |
Installation
Quick start
Environment variables
Instead of passing options explicitly, set environment variables:API reference
OneCLI
Main SDK client.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey | string | process.env.ONECLI_API_KEY | API key (must start with oc_) |
url | string | process.env.ONECLI_URL | Base URL of the OneCLI instance |
timeout | number | 5000 | Request timeout in milliseconds |
onecli.getContainerConfig()
Fetch the raw container configuration from OneCLI.
OneCLIRequestError if OneCLI returns a non-200 response.
onecli.applyContainerConfig(args, options?)
Fetch the container config and push Docker flags onto the args array. Returns true if config was applied, false if OneCLI was unreachable.
| Parameter | Type | Default | Description |
|---|---|---|---|
combineCaBundle | boolean | true | Build combined CA bundle for system-wide trust |
addHostMapping | boolean | true | Add host.docker.internal mapping on Linux |
- Fetches
/api/container-configfrom OneCLI with Bearer auth - Pushes
-e KEY=VALUEfor each environment variable - Writes the CA certificate to a temp file and mounts it with
-v - Builds a combined CA bundle (system CAs + OneCLI CA) so all tools trust OneCLI
- Adds
--add-host host.docker.internal:host-gatewayon Linux
false without mutating the args array.
Error classes
OneCLIError
General SDK error (e.g., missing API key).
OneCLIRequestError
HTTP request error with additional context.
Types
All types are exported for use in your own code:How it works
OneCLI runs on the host machine and acts as a gateway for containerized agents. When a container makes HTTPS requests to intercepted domains (e.g.api.anthropic.com), OneCLI:
- Terminates TLS using a local CA certificate
- Inspects the request and injects real credentials (replacing placeholder tokens)
- Forwards the request to the upstream service
- Returns the response to the container
HTTPS_PROXY, HTTP_PROXY) and CA certificate mounts so this works automatically.