Skip to content

Commit a1a2183

Browse files
committed
fix: rename proxy references to onecli throughout SDK
1 parent bd428f6 commit a1a2183

7 files changed

Lines changed: 87 additions & 87 deletions

File tree

README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
## What is OneCLI?
3030

31-
**OneCLI** (`oc`) is a thin, agent-first CLI that connects AI agents to external services via plugins. The SDK provides a programmatic interface for Node.js applications to interact with OneCLI's proxy, allowing containerized agents to access external APIs without exposing credentials.
31+
**OneCLI** (`oc`) is a thin, agent-first CLI that connects AI agents to external services via plugins. The SDK provides a programmatic interface for Node.js applications to interact with OneCLI, allowing containerized agents to access external APIs without exposing credentials.
3232

3333
## Installation
3434

@@ -54,18 +54,18 @@ yarn add @onecli/sdk
5454

5555
### Standalone function
5656

57-
The simplest way to use the SDK. A single function that configures Docker containers to use the OneCLI proxy:
57+
The simplest way to use the SDK. A single function that configures Docker containers to use OneCLI:
5858

5959
```typescript
60-
import { applyProxyConfig } from "@onecli/sdk";
60+
import { applyOneCLIConfig } from "@onecli/sdk";
6161

6262
const args = ["run", "-i", "--rm", "--name", "my-agent"];
6363

64-
// Fetches proxy config and pushes -e / -v flags onto args
65-
const proxyActive = await applyProxyConfig(args, "http://localhost:18080");
64+
// Fetches container config and pushes -e / -v flags onto args
65+
const active = await applyOneCLIConfig(args, "http://localhost:18080");
6666

67-
// args now contains proxy env vars and volume mounts
68-
console.log(proxyActive); // true if proxy was reachable
67+
// args now contains OneCLI env vars and volume mounts
68+
console.log(active); // true if OneCLI was reachable
6969
```
7070

7171
### Class-based client
@@ -76,33 +76,33 @@ For more control, use the `OneCLI` client class:
7676
import { OneCLI } from "@onecli/sdk";
7777

7878
const oc = new OneCLI({
79-
proxyUrl: "http://localhost:18080",
79+
onecliUrl: "http://localhost:18080",
8080
});
8181

8282
// Get raw container configuration
83-
const config = await oc.proxy().getContainerConfig();
83+
const config = await oc.client().getContainerConfig();
8484
console.log(config.env); // { HTTPS_PROXY: "...", NODE_EXTRA_CA_CERTS: "...", ... }
8585
console.log(config.mounts); // [{ hostPath: "...", containerPath: "...", readonly: true }]
8686

8787
// Or apply directly to Docker run args
8888
const args = ["run", "-i", "--rm", "my-image"];
89-
const active = await oc.proxy().applyContainerConfig(args);
89+
const active = await oc.client().applyContainerConfig(args);
9090
```
9191

9292
### Environment variable
9393

94-
Instead of passing `proxyUrl` explicitly, set the `ONECLI_PROXY_URL` environment variable:
94+
Instead of passing `onecliUrl` explicitly, set the `ONECLI_URL` environment variable:
9595

9696
```bash
97-
export ONECLI_PROXY_URL=http://localhost:18080
97+
export ONECLI_URL=http://localhost:18080
9898
```
9999

100100
```typescript
101101
import { OneCLI } from "@onecli/sdk";
102102

103-
// Automatically reads from ONECLI_PROXY_URL
103+
// Automatically reads from ONECLI_URL
104104
const oc = new OneCLI();
105-
const active = await oc.proxy().applyContainerConfig(args);
105+
const active = await oc.client().applyContainerConfig(args);
106106
```
107107

108108
## API Reference
@@ -115,65 +115,65 @@ Main SDK client.
115115
new OneCLI(options?: OneCLIOptions)
116116
```
117117

118-
| Option | Type | Default | Description |
119-
| ---------- | -------- | -------------------------------- | ------------------------------- |
120-
| `proxyUrl` | `string` | `process.env.ONECLI_PROXY_URL` | Base URL of the OneCLI proxy |
121-
| `timeout` | `number` | `5000` | Request timeout in milliseconds |
118+
| Option | Type | Default | Description |
119+
| ----------- | -------- | -------------------------- | ------------------------------- |
120+
| `onecliUrl` | `string` | `process.env.ONECLI_URL` | Base URL of the OneCLI instance |
121+
| `timeout` | `number` | `5000` | Request timeout in milliseconds |
122122

123-
#### `oc.proxy()`
123+
#### `oc.client()`
124124

