其他类型¶
剩余的类型与方法:PluginSDK 本体的访问器、StageContext 的并发控制,以及多模态辅助类型。没有归入上面任何一个主题,但可能仍会用到。
DocMemoryAPI¶
DocMemoryAPI provides access to the document vector store.
| 方法 | 说明 |
|---|---|
Insert |
|
InsertWithMedia |
InsertWithMedia 写入文档并关联媒体。attachments 里带 Data 的会落进 |
Query |
|
Remove |
|
Stats |
DocMemoryAPI.Insert¶
memory.go:76
DocMemoryAPI.InsertWithMedia¶
InsertWithMedia 写入文档并关联媒体。attachments 里带 Data 的会落进 内容寻址存储(相同字节只存一份),只带 Digest 的直接引用已有内容。 媒体成为文档直接持有的一等记忆块:文档向量会融合它们的原生向量, 因此图片按自己的向量被召回,不依赖任何生成的描述文本。
memory.go:81
DocMemoryAPI.Query¶
memory.go:75
DocMemoryAPI.Remove¶
memory.go:82
DocMemoryAPI.Stats¶
memory.go:83
EventSubscriber¶
EventSubscriber allows plugins to subscribe to kernel events. This is a restricted interface: plugins can subscribe but the kernel controls which events are delivered.
| 方法 | 说明 |
|---|---|
Subscribe |
EventSubscriber.Subscribe¶
仅内核内置插件可用
plugin.go:279
IOInjector¶
IOInjector provides methods for injecting input and interrupts into the agent pipeline. All methods accept (source, channel) where channel is the target output channel for routing the agent's response.
| 方法 | 说明 |
|---|---|
InjectInputMedia |
|
InjectInputMediaOpts |
|
InjectInputMediaSync |
|
InjectInputMediaSyncOpts |
|
InjectInputSync |
InjectInputSync 注入输入事件并同步等待 agent 回复,返回回复文本(无回复时返回空串)。 |
InjectInputSyncOpts |
|
InjectInterruptMedia |
|
InjectInterruptMediaOpts |
|
InjectInterruptText |
|
InjectInterruptTextOpts |
|
InjectText |
|
InjectTextNoMemory |
|
InjectTextOpts |
以下 Opts 变体让调用点在这一次注入上声明记忆与裁剪行为。 |
SetToolBlocks |
SetToolBlocks 插件工具注入多模态内容块(image_url/audio_url),内核在下一条 |
IOInjector.InjectInputMedia¶
plugin.go:230
IOInjector.InjectInputMediaOpts¶
plugin.go:241
IOInjector.InjectInputMediaSync¶
plugin.go:231
IOInjector.InjectInputMediaSyncOpts¶
InjectInputMediaSyncOpts(source, channel, text string, blocks []ContentBlock, opts InjectOptions) string
plugin.go:242
IOInjector.InjectInputSync¶
InjectInputSync 注入输入事件并同步等待 agent 回复,返回回复文本(无回复时返回空串)。 用于通道消息的完整闭环:收到入站 → agent 处理 → 回复取回 → 送回通道。
示例插件里的真实用法
| 插件 | 位置 | 代码 |
|---|---|---|
a2a |
example/a2a/plugin.go:345 |
reply := p.sdk.InjectInputSync(p.name, p.name, |
acp |
example/acp/plugin.go:237 |
reply = p.sdk.InjectInputSync(p.name, p.name, |
plugin.go:226
IOInjector.InjectInputSyncOpts¶
plugin.go:240
IOInjector.InjectInterruptMedia¶
plugin.go:232
IOInjector.InjectInterruptMediaOpts¶
plugin.go:243
IOInjector.InjectInterruptText¶
plugin.go:221
IOInjector.InjectInterruptTextOpts¶
示例插件里的真实用法
| 插件 | 位置 | 代码 |
|---|---|---|
browser |
example/browser/plugin.go:1319 |
p.sdk.InjectInterruptTextOpts(p.name, p.name, |
calendar |
example/calendar/plugin.go:527 |
p.sdk.InjectInterruptTextOpts("calendar", "calendar", msg, sdk.InjectOptions{NoMemory: true}) |
memo |
example/memo/plugin.go:299 |
p.sdk.InjectInterruptTextOpts(p.name, p.name, |
qq |
example/qq/plugin.go:1493 |
p.sdk.InjectInterruptTextOpts(p.name, p.name, text, sdk.InjectOptions{ |
plugin.go:239
IOInjector.InjectText¶
plugin.go:222
IOInjector.InjectTextNoMemory¶
示例插件里的真实用法
| 插件 | 位置 | 代码 |
|---|---|---|
browser |
example/browser/plugin.go:1114 |
p.sdk.InjectTextNoMemory(p.name, p.name, fmt.Sprintf("[浏览器 %s 已导航到 %s]", id, rawURL)) |
plugin.go:223
IOInjector.InjectTextOpts¶
以下 Opts 变体让调用点在这一次注入上声明记忆与裁剪行为。
上面那些不带 opts 的方法等价于传零值 InjectOptions(记入记忆 + 不裁剪), 保留它们是为了不破坏已有插件;新代码应当用 Opts 变体把意图写清楚。
plugin.go:238
IOInjector.SetToolBlocks¶
SetToolBlocks 插件工具注入多模态内容块(image_url/audio_url),内核在下一条 tool message 的 content 数组里带上这些块,让模型在后续轮次看到图/听到音频。
plugin.go:229
KnowledgeAPI¶
KnowledgeAPI provides access to the knowledge store.
| 方法 | 说明 |
|---|---|
Add |
|
List |
|
Search |
KnowledgeAPI.Add¶
knowledge.go:6
KnowledgeAPI.List¶
knowledge.go:7
KnowledgeAPI.Search¶
knowledge.go:5
LLMAPI¶
LLMAPI provides access to the LLM provider manager.
| 方法 | 说明 |
|---|---|
CurrentSource |
|
ListSources |
|
SetSource |
LLMAPI.CurrentSource¶
llm.go:7
LLMAPI.ListSources¶
llm.go:5
LLMAPI.SetSource¶
llm.go:6
MemoryAPI¶
MemoryAPI provides access to the graph memory (entity-relation store).
| 方法 | 说明 |
|---|---|
Commit |
|
Introspect |
|
MergeEntities |
|
Purge |
|
Recall |
MemoryAPI.Commit¶
memory.go:6
MemoryAPI.Introspect¶
memory.go:7
MemoryAPI.MergeEntities¶
memory.go:8
MemoryAPI.Purge¶
memory.go:9
MemoryAPI.Recall¶
memory.go:5
Plugin¶
Plugin is the interface every plugin must implement.
| 方法 | 说明 |
|---|---|
Name |
|
Start |
|
Stop |
Plugin.Name¶
plugin.go:14
Plugin.Start¶
plugin.go:15
Plugin.Stop¶
plugin.go:16
PluginMgrAPI¶
PluginMgrAPI 提供插件管理能力(外部插件可调用)。 由 bridge 注入 dispatch 实现,走 C ABI CORE_PLUGIN_RELOAD_ONE 等。
| 方法 | 说明 |
|---|---|
IsPluginDisabled |
IsPluginDisabled 查询插件是否被禁用。 |
ListLoadedPlugins |
ListLoadedPlugins 列出已加载插件。 |
ReloadOne |
ReloadOne 重载单个插件(停止后重新加载)。 |
PluginMgrAPI.IsPluginDisabled¶
IsPluginDisabled 查询插件是否被禁用。
plugin.go:290
PluginMgrAPI.ListLoadedPlugins¶
ListLoadedPlugins 列出已加载插件。
plugin.go:288
PluginMgrAPI.ReloadOne¶
ReloadOne 重载单个插件(停止后重新加载)。
plugin.go:286
SettingsAPI¶
| 方法 | 说明 |
|---|---|
DataDir |
DataDir returns the plugin-specific data directory (guaranteed to exist): |
Defs |
Defs returns config definitions matching the prefix. |
Dump |
Dump returns all config values. |
Get |
Get reads the plugin's own config value (config_ |
GetCore |
GetCore reads the core config table. |
GetPlugin |
GetPlugin reads another plugin's config table. |
List |
List returns all keys matching the given prefix. |
ListCore |
ListCore lists core config keys matching the prefix. |
ListPlugin |
ListPlugin lists another plugin's config keys matching the prefix. |
Plugins |
Plugins returns a list of all plugin config namespaces. |
RegisterDef |
RegisterDef registers a config definition for UI display. |
Set |
Set writes a config value to the plugin's own config table. |
SetCore |
SetCore writes to the core config table. |
SetPlugin |
SetPlugin writes to another plugin's config table. |
SettingsAPI.DataDir¶
DataDir returns the plugin-specific data directory (guaranteed to exist):
settings.go:25
SettingsAPI.Defs¶
Defs returns config definitions matching the prefix.
settings.go:40
SettingsAPI.Dump¶
Dump returns all config values.
settings.go:43
SettingsAPI.Get¶
Get reads the plugin's own config value (config_
settings.go:5
SettingsAPI.GetCore¶
GetCore reads the core config table.
settings.go:14
SettingsAPI.GetPlugin¶
GetPlugin reads another plugin's config table.
settings.go:28
SettingsAPI.List¶
List returns all keys matching the given prefix.
settings.go:11
SettingsAPI.ListCore¶
ListCore lists core config keys matching the prefix.
settings.go:20
SettingsAPI.ListPlugin¶
ListPlugin lists another plugin's config keys matching the prefix.
settings.go:34
SettingsAPI.Plugins¶
Plugins returns a list of all plugin config namespaces.
settings.go:46
SettingsAPI.RegisterDef¶
RegisterDef registers a config definition for UI display.
settings.go:37
SettingsAPI.Set¶
Set writes a config value to the plugin's own config table.
settings.go:8
SettingsAPI.SetCore¶
SetCore writes to the core config table.
settings.go:17
SettingsAPI.SetPlugin¶
SetPlugin writes to another plugin's config table.
settings.go:31
SocialAPI¶
SocialAPI provides read-only access to the social graph (person profiles and relationships). External plugins can query person traits and social networks but cannot modify them.
| 方法 | 说明 |
|---|---|
GetNetwork |
|
GetPerson |
|
GetRelations |
|
GetTrait |
|
ListPersons |
SocialAPI.GetNetwork¶
memory.go:104
SocialAPI.GetPerson¶
memory.go:101
SocialAPI.GetRelations¶
memory.go:103
SocialAPI.GetTrait¶
memory.go:102
SocialAPI.ListPersons¶
memory.go:105
TextMemoryAPI¶
TextMemoryAPI provides access to chronological text event storage.
| 方法 | 说明 |
|---|---|
Append |
TextMemoryAPI.Append¶
memory.go:44
AudioURL¶
plugin.go:862
ImageURL¶
plugin.go:857
MemItem¶
type MemItem struct { Role string `json:"role"` Content string `json:"content"` Score float64 `json:"score"` }
MemItem represents a memory item in stage context.
plugin.go:179
PluginSDK¶
type PluginSDK struct { name string regTool ToolRegistrar regStage StageRegistrar regAPI APIRegistrar regOutput OutputChannelRegistrar …
PluginSDK is the main API surface provided to plugins at runtime. It wraps tool registration, settings, memory, knowledge, LLM, and IO injection.
plugin.go:337
SDKVersion¶
SDKVersion 是对外暴露的 SDK 版本号。
plugin.go:10
PluginSDK.UnregisterOutputChannel¶
仅内核内置插件可用
外部插件的桥接模板只注入 SetOutputChannelRegistrar(proc_main.go.tmpl:693-705),未注入 SetOutputChannelUnregistrar(grep Unregistrar 在 templates/ 下无命中)。因此外部插件的 regOutputUnreg 为 nil,UnregisterOutputChannel 会命中 if reg != nil 的 else 分支直接返回 nil(sdk/plugin.go:539-549)——即静默无效:不报错、通道也没注销。内置插件由 internal/sdk/plugin.go:330 注入 cfg.RegOutputUnreg,真正生效。外部插件要让通道下线,只能重载插件。
UnregisterOutputChannel 注销一个输出通道(动态通道随资源生灭时必须调用)。
plugin.go:539