# acde RFC 0.1

| | |
| --- | --- |
| Version | 0.1 |
| Status | Draft (0.x): the next minor version may change it incompatibly |
| Contract level (`api-level`) | 1 |
| Source | libacde `acde-api/` (`@dopame/acde-api` 0.0.11, commit `09cf894`), frozen as is |
| Frozen | 2026-11-21 (first published as 1.0, renumbered 0.1 the same day; see [Changes](https://docs.dopame.ai/rfc/overview.md#changes)) |
| Files | `rfc/0.1/` in `ssh://git@gitea.dopamine:2333/AC/acde-RFC.git` |
| Conformance on a real runtime | Not run yet |

## 1. Scope

This version specifies the `acde:*` built-in modules the runtime injects into a page: which modules exist, what each one exports, the members of each export, their types, and which behavior tests may check. Web standard APIs (the DOM, `fetch`, storage, ...) are not covered; they follow the Web standards and may not be changed.

The specification has three parts. When they disagree, the first wins:

1. `api/`: the TypeScript declarations (`.d.ts`), the source of truth.
2. `RFC.md`: the rules the declarations cannot express (export shape, visibility, error codes, versioning), summarized on this page.
3. `surface.json`: generated from `api/` (`bun run extract 0.1`) for the runtime validator; never edited by hand.

## 2. Importing

- A module is imported only through the ES module specifier `acde:<name>`, like `node:fs`. There is no `acde` on the global object.
- Each module has a default export and a named export of the same name, and both are **the same object** (`===`). The exception: the named export of `acde:window` is `window`.
- The exported objects are injected in-process by the runtime; calls go straight into the runtime, not over RPC.
- A member declared optional (`?`) may be missing (`undefined`); when present it must match its declared type.

## 3. Visibility (`modules.json`)

| Class | Modules | Who may import them |
| --- | --- | --- |
| `capability` | fs, terminal, network, system, bluetooth, audio, devices, power, input, display, office | Apps that declare it under `capabilities` in the manifest, while `get(name).state` of `acde:capabilities` is `available` |
| `app` | launch, apps, open, openPath, handlers, window, capabilities | Every app |
| `shell` | windows, packages, session, desktops, inspect, desktop, setDefault, permissions | Only desktops and the services a desktop declares |

Importing a module that is not allowed must fail (`import()` rejects).

## 4. The modules

26 modules; `surface.json` also records 157 exported interfaces. Members marked `?` are optional.

| Module | Class | Export | Members |
| --- | --- | --- | --- |
| `acde:fs` | capability | object | abortWrite, commitWrite, copy, delete, download, list, locate, mkdir, openPath, openWrite, preview, readBytes, readRange, readText, rename, revoke, roots, stat, truncateWrite, writeChunk, writeFile |
| `acde:terminal` | capability | object | close, input, open, resize, subscribe |
| `acde:network` | capability | object | activate, connect, disconnect, networks, setWifiEnabled, state, watch |
| `acde:system` | capability | object | info, setHostname, setNtp, setTimezone, storage, time, timezones, user |
| `acde:bluetooth` | capability | object | answer, connect, disconnect, forget, on, pair, rename, scan, setBlocked, setDiscoverable, setName, setOnLogin, setPowered, setTrusted, state |
| `acde:audio` | capability | object | moveStream, on, setBalance, setDefault, setMuted, setPort, setProfile, setVolume, state |
| `acde:devices` | capability | object | cancelJob, eject, forgetDevice, jobs, mount, on, pausePrinter, resumePrinter, setAutomount, setDefaultPrinter, setDeviceAutomount, state, unmount |
| `acde:power` | capability | object | configure, hibernate, on, setBrightness, setChargeLimit, setProfile, setScreenOff, setSleep, state, suspend |
| `acde:input` | capability | object | catalog, on, set, state |
| `acde:display` | capability | object | configure, on, setBrightness, setNightLight, state |
| `acde:office` | capability | object | editorPage, new, save, server, state, status |
| `acde:launch` | app | object | close, embed, list, on, start |
| `acde:apps` | app | object | list, on?, open |
| `acde:open` | app | function | |
| `acde:openPath` | app | function | |
| `acde:handlers` | app | function | |
| `acde:window` | app | object (named export `window`) | close, host, hostControls, id, minimizable, minimize, mount, on, output, releaseGrab, requestActivate, requestAttention, requestGrab, requestMode, requestState, setBackdrop, setGrabHint, setMenus, setTitle, shortcut, state, unshortcut |
| `acde:capabilities` | app | object | get, level, list, mode, platform, request, window |
| `acde:windows` | shell | object | animate?, close, focus?, hide?, invokeMenu?, kill?, launch, list, on, requestState?, shortcut?, show?, stats?, unshortcut? |
| `acde:packages` | shell | object | install, natives, on, refresh, runNative |
| `acde:session` | shell | object | logout, own, poweroff, reboot, setLanguage |
| `acde:desktops` | shell | object | choose, list |
| `acde:inspect` | shell | object | act, open, query, run, snapshot |
| `acde:desktop` | shell | object | apps, on, pin?, setDoubleClick?, setFrameTheme? |
| `acde:setDefault` | shell | function | |
| `acde:permissions` | shell | object | answer, list, on, pending, revoke |

The signatures are in `rfc/0.1/api/`; for how to use them see [acde: modules](https://docs.dopame.ai/reference/modules.md).

## 5. `acde:capabilities`

- `level` equals this version's `api-level`: 1.
- `platform` is one of `linux`, `win32`, `darwin`; `mode` is one of `session`, `desktop`, `standalone`.
- Each item of `list()` has the same `name` and `state` as `get()` of that name. `state` takes the values of `CapabilityState` in `api/types/capabilities.d.ts`: `available`, `not-asked`, `asking`, `denied`, `not-declared`, `unsupported`, `service-not-running`, `shell-only`.

## 6. `acde:fs` errors

A failing call rejects with an `Error` carrying a numeric `status` and a `code`:

| `code` | `status` | When |
| --- | --- | --- |
| `EINVAL` | 400 | Bad argument, path outside the root, wrong type, symbolic link |
| `EACCES` | 403 | The manifest does not grant this root, or the system refuses |
| `ENOENT` | 404 | Does not exist |
| `EEXIST` | 409 | Already exists (`create: 'new'`) |
| `ECONFLICT` | 409 | `ifModifiedMs` / `ifVersion` does not match |
| `ENOTEMPTY` | 409 | Deleting a folder that is not empty |
| `EFBIG` | 413 | Over the limit |
| `EILSEQ` | 400 | `readText` read something that is not UTF-8 |
| `ENOSPC` | 507 | Disk full |
| `EIO` | 500 | Anything else |

## 7. Conformance

A runtime conforms to 0.1 when the surface check against `surface.json` passes and every applicable test in `tests.json` passes. Tests skipped because a capability is unavailable are not failures, but the report must list them. Return values are checked deeply against the declared return types (`returns` and `types` in `surface.json`).

Tests marked `effects` change visible state (open a window, remember a default app) and run only when asked (`&effects=1`). Unmarked tests only read, or touch temporary files in their own private folder.

| Test | Scope | Requires | Checks |
| --- | --- | --- | --- |
| `surface_app-0.1` | app | | Every available `app` and `capability` module against `surface.json` |
| `surface_shell-0.1` | shell | | Every `shell` module against `surface.json` |
| `capabilities_level-0.1` | app | | `level` equals the contract level; `window.backdrop` is a known value |
| `capabilities_status-0.1` | app | | `list()` and `get()` agree; every state is a known value |
| `window_self-0.1` | app | | Named export `window` is the default; `id`, `state`, `output`; `on()` returns an unsubscribe |
| `fs_roots-0.1` | app | fs | `roots()`: sources, modes, places |
| `fs_text_roundtrip-0.1` | app | fs | Write and read back text in a private root |
| `fs_errors-0.1` | app | fs | Each error's `code` and `status` |
| `terminal_lifecycle-0.1` | app | terminal | `open`, `input`, `resize`, `close`; event types |
| `network_state-0.1` | app | network | `state()`, `networks()` |
| `system_info-0.1` | app | system | `info()`, `storage()`, `time()`, `timezones()`, `user()` |
| `bluetooth_state-0.1` | app | bluetooth | `state()`, events `changed` and `pairing` |
| `audio_state-0.1` | app | audio | At most one default device per direction |
| `devices_state-0.1` | app | devices | At most one default printer; jobs of each printer |
| `power_state-0.1` | app | power | `state()`, events |
| `input_state-0.1` | app | input | `state()`, `catalog()` |
| `display_state-0.1` | app | display | At most one primary display |
| `office_server-0.1` | app | office | `server()` |
| `launch_list-0.1` | app | | `list()`, every launch event |
| `apps_list-0.1` | app | | Unique ids in `list()` |
| `open_link-0.1` | app | | `open({ kind: 'open-link' })` returns an `Opened` (effects) |
| `handlers_file-0.1` | app | fs | Handlers of a text file: unique, at most one default |
| `openPath_file-0.1` | app | fs | Opening a file (effects) |
| `windows_list-0.1` | shell | | Unique ids in `list()`; `stats()` if present; every window event |
| `packages_list-0.1` | shell | | `natives()`, `refresh()`, event `changed` |
| `session_own-0.1` | shell | | `own()` is stable |
| `desktops_list-0.1` | shell | | Unique ids in `list()` |
| `inspect_snapshot-0.1` | shell | | `snapshot()`, `query()` |
| `desktop_apps-0.1` | shell | | `apps()`, desktop events |
| `setDefault_roundtrip-0.1` | shell | fs | Set and read back a default app (effects) |
| `permissions_list-0.1` | shell | | `pending()`, `list()`, events |

## 8. Versioning

0.1 is a draft: 0.2 may change anything here incompatibly, and the tests of 0.1 are not promised to pass on 0.2. The files of 0.1 (`api/`, `modules.json`, `RFC.md`) do not change; corrections go into 0.2. See [Version rules](https://docs.dopame.ai/rfc/overview.md#version-rules).
