diff --git a/README.md b/README.md index f2687eb..7cf0084 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ import { OneCLI } from "@onecli-sh/sdk"; const onecli = new OneCLI({ apiKey: "oc_...", // optional: falls back to ONECLI_API_KEY env var - url: "http://localhost:3000", // optional: falls back to ONECLI_URL env var, then https://app.onecli.sh + url: "http://localhost:3000", // optional: falls back to ONECLI_URL env var, then https://api.onecli.sh }); // Get raw container configuration @@ -77,7 +77,7 @@ const active = await onecli.applyContainerConfig(args); | Variable | Description | | ---------------- | -------------------------------------------------------- | | `ONECLI_API_KEY` | User API key (`oc_...`). Used when `apiKey` is not passed to constructor. | -| `ONECLI_URL` | Base URL of OneCLI instance. Defaults to `https://app.onecli.sh`. | +| `ONECLI_URL` | Base URL of OneCLI instance. Defaults to `https://api.onecli.sh`. | ## API Reference @@ -92,7 +92,7 @@ new OneCLI(options?: OneCLIOptions) | Option | Type | Required | Default | Description | | --------- | -------- | -------- | ----------------------------------- | ------------------------------- | | `apiKey` | `string` | No | `ONECLI_API_KEY` env var | User API key (`oc_...`) | -| `url` | `string` | No | `ONECLI_URL` or `https://app.onecli.sh` | Base URL of the OneCLI instance | +| `url` | `string` | No | `ONECLI_URL` or `https://api.onecli.sh` | Base URL of the OneCLI instance | | `timeout` | `number` | No | `5000` | Request timeout in milliseconds | #### `onecli.getContainerConfig()` @@ -123,7 +123,7 @@ const active = await onecli.applyContainerConfig(args, { | `addHostMapping` | `boolean` | `true` | Add `host.docker.internal` mapping on Linux | **What it does:** -1. Fetches `/api/container-config` with `Authorization: Bearer {apiKey}` +1. Fetches `/v1/container-config` with `Authorization: Bearer {apiKey}` 2. Pushes `-e KEY=VALUE` for each server-controlled environment variable 3. Writes CA certificate to a temp file and mounts it into the container 4. Builds a combined CA bundle (system CAs + OneCLI CA) so curl, Python, Go, etc. also trust OneCLI diff --git a/src/agents/index.ts b/src/agents/index.ts index d574f01..6075d62 100644 --- a/src/agents/index.ts +++ b/src/agents/index.ts @@ -49,7 +49,7 @@ export class AgentsClient { input: CreateAgentInput, options?: RequestOptions, ): Promise => { - const url = `${this.baseUrl}/api/agents`; + const url = `${this.baseUrl}/v1/agents`; try { const res = await fetch(url, { diff --git a/src/approvals/index.ts b/src/approvals/index.ts index 3e7a523..4b377cf 100644 --- a/src/approvals/index.ts +++ b/src/approvals/index.ts @@ -55,7 +55,7 @@ export class ApprovalClient { ): Promise { if (this.gatewayUrl) return this.gatewayUrl; - const url = `${this.baseUrl}/api/gateway-url`; + const url = `${this.baseUrl}/v1/gateway-url`; const res = await fetch(url, { headers: this.buildAuthHeaders(projectId), signal: AbortSignal.timeout(5000), @@ -147,7 +147,7 @@ export class ApprovalClient { ): Promise { this.abortController = new AbortController(); - let url = `${gatewayUrl}/api/approvals/pending`; + let url = `${gatewayUrl}/v1/approvals/pending`; if (this.inFlight.size > 0) { const exclude = [...this.inFlight].join(","); url += `?exclude=${encodeURIComponent(exclude)}`; @@ -177,7 +177,7 @@ export class ApprovalClient { decision: string, projectId?: string | null, ): Promise { - const url = `${gatewayUrl}/api/approvals/${encodeURIComponent(id)}/decision`; + const url = `${gatewayUrl}/v1/approvals/${encodeURIComponent(id)}/decision`; const headers = this.buildAuthHeaders(projectId); headers["Content-Type"] = "application/json"; diff --git a/src/client.ts b/src/client.ts index d05d4da..7dea394 100644 --- a/src/client.ts +++ b/src/client.ts @@ -23,7 +23,7 @@ import type { ProvisionProjectResponse, } from "./provisions/types.js"; -const DEFAULT_URL = "https://app.onecli.sh"; +const DEFAULT_URL = "https://api.onecli.sh"; const DEFAULT_TIMEOUT = 5000; export class OneCLI { diff --git a/src/container/index.ts b/src/container/index.ts index 5d5a164..089f6b6 100644 --- a/src/container/index.ts +++ b/src/container/index.ts @@ -41,7 +41,7 @@ export class ContainerClient { * Fetch the gateway skill markdown from OneCLI. */ getGatewaySkill = async (options?: RequestOptions): Promise => { - const url = `${this.baseUrl}/api/skill/gateway`; + const url = `${this.baseUrl}/v1/skill/gateway`; try { const res = await fetch(url, { headers: this.buildHeaders(options), @@ -75,8 +75,8 @@ export class ContainerClient { ): Promise => { const { agent, ...requestOptions } = options ?? {}; const url = agent - ? `${this.baseUrl}/api/container-config?agent=${encodeURIComponent(agent)}` - : `${this.baseUrl}/api/container-config`; + ? `${this.baseUrl}/v1/container-config?agent=${encodeURIComponent(agent)}` + : `${this.baseUrl}/v1/container-config`; try { const res = await fetch(url, { diff --git a/src/provisions/index.ts b/src/provisions/index.ts index e48e964..ede52b0 100644 --- a/src/provisions/index.ts +++ b/src/provisions/index.ts @@ -47,7 +47,7 @@ export class ProvisionClient { input?: ProvisionProjectInput, options?: RequestOptions, ): Promise => { - const url = `${this.baseUrl}/api/team/provisions`; + const url = `${this.baseUrl}/v1/team/provisions`; try { const res = await fetch(url, { diff --git a/src/types.ts b/src/types.ts index 2ca0eab..6f9e2e2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,7 +8,7 @@ export interface OneCLIOptions { /** * Base URL of the OneCLI instance. - * Falls back to `ONECLI_URL` env var, then `https://app.onecli.sh`. + * Falls back to `ONECLI_URL` env var, then `https://api.onecli.sh`. */ url?: string; @@ -21,7 +21,7 @@ export interface OneCLIOptions { /** * Gateway URL for manual approval polling. * Falls back to `ONECLI_GATEWAY_URL` env var, then auto-resolved - * from the web app via `GET /api/gateway-url`. + * from the web app via `GET /v1/gateway-url`. */ gatewayUrl?: string; diff --git a/test/agents/client.test.ts b/test/agents/client.test.ts index 94ec54e..58e3014 100644 --- a/test/agents/client.test.ts +++ b/test/agents/client.test.ts @@ -30,7 +30,7 @@ describe("AgentsClient", () => { client.createAgent({ name: "Test", identifier: "test" }); expect(fetchSpy).toHaveBeenCalledWith( - "http://localhost:3000/api/agents", + "http://localhost:3000/v1/agents", expect.any(Object), ); }); @@ -50,7 +50,7 @@ describe("AgentsClient", () => { await client.createAgent({ name: "My Agent", identifier: "my-agent" }); expect(fetchSpy).toHaveBeenCalledWith( - "http://localhost:3000/api/agents", + "http://localhost:3000/v1/agents", expect.objectContaining({ method: "POST", headers: { @@ -118,7 +118,7 @@ describe("AgentsClient", () => { client.createAgent({ name: "Test", identifier: "test" }), ).rejects.toMatchObject({ statusCode: 401, - url: "http://localhost:3000/api/agents", + url: "http://localhost:3000/v1/agents", }); }); diff --git a/test/client.test.ts b/test/client.test.ts index a4714bd..6292990 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -115,7 +115,7 @@ describe("OneCLI", () => { oc.getContainerConfig(); expect(fetchSpy).toHaveBeenCalledWith( - "http://options-url:3000/api/container-config", + "http://options-url:3000/v1/container-config", expect.any(Object), ); diff --git a/test/container/client.test.ts b/test/container/client.test.ts index bfe8db9..884d15e 100644 --- a/test/container/client.test.ts +++ b/test/container/client.test.ts @@ -37,7 +37,7 @@ describe("ContainerClient", () => { client.getContainerConfig(); expect(fetchSpy).toHaveBeenCalledWith( - "http://localhost:3000/api/container-config", + "http://localhost:3000/v1/container-config", expect.any(Object), ); }); @@ -57,7 +57,7 @@ describe("ContainerClient", () => { await client.getContainerConfig(); expect(fetchSpy).toHaveBeenCalledWith( - "http://localhost:3000/api/container-config", + "http://localhost:3000/v1/container-config", expect.objectContaining({ headers: { Authorization: "Bearer oc_mykey" }, }), @@ -118,7 +118,7 @@ describe("ContainerClient", () => { ); await expect(client.getContainerConfig()).rejects.toMatchObject({ statusCode: 401, - url: "http://localhost:3000/api/container-config", + url: "http://localhost:3000/v1/container-config", }); }); diff --git a/test/errors.test.ts b/test/errors.test.ts index b5e6b99..56e936b 100644 --- a/test/errors.test.ts +++ b/test/errors.test.ts @@ -13,14 +13,14 @@ describe("OneCLIError", () => { describe("OneCLIRequestError", () => { it("sets name, url, statusCode, and formatted message", () => { const err = new OneCLIRequestError("Not Found", { - url: "http://localhost:3000/api/container-config", + url: "http://localhost:3000/v1/container-config", statusCode: 404, }); expect(err.name).toBe("OneCLIRequestError"); - expect(err.url).toBe("http://localhost:3000/api/container-config"); + expect(err.url).toBe("http://localhost:3000/v1/container-config"); expect(err.statusCode).toBe(404); expect(err.message).toBe( - "[URL=http://localhost:3000/api/container-config] [StatusCode=404] Not Found", + "[URL=http://localhost:3000/v1/container-config] [StatusCode=404] Not Found", ); expect(err).toBeInstanceOf(Error); });