Skip to content

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

Transport: Plugin page / Run token Permission: library.read Target: Library Callers: Plugin pages & programs MCP: none

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

const { value } = await curio.plugin.state.get({ key: 'lastPreset' })

Example response

{ "value": { "format": "webp", "quality": 88 } }

Events and errors Read-only. Returns 403 not_allowed outside a plugin caller.


plugin.state.set

Transport: Plugin page / Run token Permission: library.read Target: Library Callers: Plugin pages & programs MCP: none

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

await curio.plugin.state.set({ key: 'lastPreset', value: { format: 'webp', quality: 88 } })

Example response

{ "success": true }

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

Transport: Plugin page / Run token Permission: library.read Target: Library Callers: Plugin pages & programs MCP: none

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

const { value } = await curio.plugin.itemState.get({ id: item.id })

Example response

{ "value": { "page": 14, "bookmarks": [{ "page": 3, "name": "Map" }] } }

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

Transport: Plugin page / Run token Permission: library.read Target: Library Callers: Plugin pages & programs MCP: none

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

const states = await curio.plugin.itemState.getMany({ ids: [book1, book2] })

Example response

{ "0194b7a2-...": { "page": 14 } }

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

Transport: Plugin page / Run token Permission: library.read Target: Library Callers: Plugin pages & programs MCP: none

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

await curio.plugin.itemState.set({ id: item.id, value: { page: 15 } })

Example response

{ "success": true }

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

Transport: Plugin page / Run token Permission: library.read Target: App (per computer) Callers: Plugin pages & programs MCP: none

Read the plugin's computer-wide settings (shared across all libraries on this machine).

Parameters None ({}).

Returns Record<string, unknown>.

Example request

const settings = await curio.plugin.settings.get()

Example response

{ "theme": "sepia", "fontSize": 18, "trackProgress": true }

Events and errors Read-only. Returns 403 not_allowed outside a plugin caller.


plugin.settings.set

Transport: Plugin page / Run token Permission: library.read Target: App (per computer) Callers: Plugin pages & programs MCP: none

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

const updated = await curio.plugin.settings.set({ values: { fontSize: 20, oldKey: null } })

Example response

{ "theme": "sepia", "fontSize": 20, "trackProgress": true }

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

Transport: Plugin page / Run token Permission: library.read Target: App Callers: Plugin pages & programs MCP: none

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

await curio.plugin.log({ level: 'warn', message: 'Fallback parser used for legacy header' })

Example response

{ "success": true }

Events and errors Writes to curio.log. Returns 403 not_allowed outside a plugin caller.


plugin.close

Transport: Plugin page bridge Permission: library.read Target: App (host window) Callers: Plugin window or popover pages only MCP: none

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

await curio.plugin.close({ result: { picked: 'option-b' } })

Example response

{ "success": true }

Events and errors Returns 403 not_allowed if called from a widget, tab or viewer page.