# Extension

An Extension is a code package that runs in its own background process. In 0.1.41 it registers **Connectors**: the parts that send and receive messages between an outside channel and Cowork's Gateway. With the browser permission it can also read and act on the pages of the websites it names.

## How it goes live

1. Put the package in `<Cowork home>/extensions/packages/<name>/`, or use **Install from folder** in **Settings › Extensions**, which copies a folder there.
2. **Settings › Extensions** shows it as waiting for approval. Nothing in it runs yet.
3. You approve it and switch it on. Cowork starts its process and calls its `activate` function.
4. If any file in the folder changes, it waits for approval again.

## The package

| File or folder | What it holds |
|---|---|
| `package.json` | `name`, which must equal the folder name (lowercase letters, digits and hyphens); `version`; `description`; `pi.extensions`, which lists exactly one entry file; and the Cowork section, which declares `connectors`, `capabilities`, `origins` and `platforms` |
| The entry file, for example `index.mjs` | Exports `activate(api)`, which calls `api.registerConnector(...)` for each declared Connector |
| `<Cowork home>/extensions/logs/<name>.log` | What the Extension writes to its log; Cowork writes the file |
| `<Cowork home>/extensions/data/<name>/` | The Extension's own folder for its data; its process runs in this folder |

## What it can declare

| Item | Meaning |
|---|---|
| `connectors` | The IDs of the Connectors it registers. Registering an ID that is not listed is refused |
| `capabilities` | `browser` to act on web pages; `audio` (needs `browser`) to capture a page's sound; `platform-gate-v1` to use `platforms` |
| `origins` | With `browser`: the exact websites it may use, from 1 to 20, such as `https://example.com` |
| `platforms` | The computers it supports: `darwin-arm64`, `darwin-x64`, `win32-x64` |

## A Connector

A Connector has an `id` and three functions. `start(ctx)` starts it: open connections and timers here, not in `activate`; it has 5 seconds. `stop()` must be safe to call more than once; it has 5 seconds. `send(reply)` delivers one reply to the channel; it has 30 seconds. Through `ctx`, the Connector hands incoming messages to Cowork (`ctx.emit`), writes to its log (`ctx.log`), and, with the browser permission, uses `ctx.browser`.

## Limits

- Only you can approve an Extension. The AI cannot.
- The approval covers the exact files you approved. Changing one byte means approving again.
- A package can have at most 200 files and 5 MB. Packages from npm and `dependencies` are not installed.
- If the process crashes, Cowork restarts it after a short wait.
- In 0.1.41 an Extension cannot add tools or commands for the AI. To give the AI a new method, write a [Skill](https://docs.micromeet.ai/extend/skills.md).

## Related

- [Extensions](https://docs.micromeet.ai/connections/extensions.md): Install, approve and switch on an Extension
- [Gateway: Outside Messages](https://docs.micromeet.ai/connections/gateway.md): Where Connector messages go
- [Injection](https://docs.micromeet.ai/extend/injections.md): Scripts an Extension runs inside web pages
