阶段钩子(Stages)¶
在消息处理管道的固定点位插入自己的逻辑。阶段比工具更底层:工具是模型主动调用的,阶段是流程经过时必然触发的。
StageContext.IsResponded¶
plugin.go:342
StageContext.Lock¶
示例插件里的真实用法
| 插件 | 位置 | 代码 |
|---|---|---|
rtvoice |
example/rtvoice/plugin_test.go:29 |
r.mu.Lock() |
plugin.go:340
StageContext.RLock¶
plugin.go:338
StageContext.RUnlock¶
plugin.go:339
PluginSDK.RegisterStage¶
RegisterStage registers a handler for a pipeline stage.
scope: StageScopeGlobal (default) — receives all stage events.
StageScopeOwnTools — only before_toolcall/after_toolcall for this plugin's tools.
plugin.go:802
Stage¶
Stage represents a point in the message processing pipeline.
plugin.go:60
StageContext¶
type StageContext struct { mu sync.RWMutex RawMessage string UserID string GroupID string ContextMsgs []map[string]interface{} L …
StageContext provides context for stage handlers.
plugin.go:318
StageHandler¶
StageHandler is a function that handles a pipeline stage event.
plugin.go:57
StageRegistrar¶
StageRegistrar registers a stage handler.
plugin.go:582
StageScope¶
StageScope controls which events a stage handler receives.
plugin.go:568
StageContext.Unlock¶
示例插件里的真实用法
| 插件 | 位置 | 代码 |
|---|---|---|
rtvoice |
example/rtvoice/plugin_test.go:31 |
r.mu.Unlock() |
plugin.go:341