core/settings/settings.go
Alex Dunmow 9e39119555 feat(abi): injection-complete capability surface — provisioner family, content authoring, 4 callback hooks (WO-WZ-019)
Dynamic families added to the ABI + guest SDK:
- provisioner.* (14 methods, 1:1 plugin.Provisioner): wasm provisioning was
  silently dead (RegisterWithProvisioner got a noopProvisioner and the cms
  loader ignored has_provisioner). Now a LOAD-TIME capability via the new
  CoreServices.Provisioner field; EnsureEmbed rejects RenderFunc-only embeds.
- content.* writes (content.Author + CoreServices.ContentAuthor):
  create_page, set_page_blocks, publish_page, set_page_seo, upsert_post.
- settings.update_plugin_settings (settings.Updater grows the method).
- bridge.invoke + plugin.BridgeInvokable: opaque-payload cross-plugin calls
  (typed GetService still returns nil across the sandbox by design).
- jobs.progress: HOOK_JOB handlers' progress() now crosses (was discarded).

New host→guest hooks: HOOK_AI_TOOL_CALL (executes recorded ai.ToolDefinition
handlers — registers tools in Register so every pooled instance has them),
HOOK_BRIDGE_CALL, HOOK_DIRECTORY_PANEL_SECTION, HOOK_DIRECTORY_PIN_DECORATOR.
The ai/bridge stubs now record handlers/values locally in addition to
forwarding names.

buf breaking clean (additive within ABI major 1); golden round-trips added
for the new families (cms host replays the same goldens).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 10:02:21 +08:00

54 lines
1.6 KiB
Go

package settings
import "context"
// Settings provides settings access for plugins.
type Settings interface {
GetSiteSettings(ctx context.Context) (map[string]any, error)
GetPluginSettings(ctx context.Context, pluginName string) (map[string]any, error)
}
// Updater allows plugins to modify site settings and their own plugin
// settings.
type Updater interface {
UpdateSiteSetting(ctx context.Context, key string, value any) error
// UpdatePluginSettings replaces the plugin's own settings map. Across the
// wasm ABI the host enforces that pluginName matches the calling plugin.
UpdatePluginSettings(ctx context.Context, pluginName string, settings map[string]any) error
}
// GetStringOr returns a string value from a map, or defaultVal if not found/wrong type.
func GetStringOr(m map[string]any, key, defaultVal string) string {
if v, ok := m[key].(string); ok {
return v
}
return defaultVal
}
// GetBoolOr returns a bool value from a map, or defaultVal if not found/wrong type.
func GetBoolOr(m map[string]any, key string, defaultVal bool) bool {
if v, ok := m[key].(bool); ok {
return v
}
return defaultVal
}
// GetIntOr returns an int value from a map, handling both int and float64 (JSON numbers).
func GetIntOr(m map[string]any, key string, defaultVal int) int {
if v, ok := m[key].(float64); ok {
return int(v)
}
if v, ok := m[key].(int); ok {
return v
}
return defaultVal
}
// GetFloat64Or returns a float64 value from a map, or defaultVal if not found/wrong type.
func GetFloat64Or(m map[string]any, key string, defaultVal float64) float64 {
if v, ok := m[key].(float64); ok {
return v
}
return defaultVal
}