Documentation
¶
Index ¶
- func Dir(cfg *config.Config, cfgPath string) string
- func GetEventsByIDs(ctx context.Context, store eventQuerier, ids []string) ([]*nostr.Event, error)
- func MatchInterceptREQ(subs []sdk.TrafficSubscription, filters []nostr.Filter) bool
- func MatchObserve(subs []sdk.TrafficSubscription, msg any) bool
- func MatchOnStoredEvent(subs []sdk.TrafficSubscription, kind int) bool
- type InstanceSnapshot
- type InterceptAction
- type InterceptLogEntry
- type InterceptLogSnapshot
- type InterceptResult
- type Manager
- func (m *Manager) AdminAction(ctx context.Context, id, name string, payload []byte) ([]byte, error)
- func (m *Manager) ApplySettings(ctx context.Context, id string, settings []byte) error
- func (m *Manager) Disable(id string) error
- func (m *Manager) Enable(id string) error
- func (m *Manager) EnqueueStoredEvent(ev *nostr.Event, stored bool)
- func (m *Manager) InstallLocal(src string, enable bool) (*Manifest, error)
- func (m *Manager) InstallURL(ctx context.Context, url, sha256hex string, enable bool) (*Manifest, error)
- func (m *Manager) InterceptLogSnapshot(id string) InterceptLogSnapshot
- func (m *Manager) InterceptREQ(ctx context.Context, req *nostr.ReqMessage) InterceptResult
- func (m *Manager) MetricsSnapshot() Metrics
- func (m *Manager) Observe(msg any)
- func (m *Manager) PersistConfig() error
- func (m *Manager) RecordInterceptLog(pluginID string, req *nostr.ReqMessage, res InterceptResult, fail string)
- func (m *Manager) SetInterceptLogLimit(n int) int
- func (m *Manager) Snapshot() []InstanceSnapshot
- func (m *Manager) Start(parent context.Context) error
- func (m *Manager) StartInterceptLogWorker(ctx context.Context)
- func (m *Manager) StatusJSON(ctx context.Context, id string) ([]byte, bool, error)
- func (m *Manager) Stop()
- func (m *Manager) UIDir(id string) string
- func (m *Manager) Uninstall(id string, wipeData bool) error
- type Manifest
- type Metrics
- type PluginHooks
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEventsByIDs ¶
GetEventsByIDs loads events and returns them in the same order as ids. Missing ids are skipped.
func MatchInterceptREQ ¶
func MatchInterceptREQ(subs []sdk.TrafficSubscription, filters []nostr.Filter) bool
MatchInterceptREQ reports whether any subscription wants a sync REQ intercept.
func MatchObserve ¶
func MatchObserve(subs []sdk.TrafficSubscription, msg any) bool
MatchObserve reports whether any subscription wants a listen copy of this inbound message.
func MatchOnStoredEvent ¶
func MatchOnStoredEvent(subs []sdk.TrafficSubscription, kind int) bool
MatchOnStoredEvent reports whether the plugin should be notified of an accepted event.
Types ¶
type InstanceSnapshot ¶
type InstanceSnapshot struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Enabled bool `json:"enabled"`
State string `json:"state"`
Ready bool `json:"ready"`
LastError string `json:"last_error,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
SourceURL string `json:"source_url,omitempty"`
SHA256 string `json:"sha256,omitempty"`
}
InstanceSnapshot is admin JSON for one plugin.
type InterceptAction ¶
type InterceptAction int
InterceptAction mirrors the SDK intercept decision.
const ( InterceptPassthrough InterceptAction = iota InterceptReshapeREQ InterceptRespond )
type InterceptLogEntry ¶
type InterceptLogEntry struct {
UnixMilli int64 `json:"unix_milli"`
DurationMs int64 `json:"duration_ms"`
SubID string `json:"sub_id"`
Filters []nostr.Filter `json:"filters"`
Action string `json:"action"`
EventIDs []string `json:"event_ids,omitempty"`
ReshapeFilters []nostr.Filter `json:"reshape_filters,omitempty"`
SubscriptionFilters []nostr.Filter `json:"subscription_filters,omitempty"`
Error string `json:"error,omitempty"`
}
InterceptLogEntry is one recorded intercept decision for admin UI.
type InterceptLogSnapshot ¶
type InterceptLogSnapshot struct {
Limit int `json:"limit"`
Dropped int64 `json:"dropped"`
Entries []InterceptLogEntry `json:"entries"`
}
InterceptLogSnapshot is the admin JSON for one plugin's intercept log.
type InterceptResult ¶
type InterceptResult struct {
Action InterceptAction
Filters []nostr.Filter
EventIDs []string
SubscriptionFilters []nostr.Filter
}
InterceptResult is returned to the relay REQ handler.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns plugin processes and implements Runtime.
func NewManager ¶
func NewManager(cfg *config.Config, cfgPath string, store storage.Store, log zerolog.Logger) *Manager
NewManager constructs a plugin manager. Call Start after host.sock is needed.
func (*Manager) AdminAction ¶
AdminAction invokes a plugin action.
func (*Manager) ApplySettings ¶
ApplySettings pushes settings to a running plugin and persists them on the item.
func (*Manager) EnqueueStoredEvent ¶
EnqueueStoredEvent implements Runtime.
func (*Manager) InstallLocal ¶
InstallLocal copies a directory that contains plugin.json.
func (*Manager) InstallURL ¶
func (m *Manager) InstallURL(ctx context.Context, url, sha256hex string, enable bool) (*Manifest, error)
InstallURL downloads, verifies sha256, and copies the package into the plugins dir. Re-installing the same plugin id stops the process, replaces bin/ui, keeps data/, runs hooks.update (or install if update is omitted), then optionally starts again.
func (*Manager) InterceptLogSnapshot ¶
func (m *Manager) InterceptLogSnapshot(id string) InterceptLogSnapshot
InterceptLogSnapshot returns newest-first intercept log rows for a plugin.
func (*Manager) InterceptREQ ¶
func (m *Manager) InterceptREQ(ctx context.Context, req *nostr.ReqMessage) InterceptResult
InterceptREQ implements Runtime. First non-passthrough wins (config order).
func (*Manager) MetricsSnapshot ¶
func (*Manager) PersistConfig ¶
PersistConfig writes cfg to cfgPath if set.
func (*Manager) RecordInterceptLog ¶
func (m *Manager) RecordInterceptLog(pluginID string, req *nostr.ReqMessage, res InterceptResult, fail string)
RecordInterceptLog injects a completed intercept decision. Never blocks. Used by tests.
func (*Manager) SetInterceptLogLimit ¶
SetInterceptLogLimit updates the host-wide rolling window and trims stored rows.
func (*Manager) Snapshot ¶
func (m *Manager) Snapshot() []InstanceSnapshot
Snapshot implements Runtime.
func (*Manager) Start ¶
Start listens on a shared host.sock (under root) and starts enabled plugins.
func (*Manager) StartInterceptLogWorker ¶
StartInterceptLogWorker starts the async intercept log goroutine without opening host.sock.
func (*Manager) StatusJSON ¶
StatusJSON returns the plugin Status RPC payload.
type Manifest ¶
type Manifest struct {
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
APIVersion int `json:"api_version"`
Exec map[string]string `json:"exec"`
Hooks PluginHooks `json:"hooks"`
}
Manifest is plugin.json in an installed package.
type Metrics ¶
type Metrics struct {
ListenEnqueued int64 `json:"listen_enqueued"`
ListenDropped int64 `json:"listen_dropped"`
InterceptN int64 `json:"intercept_n"`
InterceptPassthroughNotReady int64 `json:"plugin_intercept_passthrough_not_ready"`
InterceptPassthroughTimeout int64 `json:"plugin_intercept_passthrough_timeout"`
InterceptPassthroughError int64 `json:"plugin_intercept_passthrough_error"`
}
Metrics is a snapshot of plugin host counters.
type PluginHooks ¶
type PluginHooks struct {
Install []string `json:"install,omitempty"`
Update []string `json:"update,omitempty"`
Launch []string `json:"launch,omitempty"`
Uninstall []string `json:"uninstall,omitempty"`
}
PluginHooks are extra argv passed to the plugin exec after install, on package upgrade, before Serve, and before package delete. Example: "install": ["--hook=install"], "update": ["--hook=update"], "launch": ["--hook=launch"], "uninstall": ["--hook=uninstall"].
type Runtime ¶
type Runtime interface {
// Observe enqueues a listen-only copy. Never blocks the caller.
Observe(msg any)
// InterceptREQ is the only synchronous plugin call on the REQ path.
InterceptREQ(ctx context.Context, req *nostr.ReqMessage) InterceptResult
// EnqueueStoredEvent enqueues an accepted EVENT for index plugins. Never blocks.
// Called for WebSocket EVENT post-hooks and for NIP-77 imported events.
EnqueueStoredEvent(ev *nostr.Event, stored bool)
// Snapshot returns admin-facing plugin rows.
Snapshot() []InstanceSnapshot
}
Runtime is the relay-facing plugin surface. All methods are nil-safe on a nil Runtime.