# Plugin lifecycle

## Install

Installing checks the package and stores it; no plugin code runs. A new
plugin is **disabled until you consent**: Settings › Plugins lists what
it asks to do, and **Grant and enable** grants exactly that.

## Update

Install the newer package of the same plugin `id`:

- **Same permissions:** the plugin stays as it was (enabled or not), and
  the row shows which version it was updated from.
- **More permissions:** the plugin is disabled with *This version asks
  for more*, and the new permission is listed as not granted. It runs
  again only after you grant the new set. A plugin never gains a
  permission by updating.
- **An older version** is refused; uninstall first to go back.
- **The same version with different contents** is refused; a changed
  package needs a new version number.

The new version is unpacked before the switch, and the old files are
removed after it, so a failed update leaves the installed version working.

## Pin

**Pin to this version** refuses every update of that plugin until you
choose **Allow updates**.

## Disable and uninstall

**Disable** stops a plugin and keeps what you granted, so **Enable again**
needs no new consent. **Uninstall** removes it and its files.

## Failures

A call that raises, crashes, runs past its time or returns something
Phantom cannot use fails on its own: you see the error, and Phantom keeps
working. After **three failures in a row** the plugin is disabled, with
its last error shown, so a broken plugin does not fail on every request.
A successful call resets the count; an update starts it again.

## Where plugins live

Each version is unpacked into its own folder under the plugins directory:
`~/.phantom/plugins` on a workstation (`PHANTOM_PLUGINS_DIR` changes it),
`/data/plugins` (the `plugins` volume) in Docker Compose.

## Agents

Plugins are yours. Agents cannot install, enable or call them, over MCP
or REST.
