moeru-ai/airi · error · Error

Unknown plugin transport kind.

Error message

Unknown plugin transport kind.

What it means

Thrown by the `default` branch of the transport switch in the web runtime's `createPluginContext()`. It fires when `transport.kind` is not one of the known cases (`in-memory`, `websocket`, `web-worker`, `node-worker`, `electron`). Because the switch is exhaustive over a union, this typically indicates a value outside the union or a stale/distinct transport type.

Source

Thrown at packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts:36

 * - `transport` describes a transport supported by the web runtime
 *
 * Returns:
 * - A web-compatible Eventa context, or throws if the transport is not implemented
 */
export function createPluginContext(transport: PluginTransport): EventContext<any, any> {
  switch (transport.kind) {
    case 'in-memory':
      return createContext()
    case 'websocket':
      throw new Error('WebSocket transport is not implemented for web runtime yet.')
    case 'web-worker':
      throw new Error('Web worker transport is not implemented yet.')
    case 'node-worker':
      throw new Error('Node worker transport is not available in web runtime.')
    case 'electron':
      throw new Error('Electron transport is not available in web runtime.')
    default:
      throw new Error('Unknown plugin transport kind.')
  }
}

View on GitHub (pinned to 27111382b4)

Solutions

  1. Ensure `transport.kind` is one of the supported web-runtime values (currently `in-memory`); check the value before calling `createPluginContext`.
  2. If you extended the `PluginTransport` union with a new kind, add a case to the switch (or explicitly throw a clearer message) rather than relying on default.
  3. Validate the config object shape (presence and value of `kind`) before constructing the context.
  4. Check for version mismatch between the plugin-sdk transport type definitions and the web runtime build.

Example fix

// before
const ctx = createPluginContext({ kind: 'memory-local' } as any)

// after
const ctx = createPluginContext({ kind: 'in-memory' })
Defensive patterns

Strategy: type-guard

Validate before calling

const knownKinds = new Set(['in-memory', 'websocket', 'web-worker', 'node-worker', 'electron'])
if (!knownKinds.has(transport.kind)) {
  throw new Error(`Unknown transport kind: ${transport.kind}`)
}
const ctx = createPluginContext(transport)

Type guard

const WEB_TRANSPORT_KINDS = ['in-memory'] as const
type WebTransportKind = (typeof WEB_TRANSPORT_KINDS)[number]

function isWebTransportKind(t: PluginTransport): t is { kind: WebTransportKind } {
  return (WEB_TRANSPORT_KINDS as readonly string[]).includes(t.kind)
}

Try / catch

try {
  ctx = createPluginContext(transport)
} catch (e) {
  if (e instanceof Error && e.message === 'Unknown plugin transport kind.') {
    ctx = createPluginContext({ kind: 'in-memory' })
  } else throw e
}

Prevention

When it happens

Trigger: Passing a transport object whose `kind` is undefined, misspelled, or a newly added transport kind not yet handled by the web runtime. Also triggered by malformed config that omits `kind` entirely.

Common situations: Adding a new transport kind to the union without updating the web-runtime switch; config loaded from a source with a typo in the kind string; passing a plain object without a `kind` field; version skew between the transport type definitions and the web runtime implementation.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/ccd195ac8b447710. Report an issue: GitHub.