move tool.go and root.go into server/ (they're server wiring, not fs abstractions)

This commit is contained in:
Levi Neely 2026-05-19 18:21:14 +02:00
parent a9e9538015
commit 21f39c1d55
3 changed files with 18 additions and 15 deletions

View File

@ -1,7 +1,8 @@
package fs
package server
import (
"context"
"olliesrv/fs"
"fmt"
"os"
"strings"
@ -11,7 +12,7 @@ import (
)
// NewRootStore returns a read-only FileTree for synthetic root-level files.
func NewRootStore() *Tree {
func NewRootStore() *fs.Tree {
helpPath := paths.CfgDir() + "/help.md"
entries := map[string]func() ([]byte, error){
"backends": func() ([]byte, error) {
@ -26,27 +27,27 @@ func NewRootStore() *Tree {
}
readOnly := func([]byte) error { return fmt.Errorf("read-only") }
return NewTree(nil, 0444,
WithReadOnly(),
WithResolver(func(_ []string, name string) (string, error) {
return fs.NewTree(nil, 0444,
fs.WithReadOnly(),
fs.WithResolver(func(_ []string, name string) (string, error) {
if _, ok := entries[name]; ok {
return name, nil
}
return "", fmt.Errorf("%s: not found", name)
}),
WithLister(func(_ []string) ([]os.DirEntry, error) {
fs.WithLister(func(_ []string) ([]os.DirEntry, error) {
return []os.DirEntry{
FileEntry("backends", 0444),
FileEntry("help", 0444),
fs.FileEntry("backends", 0444),
fs.FileEntry("help", 0444),
}, nil
}),
WithOpener(func(_ []string, name string) (File, error) {
fs.WithOpener(func(_ []string, name string) (fs.File, error) {
readFn, ok := entries[name]
if !ok {
return nil, fmt.Errorf("%s: not found", name)
}
return &FileConfig{
StatFn: func() (os.FileInfo, error) { return &SyntheticFileInfo{Name_: name, Mode_: 0444}, nil },
return &fs.FileConfig{
StatFn: func() (os.FileInfo, error) { return &fs.SyntheticFileInfo{Name_: name, Mode_: 0444}, nil },
ReadFn: readFn,
WriteFn: readOnly,
BlockingReadFn: notBlocking,

View File

@ -104,13 +104,13 @@ func New(sink *olog.Sink, opts ...Option) *Server {
agentStore: fs.NewTree(agentsDirs, 0644),
promptStore: fs.NewTree(agent.PromptsDirs(), 0444, fs.WithReadOnly()),
memStore: fs.NewTree([]string{memDir}, 0644),
toolStore: fs.NewTree([]string{execute.ToolsPath()}, 0755, fs.WithIndex(fs.ToolIndex)),
toolStore: fs.NewTree([]string{execute.ToolsPath()}, 0755, fs.WithIndex(ToolIndex)),
utilStore: fs.NewTree([]string{paths.CfgDir() + "/scripts/u"}, 0555, fs.WithReadOnly()),
pluginStore: fs.NewTree([]string{execute.PluginsPath()}, 0555, fs.WithReadOnly()),
skillStore: fs.NewSkillStore(),
transcriptStore: fs.NewTree([]string{transcriptDir}, 0444, fs.WithReadOnly()),
tmpStore: fs.NewTree([]string{tmpDir}, 0600),
rootStore: fs.NewRootStore(),
rootStore: NewRootStore(),
groups: make(map[string]map[string]bool),
}
for _, o := range opts {

View File

@ -1,12 +1,14 @@
package fs
package server
import (
"fmt"
"olliesrv/fs"
"strings"
)
// ToolIndex generates a tool index from a store's file listing.
func ToolIndex(s FileTree) ([]byte, error) {
func ToolIndex(s fs.FileTree) ([]byte, error) {
entries, err := s.List()
if err != nil {
return nil, err