feat(go-agent): Ported retrieval node, added Keenable web search tool (#16396)

Ported retrieval node, added Keenable web search tool
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Zhichang Yu
2026-06-26 22:55:49 +08:00
committed by GitHub
parent 9d18f33296
commit 70546ea406
91 changed files with 5920 additions and 3817 deletions

View File

@@ -104,8 +104,8 @@ func (e *Engine) resolveProvider(path string) (Provider, string, error) {
// List lists nodes at the given path
// If path is empty, returns:
// 1. Built-in providers (e.g., datasets)
// 2. Top-level directories from files provider (if any)
// 1. Built-in providers (e.g., datasets)
// 2. Top-level directories from files provider (if any)
func (e *Engine) List(ctx stdctx.Context, path string, opts *ListOptions) (*Result, error) {
// Normalize path
path = normalizePath(path)

View File

@@ -18,7 +18,7 @@ package security
// ThreatPattern represents a security threat detection pattern
// Inspired by hermes-agent's skills_guard.py
type ThreatPattern struct {
type ThreatPattern struct {
Pattern string // Regular expression pattern
PatternID string // Unique identifier for this pattern
Severity string // critical | high | medium | low
@@ -271,9 +271,9 @@ var TrustedRepos = map[string]bool{
// Format: [safe, caution, dangerous] -> action
// Actions: allow, block, ask
var InstallPolicy = map[string][3]string{
"builtin": {"allow", "allow", "allow"}, // Official skills: always allow
"trusted": {"allow", "allow", "block"}, // Trusted repos: caution allowed, dangerous blocked
"community": {"allow", "block", "block"}, // Community: only safe allowed
"builtin": {"allow", "allow", "allow"}, // Official skills: always allow
"trusted": {"allow", "allow", "block"}, // Trusted repos: caution allowed, dangerous blocked
"community": {"allow", "block", "block"}, // Community: only safe allowed
}
// VerdictIndex maps verdict to array index

View File

@@ -36,8 +36,8 @@ type Finding struct {
type ScanResult struct {
SkillName string
Source string
TrustLevel string // builtin | trusted | community
Verdict string // safe | caution | dangerous
TrustLevel string // builtin | trusted | community
Verdict string // safe | caution | dangerous
Findings []Finding
}

View File

@@ -897,12 +897,12 @@ func extractQueryTerms(query string) []string {
func isSafePath(path string) bool {
// Clean the path
clean := filepath.Clean(path)
// Check for absolute paths
if filepath.IsAbs(clean) {
return false
}
// Check for parent directory references
parts := strings.Split(clean, string(filepath.Separator))
for _, part := range parts {
@@ -910,7 +910,7 @@ func isSafePath(path string) bool {
return false
}
}
return true
}

View File

@@ -149,7 +149,7 @@ func (s *GitHubSource) fetchFileContent(owner, repo, filePath string) (string, e
}
var result struct {
Content string `json:"content"`
Content string `json:"content"`
Encoding string `json:"encoding"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
@@ -194,9 +194,9 @@ func (s *GitHubSource) fetchDirectoryContents(owner, repo, dirPath string) (map[
}
var items []struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
DownloadURL string `json:"download_url"`
}
if err := json.NewDecoder(resp.Body).Decode(&items); err != nil {

View File

@@ -58,7 +58,7 @@ type SkillInstallCommand struct {
// sourceHTTPClientAdapter adapts filesystem.HTTPClientInterface to source.HTTPClientInterface
// This allows us to use the existing HTTP client infrastructure with the source package
type sourceHTTPClientAdapter struct {
client HTTPClientInterface
client HTTPClientInterface
httpClient *http.Client
}
@@ -121,9 +121,9 @@ func NewInstallSkillCommand(client HTTPClientInterface, fileProvider *FileProvid
adaptedClient := &sourceHTTPClientAdapter{
client: client,
httpClient: &http.Client{
Timeout: 60 * time.Second,
Transport: transport,
Jar: jar,
Timeout: 60 * time.Second,
Transport: transport,
Jar: jar,
},
}

View File

@@ -34,13 +34,13 @@ const (
// Node represents a node in the context filesystem
// This is the unified output format for all providers
type Node struct {
Name string `json:"name"`
Path string `json:"path"`
Type NodeType `json:"type"`
Size int64 `json:"size,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Name string `json:"name"`
Path string `json:"path"`
Type NodeType `json:"type"`
Size int64 `json:"size,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// CommandType represents the type of command
@@ -70,12 +70,12 @@ type ListOptions struct {
// SearchOptions represents options for search operations
type SearchOptions struct {
Query string `json:"query"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Recursive bool `json:"recursive,omitempty"`
TopK int `json:"top_k,omitempty"` // Number of top results to return (default: 10)
Threshold float64 `json:"threshold,omitempty"` // Similarity threshold (default: 0.2)
Query string `json:"query"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Recursive bool `json:"recursive,omitempty"`
TopK int `json:"top_k,omitempty"` // Number of top results to return (default: 10)
Threshold float64 `json:"threshold,omitempty"` // Similarity threshold (default: 0.2)
Dirs []string `json:"dirs,omitempty"` // List of directories to search in
}
@@ -90,12 +90,12 @@ type Result struct {
// PathInfo represents parsed path information
type PathInfo struct {
Provider string // The provider name (e.g., "datasets", "chats")
Path string // The full path
Components []string // Path components
IsRoot bool // Whether this is the root path for the provider
ResourceID string // Resource ID if applicable
ResourceName string // Resource name if applicable
Provider string // The provider name (e.g., "datasets", "chats")
Path string // The full path
Components []string // Path components
IsRoot bool // Whether this is the root path for the provider
ResourceID string // Resource ID if applicable
ResourceName string // Resource name if applicable
}
// ProviderInfo holds metadata about a provider
@@ -107,10 +107,10 @@ type ProviderInfo struct {
// Common error messages
const (
ErrInvalidPath = "invalid path"
ErrInvalidPath = "invalid path"
ErrProviderNotFound = "provider not found for path"
ErrNotSupported = "operation not supported"
ErrNotFound = "resource not found"
ErrUnauthorized = "unauthorized"
ErrInternal = "internal error"
ErrNotSupported = "operation not supported"
ErrNotFound = "resource not found"
ErrUnauthorized = "unauthorized"
ErrInternal = "internal error"
)

View File

@@ -36,10 +36,10 @@ func FormatNode(node *Node, format string) map[string]interface{} {
}
case "table":
return map[string]interface{}{
"name": node.Name,
"path": node.Path,
"type": string(node.Type),
"size": formatSize(node.Size),
"name": node.Name,
"path": node.Path,
"type": string(node.Type),
"size": formatSize(node.Size),
"created_at": formatTime(node.CreatedAt),
"updated_at": formatTime(node.UpdatedAt),
}