feat(plugin): add plugin interface system and iot-mock implementation
- internal/plugin: Plugin/IoTProvider/ToolProvider/RAGProvider interfaces - internal/plugin: Registry with type-safe auto-detection, 11 tests - plugins/iot-mock: 8 simulated smart home devices, 11 tests - 63 total tests, build + vet clean
This commit is contained in:
1 parent
7943e290ec
commit
750d594055
8 files changed
+1109
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package plugin
|
||||
|
||||
import "context"
|
||||
|
||||
// IoTProvider is implemented by plugins that manage IoT devices.
|
||||
// Only one IoTProvider can be active at a time.
|
||||
type IoTProvider interface {
|
||||
Plugin
|
||||
|
||||
// ListDevices returns all managed devices.
|
||||
ListDevices(ctx context.Context) ([]Device, error)
|
||||
|
||||
// GetDevice returns a single device by ID.
|
||||
GetDevice(ctx context.Context, id string) (*Device, error)
|
||||
|
||||
// SetDevice sets a property on a device (e.g., brightness=80).
|
||||
SetDevice(ctx context.Context, id, field string, value any) error
|
||||
|
||||
// ToggleDevice toggles a device's power state.
|
||||
ToggleDevice(ctx context.Context, id string) error
|
||||
|
||||
// SubscribeChanges returns a channel that emits device state changes.
|
||||
// The channel is closed when the context is cancelled.
|
||||
SubscribeChanges(ctx context.Context) (<-chan DeviceEvent, error)
|
||||
}
|
||||
Reference in new issue
Block a user