mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
【SDK DataDir API】
- SettingsAPI 新增 DataDir() string:返回插件专属数据目录
<data>/plugin_data/<name>(内核保证存在),解决此前插件只能
靠 GetCore("daemon.data_dir") 手工解析的缺陷
- settingsImpl 新增 dataDir 字段 + SetDataDir;Registry buildSDK
注入(<data>/plugin_data/<name> 并 MkdirAll);main.go 接线
- cabi 新增 CORE_SETTINGS_DATA_DIR (id 51);plugindev dispatchSettings
模板补 DataDir() 实现
【ai_image 交付本地路径】
- 生成后下载临时 S3 URL 到插件数据目录,返回本地文件路径(永久不
过期),而非 1 小时过期的 S3 URL。带 UA 规避图床对无 UA 客户端拦截
(此前 agent 裸 curl 验证被拒导致误报失败)
- 返回 local_paths 字段 + 提示用 output_send(type=image) 展示
端到端:ai_image_generate → plugin_data/ai_image/*.png 有效 PNG(1024²),
经 llmsproxy→siliconflow 生成。
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
package sdk
|
|
|
|
type SettingsAPI interface {
|
|
// Get reads the plugin's own config value (config_<name> table).
|
|
Get(key string) (interface{}, error)
|
|
|
|
// Set writes a config value to the plugin's own config table.
|
|
Set(key string, value interface{}) error
|
|
|
|
// List returns all keys matching the given prefix.
|
|
List(prefix string) ([]string, error)
|
|
|
|
// GetCore reads the core config table.
|
|
GetCore(key string) (interface{}, error)
|
|
|
|
// SetCore writes to the core config table.
|
|
SetCore(key string, value interface{}) error
|
|
|
|
// ListCore lists core config keys matching the prefix.
|
|
ListCore(prefix string) ([]string, error)
|
|
|
|
// DataDir returns the plugin-specific data directory (guaranteed to exist):
|
|
// <daemon data>/plugin_data/<plugin_name>. Plugins should persist any
|
|
// runtime files (generated images, caches, downloads) here.
|
|
DataDir() string
|
|
|
|
// GetPlugin reads another plugin's config table.
|
|
GetPlugin(plugin, key string) (interface{}, error)
|
|
|
|
// SetPlugin writes to another plugin's config table.
|
|
SetPlugin(plugin, key string, value interface{}) error
|
|
|
|
// ListPlugin lists another plugin's config keys matching the prefix.
|
|
ListPlugin(plugin, prefix string) ([]string, error)
|
|
|
|
// RegisterDef registers a config definition for UI display.
|
|
RegisterDef(def ConfigDef)
|
|
|
|
// Defs returns config definitions matching the prefix.
|
|
Defs(prefix string) []*ConfigDef
|
|
|
|
// Dump returns all config values.
|
|
Dump() map[string]interface{}
|
|
|
|
// Plugins returns a list of all plugin config namespaces.
|
|
Plugins() []string
|
|
}
|
|
|
|
// ConfigDef describes a configuration field for the WebUI.
|
|
type ConfigDef struct {
|
|
Key string `json:"key"`
|
|
Default interface{} `json:"default,omitempty"`
|
|
Type string `json:"type"`
|
|
DisplayName string `json:"display_name"`
|
|
Description string `json:"description,omitempty"`
|
|
Category string `json:"category,omitempty"`
|
|
Options []string `json:"options,omitempty"`
|
|
Min float64 `json:"min,omitempty"`
|
|
Max float64 `json:"max,omitempty"`
|
|
Step float64 `json:"step,omitempty"`
|
|
Required bool `json:"required,omitempty"`
|
|
Secret bool `json:"secret,omitempty"`
|
|
}
|