Skip to content

Commit 3b62197

Browse files
fix: Fixed issue with openclaw skill page return empty (#12345)
1 parent 2d78ca5 commit 3b62197

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

agent/app/service/agents_overview.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func countOpenclawConfiguredChannels(conf map[string]interface{}) int {
103103

104104
func loadOpenclawOverviewSkillStats(containerName string) (int, error) {
105105
output, err := cmd.RunDefaultWithStdoutBashCfAndTimeOut(
106-
"docker exec %s openclaw skills list --json 2>&1",
106+
"docker exec %s openclaw gateway call skills.status --json 2>&1",
107107
30*time.Second,
108108
containerName,
109109
)

agent/app/service/agents_skills.go

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ type openclawSkillListItem struct {
2323
Source string `json:"source"`
2424
Bundled bool `json:"bundled"`
2525
Disabled bool `json:"disabled"`
26-
}
27-
28-
type openclawSkillInfo struct {
29-
SkillKey string `json:"skillKey"`
26+
SkillKey string `json:"skillKey"`
3027
}
3128

3229
type skillhubSearchPayload struct {
@@ -44,11 +41,7 @@ func (a AgentService) ListSkills(req dto.AgentIDReq) ([]dto.AgentSkillItem, erro
4441
if err := ensureContainerRunning(install.ContainerName); err != nil {
4542
return nil, err
4643
}
47-
output, err := cmd.RunDefaultWithStdoutBashCfAndTimeOut(
48-
"docker exec %s openclaw skills list --json 2>&1",
49-
30*time.Second,
50-
install.ContainerName,
51-
)
44+
output, err := loadOpenclawSkillsStatus(install.ContainerName)
5245
if err != nil {
5346
return nil, err
5447
}
@@ -93,7 +86,7 @@ func (a AgentService) UpdateSkill(req dto.AgentSkillUpdateReq) error {
9386
if err != nil {
9487
return err
9588
}
96-
skillKey, err := getOpenclawSkillKey(install.ContainerName, req.Name)
89+
skillKey, err := getOpenclawSkillKeyFromStatus(install.ContainerName, req.Name)
9790
if err != nil {
9891
return err
9992
}
@@ -126,8 +119,12 @@ func (a AgentService) InstallSkill(req dto.AgentSkillInstallReq) error {
126119
}
127120

128121
func parseOpenclawSkillsList(output string) ([]dto.AgentSkillItem, error) {
122+
trimmed := strings.TrimSpace(output)
123+
if trimmed == "" {
124+
return nil, nil
125+
}
129126
var payload openclawSkillsList
130-
if err := json.Unmarshal([]byte(strings.TrimSpace(output)), &payload); err != nil {
127+
if err := json.Unmarshal([]byte(trimmed), &payload); err != nil {
131128
return nil, err
132129
}
133130
items := make([]dto.AgentSkillItem, 0, len(payload.Skills))
@@ -143,6 +140,14 @@ func parseOpenclawSkillsList(output string) ([]dto.AgentSkillItem, error) {
143140
return items, nil
144141
}
145142

143+
func loadOpenclawSkillsStatus(containerName string) (string, error) {
144+
return cmd.RunDefaultWithStdoutBashCfAndTimeOut(
145+
"docker exec %s openclaw gateway call skills.status --json 2>&1",
146+
30*time.Second,
147+
containerName,
148+
)
149+
}
150+
146151
func loadOpenclawSkillSearchOutput(containerName, source, keyword string) (string, error) {
147152
switch source {
148153
case "skillhub":
@@ -224,28 +229,32 @@ func buildOpenclawSkillInstallCommand(source, slug string) string {
224229
}
225230
}
226231

227-
func getOpenclawSkillKey(containerName, name string) (string, error) {
228-
output, err := cmd.RunDefaultWithStdoutBashCfAndTimeOut(
229-
"docker exec %s openclaw skills info %q --json 2>&1",
230-
30*time.Second,
231-
containerName,
232-
name,
233-
)
232+
func getOpenclawSkillKeyFromStatus(containerName, name string) (string, error) {
233+
output, err := loadOpenclawSkillsStatus(containerName)
234234
if err != nil {
235235
return "", err
236236
}
237-
return parseOpenclawSkillKey(name, output)
237+
return parseOpenclawSkillKeyFromStatus(name, output)
238238
}
239239

240-
func parseOpenclawSkillKey(name, output string) (string, error) {
241-
var payload openclawSkillInfo
242-
if err := json.Unmarshal([]byte(strings.TrimSpace(output)), &payload); err != nil {
240+
func parseOpenclawSkillKeyFromStatus(name, output string) (string, error) {
241+
trimmed := strings.TrimSpace(output)
242+
if trimmed == "" {
243+
return "", fmt.Errorf("skill %s does not have a skillKey", name)
244+
}
245+
var payload openclawSkillsList
246+
if err := json.Unmarshal([]byte(trimmed), &payload); err != nil {
243247
return "", err
244248
}
245-
if payload.SkillKey == "" {
246-
return "", fmt.Errorf("skill %s does not have a skillKey", name)
249+
for _, item := range payload.Skills {
250+
if item.Name == name {
251+
if item.SkillKey == "" {
252+
return "", fmt.Errorf("skill %s does not have a skillKey", name)
253+
}
254+
return item.SkillKey, nil
255+
}
247256
}
248-
return payload.SkillKey, nil
257+
return "", fmt.Errorf("skill %s not found", name)
249258
}
250259

251260
func setOpenclawSkillEnabled(conf map[string]interface{}, skillKey string, enabled bool) {

0 commit comments

Comments
 (0)