This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/toolsrv/accessors.go

47 lines
1.5 KiB
Go

package toolsrv
import (
"context"
"ollie/skills"
)
// --- Exported accessors for builtin tool handlers ---
// CWD returns the current working directory for this server.
func (e *Server) CWD() string {
e.wdMu.RLock()
defer e.wdMu.RUnlock()
return e.cwd
}
// ToolRegistry returns the attached tool registry, or nil.
func (e *Server) ToolRegistry() *Registry { return e.toolRegistry }
// SessionID returns the session ID associated with this server.
func (e *Server) SessionID() string { return e.sessionID }
// SkillsRegistry returns the attached skills registry, or nil.
func (e *Server) SkillsRegistry() *skills.Registry { return e.skillsRegistry }
// InjectContent calls the OnInjection hook if set.
func (e *Server) InjectContent(content string) {
if e.OnInjection != nil {
e.OnInjection(content)
}
}
// SetOnToolsChanged sets the callback for tool directory changes.
func (e *Server) SetOnToolsChanged(fn func(string)) {
e.OnToolsChanged = fn
}
// ExecuteInSandbox runs a command in the sandbox. Exported for builtin tools.
func (e *Server) ExecuteInSandbox(ctx context.Context, cmd, language string, timeout int, sandbox string, trusted bool, stdin string, detach bool) (string, error) {
return e.executeWithStdin(ctx, cmd, language, timeout, sandbox, trusted, stdin, detach)
}
// ExecuteElevated runs a command outside the sandbox via the elevation broker.
func (e *Server) ExecuteElevated(ctx context.Context, cmd, dir string, timeout int, detach bool) (string, error) {
return e.executeElevated(ctx, cmd, dir, timeout, detach)
}