Package layout
A plugin is an npm-style package with a permanent package ID and four source roots: manifest/,
backend/, client/ and shared/. This page covers the package identity, what may live in each
root and import what, how provider scripts are laid out, how ryot plugin build discovers sandbox
scripts, and the rules for environment-neutral shared code.
Identity
Section titled “Identity”Package ID
Section titled “Package ID”Set metadata.packageId to a permanent publisher/name package ID.
| Rule | Value |
|---|---|
| Segment pattern | Lowercase [a-z0-9]+(-[a-z0-9]+)* |
| Segment length | 1–64 characters |
| Reserved | The ryot/ publisher is reserved for bundled plugins |
| Forks | A fork must choose a new package ID |
| Publisher proof | None. Package IDs and content hashes do not verify a publisher |
The package ID is portable. The local plugin.id identifies one system record or one user’s private
record. Names and slugs are display metadata, not selectors.
Routes and saved-view URLs
Section titled “Routes and saved-view URLs”Build URLs with the shared navigation helpers:
| Target | Path |
|---|---|
| Plugin routes | /p/<publisher>/<name> |
| Saved views | /v/c/<savedViewId>, /v/k/<slug>, or /v/p/<publisher>/<name>/<slug> |
Identity references
Section titled “Identity references”Domain recipes accept a PluginIdentityReference (from @ryot-app/plugin-kit/schema):
| Caller | Reference to pass |
|---|---|
| Authored saved views, trusted sandbox scripts | { kind: "self" } |
| Browser contributors | usePluginIdentity(packageId), or the non-React client.pluginIdentity(packageId) |
| Presentation declarations | { kind: "self" }; the executor binds it to the selected entity’s stored owner |
| Ordinary HTTP queries | local or { kind: "package", packageId, scope }, never self |
Dependencies
Section titled “Dependencies”Plugin dependencies are a top-level, importer-local alias map. Each alias names a package ID and the scope it is installed in:
dependencies: { catalog: { packageId: PluginPackageId.make("ryot/catalog"), scope: "system" },},- Every
packagereference in declared queries, saved views, browse fields, calendar sources and signal schedules must name a declared dependency. - Client imports use
@ryot-app/plugins/<alias>/<export-name>. Compilation replaces the alias with the exact scoped package target; it does not install dependencies or select revisions. - Installation requires each dependency to be available, and page composition includes dependencies that ship a client.
ryot plugin buildloads each dependency from an installed npm package whoseexports["."].defaultis its manifest (see CLI).- Dependencies do not grant read or write authority. Contributors share one JavaScript realm, so identity bindings do not isolate modules.
Scope conflicts and backups
Section titled “Scope conflicts and backups”- A system package ID cannot be installed privately.
- When system activation meets a retained private claim, the private installation is quarantined with its data intact until it is explicitly re-enabled.
- Backups remap typed plugin references by package ID and scope. IDs inside opaque plugin JSON are not rewritten.
System configuration for a package is read from environment variables derived from the package ID; see Configuration schema.
Source roots
Section titled “Source roots”| Root | Archive output | Owner and allowed dependencies |
|---|---|---|
manifest/ |
None | Manifest and declarations imported directly by the server or kernel client |
backend/ |
Compiled JavaScript | Sandbox entrypoints and libraries; may import siblings and shared/ |
client/ |
Emitted client assets | Optional client source; uses client SDK/UI SDK and may import siblings and shared/ |
shared/ |
Bundled when reachable into scripts/assets | Environment-neutral .ts; may import shared siblings and plugin-kit neutral shims |
shared/messages/<locale>.json holds the plugin’s message catalogs; see
Messages.
Import boundaries
Section titled “Import boundaries”- Backend, client and shared sources never import
manifest/. - Manifest code reaches backend source only through
backend/contracts/**, which holds sandbox-owned schemas, recipes and helpers that server callers need. - Environment-neutral values used by both the manifest and backend belong in
shared/. - Nothing manifest-only belongs under
backend/,client/orshared/.
Client sources
Section titled “Client sources”- Client entries default-export components or presentation definitions. They do not mount or bootstrap an application. The compiler generates one application bootstrap and React root for plugin routes, entity pages, saved-view renderers and workspace homes.
- Public cross-plugin imports use
@ryot-app/plugins/<dependency-alias>/<export-name>and must name a declared client dependency. - Client code may read
usePageContext().target.kind, but must derive target paths, route parameters, entity IDs and entity schema slugs from the live routing APIs. The kernel retains and reuses a client realm across locations, so the initial page context is not a navigation state source. - Navigation owns scroll and focus. A new screen opens at the top with focus on its screen container, going back restores the screen returned to, and page-search replacements keep both. Push a route for new content and replace page search for state of the same screen. Do not reset scroll or move focus on navigation. Routes whose pages render the same component are one screen, so replacing one with another updates it in place.
- Client code runs in an opaque-origin iframe without
localStorage. Keep per-device preferences with the client SDK’susePluginStorage. - Plugins can request a kernel-rendered fixed card through
client.iosLiveActivities; the client SDK documents its Effect API and lifecycle.
Manifest-level client declarations (exports, routes, entity registrations, assistant starters) are covered in Manifest → Client entry.
Backend areas
Section titled “Backend areas”Backend entrypoints are grouped under automations/, bootstrap/, imports/, integrations/,
operations/, workflows/ and providers/. Cross-area code belongs in backend/lib/.
Provider scripts
Section titled “Provider scripts”Provider entrypoints live at:
backend/providers/<provider slug path>/<operation>.sandbox.tsThe path is the provider slug with / replacing .. The basename is the provider operation:
| Operation | Purpose |
|---|---|
details |
Required. Populates one entity and its children, and related groups at full level |
search |
Searches the source; may declare a searchOptionsSchema |
search-options |
Supplies dynamic choices for the search schema; required when that schema has dynamic choices |
related |
Pages through related-entity groups; may declare relatedInputs |
assets |
Supplies the full artwork inventory; declares assetInputs |
resolve |
Maps { value, identifierType } to the source’s externalId, or null |
translate |
Translates an entity’s canonical properties; declares translationInputs |
Other sandbox basenames in a provider directory are provider-associated ordinary scripts.
Search results return details.nextPage independently of an optional details.totalItems. Omit the
total when the source does not provide it; a continuation does not prove an exact catalog count.
Population levels
Section titled “Population levels”details receives { externalId, level? }. level is "base" or "full"; absent means full.
- The provider result is authoritative. The kernel does not pass existing properties to
detailsor preserve omitted old property keys when provider data is updated. - At
base, return entity fields and child entities and skip fetching related data. The kernel ignores anyrelatedEntityGroupsreturned atbase. - At
full, return related groups as well.
An entity schema may declare refreshIntervalDays, a positive integer. When a page shows an entity
of that schema whose data is older than the interval, the kernel refreshes it from the provider,
trying at most once per day. Without it, data refreshes only on request or through monitoring.
Instance Admin can override the interval per schema.
Provider assets
Section titled “Provider assets”A provider can include assets on a details result or any child result. Each remote asset has a
stable source ID, a purpose and a URL, with optional language and rendition URLs. For a schema
without a supplemental assets script, omission leaves prior assets alone and an empty list clears
them.
An assets script declares assetInputs, mapping supported root or child schema slugs to the
canonical properties needed to address them.
| Input | Meaning |
|---|---|
externalId |
The entity’s external ID |
entitySchemaSlug |
The schema being addressed |
properties |
Only the properties selected by assetInputs |
continuation |
null for the first page |
It returns { assets, coverage } using the same coverage contract as
paged related groups.
- Details assets provide initial artwork and preferred source IDs.
- The full inventory replaces the published set after complete coverage.
- A failed, interrupted or superseded refresh leaves the prior set visible.
- Imports queue asset work after writing metadata, so the inventory populates without a client read.
Paged related groups
Section titled “Paged related groups”Every details related-entity group and every related result declares coverage:
| Coverage | Meaning |
|---|---|
{ status: "complete" } |
The declared inventory is exhausted, including an empty inventory |
{ status: "more", continuation } |
Carries the next page’s JSON cursor, at most 4 KiB encoded |
{ status: "source-limited", reason } |
The source cannot supply the declared inventory |
A group with more pages requires a related script. It receives
{ externalId, entitySchemaSlug, properties, relationshipSchemaSlug, direction, continuation } and
returns { entities, coverage }; properties is empty for root pages.
- Each run is its own sandbox execution with its own host-call budget.
- The kernel writes each page as it arrives, so a page must be self-contained.
- Only complete coverage permits an
authoritativesweep. - A source-limited result fails explicitly without writing that page, deleting stale relationships or marking related data complete.
- Repeated cursors and exhausted execution or page budgets also fail.
- Curated selections must have a defined scope: completing a recommendation selection does not imply that a source’s entire catalog was fetched. Do not disguise an arbitrary inventory cap as a selection.
- A full population waits for all related pages and authoritative sweeps before marking related data complete. Root data is published earlier, and pages remain visible while partial.
See provider population for the kernel side.
Child related groups
Section titled “Child related groups”A related script may also declare relatedInputs, which gives child entity schemas their own
related level.
- Each entry names the child’s addressing properties and its groups (
relationshipSchemaSlug,direction,synchronization). - Each group’s relationship must anchor on the child schema, and the provider root cannot be declared.
- A child’s related level populates on foreground interest or refresh. Its first page receives a
nullcontinuation and the selected properties. - The parent’s population still owns the child’s canonical data.
See child related groups.
Translations
Section titled “Translations”Each translate provider script declares translationInputs, a map from supported entity-schema
slugs to the canonical property keys the script needs. The kernel pins this declaration with the
provider script revision.
- The required input is
{ name, externalId, entitySchemaSlug, language, properties }.nameis the captured canonical name, andpropertiescontains only the selected canonical properties. - The full input, including the name, is bounded.
- Missing selected data or an oversized translation input fails closed. The kernel never falls back to the full properties object.
- A successful empty translation result is a negative-cache result, distinct from workflow failure.
Script discovery
Section titled “Script discovery”ryot plugin build compiles every local backend/**/*.sandbox.ts entry and derives the archive
manifest’s scripts section from them; scripts is never authored.
- Archives contain compiled backend and client artifacts, not authored sources.
- Installation validates structure and hashes without recompilation or source-provenance proof.
- Renaming a script slug requires updating its manifest references.
See the archive format.
Script entries
Section titled “Script entries”Each entry default-exports exactly one direct definition with a static manifest, input schema,
output schema and Effect-returning run.
import { deleteEventChange } from "@ryot-app/plugin-backend-sdk/core";import { defineManifest } from "@ryot-app/plugin-backend-sdk/driver";import { Effect } from "@ryot-app/plugin-backend-sdk/effect";import { defineOperation } from "@ryot-app/plugin-backend-sdk/operation";import { EventId } from "@ryot-app/plugin-kit/schema";
import { ExerciseNoteDeleteInput, ExerciseNoteOutput } from "../../shared/exercise-note-operations";import { requireExerciseNote } from "./exercise-notes";
export const manifest = defineManifest({ kind: "operation", name: "Delete exercise note", slug: "operation.exercise-note-delete",});
export default defineOperation({ manifest, output: ExerciseNoteOutput, input: ExerciseNoteDeleteInput, run: (input, host) => Effect.gen(function* () { const eventId = yield* requireExerciseNote(input.noteId, host.executeRyotql); return { output: { count: 1 }, changes: { events: { changes: [deleteEventChange(EventId.make(eventId))] } }, }; }),});defineManifest contains the script identity and kind plus its kind-specific authored fields, such
as an automation inputProjection or a provider searchOptionsSchema, relatedInputs,
assetInputs or translationInputs. It does not contain capabilities, configuration requirements,
OAuth fields or executable dependencies. The compiler derives those from the entry’s used code and
writes them to the build-derived script metadata. There are no driver maps or runtime kind
selection.
Script slugs (and other sandbox slugs) use lowercase letters and numbers separated by ., _ or
-; / is reserved for path mapping.
Script kinds
Section titled “Script kinds”| Kind | Helper | Use |
|---|---|---|
script |
defineScript |
Cron, bootstrap or internal execution |
script |
defineActivity |
A script with activity: true that a workflow calls with step.activity |
operation |
defineOperation |
Public plugins.invoke entrypoint |
workflow |
defineWorkflow |
Bounded orchestration with explicit saved checkpoints; no local host capabilities |
automation |
defineAutomation |
After hook (automationType: "automation") |
automation |
defineAutomationPolicy |
Before hook (automationType: "policy") |
provider |
defineProvider |
One logical provider operation |
Activities and workflows are covered in Checkpoint workflows; hook scripts in Lifecycle hooks.
Logical providers
Section titled “Logical providers”- A logical provider requires
detailsand may declaresearch,search-options,related,assets,resolveandtranslate, each as a separate provider script. - Generated
providerSlug/providerOperationscript tuples are the sole operation bindings. Each tuple must be unique and reference a declared provider. - Dynamic choices in a search schema require that provider’s
search-optionsscript. - Authored and archive
providerscontain only descriptive metadata, includingrootEntitySchemaSlug, which references an entity schema from the same plugin. - User-effective provider and schema resolution includes ready private installations only for their owner. APIs without user context resolve system definitions only.
- Persisted provenance uses the stable plugin ID, not the installation ID.
Failures and Effect imports
Section titled “Failures and Effect imports”- Sandbox definition helpers infer the
runfailure type from its implementation. Use typed or tagged failures for expected plugin errors; host capability calls contributeSandboxHostErrorto that type. - Workflow body failures become failed replay envelopes.
- Import
Effectfrom@ryot-app/plugin-backend-sdk/effectin ordinary backend scripts, and from the restricted@ryot-app/plugin-backend-sdk/workflowsurface in workflows. - The shared
@ryot-app/plugin-kit/effectshim stays environment-neutral and does not exportEffect.
Shared sources
Section titled “Shared sources”shared/** accepts .ts, not .tsx. Relative imports stay inside shared/, and the only bare
imports allowed are the neutral plugin-kit shims:
| Module | Exports |
|---|---|
@ryot-app/plugin-kit/compression |
deflateSync, inflateSync |
@ryot-app/plugin-kit/effect |
DateTime, Option, Result, Schema, SchemaGetter (not Effect) |
@ryot-app/plugin-kit/ryotql |
Query builders and recipe helpers, not application recipes; see Recipe helpers |
@ryot-app/plugin-kit/languages |
Language catalog helpers; see Languages |
@ryot-app/plugin-kit/messages |
Message, LocalMessage, DisplayText, isMessage, isCalendarDate and builder types |
@ryot-app/plugin-kit/schema |
Shared schemas and brands, roundHalfUp, jsonValueEquals, review and reporting helpers |
- The plugin client and backend compilers enforce the same rule, and reject client-only or backend-only SDK imports.
- Backend compilation reuses runtime modules to avoid duplicate bundles.
- Compiled client code can use the reporting exports from
@ryot-app/plugin-client-sdk/plugin.