diff --git a/go/go.mod b/go/go.mod index 7a82af3..519b284 100644 --- a/go/go.mod +++ b/go/go.mod @@ -4,7 +4,6 @@ go 1.26.2 require ( dappco.re/go/io v0.9.0 - dappco.re/go/log v0.9.0 dappco.re/go/process v0.10.0 dappco.re/go/rag v0.10.0 dappco.re/go/ws v0.5.0 @@ -15,6 +14,7 @@ require ( ) require ( + dappco.re/go/log v0.9.0 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect diff --git a/go/pkg/mcp/agentic/coreio_compat.go b/go/pkg/mcp/agentic/coreio_compat.go index 1b47eeb..e7b09f2 100644 --- a/go/pkg/mcp/agentic/coreio_compat.go +++ b/go/pkg/mcp/agentic/coreio_compat.go @@ -14,30 +14,19 @@ var coreio = struct { Local: &localCoreFS{fs: (&core.Fs{}).New("/")}, } -func localCoreFSErr( - r core.Result, -) ( - _ error, // result -) { - if r.OK { - return nil - } - if err, ok := r.Value.(error); ok && err != nil { - return err - } - if r.Value != nil { - return core.E("localCoreFS", core.Sprint(r.Value), nil) - } - return core.E("localCoreFS", "operation failed", nil) -} - func (l *localCoreFS) Read(path string) ( string, error, ) { r := l.fs.Read(path) if !r.OK { - return "", localCoreFSErr(r) + if err, ok := r.Value.(error); ok && err != nil { + return "", err + } + if r.Value != nil { + return "", core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return "", core.E("localCoreFS", "operation failed", nil) } content, ok := r.Value.(string) if !ok { @@ -51,7 +40,17 @@ func (l *localCoreFS) EnsureDir( ) ( _ error, // result ) { - return localCoreFSErr(l.fs.EnsureDir(path)) + r := l.fs.EnsureDir(path) + if r.OK { + return nil + } + if err, ok := r.Value.(error); ok && err != nil { + return err + } + if r.Value != nil { + return core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return core.E("localCoreFS", "operation failed", nil) } func (l *localCoreFS) List(path string) ( @@ -60,7 +59,13 @@ func (l *localCoreFS) List(path string) ( ) { r := l.fs.List(path) if !r.OK { - return nil, localCoreFSErr(r) + if err, ok := r.Value.(error); ok && err != nil { + return nil, err + } + if r.Value != nil { + return nil, core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return nil, core.E("localCoreFS", "operation failed", nil) } entries, ok := r.Value.([]core.FsDirEntry) if !ok { @@ -78,5 +83,15 @@ func (l *localCoreFS) Delete( ) ( _ error, // result ) { - return localCoreFSErr(l.fs.Delete(path)) + r := l.fs.Delete(path) + if r.OK { + return nil + } + if err, ok := r.Value.(error); ok && err != nil { + return err + } + if r.Value != nil { + return core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return core.E("localCoreFS", "operation failed", nil) } diff --git a/go/pkg/mcp/brain/client/coreio_compat.go b/go/pkg/mcp/brain/client/coreio_compat.go index 0b5a218..e486934 100644 --- a/go/pkg/mcp/brain/client/coreio_compat.go +++ b/go/pkg/mcp/brain/client/coreio_compat.go @@ -14,30 +14,19 @@ var coreio = struct { Local: &localCoreFS{fs: (&core.Fs{}).New("/")}, } -func localCoreFSErr( - r core.Result, -) ( - _ error, // result -) { - if r.OK { - return nil - } - if err, ok := r.Value.(error); ok && err != nil { - return err - } - if r.Value != nil { - return core.E("localCoreFS", core.Sprint(r.Value), nil) - } - return core.E("localCoreFS", "operation failed", nil) -} - func (l *localCoreFS) Stat(path string) ( core.FsFileInfo, error, ) { r := l.fs.Stat(path) if !r.OK { - return nil, localCoreFSErr(r) + if err, ok := r.Value.(error); ok && err != nil { + return nil, err + } + if r.Value != nil { + return nil, core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return nil, core.E("localCoreFS", "operation failed", nil) } info, ok := r.Value.(core.FsFileInfo) if !ok { @@ -52,7 +41,13 @@ func (l *localCoreFS) Read(path string) ( ) { r := l.fs.Read(path) if !r.OK { - return "", localCoreFSErr(r) + if err, ok := r.Value.(error); ok && err != nil { + return "", err + } + if r.Value != nil { + return "", core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return "", core.E("localCoreFS", "operation failed", nil) } content, ok := r.Value.(string) if !ok { @@ -68,5 +63,15 @@ func (l *localCoreFS) WriteMode( ) ( _ error, // result ) { - return localCoreFSErr(l.fs.WriteMode(path, content, mode)) + r := l.fs.WriteMode(path, content, mode) + if r.OK { + return nil + } + if err, ok := r.Value.(error); ok && err != nil { + return err + } + if r.Value != nil { + return core.E("localCoreFS", core.Sprint(r.Value), nil) + } + return core.E("localCoreFS", "operation failed", nil) }