Skip to content

Plugin/hook SDK for message middleware (pre-send and post-receive transforms) #45

Description

@PAMulligan

Summary

Introduce a small plugin API that lets consumers run middleware around chat messages without forking the widget. Both client-side (widget) and server-side (worker) extension points should be supported.

Motivation

Customers want to inject context, redact PII, route to different models, log analytics events, and inject canned responses for specific intents. A plugin system makes Claudius extensible without bloating the core.

Acceptance Criteria

  • Define ClaudiusPlugin interface with lifecycle hooks: onBeforeSend(message, ctx), onAfterReceive(message, ctx), onError(err, ctx)
  • Hooks can be async and may modify, replace, or short-circuit messages
  • ChatWidget accepts a plugins: ClaudiusPlugin[] prop
  • Server-side worker exposes equivalent hooks in hono middleware form
  • Three reference plugins: pluginAnalytics, pluginRedactPII, pluginCannedResponses
  • Documented in the docs site with copy-paste examples

Metadata

Metadata

Assignees

Labels

backendCloudflare Workers API and AI integrationenhancementNew feature or requestwidgetChat widget UI and embed functionality

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions