# Extension SDK

An Extension is code that runs in its own background process. Cowork loads its entry file and calls `activate(api)` once. Everything the Extension can do goes through that `api` object, and through the `ctx` objects Cowork hands to what it registers. This chapter lists every module and function.

> **Release status**
> Functions marked <Badge type="warning" text="Not yet released" /> are in Cowork's source but not in a released version yet.

## Modules

| Module | Functions | Needs |
|---|---|---|
| [Entry and Registration](https://docs.micromeet.ai/extension-sdk/entry.md) | `activate(api)` · `api.registerConnector` · `api.registerService` · `api.log` | — |
| [Connector](https://docs.micromeet.ai/extension-sdk/connector.md) | `start(ctx)` · `stop()` · `send(reply)` · `ctx.emit` · `ctx.log` | — (in 0.1.41: listed in `connectors`) |
| [Background Tasks](https://docs.micromeet.ai/extension-sdk/service.md) | `run(ctx)` · `ctx.status` · `ctx.log` · `ctx.readJson` · `ctx.writeJson` · `ctx.env` · `ctx.dataDir` · `ctx.signal` | capability `service` |
| [Site Requests](https://docs.micromeet.ai/extension-sdk/site.md) | `ctx.site.request` · `ctx.site.session` | `service` + `sites` |
| [Service Conversations](https://docs.micromeet.ai/extension-sdk/agent.md) | `ctx.agent.handoff` | `service` + `agent` |
| [Browser](https://docs.micromeet.ai/extension-sdk/browser.md) | `ctx.browser.adoptTab` · `releaseTab` · `evaluate` · `inject` · `uninject` · `captureAudio` · `stopAudio` · `onEvent` | capability `browser` (`audio` for sound) |

## package.json

This example uses `service` and `sites`, which are not released yet; on 0.1.41 it is refused.

```json
{
  "name": "janeapp-operator",
  "version": "0.1.0",
  "pi": { "extensions": ["./index.mjs"] },
  "dozin": {
    "capabilities": ["service"],
    "sites": [{ "host": "welladjustedhk.janeapp.com", "methods": ["GET"], "pathPrefixes": ["/admin/api/v2/"], "minIntervalMs": 1000 }]
  }
}
```

| Field | Description |
|---|---|
| `name` | Lowercase letters, digits and hyphens; equals the folder name |
| `version` | The version shown in **Settings › Extensions**. Required in 0.1.41; from the next version it defaults to `0.0.0` |
| `pi.extensions` | Exactly one entry file. Required in 0.1.41. <Badge type="warning" text="Not yet released" />: may be left out, then `main` is used, else the first of `index.mjs`, `index.js`, `index.ts` |
| `dozin.connectors` | IDs of the Connectors it registers. When listed, only these ids can register. In 0.1.41 a Connector can register only if its id is listed here |
| `dozin.capabilities` | `browser`, `audio` (needs `browser`), `platform-gate-v1`, and `service` <Badge type="warning" text="Not yet released" /> |
| `dozin.origins` | With `browser`: 1 to 20 exact websites (`https://example.com`) it may use. Required with `browser` in 0.1.41; from the next version it may be left out, and then any http(s) site is allowed, still only in tabs the person hands over |
| `dozin.platforms` | `darwin-arm64`, `darwin-x64`, `win32-x64`; needs exactly one `platform-gate-v1` in `capabilities` |
| `dozin.secrets` <Badge type="warning" text="Not yet released" /> | With `service`: up to 8 values the person fills in, `{ env, label }`; `env` matches `^[A-Z][A-Z0-9_]{0,63}$` |
| `dozin.sites` <Badge type="warning" text="Not yet released" /> | With `service`: up to 8 sites for `ctx.site`, `{ host, methods, pathPrefixes, minIntervalMs }` |
| `dozin.agent` <Badge type="warning" text="Not yet released" /> | With `service`: `{ brief, model?, tools?, secret? }` for service conversations |

The type name is `DozinAPI` in both Cowork and Dozin, so one Extension installs unchanged in either.

## Rules that apply to every module

- Nothing runs until a person approves the exact files in **Settings › Extensions**. Changing one file means approving again.
- A package has at most 200 files and 5 MB; `dependencies` are not installed.
- An Extension cannot read cookies, tokens or other extensions' data.

## Related

- [Extension](https://docs.micromeet.ai/extend/extensions.md): What an Extension is and how it goes live
- [Mini App SDK](https://docs.micromeet.ai/miniapp-sdk/overview.md): What the Mini App of the same package can call
- [Extensions settings](https://docs.micromeet.ai/connections/extensions.md): Install, approve and switch on
