Getting Started
What are DeepIntShield Plugins?
Section titled “What are DeepIntShield Plugins?”DeepIntShield plugins allow you to extend the gateway’s functionality by intercepting requests and responses. Plugins can modify, log, validate, or enrich data as it flows through the system, giving you powerful hooks into DeepIntShield’s request lifecycle.
Use Cases
Section titled “Use Cases”Custom plugins enable you to:
- Transform requests and responses - Modify data before it reaches providers or after it returns
- Add custom validation - Enforce business rules on incoming requests
- Implement custom caching - Cache responses based on custom logic
- Integrate with external systems - Send data to logging, monitoring, or analytics platforms
- Apply custom transformations - Parse, filter, or enrich LLM responses
Plugin Architecture
Section titled “Plugin Architecture”
DeepIntShield leverages Go’s native plugin system to enable dynamic extensibility. Plugins are built as shared object files (.so files) that are loaded at runtime by the DeepIntShield gateway.
How Go Plugins Work
Section titled “How Go Plugins Work”Go plugins use the plugin package from the standard library, which allows Go programs to dynamically load code at runtime. Here’s what makes this approach powerful:
- Native Go Integration - Plugins are written in Go and have full access to DeepIntShield’s type system and interfaces
- Dynamic Loading - Plugins can be loaded, unloaded, and reloaded without restarting DeepIntShield
- Type Safety - Go’s type system ensures plugin methods match expected signatures
- Performance - No IPC overhead; plugins run in the same process as DeepIntShield
Building Shared Objects
Section titled “Building Shared Objects”Plugins must be compiled as shared objects using Go’s -buildmode=plugin flag:
go build -buildmode=plugin -o myplugin.so main.goThis generates a .so file that exports specific functions matching DeepIntShield’s plugin interface:
Init(config any) error- Initialize the plugin with configurationGetName() string- Return the plugin nameHTTPTransportPreHook()- Intercept HTTP requests before they enter DeepIntShield core (HTTP transport only)HTTPTransportPostHook()- Intercept HTTP responses after they exit DeepIntShield core (HTTP transport only)PreLLMHook()- Intercept requests before they reach providersPostLLMHook()- Process responses after provider callsCleanup() error- Clean up resources on shutdown
Init(config any) error- Initialize the plugin with configurationGetName() string- Return the plugin nameTransportInterceptor()- Modify raw HTTP headers/body (HTTP transport only)PreLLMHook()- Intercept requests before they reach providersPostLLMHook()- Process responses after provider callsCleanup() error- Clean up resources on shutdown
Platform Requirements
Section titled “Platform Requirements”Important Limitations:
- Supported Platforms: Linux and macOS (Darwin) only
- No Cross-Compilation: Plugins must be built on the target platform
- Architecture Matching: Plugin and DeepIntShield must use the same architecture (amd64, arm64)
- Go Version Compatibility: Plugin must be built with the same Go version as DeepIntShield
This means if you’re running DeepIntShield on Linux AMD64, you must build your plugin on Linux AMD64 with the same Go version.
Plugin Lifecycle
Section titled “Plugin Lifecycle”- Load - DeepIntShield loads the
.sofile using Go’splugin.Open() - Initialize - Calls
Init()with configuration fromconfig.json - Hook Execution - Calls
PreLLMHook()andPostLLMHook()for each request - Cleanup - Calls
Cleanup()when DeepIntShield shuts down
Plugins execute in a specific order:
HTTPTransportPreHook- Intercept HTTP requests (HTTP transport only)PreLLMHook/PreMCPHook- Executes in registration order, can short-circuit requests- Provider call (if not short-circuited)
PostLLMHook/PostMCPHook- Executes in reverse order of PreHooksHTTPTransportPostHook- Intercept HTTP responses (HTTP transport only, reverse order)
TransportInterceptor- Modifies raw HTTP requests (HTTP transport only)PreHook- Executes in registration order, can short-circuit requests- Provider call (if not short-circuited)
PostHook- Executes in reverse order of PreHooks
Next Steps
Section titled “Next Steps”Ready to build your first plugin? Choose your approach:
- Writing Go Plugins - Native Go plugins using shared objects (
.sofiles). Best for performance and full Go ecosystem access. - Writing WASM Plugins - Cross-platform plugins using WebAssembly. Write in TypeScript, Go (TinyGo), or Rust. No version matching required.