125-
Returns the `ProxyClient` for container configuration. Throws `OneCLIError` if no proxy URL is configured.
125+
Returns the `Client` for container configuration. Throws `OneCLIError` if no OneCLI URL is configured.
126126

127127
---
128128

129-
### `ProxyClient`
129+
### `Client`
130130

131-
Manages communication with the OneCLI proxy's `/container-config` endpoint.
131+
Manages communication with the OneCLI `/container-config` endpoint.
132132

133-
#### `proxyClient.getContainerConfig()`
133+
#### `client.getContainerConfig()`
134134

135-
Fetch the raw container configuration from the proxy.
135+
Fetch the raw container configuration from OneCLI.
136136

137137
```typescript
138-
const config = await oc.proxy().getContainerConfig();
138+
const config = await oc.client().getContainerConfig();
139139
// Returns: { env: Record<string, string>, mounts: ContainerMount[] }
140140
```
141141

142-
**Throws** `OneCLIRequestError` if the proxy returns a non-200 response.
142+
**Throws** `OneCLIRequestError` if OneCLI returns a non-200 response.
143143

144-
#### `proxyClient.applyContainerConfig(args, options?)`
144+
#### `client.applyContainerConfig(args, options?)`
145145

146-
Fetch the proxy config and push Docker flags onto the `args` array. Returns `true` if config was applied, `false` if the proxy was unreachable.
146+
Fetch the container config and push Docker flags onto the `args` array. Returns `true` if config was applied, `false` if OneCLI was unreachable.
147147

148148
```typescript
149-
const active = await oc.proxy().applyContainerConfig(args, {
150-
combineCaBundle: true, // Merge system + proxy CAs (default: true)
149+
const active = await oc.client().applyContainerConfig(args, {
150+
combineCaBundle: true, // Merge system + OneCLI CAs (default: true)
151151
addHostMapping: true, // Add --add-host on Linux (default: true)
152152
});
153153
```
154154

155155
| Option | Type | Default | Description |
156156
| ---------------- | --------- | ------- | ----------------------------------------------------- |
157-
| `combineCaBundle`| `boolean` | `true` | Build combined CA bundle for system-wide proxy trust |
157+
| `combineCaBundle`| `boolean` | `true` | Build combined CA bundle for system-wide trust |
158158
| `addHostMapping` | `boolean` | `true` | Add `host.docker.internal` mapping on Linux |
159159

160160
**What it does:**
161-
1. Fetches `/container-config` from the proxy
161+
1. Fetches `/container-config` from OneCLI
162162
2. Pushes `-e KEY=VALUE` for each environment variable
163163
3. Pushes `-v host:container[:ro]` for each mount
164-
4. Builds a combined CA bundle (system CAs + proxy CA) so all tools trust the proxy
164+
4. Builds a combined CA bundle (system CAs + OneCLI CA) so all tools trust OneCLI
165165
5. Adds `--add-host host.docker.internal:host-gateway` on Linux
166166

167167
---
168168

169-
### `applyProxyConfig(args, proxyUrl?)`
169+
### `applyOneCLIConfig(args, onecliUrl?)`
170170

171-
Standalone convenience function. Equivalent to creating a `ProxyClient` and calling `applyContainerConfig`.
171+
Standalone convenience function. Equivalent to creating a `Client` and calling `applyContainerConfig`.
172172

173173
```typescript
174-
import { applyProxyConfig } from "@onecli/sdk";
174+
import { applyOneCLIConfig } from "@onecli/sdk";
175175

176-
const active = await applyProxyConfig(args, "http://localhost:18080");
176+
const active = await applyOneCLIConfig(args, "http://localhost:18080");
177177
// Pass undefined/null to skip (returns false immediately)
178178
```
179179

@@ -189,7 +189,7 @@ General SDK error.
189189
import { OneCLIError } from "@onecli/sdk";
190190

