Commit ff6f17c
authored
feat(plugins): add advanced plugin system with full TUI customization (#551)
* feat(plugins): add TUI event hooks for plugin system
* feat(plugins): expand UI hooks with advanced TUI customization types
- Add UiRegion enum for content injection zones (header, footer, sidebars, overlays)
- Add comprehensive style types: Color, TextStyle, WidgetStyle, BorderStyle
- Add WidgetSize/WidgetConstraints for layout control
- Expand UiWidget with Text, List, Table, Gauge, Sparkline, layouts, Block
- Add keyboard binding types: KeyBinding, KeyModifier, KeyBindingResult
- Add ThemeColors and ThemeOverride for dynamic theming
- Add hooks: WidgetRegisterHook, KeyBindingHook, ThemeOverrideHook
- Add LayoutCustomizeHook with LayoutPanel and LayoutDirection
- Add ModalInjectHook with ModalDefinition and ModalLayer
- Add ToastShowHook with ToastDefinition and ToastLevel
- All public types documented, 9 unit tests passing
* feat(plugins): add new UI and TUI event hook types to HookType enum
* feat(plugins/sdk): add hot-reload support and comprehensive templates
- Add TypeScript template for JS/TS plugin development
- Add tsconfig.json template for TypeScript plugins
- Add hot-reload configuration template with watch patterns and debounce
- Add testing utilities template with MockContext and MockToolInput
- Add advanced Rust template with TUI hooks, widgets, and keybindings
- Add HotReloadConfig struct with builder pattern
- Add scaffold_advanced() method for advanced plugin scaffolding
- Add tests for all new generator functions
* feat(plugins): expand hook registry with full TUI hook support
Add comprehensive hook registration support for all TUI-related hooks:
- UI hooks: UiRender, WidgetRegister, KeyBinding, ThemeOverride,
LayoutCustomize, ModalInject, ToastShow
- TUI event hooks: TuiEventSubscribe, TuiEventDispatch,
CustomEventEmit, EventIntercept, AnimationFrame
- Additional hooks: CommandExecuteBefore/After, InputIntercept,
SessionStart/End, FocusChange
Each hook type includes:
- Registered hook wrapper struct with plugin_id, hook, and priority
- Registration method with priority-based sorting
- Unregistration support via unregister_plugin()
- Hook count tracking via hook_count() and total_hook_count()
- Plugin tracking via registered_plugins()
* feat(plugins): update lib.rs exports with TUI events and SDK types
* feat(plugins): add command completion hooks for plugin autocompletion
* feat(plugins): export completion hooks in lib.rs
* security(plugins): fix critical security vulnerabilities in plugin system
WASM Runtime DoS Protection:
- Add fuel-based CPU limiting (10M operations max)
- Add epoch interruption support for timeout handling
- Implement ResourceLimiter with 16MB memory cap
- Add table/instance/memory limits
- Remove panic-prone Default impl for WasmRuntime
Path Traversal Prevention:
- Canonicalize all paths before access checks
- Resolve symlinks to prevent traversal via symlinks
- Validate paths stay within allowed boundaries
- Handle non-existent paths safely for write operations
Fail-Closed Security Model:
- Empty command allowlist now denies all commands
- Empty domain allowlist now denies all network access
- None allowed_domains denies network access
- Explicit opt-in required via '*' wildcard
SSRF Protection:
- Block localhost/loopback addresses (127.0.0.1, ::1, etc.)
- Block private IP ranges (10.x, 172.16-31.x, 192.168.x)
- Block link-local addresses (169.254.x.x)
- Block .local/.internal domain suffixes
- Block dangerous ports (SSH, databases, etc.)
- Allow only http/https protocols
Permission Hook Security:
- Document security implications of Allow decision
- Add requires_elevated_trust() method
- Add validate_for_third_party() method
Hook Priority Security:
- Reserve priorities 0-49 for system use
- Add SYSTEM_CRITICAL, SYSTEM, SYSTEM_HIGH constants
- Add PLUGIN_MIN (50), PLUGIN_HIGH (75) for third-party
- Add validate_for_plugin() method
- Deprecate HIGHEST/HIGH in favor of explicit names
SDK Safety Documentation:
- Add SAFETY comments to all unsafe FFI calls
- Document host contract assumptions1 parent 6e7b9c8 commit ff6f17c
14 files changed
Lines changed: 4710 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
0 commit comments