Skip to content

Commit 34184c3

Browse files
authored
feat!: migrate API prefix from /api to /v1 and default to api.onecli.sh (#31)
1 parent fff045a commit 34184c3

11 files changed

Lines changed: 25 additions & 25 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import { OneCLI } from "@onecli-sh/sdk";
5959

6060
const onecli = new OneCLI({
6161
apiKey: "oc_...", // optional: falls back to ONECLI_API_KEY env var
62-
url: "http://localhost:3000", // optional: falls back to ONECLI_URL env var, then https://app.onecli.sh
62+
url: "http://localhost:3000", // optional: falls back to ONECLI_URL env var, then https://api.onecli.sh
6363
});
6464

6565
// Get raw container configuration
@@ -77,7 +77,7 @@ const active = await onecli.applyContainerConfig(args);
7777
| Variable | Description |
7878
| ---------------- | -------------------------------------------------------- |
7979
| `ONECLI_API_KEY` | User API key (`oc_...`). Used when `apiKey` is not passed to constructor. |
80-
| `ONECLI_URL` | Base URL of OneCLI instance. Defaults to `https://app.onecli.sh`. |
80+
| `ONECLI_URL` | Base URL of OneCLI instance. Defaults to `https://api.onecli.sh`. |
8181

8282
## API Reference
8383

@@ -92,7 +92,7 @@ new OneCLI(options?: OneCLIOptions)
9292
| Option | Type | Required | Default | Description |
9393
| --------- | -------- | -------- | ----------------------------------- | ------------------------------- |
9494
| `apiKey` | `string` | No | `ONECLI_API_KEY` env var | User API key (`oc_...`) |
95-
| `url` | `string` | No | `ONECLI_URL` or `https://app.onecli.sh` | Base URL of the OneCLI instance |
95+
| `url` | `string` | No | `ONECLI_URL` or `https://api.onecli.sh` | Base URL of the OneCLI instance |
9696
| `timeout` | `number` | No | `5000` | Request timeout in milliseconds |
9797

9898
#### `onecli.getContainerConfig()`
@@ -123,7 +123,7 @@ const active = await onecli.applyContainerConfig(args, {
123123
| `addHostMapping` | `boolean` | `true` | Add `host.docker.internal` mapping on Linux |
124124

125125
**What it does:**
126-
1. Fetches `/api/container-config` with `Authorization: Bearer {apiKey}`
126+
1. Fetches `/v1/container-config` with `Authorization: Bearer {apiKey}`
127127
2. Pushes `-e KEY=VALUE` for each server-controlled environment variable
128128
3. Writes CA certificate to a temp file and mounts it into the container
129129
4. Builds a combined CA bundle (system CAs + OneCLI CA) so curl, Python, Go, etc. also trust OneCLI

src/agents/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class AgentsClient {
4949
input: CreateAgentInput,
5050
options?: RequestOptions,
5151
): Promise<CreateAgentResponse> => {
52-
const url = `${this.baseUrl}/api/agents`;
52+
const url = `${this.baseUrl}/v1/agents`;
5353

5454
try {
5555
const res = await fetch(url, {

src/approvals/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class ApprovalClient {
5555
): Promise<string> {
5656
if (this.gatewayUrl) return this.gatewayUrl;
5757

58-
const url = `${this.baseUrl}/api/gateway-url`;
58+
const url = `${this.baseUrl}/v1/gateway-url`;
5959
const res = await fetch(url, {
6060
headers: this.buildAuthHeaders(projectId),
6161
signal: AbortSignal.timeout(5000),
@@ -147,7 +147,7 @@ export class ApprovalClient {
147147
): Promise<PollResponse> {
148148
this.abortController = new AbortController();
149149

150-
let url = `${gatewayUrl}/api/approvals/pending`;
150+
let url = `${gatewayUrl}/v1/approvals/pending`;
151151
if (this.inFlight.size > 0) {
152152
const exclude = [...this.inFlight].join(",");
153153
url += `?exclude=${encodeURIComponent(exclude)}`;
@@ -177,7 +177,7 @@ export class ApprovalClient {
177177
decision: string,
178178
projectId?: string | null,
179179
): Promise<void> {
180-
const url = `${gatewayUrl}/api/approvals/${encodeURIComponent(id)}/decision`;
180+
const url = `${gatewayUrl}/v1/approvals/${encodeURIComponent(id)}/decision`;
181181

182182
const headers = this.buildAuthHeaders(projectId);
183183
headers["Content-Type"] = "application/json";

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type {
2323
ProvisionProjectResponse,
2424
} from "./provisions/types.js";
2525

26-
const DEFAULT_URL = "https://app.onecli.sh";
26+
const DEFAULT_URL = "https://api.onecli.sh";
2727
const DEFAULT_TIMEOUT = 5000;
2828

2929
export class OneCLI {

src/container/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class ContainerClient {
4141
* Fetch the gateway skill markdown from OneCLI.
4242
*/
4343
getGatewaySkill = async (options?: RequestOptions): Promise<string> => {
44-
const url = `${this.baseUrl}/api/skill/gateway`;
44+
const url = `${this.baseUrl}/v1/skill/gateway`;
4545
try {
4646
const res = await fetch(url, {
4747
headers: this.buildHeaders(options),
@@ -75,8 +75,8 @@ export class ContainerClient {
7575
): Promise<ContainerConfig> => {
7676
const { agent, ...requestOptions } = options ?? {};
7777
const url = agent
78-
? `${this.baseUrl}/api/container-config?agent=${encodeURIComponent(agent)}`
79-
: `${this.baseUrl}/api/container-config`;
78+
? `${this.baseUrl}/v1/container-config?agent=${encodeURIComponent(agent)}`
79+
: `${this.baseUrl}/v1/container-config`;
8080

8181
try {
8282
const res = await fetch(url, {

src/provisions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class ProvisionClient {
4747
input?: ProvisionProjectInput,
4848
options?: RequestOptions,
4949
): Promise<ProvisionProjectResponse> => {
50-
const url = `${this.baseUrl}/api/team/provisions`;
50+
const url = `${this.baseUrl}/v1/team/provisions`;
5151

5252
try {
5353
const res = await fetch(url, {

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface OneCLIOptions {
88

99
/**
1010
* Base URL of the OneCLI instance.
11-
* Falls back to `ONECLI_URL` env var, then `https://app.onecli.sh`.
11+
* Falls back to `ONECLI_URL` env var, then `https://api.onecli.sh`.
1212
*/
1313
url?: string;
1414

@@ -21,7 +21,7 @@ export interface OneCLIOptions {
2121
/**
2222
* Gateway URL for manual approval polling.
2323
* Falls back to `ONECLI_GATEWAY_URL` env var, then auto-resolved
24-
* from the web app via `GET /api/gateway-url`.
24+
* from the web app via `GET /v1/gateway-url`.
2525
*/
2626
gatewayUrl?: string;
2727

test/agents/client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("AgentsClient", () => {
3030
client.createAgent({ name: "Test", identifier: "test" });
3131

3232
expect(fetchSpy).toHaveBeenCalledWith(
33-
"http://localhost:3000/api/agents",
33+
"http://localhost:3000/v1/agents",
3434
expect.any(Object),
3535
);
3636
});
@@ -50,7 +50,7 @@ describe("AgentsClient", () => {
5050
await client.createAgent({ name: "My Agent", identifier: "my-agent" });
5151

5252
expect(fetchSpy).toHaveBeenCalledWith(
53-
"http://localhost:3000/api/agents",
53+
"http://localhost:3000/v1/agents",
5454
expect.objectContaining({
5555
method: "POST",
5656
headers: {
@@ -118,7 +118,7 @@ describe("AgentsClient", () => {
118118
client.createAgent({ name: "Test", identifier: "test" }),
119119
).rejects.toMatchObject({
120120
statusCode: 401,
121-
url: "http://localhost:3000/api/agents",
121+
url: "http://localhost:3000/v1/agents",
122122
});
123123
});
124124

test/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe("OneCLI", () => {
115115
oc.getContainerConfig();
116116

117117
expect(fetchSpy).toHaveBeenCalledWith(
118-
"http://options-url:3000/api/container-config",
118+
"http://options-url:3000/v1/container-config",
119119
expect.any(Object),
120120
);
121121

test/container/client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("ContainerClient", () => {
3737
client.getContainerConfig();
3838

3939
expect(fetchSpy).toHaveBeenCalledWith(
40-
"http://localhost:3000/api/container-config",
40+
"http://localhost:3000/v1/container-config",
4141
expect.any(Object),
4242
);
4343
});
@@ -57,7 +57,7 @@ describe("ContainerClient", () => {
5757
await client.getContainerConfig();
5858

5959
expect(fetchSpy).toHaveBeenCalledWith(
60-
"http://localhost:3000/api/container-config",
60+
"http://localhost:3000/v1/container-config",
6161
expect.objectContaining({
6262
headers: { Authorization: "Bearer oc_mykey" },
6363
}),
@@ -118,7 +118,7 @@ describe("ContainerClient", () => {
118118
);
119119
await expect(client.getContainerConfig()).rejects.toMatchObject({
120120
statusCode: 401,
121-
url: "http://localhost:3000/api/container-config",
121+
url: "http://localhost:3000/v1/container-config",
122122
});
123123
});
124124

0 commit comments

Comments
 (0)