191191
try {
192-
oc.proxy(); // throws if no proxy URL configured
192+
oc.client(); // throws if no OneCLI URL configured
193193
} catch (error) {
194194
if (error instanceof OneCLIError) {
195195
console.error(error.message);
@@ -205,7 +205,7 @@ HTTP request error with context.
205205
import { OneCLIRequestError } from "@onecli/sdk";
206206

207207
try {
208-
await oc.proxy().getContainerConfig();
208+
await oc.client().getContainerConfig();
209209
} catch (error) {
210210
if (error instanceof OneCLIRequestError) {
211211
console.error(error.url); // Request URL
@@ -232,16 +232,16 @@ import type {
232232

233233
## How It Works
234234

235-
The OneCLI proxy runs on the host machine and acts as a MITM proxy for containerized agents. When a container makes HTTPS requests to intercepted domains (e.g. `api.anthropic.com`), the proxy:
235+
OneCLI runs on the host machine and acts as a MITM proxy for containerized agents. When a container makes HTTPS requests to intercepted domains (e.g. `api.anthropic.com`), OneCLI:
236236

237237
1. Terminates TLS using a local CA certificate
238238
2. Inspects the request and injects real credentials (replacing placeholder tokens)
239239
3. Forwards the request to the upstream service
240240
4. Returns the response to the container
241241

242-
This means **containers never see real API keys**. They only have placeholder tokens that the proxy swaps out transparently.
242+
This means **containers never see real API keys**. They only have placeholder tokens that OneCLI swaps out transparently.
243243

244-
The SDK configures containers with the right environment variables (`HTTPS_PROXY`, `NODE_EXTRA_CA_CERTS`) and volume mounts (proxy CA certificate) so this works automatically.
244+
The SDK configures containers with the right environment variables (`HTTPS_PROXY`, `NODE_EXTRA_CA_CERTS`) and volume mounts (OneCLI CA certificate) so this works automatically.
245245

246246
## Development
247247

src/client.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
import { OneCLIError } from "./errors.js";
2-
import { ProxyClient } from "./proxy/index.js";
2+
import { Client } from "./container/index.js";
33
import type { OneCLIOptions } from "./types.js";
44

55
const DEFAULT_TIMEOUT = 5000;
66

77
export class OneCLI {
8-
private proxyUrl: string | undefined;
8+
private onecliUrl: string | undefined;
99
private timeout: number;
1010

11-
private proxyClient: ProxyClient | undefined;
11+
private _client: Client | undefined;
1212

1313
constructor(options?: OneCLIOptions) {
14-
this.proxyUrl = options?.proxyUrl ?? process.env.ONECLI_PROXY_URL;
14+
this.onecliUrl = options?.onecliUrl ?? process.env.ONECLI_URL;
1515
this.timeout = options?.timeout ?? DEFAULT_TIMEOUT;
1616

17-
if (this.proxyUrl) {
18-
this.proxyClient = new ProxyClient(this.proxyUrl, this.timeout);
17+
if (this.onecliUrl) {
18+
this._client = new Client(this.onecliUrl, this.timeout);
1919
}
2020
}
2121

2222
/**
23-
* Access the proxy client for container configuration.
24-
* Throws if no proxy URL was configured.
23+
* Access the OneCLI client for container configuration.
24+
* Throws if no OneCLI URL was configured.
2525
*/
26-
proxy = (): ProxyClient => {
27-
if (!this.proxyClient) {
26+
client = (): Client => {
27+
if (!this._client) {
2828
throw new OneCLIError(
29-
'No proxy URL configured. Pass { proxyUrl: "..." } to OneCLI() or set the ONECLI_PROXY_URL environment variable.',
29+
'No OneCLI URL configured. Pass { onecliUrl: "..." } to OneCLI() or set the ONECLI_URL environment variable.',
3030
);
3131
}
32-
return this.proxyClient;
32+
return this._client;
3333
};
3434
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ const SYSTEM_CA_PATHS = [
99
];
1010

1111
/**
12-
* Build a combined CA bundle (system CAs + proxy CA) on the host.
12+
* Build a combined CA bundle (system CAs + OneCLI CA) on the host.
1313
* Returns the path to the combined file, or `null` on failure.
1414
*/
15-
export function buildCombinedCaBundle(proxyCaHostPath: string): string | null {
16-
let proxyCa: string;
15+
export function buildCombinedCaBundle(onecliCaHostPath: string): string | null {
16+
let onecliCa: string;
1717
try {
18-
proxyCa = readFileSync(proxyCaHostPath, "utf8");
18+
onecliCa = readFileSync(onecliCaHostPath, "utf8");
1919
} catch {
2020
return null;
2121
}
2222

2323
for (const sysPath of SYSTEM_CA_PATHS) {
2424
try {
2525
const sysCa = readFileSync(sysPath, "utf8");
26-
const combined = sysCa.trimEnd() + "\n" + proxyCa.trimEnd() + "\n";
27-
const outPath = join(dirname(proxyCaHostPath), "combined-ca.crt");
26+
const combined = sysCa.trimEnd() + "\n" + onecliCa.trimEnd() + "\n";
27+
const outPath = join(dirname(onecliCaHostPath), "combined-ca.crt");
2828
writeFileSync(outPath, combined);
2929
return outPath;
3030
} catch {
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import type {
66
ContainerMount,
77
} from "./types.js";
88

9-
export class ProxyClient {
10-
private proxyUrl: string;
9+
export class Client {
10+
private onecliUrl: string;
1111
private timeout: number;
1212

13-
constructor(proxyUrl: string, timeout: number) {
14-
this.proxyUrl = proxyUrl.replace(/\/+$/, "");
13+
constructor(onecliUrl: string, timeout: number) {
14+
this.onecliUrl = onecliUrl.replace(/\/+$/, "");
1515
this.timeout = timeout;
1616
}
1717

1818
/**
19-
* Fetch the raw container configuration from the proxy.
20-
* Returns the env vars and mounts the proxy wants injected into the container.
19+
* Fetch the raw container configuration from OneCLI.
20+
* Returns the env vars and mounts to inject into the container.
2121
*/
2222
getContainerConfig = async (): Promise<ContainerConfig> => {
23-
const url = `${this.proxyUrl}/container-config`;
23+
const url = `${this.onecliUrl}/container-config`;
2424

2525
try {
2626
const res = await fetch(url, {
@@ -29,7 +29,7 @@ export class ProxyClient {
2929

3030
if (!res.ok) {
3131
throw new OneCLIRequestError(
32-
`Proxy returned ${res.status} ${res.statusText}`,
32+
`OneCLI returned ${res.status} ${res.statusText}`,
3333
{ url, statusCode: res.status },
3434
);
3535
}
@@ -47,10 +47,10 @@ export class ProxyClient {
4747
};
4848

4949
/**
50-
* Fetch the proxy's container config and push the corresponding
50+
* Fetch the container config from OneCLI and push the corresponding
5151
* `-e` and `-v` flags onto the Docker `run` argument array.
5252
*
53-
* Returns `true` if the proxy was reachable and config was applied.
53+
* Returns `true` if OneCLI was reachable and config was applied.
5454
*
5555
* @param args The Docker `run` argument array to mutate.
5656
* @param options Optional configuration for the apply behavior.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export interface ContainerConfig {
1111

1212
export interface ApplyContainerConfigOptions {
1313
/**
14-
* Build a combined CA bundle (system CAs + proxy CA) for full system trust.
15-
* When enabled, tools like curl, Python, and Go will also trust the proxy.
14+
* Build a combined CA bundle (system CAs + OneCLI CA) for full system trust.
15+
* When enabled, tools like curl, Python, and Go will also trust OneCLI.
1616
* @default true
1717
*/
1818
combineCaBundle?: boolean;

src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
export { OneCLI } from "./client.js";
2-
export { ProxyClient } from "./proxy/index.js";
2+
export { Client } from "./container/index.js";
33
export { OneCLIError, OneCLIRequestError } from "./errors.js";
44

55
export type { OneCLIOptions } from "./types.js";
66
export type {
77
ContainerConfig,
88
ContainerMount,
99
ApplyContainerConfigOptions,
10-
} from "./proxy/types.js";
10+
} from "./container/types.js";
1111

1212
// ---------------------------------------------------------------------------
1313
// Standalone convenience function
1414
// ---------------------------------------------------------------------------
1515

16-
import { ProxyClient } from "./proxy/index.js";
16+
import { Client } from "./container/index.js";
1717

1818
/**
19-
* Standalone helper: fetch the proxy's container config and push the
19+
* Standalone helper: fetch the container config from OneCLI and push the
2020
* corresponding `-e` and `-v` flags onto a Docker `run` argument array.
2121
*
22-
* Returns `true` if the proxy was reachable and config was applied,
22+
* Returns `true` if OneCLI was reachable and config was applied,
2323
* `false` otherwise.
2424
*
25-
* @param args Docker `run` argument array to mutate.
26-
* @param proxyUrl Base URL of the proxy (e.g. "http://localhost:18080").
27-
* Pass `undefined` / `null` to skip (returns `false`).
25+
* @param args Docker `run` argument array to mutate.
26+
* @param onecliUrl Base URL of OneCLI (e.g. "http://localhost:18080").
27+
* Pass `undefined` / `null` to skip (returns `false`).
2828
*/
29-
export async function applyProxyConfig(
29+
export async function applyOneCLIConfig(
3030
args: string[],
31-
proxyUrl?: string | null,
31+
onecliUrl?: string | null,
3232
): Promise<boolean> {
33-
if (!proxyUrl) return false;
34-
const client = new ProxyClient(proxyUrl, 3000);
33+
if (!onecliUrl) return false;
34+
const client = new Client(onecliUrl, 3000);
3535
return client.applyContainerConfig(args);
3636
}

0 commit comments

Comments
 (0)