fix: strip scoped openclaw artifact bodies
This commit is contained in:
parent
f2d281bf12
commit
1781a01f80
@ -776,9 +776,6 @@ func (o *SessionOrchestrator) normalizeResult(sess *session, result map[string]a
|
||||
}
|
||||
|
||||
func openClawArtifactResponse(result map[string]any, routing RoutingResult, params map[string]any) bool {
|
||||
if routing.TargetID != "gateway" {
|
||||
return false
|
||||
}
|
||||
for _, provider := range []string{
|
||||
routing.GatewayProviderID,
|
||||
shared.StringArg(result, "resolvedGatewayProviderId", ""),
|
||||
@ -797,7 +794,34 @@ func openClawArtifactResponse(result map[string]any, routing RoutingResult, para
|
||||
return true
|
||||
}
|
||||
}
|
||||
return strings.HasPrefix(strings.TrimSpace(shared.StringArg(result, "artifactScope", "")), ".xworkmate/artifacts/tasks/")
|
||||
if strings.HasPrefix(strings.TrimSpace(shared.StringArg(result, "artifactScope", "")), ".xworkmate/artifacts/tasks/") {
|
||||
return true
|
||||
}
|
||||
for _, key := range []string{"artifacts", "files", "attachments"} {
|
||||
if openClawArtifactListHasScopedArtifact(result[key]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func openClawArtifactListHasScopedArtifact(raw any) bool {
|
||||
switch values := raw.(type) {
|
||||
case []map[string]any:
|
||||
for _, artifact := range values {
|
||||
if strings.HasPrefix(strings.TrimSpace(shared.StringArg(artifact, "artifactScope", "")), ".xworkmate/artifacts/tasks/") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case []any:
|
||||
for _, item := range values {
|
||||
artifact := shared.AsMap(item)
|
||||
if strings.HasPrefix(strings.TrimSpace(shared.StringArg(artifact, "artifactScope", "")), ".xworkmate/artifacts/tasks/") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func taskKindFromParams(params map[string]any, routing RoutingResult) TaskKind {
|
||||
|
||||
@ -811,21 +811,21 @@ func TestNormalizeResultStripsOpenClawInlineArtifactsAfterRecordNormalization(t
|
||||
"output": "created files",
|
||||
"artifacts": []any{
|
||||
map[string]any{
|
||||
"relativePath": "reports/final.md",
|
||||
"label": "final.md",
|
||||
"contentType": "text/markdown",
|
||||
"sizeBytes": 12,
|
||||
"sha256": "fake-sha256",
|
||||
"downloadUrl": "https://xworkmate-bridge.svc.plus/artifacts/openclaw/download?relativePath=reports%2Ffinal.md",
|
||||
"encoding": "base64",
|
||||
"content": "ZmluYWwgcmVwb3J0",
|
||||
"relativePath": "reports/final.md",
|
||||
"label": "final.md",
|
||||
"contentType": "text/markdown",
|
||||
"sizeBytes": 12,
|
||||
"sha256": "fake-sha256",
|
||||
"artifactScope": ".xworkmate/artifacts/tasks/thread-openclaw-normalize/turn-openclaw-normalize",
|
||||
"downloadUrl": "https://xworkmate-bridge.svc.plus/artifacts/openclaw/download?relativePath=reports%2Ffinal.md",
|
||||
"encoding": "base64",
|
||||
"content": "ZmluYWwgcmVwb3J0",
|
||||
},
|
||||
},
|
||||
},
|
||||
RoutingResult{
|
||||
TargetID: "gateway",
|
||||
ProviderID: "gateway",
|
||||
GatewayProviderID: "openclaw",
|
||||
TargetID: "gateway",
|
||||
ProviderID: "gateway",
|
||||
},
|
||||
"turn-openclaw-normalize",
|
||||
map[string]any{},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user