AviatoAviato
DeveloperPlugins

Host RPC

How plugins call back into the Aviato server. The host.* namespace, available methods, and notifications.

Plugins can make typed requests to the Aviato server using client.call('host.<method>', params), or one of the typed sugar helpers like client.getAccount. The server can also push notifications down to plugins; the plugin SDK exposes typed subscription helpers like client.onAccountChanged(cb).

Wire format: standard JSON-RPC 2.0 over the existing stdio channel. Requests carry a numeric id; notifications omit it. Method names in the host.* namespace are reserved for plugin-to-server traffic.

Methods

host.getAccount(name) → Account<T>

Returns the decrypted contents of the named account managed by the calling plugin. The returned object has the shape declared in the plugin's accounts.schema (see Manifest).

import { createPlugin } from '@aviato-media/plugin-sdk'

interface S3Account {
  accessKeyId?:     string
  secretAccessKey?: string
  region:           string
  endpoint?:        string
}

const plugin = createPlugin({ /* handlers */ })

async function getClient (name: string): Promise<S3Client> {
  const account = await plugin.client.getAccount<S3Account>(name)
  // build client with account.accessKeyId / .region / ...
}

Throws AccountNotFound (JSON-RPC error code -32004) if no account with name exists for this plugin. The plugin must declare an accounts block in its manifest; calling host.getAccount from a plugin without one returns -32602.

Notifications

host.accountChanged

Sent whenever the server creates, updates, or deletes an account belonging to the receiving plugin. Subscribe with client.onAccountChanged(cb):

plugin.client.onAccountChanged(({ name, change }) => {
  if (change === 'updated' || change === 'deleted') {
    // invalidate any cached resource keyed by `name`
  }
})

The plugin should invalidate cached clients or resources keyed by name on updated and deleted. On created there is typically nothing to invalidate, but plugins that proactively warm clients may want to handle it.

Limits

  • plugins.hostRpc.maxConcurrency (default 16) — per-plugin inflight host method cap. Excess calls queue.
  • plugins.hostRpc.timeoutMs (default 5000) — per-call timeout. Slow handlers reject with code -32000.

Both values are configurable. See Configuration for the full option reference.

Future versions will add a manifest-declared permission list governing which host.* methods a plugin may call. Today, any plugin declaring an accounts block may call host.getAccount.

See also

On this page