session wiring: use execute.SetToolRegistry instead of separate registry server

This commit is contained in:
lkn 2026-07-28 22:08:53 +02:00
parent b387b33593
commit 7c15f9ec3b
4 changed files with 11 additions and 15 deletions

View File

@ -21,7 +21,6 @@ import (
olog "ollie/pkg/log"
"ollie/pkg/paths"
"ollie/pkg/tools/execute"
"ollie/pkg/tools/registry"
fs "olliesrv/fs"
"olliesrv/mount"
"olliesrv/server"
@ -161,7 +160,7 @@ func runServer(sockPath string) {
sessionsDir := paths.DataDir() + "/sessions"
// Create the tool registry
toolRegistry, regErr := registry.NewRegistry()
toolRegistry, regErr := execute.NewRegistry()
if regErr != nil {
fmt.Fprintf(os.Stderr, "warning: tool registry: %v\n", regErr)
}
@ -337,7 +336,7 @@ func runServer(sockPath string) {
// ToolIndex generates a tool index from a tree's file listing.
// NewRootStore returns a read-only FileTree for synthetic root-level files.
func NewRootStore(reg *registry.Registry) *fs.Tree {
func NewRootStore(reg *execute.Registry) *fs.Tree {
helpPath := paths.CfgDir() + "/help.md"
readEntries := map[string]func() ([]byte, error){
"backends": func() ([]byte, error) {

View File

@ -16,10 +16,10 @@ import (
"time"
"ollie/pkg/backend"
"ollie/pkg/tools/execute"
"ollie/pkg/elevate"
olog "ollie/pkg/log"
"ollie/pkg/paths"
"ollie/pkg/tools/registry"
"olliesrv/fs"
"olliesrv/session"
@ -75,7 +75,7 @@ type Server struct {
groups map[string]map[string]bool // group → set of members
invalidateModels func()
toolPrompt func(string) string
toolRegistry *registry.Registry
toolRegistry *execute.Registry
}
// Config holds the pre-built trees and manager for the server.
@ -87,7 +87,7 @@ type Config struct {
InvalidateModels func()
ToolPrompt func(string) string
// ToolRegistry is the shared tool registry for lazy tool promotion.
ToolRegistry *registry.Registry
ToolRegistry *execute.Registry
}
// Option configures the 9P server.

View File

@ -21,7 +21,6 @@ import (
"ollie/pkg/remote"
"ollie/pkg/tools"
"ollie/pkg/tools/execute"
"ollie/pkg/tools/registry"
"olliesrv/fs"
"olliesrv/prompts"
)
@ -251,7 +250,7 @@ type ManagerConfig struct {
// InvalidateModels clears the model cache, forcing a refresh.
InvalidateModels func()
// ToolRegistry is the shared tool registry for lazy tool promotion.
ToolRegistry *registry.Registry
ToolRegistry *execute.Registry
// OnSessionCreated is called after a new session is added to the manager.
// Receives the session ID and the Session pointer.
OnSessionCreated func(id string, sess *Session)
@ -910,8 +909,7 @@ func (s *Manager) restoreSession(ps *agent.PersistedSession) error {
if s.cfg.ToolRegistry != nil {
if execSrv, ok := disp.GetServer("execute"); ok {
if es, ok := execSrv.(*execute.Server); ok {
regSrv := registry.NewServer(s.cfg.ToolRegistry, sessID, es)
disp.AddServer("registry", regSrv)
es.SetToolRegistry(s.cfg.ToolRegistry, sessID)
}
}
}
@ -1237,8 +1235,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
if s.cfg.ToolRegistry != nil {
if execSrv, ok := disp.GetServer("execute"); ok {
if es, ok := execSrv.(*execute.Server); ok {
regSrv := registry.NewServer(s.cfg.ToolRegistry, sessID, es)
disp.AddServer("registry", regSrv)
es.SetToolRegistry(s.cfg.ToolRegistry, sessID)
}
}
}

View File

@ -10,8 +10,8 @@ import (
"ollie/pkg/agent"
"ollie/pkg/backend"
"ollie/pkg/tools/execute"
olog "ollie/pkg/log"
"ollie/pkg/tools/registry"
"olliesrv/fs"
)
@ -53,7 +53,7 @@ func sessionFilePerms() map[string]os.FileMode {
return fs.Perms[fs.PathSessionFile].Files
}
func NewSessionTree(sess *Session, log *olog.Logger, kill func(), rename func(newID string) error, saveTranscript func([]byte) error, invalidateModels func(), toolRegistry *registry.Registry) *fs.Tree {
func NewSessionTree(sess *Session, log *olog.Logger, kill func(), rename func(newID string) error, saveTranscript func([]byte) error, invalidateModels func(), toolRegistry *execute.Registry) *fs.Tree {
h := &sessionHelper{sess: sess, log: log, kill: kill, rename: rename, saveTranscript: saveTranscript, invalidateModels: invalidateModels, toolRegistry: toolRegistry}
perms := sessionFilePerms()
specs := make([]fs.FileSpec, len(FileList))
@ -73,7 +73,7 @@ type sessionHelper struct {
rename func(newID string) error
saveTranscript func([]byte) error
invalidateModels func()
toolRegistry *registry.Registry
toolRegistry *execute.Registry
}
func (h *sessionHelper) fileSpec(name string, mode os.FileMode) fs.FileSpec {