Files
kandev/apps/web/lib/ws/plugin-bridge.ts
T
Kandev Agent c53f699714 feat: add plugin system with grpc runtime and native ui plugins
- go plugin backends ship as release tarballs (per-platform binaries, checksums) that
  kandev installs from url/upload or filesystem sideload+sync, then spawns and
  supervises via hashicorp/go-plugin (unix socket / loopback tcp+automtls)
- strict typed grpc contract (kandev.plugin.v1): DeliverEvent/InvokeTool/HandleWebhook
  plus a capability-gated host service (state, secrets, emit); author sdk in
  pkg/pluginsdk; packaging cli in cmd/plugin-pack
- native frontend bundles: window.registerKandevPlugin + registry/host loader with
  dynamic routes, nav items, slots and ws handlers; plugins settings page with
  install dialog, sync button and enable/disable/uninstall
- gated behind the plugins feature flag (prod off, dev/e2e on); covered by unit and
  integration tests plus playwright e2e against a real packaged fixture plugin

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 17:55:45 +01:00

20 lines
781 B
TypeScript

/**
* Bridges decoded WS notifications into plugin-registered handlers
* (`registry.registerWsHandler(action, handler)`, PLUGIN-API.md). Called from
* `lib/ws/client.ts` after the built-in `handlers` dispatch for a message, so
* plugin handlers see the same notification vocabulary as the rest of the app.
*/
import { pluginRegistry } from "@/lib/plugins/registry";
/** Forwards `payload` to every plugin handler registered for `action`. Never throws. */
export function dispatchToPluginWsHandlers(action: string, payload: unknown): void {
const handlers = pluginRegistry.getWsHandlers(action);
for (const handler of handlers) {
try {
handler(payload);
} catch (error) {
console.error(`[plugins] ws handler for "${action}" threw`, error);
}
}
}