delete Decl/RemoteDecl — callers use New() directly
This commit is contained in:
parent
4ac5fc94be
commit
47141c764d
|
|
@ -421,38 +421,3 @@ func shellEscape(s string) string {
|
|||
return "'" + strings.ReplaceAll(s, "'", "'\\''") + "'"
|
||||
}
|
||||
|
||||
// Decl returns a factory function for remote tool servers.
|
||||
// It dials the remote on first call and returns a Runner.
|
||||
func RemoteDecl(cfg RemoteConfig) func() Runner {
|
||||
var (
|
||||
once sync.Once
|
||||
server *RemoteServer
|
||||
err error
|
||||
)
|
||||
return func() Runner {
|
||||
once.Do(func() {
|
||||
server, err = RemoteDial(context.Background(), cfg)
|
||||
if err != nil {
|
||||
// Return a stub that errors on every call
|
||||
server = nil
|
||||
}
|
||||
})
|
||||
if server == nil {
|
||||
return &errRunner{err: err}
|
||||
}
|
||||
return server
|
||||
}
|
||||
}
|
||||
|
||||
// errRunner is a Runner that returns an error for every call.
|
||||
type errRunner struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (e *errRunner) ListTools() ([]ToolInfo, error) {
|
||||
return nil, e.err
|
||||
}
|
||||
|
||||
func (e *errRunner) CallTool(_ context.Context, _ string, _ json.RawMessage) (json.RawMessage, error) {
|
||||
return nil, e.err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,16 +135,6 @@ func WithSkillsRegistry(r *skills.Registry) Option {
|
|||
return func(s *Server) { s.skillsRegistry = r }
|
||||
}
|
||||
|
||||
// Decl returns a factory for an execute Server with the given working directory.
|
||||
func Decl(cwd string, opts ...Option) func() Runner {
|
||||
return func() Runner {
|
||||
s := New(cwd)
|
||||
for _, o := range opts {
|
||||
o(s)
|
||||
}
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
// ListTools implements Server, returning shell plus any
|
||||
// tools promoted in the session's tool registry.
|
||||
|
|
|
|||
Reference in New Issue