fix: correct OpenClaw plugin architecture - notifications as sole registration path

- Remove SKILL tool registration with nil handler (was causing nil
  pointer in StageHost.ExecuteTool)
- Rewrite loadOCPlugin: notifications are the only registration path.
  Synchronously drain all buffered register notifications after
  waitReady, then start persistent notifyLoop for future registrations.
  ListTools is verification-only, no longer registers tools.
- notifyLoop: persistent via for n := range sp.NotifyChan(), lifecycle
  bound to sidecar process
- StageHost.ExecuteTool: add nil-handler check (defense-in-depth)
- Remove unused OCNamedParam, DrainNotify from sidecar.go
This commit is contained in:
root
2026-07-04 14:32:39 +08:00
parent e273e746ea
commit 68a373ede0
3 changed files with 61 additions and 71 deletions

View File

@ -50,14 +50,6 @@ type OCNotification struct {
Params json.RawMessage `json:"params"`
}
// OCNamedParam 通知参数中至少包含 name 的结构
type OCNamedParam struct {
Type string `json:"type"`
Data *struct {
Name string `json:"name,omitempty"`
} `json:"data"`
}
type sidecarProcess struct {
name string
dir string
@ -313,17 +305,6 @@ func (s *sidecarProcess) CallTool(name string, args map[string]interface{}) (str
return sb, nil
}
// DrainNotify 排空通知通道
func (s *sidecarProcess) DrainNotify() {
for {
select {
case <-s.notifyCh:
default:
return
}
}
}
func (s *sidecarProcess) Close() {
s.mu.Lock()
if s.closed || s.stopped {