yao/tools/docs/docs.go
Max 7da06a4ae1 feat(search): refactor builtinSearch to utilize websearch tool and enhance context handling
- Updated the builtinSearch function to delegate search operations to the websearch tool, improving modularity and maintainability.
- Enhanced context handling by passing the agent context to builtinSearch, allowing for user and team identification during searches.
- Added a new DecryptValue function in cloud.go to streamline value decryption, delegating to the existing config.DecryptValue method.
- Updated .gitignore to include tools/README.md for better project organization.
2026-05-02 19:58:03 +08:00

54 lines
1.3 KiB
Go

package docs
import (
_ "embed"
goudoc "github.com/yaoapp/gou/doc"
"github.com/yaoapp/gou/process"
)
//go:embed list.json
var ListSchemaJSON []byte
//go:embed inspect.json
var InspectSchemaJSON []byte
//go:embed validate.json
var ValidateSchemaJSON []byte
// ListHandler is the tools.doclist process handler.
// Args[0]: keyword (string, optional — empty lists all)
// Args[1]: limit (int, default 20)
func ListHandler(proc *process.Process) interface{} {
keyword := proc.ArgsString(0)
limit := proc.ArgsInt(1, 20)
var results []*goudoc.Entry
if keyword != "" {
results = goudoc.List(goudoc.TypeProcess, goudoc.ListOption{Search: keyword})
} else {
results = goudoc.List(goudoc.TypeProcess)
}
if len(results) > limit {
results = results[:limit]
}
return results
}
// InspectHandler is the tools.docinspect process handler.
// Args[0]: name (string — process name, e.g. "models.user.Find")
func InspectHandler(proc *process.Process) interface{} {
name := proc.ArgsString(0)
entry, ok := goudoc.Get(goudoc.TypeProcess, name)
if !ok {
return nil
}
return entry
}
// ValidateHandler is the tools.docvalidate process handler.
// Args[0]: name (string — process name)
func ValidateHandler(proc *process.Process) interface{} {
name := proc.ArgsString(0)
return goudoc.Validate(goudoc.TypeProcess, name)
}