clawmoney 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hub/executor.js +28 -11
- package/package.json +1 -1
package/dist/hub/executor.js
CHANGED
|
@@ -86,29 +86,46 @@ function parseOpenClawResponse(raw) {
|
|
|
86
86
|
const files = [];
|
|
87
87
|
let result = raw;
|
|
88
88
|
let meta = null;
|
|
89
|
-
// OpenClaw returns: { payloads: [
|
|
90
|
-
const
|
|
89
|
+
// OpenClaw returns: { result: { payloads: [...], meta: {...} } } or { payloads: [...], meta: {...} }
|
|
90
|
+
const resultObj = raw.result ?? raw;
|
|
91
|
+
const payloads = (resultObj.payloads ?? raw.payloads);
|
|
91
92
|
if (payloads && Array.isArray(payloads) && payloads.length > 0) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
// Scan ALL payloads for JSON and file paths (not just [0])
|
|
94
|
+
let parsedJson = null;
|
|
95
|
+
const allText = [];
|
|
96
|
+
for (const p of payloads) {
|
|
97
|
+
const text = p.text ?? "";
|
|
98
|
+
allText.push(text);
|
|
99
|
+
// Try to parse as JSON
|
|
100
|
+
if (!parsedJson) {
|
|
101
|
+
parsedJson = parseJsonOutput(text);
|
|
102
|
+
}
|
|
103
|
+
// Extract file paths from text (lines that look like absolute paths)
|
|
104
|
+
const pathMatch = text.match(/^\/\S+\.(png|jpg|jpeg|webp|gif|mp4|webm|mov|mp3|wav|pdf)$/im);
|
|
105
|
+
if (pathMatch) {
|
|
106
|
+
files.push(pathMatch[0]);
|
|
107
|
+
}
|
|
108
|
+
// MediaUrl
|
|
109
|
+
if (p.mediaUrl) {
|
|
110
|
+
files.push(p.mediaUrl);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (parsedJson) {
|
|
114
|
+
result = parsedJson;
|
|
97
115
|
// Extract file paths from the parsed result
|
|
98
|
-
const resultFiles =
|
|
116
|
+
const resultFiles = parsedJson.files;
|
|
99
117
|
if (Array.isArray(resultFiles)) {
|
|
100
118
|
files.push(...resultFiles.filter((f) => typeof f === "string" && f.startsWith("/")));
|
|
101
119
|
}
|
|
102
|
-
// Also check common path keys
|
|
103
120
|
for (const key of ["image_path", "video_path", "audio_path", "file_path"]) {
|
|
104
|
-
const val =
|
|
121
|
+
const val = parsedJson[key];
|
|
105
122
|
if (typeof val === "string" && val.startsWith("/")) {
|
|
106
123
|
files.push(val);
|
|
107
124
|
}
|
|
108
125
|
}
|
|
109
126
|
}
|
|
110
127
|
else {
|
|
111
|
-
result = { text:
|
|
128
|
+
result = { text: allText.join("\n").trim() };
|
|
112
129
|
}
|
|
113
130
|
// Extract useful meta (strip systemPromptReport which is huge)
|
|
114
131
|
const rawMeta = raw.meta;
|