- Implemented AssistantReloadFunc to enable hot-reloading of assistants after deployment, improving deployment flexibility. - Enhanced gRPC authProvider to include workspace and sandbox IDs from incoming context metadata, enriching the authentication context. - Updated tools to support new agent-related functionalities, including listing, downloading, deploying, and connecting agents. - Expanded system tools documentation to include new agent commands, ensuring comprehensive guidance for users.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/yaoapp/gou/process"
|
|
"github.com/yaoapp/yao/config"
|
|
)
|
|
|
|
// DownloadHandler handles the agent_download tool.
|
|
// Args[0]: id (string, dot notation e.g. "yao.slides")
|
|
func DownloadHandler(proc *process.Process) interface{} {
|
|
id := proc.ArgsString(0)
|
|
if id == "" {
|
|
return map[string]interface{}{"error": "id is required (e.g. 'yao.slides')"}
|
|
}
|
|
if err := validateID(id); err != nil {
|
|
return map[string]interface{}{"error": err.Error()}
|
|
}
|
|
|
|
wsFS, err := resolveWorkspaceFS(proc)
|
|
if err != nil {
|
|
return map[string]interface{}{"error": err.Error()}
|
|
}
|
|
|
|
relPath := idToPath(id)
|
|
appRoot := config.Conf.Root
|
|
srcURI := "local:///" + filepath.Join(appRoot, "assistants", relPath)
|
|
dstPath := filepath.Join("agent-smith-dev", "assistants", relPath)
|
|
|
|
result, copyErr := wsFS.Copy(srcURI, dstPath)
|
|
if copyErr != nil {
|
|
return map[string]interface{}{"error": fmt.Sprintf("download failed: %s", copyErr.Error())}
|
|
}
|
|
|
|
files := 0
|
|
if result != nil {
|
|
files = result.FilesSynced
|
|
}
|
|
|
|
return map[string]interface{}{
|
|
"status": "ok",
|
|
"path": dstPath,
|
|
"files": files,
|
|
}
|
|
}
|