plugin¶
Plugin-exclusive operations for storing private library-scoped JSON state, per-item private state, computer-scoped plugin settings, structured logging and closing plugin windows or popovers. Every operation requires only the plugin's implicit library.read permission and is isolated to the calling plugin's own ID. None of these operations are exposed to external web tokens or MCP.
plugin.state.get¶
Read a private JSON value stored by this plugin for the current library under key (null if unset).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
key |
string |
Yes | — | Storage key within this plugin's namespace. |
Returns { value: unknown }.
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside a plugin caller.
plugin.state.set¶
Store any JSON value (up to 1 MiB) for this plugin in the current library. Pass value: null to delete the key.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
key |
string |
Yes | — | Storage key (1–200 characters). |
value |
unknown |
Yes | — | Any JSON-serializable value (≤ 1 MiB), or null to delete. |
Returns Done.
Example request
Example response
Events and errors Emits no library events. Returns 400 bad_request if key is empty or exceeds 200 characters, or serialized JSON exceeds 1 MiB; 403 not_allowed outside a plugin caller.
plugin.itemState.get¶
Read private data stored by this plugin for one item (such as a Reader page position or bookmarks); returns { value: null } when none exists.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
Returns { value: unknown }.
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside a plugin caller, or 404 not_found if id does not exist.
plugin.itemState.getMany¶
Batch-read private plugin item state for multiple items at once. Items with no saved state are omitted from the returned object.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
ids |
(string \| number)[] |
Yes | — | Item IDs to read. |
Returns Record<string, unknown> (keyed by item UUID).
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside a plugin caller, or 404 not_found if any ID in ids does not exist.
plugin.itemState.set¶
Store private JSON data (up to 64 KiB) attached to an item, automatically deleted if the item is purged. Pass value: null to remove it. Emits no items.changed event, so saving scroll or reading progress frequently never causes UI redraws.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string \| number |
Yes | — | Item UUID or row ID. |
value |
unknown |
Yes | — | JSON value (≤ 64 KiB), or null to delete. |
Returns Done.
Example request
Example response
Events and errors Emits no events. Returns 400 bad_request if payload exceeds 64 KiB, 403 not_allowed outside a plugin caller or 404 not_found if id does not exist.
plugin.settings.get¶
Read the plugin's computer-wide settings (shared across all libraries on this machine).
Parameters None ({}).
Returns Record<string, unknown>.
Example request
Example response
Events and errors Read-only. Returns 403 not_allowed outside a plugin caller.
plugin.settings.set¶
Merge key-value updates into the plugin's computer-wide settings (up to 1 MiB total; null deletes a key). All other pages of this plugin across open Curio windows receive plugin.settingsChanged.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
values |
Record<string, unknown> |
Yes | — | Keys to set or clear (null). |
Returns Record<string, unknown> — the full merged settings object.
Example request
Example response
Events and errors Delivers plugin.settingsChanged to sibling pages of the plugin. Returns 400 bad_request if total settings exceed 1 MiB, 403 not_allowed outside a plugin caller or 422 failed if the settings file cannot be written.
plugin.log¶
Append a line tagged with this plugin's ID to Curio's diagnostic log (curio.log).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
message |
string |
Yes | — | Log line text. |
level |
string |
No | "info" |
info, warn or error. |
Returns Done.
Example request
Example response
Events and errors Writes to curio.log. Returns 403 not_allowed outside a plugin caller.
plugin.close¶
Close the standalone plugin window hosting this page, or close a popover opened via ui.popover and resolve the caller's promise with result.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
result |
unknown |
No | null |
Value returned to the ui.popover caller when closing a popover. |
Returns Done.
Example request
Example response
Events and errors Returns 403 not_allowed if called from a widget, tab or viewer page.