> _**SDK skill · `code` namespace** · ~6,748 tokens · hoody-sdk v1.0.0-beta.17_ # `code` — VS Code in the browser, per container ## Purpose **This is the VS Code IDE running in a browser tab — not a programmatic API.** Open `https://{P}-{C}-code-1.{N}.containers.hoody.com/` and you get the full editor: file tree, diff view, debugger, terminals, extensions marketplace, all backed by the container's filesystem. The `code-N` URL is served by an **orchestrator** that starts one isolated editor instance per index and returns a page that embeds it. The index is the hostname: `code-1` is instance 1, `code-2` is instance 2, each with its own settings, state and running process. On a `code-N` host the platform's edge fills in the two parameters the entry page needs. It sets the instance selector `id` from the hostname, overwriting anything the caller sent, and it sets `folder` to the container's default workspace when the request names none. Add `?folder=` to open a different folder. Talking to a bare kit server with no edge in front of it, a client must send both `folder` and `id` itself: with neither the entry path returns the kit specification, with only one it returns `400`. The methods in this namespace read the service's state (health, running instances, versions), stop editor instances, stage extensions and confirm what an instance has installed, and build embed URLs. Day-to-day use is "open the URL". Like every Hoody kit URL, `code` is **iframable**: drop the `code-N` URL into an ` ``` To keep the `containerId` out of the iframe `src`, create a proxy alias on the `code` service with the landing query as its `target_path`, and use the URL the call returns. Leave `id` out of the target: the alias's `index` picks the instance, and a target query naming `id` is refused with `404 ALIAS_TARGET_QUERY_FORCED_KEY`. The `folder` (and `extension`) in the target is a landing preference only: the editor opens there, but it does not confine the session, and anyone using the editor can open any other folder the container user can read. ```typescript const alias = await client.api.proxy.aliases.create({ container_id: C, program: 'code', index: 1, alias: 'agent', target_path: '/?extension=saoudrizwan.claude-dev&folder=/home/user/myrepo', }); ``` Gate the alias with `proxy.containerPermissions.*` before sharing it (see the `api` namespace). The same iframe pattern works for **every** Hoody kit (`files`, `terminal`, `display`, `desktop`, `browser`, `notes`, `agent`, …). ## Reference **Accessor:** `client.code` | **Import:** `import * as code from 'hoody-sdk/code'` Every `…Response` type here, and `ApiResponse`, is the envelope `{ statusCode: number; message: string; data: T }`: read the payload from `.data`. Signatures list only the operation's own parameters. Kit methods also take `_templateVars` — `{ projectId?, containerId?, serviceIndex?, server? }`, which retargets the call — as a positional argument these signatures omit, and the per-call transport options `signal`, `timeoutMs`, `retries`, `retryDelayMs`, `retryOnStatuses`, `rawResponse`, `responseType`, `authRetry`, `middlewareContext`, `headers` (extra request headers for this call; `Authorization`, `X-Hoody-Client-ID` and `X-Hoody-Client-Name` are refused) and `cache` (a GET's response cache: `true`, a TTL in ms, or `false` to bypass) (no `_realm`: that one is control-plane only). When the signature shows an options object, the transport options go inside it and `_templateVars` is the argument right after it. When it does not, `_templateVars` is the next argument and the transport options an object after that — so pass `undefined` for the target you are not overriding: `method(…, undefined, { timeoutMs: 5000 })`. A signature that shows `_templateVars` itself is complete as written: the object after it takes the transport options too. ### `client.code` (1) — VS Code web interface #### `stop` — Stop an editor instance ```typescript client.code.stop(options?: { id?: number }) ``` | Parameter | Type | In | Required | Description | |-----------|------|------|----------|-------------| | `id` | `number` | query | No | Which instance to stop. On a `code-{N}` service URL the edge proxy sets it from the hostname and overrides any value sent, so a caller there neither needs to send it nor can change it. It is required: there is no default instance to stop, so a request without it is answered `400`. Read exactly as strictly as the selector on `GET /api/v1/code`: an unsigned decimal integer, under the literal name `id` only, never given more than once, and at most `65535 - basePort`. | **Returns:** `Promise` | **HTTP:** `DELETE /api/v1/code` **CLI:** `hoody code stop` --- ### `client.code.extensions` (2) — Extension staging and inspection #### `install` — Stage a VS Code extension from a URL ```typescript client.code.extensions.install(data: CodeExtensionsInstallRequest, options?: { id?: number }) ``` | Parameter | Type | In | Required | Description | |-----------|------|------|----------|-------------| | `id` | `number` | query | No | Which instance this request is about. Required here, unlike on `GET /api/v1/code`. That operation has a discovery branch to fall back to when no selector is given; this one does not, so a request without an `id` has named no instance and is rejected rather than defaulted to a first one. The value is read exactly as strictly as the selector on `GET /api/v1/code`: an unsigned decimal integer, under the literal name `id` only, never given more than once, and at most `65535 - basePort`. See that operation for the full rules. Where it comes from: On a `code-N` service URL the platform's edge proxy sets it from the hostname, so a caller behind the edge neither sends it nor can override it, and the generated clients leave it out of the query for exactly that reason. It is required because there is no discovery branch here to fall back to: a request without an `id` has named no instance and is answered `400`. | | `data` | `CodeExtensionsInstallRequest` | body | Yes | | **Body:** `{ url*: string, allowDowngrade: bool=false }` - `allowDowngrade` — Permit replacing a staged version with an older one. Refused by default so a routine restage cannot silently roll an extension back. **Returns:** `Promise` | **HTTP:** `POST /api/v1/code/extensions/install` **CLI:** `hoody code extensions install` --- #### `list` — Staged extensions, and what the instance appears to have installed ```typescript client.code.extensions.list(options?: { id?: number }) ``` | Parameter | Type | In | Required | Description | |-----------|------|------|----------|-------------| | `id` | `number` | query | No | Which instance this request is about. Required here, unlike on `GET /api/v1/code`. That operation has a discovery branch to fall back to when no selector is given; this one does not, so a request without an `id` has named no instance and is rejected rather than defaulted to a first one. The value is read exactly as strictly as the selector on `GET /api/v1/code`: an unsigned decimal integer, under the literal name `id` only, never given more than once, and at most `65535 - basePort`. See that operation for the full rules. Where it comes from: On a `code-N` service URL the platform's edge proxy sets it from the hostname, so a caller behind the edge neither sends it nor can override it, and the generated clients leave it out of the query for exactly that reason. It is required because there is no discovery branch here to fall back to: a request without an `id` has named no instance and is answered `400`. | **Returns:** `Promise` | **HTTP:** `GET /api/v1/code/extensions/list` **CLI:** `hoody code extensions list` --- ### `client.code.kit` (3) — Health, version and status monitoring #### `getHealth` — Service health check ```typescript client.code.kit.getHealth() ``` **Returns:** `Promise` | **HTTP:** `GET /api/v1/code/health` **CLI:** `hoody code health` --- #### `getStatus` — Get orchestrator and instance status ```typescript client.code.kit.getStatus() ``` **Returns:** `Promise` | **HTTP:** `GET /status` **CLI:** `hoody code status` --- #### `getVersion` — Versions of the running orchestrator and its packaged editor ```typescript client.code.kit.getVersion() ``` **Returns:** `Promise` | **HTTP:** `GET /api/v1/code/version` **CLI:** `hoody code version` --- ### `client.code.ui` (4) — Static assets and descriptors served by this host #### `getFavicon` — Site icon ```typescript client.code.ui.getFavicon() ``` **Returns:** `Promise>` | **HTTP:** `GET /favicon.ico` --- #### `getManifest` — Web application manifest for installing the editor ```typescript client.code.ui.getManifest() ``` **Returns:** `Promise>` | **HTTP:** `GET /api/v1/code/manifest.json` --- #### `getRobots` — Crawler policy ```typescript client.code.ui.getRobots() ``` **Returns:** `Promise>` | **HTTP:** `GET /robots.txt` --- #### `getSecurityPolicy` — Security contact information ```typescript client.code.ui.getSecurityPolicy() ``` **Returns:** `Promise>` | **HTTP:** `GET /security.txt`