- plugin/types.go: Pool, EmailSender, JobHandlerFunc, Dependency, AdminPage, AIAction, MasterPageDefinition, status/source constants, MediaAnalyzedEvent, ModerationDecisionEvent, MediaHooksProvider, DirectoryExtensions - plugin/deps.go: ServiceDeps with typed capability interfaces (Content, Settings, Gating, Crypto, ToolRegistry, JobRunner, EmbeddingService, RAGService) - plugin/registration.go: PluginRegistration, RegisterFunc - plugin/service.go: ConnectServiceBinding with generics, ServiceMount, ServiceRegistration - plugin/provisioner.go: Provisioner interface with all config types - plugin/css_manifest.go: CSSManifest, MergedCSSManifest, MergeCSSManifests - plugin/version.go: ParseModVersion, CompareVersions - plugin/topo_sort.go: TopologicalSort (Kahn's algorithm) - plugin/block_registry.go: PluginBlockRegistry (auto-prefixing wrapper) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"connectrpc.com/connect"
|
|
"git.dev.alexdunmow.com/ninja/core/ai"
|
|
"git.dev.alexdunmow.com/ninja/core/content"
|
|
"git.dev.alexdunmow.com/ninja/core/crypto"
|
|
"git.dev.alexdunmow.com/ninja/core/gating"
|
|
"git.dev.alexdunmow.com/ninja/core/settings"
|
|
)
|
|
|
|
// ServiceDeps provides dependencies that plugins need for RPC service handlers.
|
|
type ServiceDeps struct {
|
|
// Capability interfaces — typed access to CMS functionality
|
|
Content content.Content
|
|
Settings settings.Settings
|
|
Gating gating.Gating
|
|
Crypto crypto.Crypto
|
|
|
|
// Database — for plugin's own sqlc queries
|
|
Pool Pool
|
|
|
|
// RPC interceptors — core-provided Connect handler options
|
|
Interceptors connect.Option
|
|
|
|
// Site configuration
|
|
MediaPath string
|
|
AppURL string
|
|
|
|
// AI
|
|
ToolRegistry ai.ToolRegistry
|
|
AITextCall func(ctx context.Context, taskKey, systemPrompt, userMessage string) (string, error)
|
|
|
|
// Email
|
|
EmailSender EmailSender
|
|
|
|
// Extension points — typed as narrow interfaces where possible
|
|
JobRunner JobRunner
|
|
EmbeddingService EmbeddingService
|
|
RAGService RAGService
|
|
}
|
|
|
|
// JobRunner submits background jobs for async processing.
|
|
type JobRunner interface {
|
|
Submit(ctx context.Context, jobType string, config []byte) error
|
|
}
|
|
|
|
// EmbeddingService generates and manages text embeddings.
|
|
type EmbeddingService interface {
|
|
GenerateEmbedding(ctx context.Context, text string) ([]float32, error)
|
|
}
|
|
|
|
// RAGService provides retrieval-augmented generation for AI agents.
|
|
type RAGService interface {
|
|
Query(ctx context.Context, query string, limit int) ([]RAGResult, error)
|
|
}
|
|
|
|
// RAGResult is a single result from a RAG query.
|
|
type RAGResult struct {
|
|
Content string
|
|
Score float64
|
|
Metadata map[string]string
|
|
}
|