update for execute/ → tools/ merge
Use tools.Runner, tools.New, tools.Decl etc. Remove ollie/execute import.
This commit is contained in:
parent
72747b887d
commit
e04aa1c69f
14
main_test.go
14
main_test.go
|
|
@ -35,7 +35,7 @@ func newNoopCore(id string) *session.Session {
|
||||||
NewBackend: func(name string) (backend.Backend, error) {
|
NewBackend: func(name string) (backend.Backend, error) {
|
||||||
return backend.NewNoop(name, "default"), nil
|
return backend.NewNoop(name, "default"), nil
|
||||||
},
|
},
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ func newBlockingCore(id string) *session.Session {
|
||||||
NewBackend: func(name string) (backend.Backend, error) {
|
NewBackend: func(name string) (backend.Backend, error) {
|
||||||
return backend.NewNoop(name, "default"), nil
|
return backend.NewNoop(name, "default"), nil
|
||||||
},
|
},
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ func newContentCore(id, content string) *session.Session {
|
||||||
NewBackend: func(name string) (backend.Backend, error) {
|
NewBackend: func(name string) (backend.Backend, error) {
|
||||||
return backend.NewNoop(name, "default"), nil
|
return backend.NewNoop(name, "default"), nil
|
||||||
},
|
},
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ func newTestSessionManagerWithCore(t *testing.T) *mgr.Manager {
|
||||||
NewBackend: func(name string) (backend.Backend, error) {
|
NewBackend: func(name string) (backend.Backend, error) {
|
||||||
return backend.NewNoop(name, "default"), nil
|
return backend.NewNoop(name, "default"), nil
|
||||||
},
|
},
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
}), nil
|
}), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -864,7 +864,7 @@ func TestSessionFileStoreMakePublishMultipleEvents(t *testing.T) {
|
||||||
AgentName: "default",
|
AgentName: "default",
|
||||||
CWD: "/tmp",
|
CWD: "/tmp",
|
||||||
SessionID: "s1",
|
SessionID: "s1",
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
})
|
})
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
@ -1160,7 +1160,7 @@ func TestSessionManagerCreateSessionEnvExpansion(t *testing.T) {
|
||||||
AgentName: agentName,
|
AgentName: agentName,
|
||||||
CWD: cwd,
|
CWD: cwd,
|
||||||
SessionID: sessionID,
|
SessionID: sessionID,
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
}), nil
|
}), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -1185,7 +1185,7 @@ func TestSessionManagerCreateSessionTildeExpansion(t *testing.T) {
|
||||||
AgentName: agentName,
|
AgentName: agentName,
|
||||||
CWD: cwd,
|
CWD: cwd,
|
||||||
SessionID: sessionID,
|
SessionID: sessionID,
|
||||||
NewToolServer: func() tools.Server { return nil },
|
NewToolServer: func() tools.Runner { return nil },
|
||||||
}), nil
|
}), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"ollie/backend"
|
"ollie/backend"
|
||||||
"ollie/execute"
|
|
||||||
"ollie/paths"
|
|
||||||
"ollie/tools"
|
"ollie/tools"
|
||||||
|
"ollie/paths"
|
||||||
"olliesrv/fs"
|
"olliesrv/fs"
|
||||||
"olliesrv/prompts"
|
"olliesrv/prompts"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -111,47 +110,47 @@ func (s *Manager) CreateSession(args []string) (string, error) {
|
||||||
return "", fmt.Errorf("sessions dir: %w", err)
|
return "", fmt.Errorf("sessions dir: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var execOpts []execute.Option
|
var execOpts []tools.Option
|
||||||
if !s.cfg.NoMount {
|
if !s.cfg.NoMount {
|
||||||
}
|
}
|
||||||
if s.cfg.Strict {
|
if s.cfg.Strict {
|
||||||
execOpts = append(execOpts, execute.WithStrict())
|
execOpts = append(execOpts, tools.WithStrict())
|
||||||
}
|
}
|
||||||
if s.cfg.Yolo {
|
if s.cfg.Yolo {
|
||||||
execOpts = append(execOpts, execute.WithYolo())
|
execOpts = append(execOpts, tools.WithYolo())
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg != nil && len(cfg.AllowTools) > 0 {
|
if cfg != nil && len(cfg.AllowTools) > 0 {
|
||||||
execOpts = append(execOpts, execute.WithAllowTools(cfg.AllowTools))
|
execOpts = append(execOpts, tools.WithAllowTools(cfg.AllowTools))
|
||||||
}
|
}
|
||||||
if s.cfg.ToolRegistry != nil {
|
if s.cfg.ToolRegistry != nil {
|
||||||
execOpts = append(execOpts, execute.WithToolRegistry(s.cfg.ToolRegistry, sessID))
|
execOpts = append(execOpts, tools.WithToolRegistry(s.cfg.ToolRegistry, sessID))
|
||||||
}
|
}
|
||||||
if s.cfg.SkillsRegistry != nil {
|
if s.cfg.SkillsRegistry != nil {
|
||||||
execOpts = append(execOpts, execute.WithSkillsRegistry(s.cfg.SkillsRegistry))
|
execOpts = append(execOpts, tools.WithSkillsRegistry(s.cfg.SkillsRegistry))
|
||||||
}
|
}
|
||||||
var newToolServer func() tools.Server
|
var newToolServer func() tools.Runner
|
||||||
var remoteEnv []string // extra env vars from remote host info
|
var remoteEnv []string // extra env vars from remote host info
|
||||||
if remoteTarget != "" {
|
if remoteTarget != "" {
|
||||||
// Dial eagerly so we get HostInfo for prompt resolution.
|
// Dial eagerly so we get HostInfo for prompt resolution.
|
||||||
// FIXME: Eager dial means session creation blocks on SSH connect.
|
// FIXME: Eager dial means session creation blocks on SSH connect.
|
||||||
// Eventually make this async or move host info into the prompt
|
// Eventually make this async or move host info into the prompt
|
||||||
// scripts themselves (running remotely via the RPC).
|
// scripts themselves (running remotely via the RPC).
|
||||||
rsrv, dialErr := execute.RemoteDial(s.cfg.Ctx, execute.RemoteConfig{
|
rsrv, dialErr := tools.RemoteDial(s.cfg.Ctx, tools.RemoteConfig{
|
||||||
SSHTarget: remoteTarget,
|
SSHTarget: remoteTarget,
|
||||||
CWD: cwd,
|
CWD: cwd,
|
||||||
})
|
})
|
||||||
if dialErr != nil {
|
if dialErr != nil {
|
||||||
return "", fmt.Errorf("remote dial: %w", dialErr)
|
return "", fmt.Errorf("remote dial: %w", dialErr)
|
||||||
}
|
}
|
||||||
newToolServer = func() tools.Server { return rsrv }
|
newToolServer = func() tools.Runner { return rsrv }
|
||||||
remoteEnv = []string{
|
remoteEnv = []string{
|
||||||
"PRIME_CWD=" + cwd,
|
"PRIME_CWD=" + cwd,
|
||||||
"PRIME_PLATFORM=" + rsrv.Info.Platform,
|
"PRIME_PLATFORM=" + rsrv.Info.Platform,
|
||||||
"PRIME_IS_GIT_REPO=" + fmt.Sprintf("%v", rsrv.Info.IsGitRepo),
|
"PRIME_IS_GIT_REPO=" + fmt.Sprintf("%v", rsrv.Info.IsGitRepo),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newToolServer = execute.Decl(cwd, execOpts...)
|
newToolServer = tools.Decl(cwd, execOpts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
var promptEnv []string
|
var promptEnv []string
|
||||||
|
|
@ -229,7 +228,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
|
||||||
sessPtr = sess
|
sessPtr = sess
|
||||||
sess.remote = remoteTarget
|
sess.remote = remoteTarget
|
||||||
|
|
||||||
// For remote sessions, the mount isn't managed by a local execute.Server
|
// For remote sessions, the mount isn't managed by a local tools.Server
|
||||||
// (which doesn't exist). Start it directly so $OLLIE is available for
|
// (which doesn't exist). Start it directly so $OLLIE is available for
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
sess.uname = uname
|
sess.uname = uname
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"ollie/backend"
|
"ollie/backend"
|
||||||
"ollie/execute"
|
|
||||||
"ollie/tools"
|
"ollie/tools"
|
||||||
"olliesrv/prompts"
|
"olliesrv/prompts"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -132,41 +131,41 @@ func (s *Manager) restoreSession(ps *agent.PersistedAgent) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
uname := s.nextUname()
|
uname := s.nextUname()
|
||||||
var newToolServer func() tools.Server
|
var newToolServer func() tools.Runner
|
||||||
var promptEnv []string
|
var promptEnv []string
|
||||||
remoteTarget := ps.Remote
|
remoteTarget := ps.Remote
|
||||||
|
|
||||||
if remoteTarget != "" {
|
if remoteTarget != "" {
|
||||||
rsrv, dialErr := execute.RemoteDial(s.cfg.Ctx, execute.RemoteConfig{
|
rsrv, dialErr := tools.RemoteDial(s.cfg.Ctx, tools.RemoteConfig{
|
||||||
SSHTarget: remoteTarget,
|
SSHTarget: remoteTarget,
|
||||||
CWD: cwd,
|
CWD: cwd,
|
||||||
})
|
})
|
||||||
if dialErr != nil {
|
if dialErr != nil {
|
||||||
return fmt.Errorf("remote dial: %w", dialErr)
|
return fmt.Errorf("remote dial: %w", dialErr)
|
||||||
}
|
}
|
||||||
newToolServer = func() tools.Server { return rsrv }
|
newToolServer = func() tools.Runner { return rsrv }
|
||||||
promptEnv = []string{
|
promptEnv = []string{
|
||||||
"PRIME_CWD=" + cwd,
|
"PRIME_CWD=" + cwd,
|
||||||
"PRIME_PLATFORM=" + rsrv.Info.Platform,
|
"PRIME_PLATFORM=" + rsrv.Info.Platform,
|
||||||
"PRIME_IS_GIT_REPO=" + fmt.Sprintf("%v", rsrv.Info.IsGitRepo),
|
"PRIME_IS_GIT_REPO=" + fmt.Sprintf("%v", rsrv.Info.IsGitRepo),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var execOpts []execute.Option
|
var execOpts []tools.Option
|
||||||
if !s.cfg.NoMount {
|
if !s.cfg.NoMount {
|
||||||
}
|
}
|
||||||
if s.cfg.Strict {
|
if s.cfg.Strict {
|
||||||
execOpts = append(execOpts, execute.WithStrict())
|
execOpts = append(execOpts, tools.WithStrict())
|
||||||
}
|
}
|
||||||
if s.cfg.Yolo {
|
if s.cfg.Yolo {
|
||||||
execOpts = append(execOpts, execute.WithYolo())
|
execOpts = append(execOpts, tools.WithYolo())
|
||||||
}
|
}
|
||||||
if s.cfg.ToolRegistry != nil {
|
if s.cfg.ToolRegistry != nil {
|
||||||
execOpts = append(execOpts, execute.WithToolRegistry(s.cfg.ToolRegistry, sessID))
|
execOpts = append(execOpts, tools.WithToolRegistry(s.cfg.ToolRegistry, sessID))
|
||||||
}
|
}
|
||||||
if s.cfg.SkillsRegistry != nil {
|
if s.cfg.SkillsRegistry != nil {
|
||||||
execOpts = append(execOpts, execute.WithSkillsRegistry(s.cfg.SkillsRegistry))
|
execOpts = append(execOpts, tools.WithSkillsRegistry(s.cfg.SkillsRegistry))
|
||||||
}
|
}
|
||||||
newToolServer = execute.Decl(cwd, execOpts...)
|
newToolServer = tools.Decl(cwd, execOpts...)
|
||||||
promptEnv = agent.PromptEnv(cwd)
|
promptEnv = agent.PromptEnv(cwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue