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.
@@ -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: [{ text: "JSON string", mediaUrl }], meta: { ... } }
90
- const payloads = raw.payloads;
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
- const text = payloads[0].text ?? "";
93
- // Try to parse the text as JSON (OpenClaw wraps the agent's output in payloads[].text)
94
- const parsed = parseJsonOutput(text);
95
- if (parsed) {
96
- result = parsed;
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 = parsed.files;
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 = parsed[key];
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: text.trim() };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {