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>
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package caps
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
abiv1 "git.dev.alexdunmow.com/block/core/abi/v1"
|
|
"git.dev.alexdunmow.com/block/core/settings"
|
|
)
|
|
|
|
// settingsStub implements both settings.Settings and settings.Updater over
|
|
// settings.* capability calls. One instance backs both CoreServices fields.
|
|
type settingsStub struct{ base }
|
|
|
|
var (
|
|
_ settings.Settings = (*settingsStub)(nil)
|
|
_ settings.Updater = (*settingsStub)(nil)
|
|
)
|
|
|
|
func (s *settingsStub) GetSiteSettings(ctx context.Context) (map[string]any, error) {
|
|
resp := &abiv1.SettingsGetSiteSettingsResponse{}
|
|
if err := s.invoke(ctx, "get_site_settings", &abiv1.SettingsGetSiteSettingsRequest{}, resp); err != nil {
|
|
return nil, err
|
|
}
|
|
return unmarshalMap(resp.GetSettingsJson()), nil
|
|
}
|
|
|
|
func (s *settingsStub) GetPluginSettings(ctx context.Context, pluginName string) (map[string]any, error) {
|
|
resp := &abiv1.SettingsGetPluginSettingsResponse{}
|
|
req := &abiv1.SettingsGetPluginSettingsRequest{PluginName: pluginName}
|
|
if err := s.invoke(ctx, "get_plugin_settings", req, resp); err != nil {
|
|
return nil, err
|
|
}
|
|
return unmarshalMap(resp.GetSettingsJson()), nil
|
|
}
|
|
|
|
func (s *settingsStub) UpdateSiteSetting(ctx context.Context, key string, value any) error {
|
|
valueJSON, err := json.Marshal(value)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
req := &abiv1.SettingsUpdateSiteSettingRequest{Key: key, ValueJson: valueJSON}
|
|
return s.invoke(ctx, "update_site_setting", req, &abiv1.SettingsUpdateSiteSettingResponse{})
|
|
}
|
|
|
|
func (s *settingsStub) UpdatePluginSettings(ctx context.Context, pluginName string, settingsMap map[string]any) error {
|
|
settingsJSON, err := json.Marshal(settingsMap)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
req := &abiv1.SettingsUpdatePluginSettingsRequest{PluginName: pluginName, SettingsJson: settingsJSON}
|
|
return s.invoke(ctx, "update_plugin_settings", req, &abiv1.SettingsUpdatePluginSettingsResponse{})
|
|
}
|