AUDIO

Listen to this page

0:00
Chapters

    Plugin marketplace (npm)

    Plugins are distributed as regular npm packages; discovery, installation and updates run through the public npm registry — no custom package infrastructure is needed. The developer-facing contract (manifest, ctx, routes, UI) is plugins-api; this page covers distribution and lifecycle.

    Package conventions

    • Naming: official plugins use the org-controlled npm scope @holai-org/plugin-<name>; community plugins use holai-plugin-<name>. Both must include "keywords": ["holai-plugin"] in package.json to be discoverable by search.
    • Contents: the package is exactly the plugin folder — manifest.json, index.js, optional migrations/, ui/. The npm package version must match manifest.json version (enforced during validation). The module code never require()s core internals — everything the runtime offers comes through the host plugin API ctx (plugins-api); own npm dependencies are listed in the package package.json and installed with the package.
    • Lock: the plugins-lock row in holai.db records every installed package: npm name, resolved version, integrity, file checksums, install date, trust level, risk acknowledgment — the plugin equivalent of package-lock.json. Rollback reads previous entries from it.

    Discovery

    The dashboard queries the npm registry through the core (the browser never talks to the internet directly):

    Marketplace search box → GET /api/v1/registry/search?q=light
        → core calls https://registry.npmjs.org/-/v1/search?text=keywords:holai-plugin+light
        → normalized results
    

    Each result card shows: package name, description, latest version, author/publisher, weekly downloads, last publish date, repo link — and a permissions preview (the scopes the plugin declares), fetched from the package metadata before anything is installed.

    Install & update flow

    Both install and update reuse the staged lifecycle — npm is just another source feeding .staging:

    1. Fetch — the core runs npm pack <pkg>@<version> (tarball into .staging/, never a global install).
    2. Verify & validate — checksum against the lock file / registry integrity field, manifest schema check, version sync check.
    3. Permission prompt — first install shows the requested scopes for admin approval; for updates a permission diff is shown if the new version requests more scopes.
    4. Migrate → swap → health check — identical to a local update; the old version lands in .versions/.
    5. Register — the tool becomes available to the Agent (filtered by role); the lock file is updated.

    Update checks & notifications: a periodic job (every 6 h; the same data on demand via GET /api/v1/plugins/updates) compares locked versions against the latest registry versions and publishes an update.available event per new version — ONCE per version, so phones and dashboards are notified without spam. Nothing auto-installs: the user opens the marketplace and clicks Update themselves; the staged lifecycle (and its scope-approval dialog) runs as usual. Semver policy: PATCH/MINOR updates are offered as one-click; MAJOR updates are badged and require explicit confirmation.

    Plugin verification & trust

    npm is open — anyone can publish a holai-plugin-* package. The home must be able to tell controlled distribution from everything else:

    level meaning gate
    official the package lives in the org-controlled npm scope @holai-org/… — only holai-org members with publish rights can put anything there, so the organization controls what is distributed under its name normal install (scope-approval dialog as always)
    approved a community package the org has reviewed and added to the curated allowlist approved-plugins.json in the holai-org/holai repository (fetched with a 24 h cache; unreachable feed = NOT approved — honest default) normal install
    unverified everything else installing (and the first update) requires an explicit "install at own risk" acknowledgment (acknowledgeRisk=true); the acknowledgment is stored in the lock so later updates of the same package do not re-ask, while every update still runs the full staged pipeline with its permission diff

    The dashboard badges every search result and update row accordingly (official / approved / unverified), and the unverified flow shows a dialog stating exactly why the package is not trusted and what access it would gain. Every install/update audit entry records the package's trust level and whether the risk was acknowledged. Verify-level knobs for forks: HOLO_OFFICIAL_SCOPE, HOLO_APPROVED_URL.

    Versioning & migrations

    Every manifest.json carries a version field (semver). Plugins own their persistent state (config, caches, device maps) in ctx.dataDir; format changes across versions ship as numbered migrations/ scripts with up(state) / down(state):

    // migrations/002_add_schedules.js
    module.exports = {
      up(state)   { state.schedules = []; return state; },
      down(state) { delete state.schedules; return state; }
    };
    
    • The Plugin Manager tracks applied migration numbers in .plugin-state.json and runs only the pending ones, in order, before activation.
    • If a migration fails, the update aborts, down is applied to already-migrated steps, and the previous plugin version stays active — the smart home never ends up with a half-migrated plugin.
    • down migrations make rollback safe even after data changes.

    Signed swap lifecycle (staged, never in-place)

    1. Stage — the new version is downloaded/unpacked into plugins/.staging/<name>/ while the old version keeps running.
    2. Validate — manifest schema check; static permission diff: if the new version requests more scopes than before, the update requires explicit admin approval (permission escalation is never silent).
    3. Migrate — pending migrations run against a backup of the plugin state.
    4. Swap — atomic rename: current folder → plugins/.versions/<name>/<old-version>/, staging → active. The Plugin Manager hot-reloads the instance and re-registers the tool schema without a server restart.
    5. Health check — an optional health() hook in index.js is called; if it fails within N seconds, automatic rollback to the previous version.
    staging → validate → migrate → atomic swap → health check
                  ↓ (any failure)              ↓ (unhealthy)
                  ←←←←←←← rollback ←←←←←←←←←←←←
    

    Local patches beat npm packages (developer flow)

    Two things must work AT THE SAME TIME in one instance: developing (a plugin author writes/tests directly in the plugins/ folder and publishes that exact folder to npm when ready) and patching (an admin manually edits a packaged plugin to fix a bug before the maintainer ships it).

    Therefore: the plugin folder on disk has higher priority than any npm package. Marketplace mechanics record the checksums of every file the PACKAGE owns (manifest.json, index.js, package.json, migrations/*) in plugins.lock.json at install/update time:

    • a "check updates / apply-update" runs a patch check first; when the active files no longer match the lock checksums the update is refused (HTTP 409, naming the changed files) — the user's patch is never silently lost;
    • overwriting on purpose is an explicit admin decision: repeat the call with force: true (published as a patch.discard event);
    • a folder that never came from npm has no lock checksums and is never affected at all.

    That is why local development and npm-published distribution coexist: develop in plugins/, publish to npm, keep patching locally — updates never lose your work silently.

    The plugin selection survives restarts

    Enabled/disabled is part of the installation, not of a process lifetime: the PluginManager keeps it in the db store ("missing entry = enabled"), written by the enable/disable routes. Restarts, container rebuilds and the installer's repair mode therefore preserve which plugins the home actually uses; the fresh-install default follows the installer — it enables only the chosen plugins, everything else stays disabled (explicit false entries).

    Optional CLI (headless servers)

    Talks to the same API with an admin token (format sketch):

    holai plugin list --outdated
    holai plugin install @holai/plugin-light
    holai plugin update --all
    holai plugin rollback manage_light
    

    Dashboard screen

    The Marketplace screen has two tabs:

    • Browse — search box + result cards; "Installed" badge on present packages; install opens a dialog with the permissions preview and target version.
    • Updates — pending updates with old → new version, changelog link, and permission diff; one-click for PATCH/MINOR, confirmation dialog for MAJOR. Shows each update's stage (migrate → swap → health check) as a progress bar, same as the Plugins screen.

    Last updated: November 2026