{"record":{"id":"ccd195ac8b447710","repo":"moeru-ai/airi","slug":"unknown-plugin-transport-kind-ccd195","errorCode":null,"errorMessage":"Unknown plugin transport kind.","messagePattern":"Unknown plugin transport kind\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts","lineNumber":36,"sourceCode":" * - `transport` describes a transport supported by the web runtime\n *\n * Returns:\n * - A web-compatible Eventa context, or throws if the transport is not implemented\n */\nexport function createPluginContext(transport: PluginTransport): EventContext<any, any> {\n  switch (transport.kind) {\n    case 'in-memory':\n      return createContext()\n    case 'websocket':\n      throw new Error('WebSocket transport is not implemented for web runtime yet.')\n    case 'web-worker':\n      throw new Error('Web worker transport is not implemented yet.')\n    case 'node-worker':\n      throw new Error('Node worker transport is not available in web runtime.')\n    case 'electron':\n      throw new Error('Electron transport is not available in web runtime.')\n    default:\n      throw new Error('Unknown plugin transport kind.')\n  }\n}\n","sourceCodeStart":18,"sourceCodeEnd":39,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/plugin-sdk/src/plugin-host/runtimes/web/index.ts#L18-L39","documentation":"Thrown by createPluginContext in the web runtime when transport.kind matches no case of the web switch (in-memory, websocket, web-worker, node-worker, electron). Hitting default means the discriminant is outside the PluginTransport union: undefined kind, a typo, or a kind string from a newer SDK passed to an older web host.","triggerScenarios":"Transport object parsed from JSON/config with a misspelled kind ('In-Memory', 'inmemory'); { kind } destructuring where kind is undefined; new transport kinds added by a newer plugin-sdk consumed by an older host build; serialized transport losing the kind field across postMessage.","commonSituations":"Config-driven transport selection without validation; mixed plugin-sdk versions between host and plugins; refactors renaming the discriminant; IPC/serialization dropping fields.","solutions":["Inspect and correct the transport object so kind is an exact union literal ('in-memory' for web today).","Validate config-derived kinds against a literal allowlist before calling createPluginContext.","Deduplicate plugin-sdk versions in the workspace so both sides share one union.","When adding a custom kind, extend the web switch rather than falling through to default."],"exampleFix":"// before\nconst transport = { kind: 'In-Memory' } as any // typo -> default throw\nconst ctx = createPluginContext(transport)\n\n// after\nconst transport = { kind: 'in-memory' } as const\nconst ctx = createPluginContext(transport)","handlingStrategy":"validation","validationCode":"const KINDS = ['in-memory', 'websocket', 'node-worker', 'electron', 'web-worker'] as const\nfunction parseTransport(raw: unknown): PluginTransport {\n  const kind = (raw as { kind?: unknown })?.kind\n  if (typeof kind !== 'string' || !(KINDS as readonly string[]).includes(kind)) {\n    throw new Error(`Invalid transport kind: ${String(kind)}`)\n  }\n  return raw as PluginTransport\n}","typeGuard":"const KNOWN_KINDS = ['in-memory', 'websocket', 'node-worker', 'electron', 'web-worker'] as const\nconst isKnownTransportKind = (value: unknown): value is (typeof KNOWN_KINDS)[number] =>\n  typeof value === 'string' && (KNOWN_KINDS as readonly string[]).includes(value)","tryCatchPattern":"try {\n  ctx = createPluginContext(transport)\n} catch (error) {\n  if (error instanceof Error && error.message === 'Unknown plugin transport kind.') {\n    console.error('transport =', transport) // inspect and fix the discriminant\n  }\n  throw error\n}","preventionTips":["Validate any config-derived transport with a literal allowlist before use.","Keep host and plugins on the same plugin-sdk version so the kind union matches.","Prefer 'in-memory' literals (as const) over string-built kinds."],"tags":["plugin-sdk","transport","discriminated-union","invalid-config"],"backgroundTag":"unsupported-transport-kind","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}