feat: añadir subcomandos upload-media y set-avatar-url en agentctl

Expone las funciones separadas de profile.go como CLI:
- agentctl upload-media <id> <path> — sube sin activar avatar
- agentctl set-avatar-url <id> <mxc://...> — activa un mxc ya subido

Complementa la refactorizacion de shell/matrix/profile.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 21:37:13 +00:00
parent 730e415dc1
commit cc8c5a6645
2 changed files with 60 additions and 0 deletions
+57
View File
@@ -41,6 +41,63 @@ func avatarCmd() *cobra.Command {
}
}
func uploadMediaCmd() *cobra.Command {
return &cobra.Command{
Use: "upload-media <agent-id> <image-path>",
Short: "Upload an image to Matrix media repo (does NOT set it as avatar)",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
agentID, imagePath := args[0], args[1]
cfg, err := loadMatrixCfg(agentID)
if err != nil {
return err
}
client, err := shellmatrix.New(cfg.Matrix)
if err != nil {
return fmt.Errorf("matrix client: %w", err)
}
uri, err := client.UploadMedia(context.Background(), imagePath)
if err != nil {
return err
}
fmt.Printf("ok %-20s uploaded → %s\n", agentID, uri)
return nil
},
}
}
func setAvatarURLCmd() *cobra.Command {
return &cobra.Command{
Use: "set-avatar-url <agent-id> <mxc-uri>",
Short: "Set the bot's avatar to an already-uploaded mxc:// URI",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
agentID, mxcURI := args[0], args[1]
cfg, err := loadMatrixCfg(agentID)
if err != nil {
return err
}
client, err := shellmatrix.New(cfg.Matrix)
if err != nil {
return fmt.Errorf("matrix client: %w", err)
}
if err := client.SetAvatarURL(context.Background(), mxcURI); err != nil {
return err
}
fmt.Printf("ok %-20s avatar-url → %s\n", agentID, mxcURI)
return nil
},
}
}
func displaynameCmd() *cobra.Command {
return &cobra.Command{
Use: "displayname <agent-id> [name]",
+3
View File
@@ -51,6 +51,9 @@ func main() {
reloadCmd(mgr),
removeCmd(mgr),
avatarCmd(),
uploadMediaCmd(),
setAvatarURLCmd(),
autoAvatarCmd(),
displaynameCmd(),
)