clawmoney 0.9.3 → 0.9.5

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.
@@ -175,7 +175,10 @@ export async function hubCallCommand(options) {
175
175
  process.exit(1);
176
176
  }
177
177
  // Extract payment_token from Worker response
178
- const paymentToken = payResult.data?.payment_token;
178
+ // awal returns {status, statusText, data: {payment_token, ...}, headers}
179
+ const payData = payResult.data;
180
+ const innerData = payData.data ?? payData;
181
+ const paymentToken = innerData.payment_token ?? payData.payment_token;
179
182
  if (!paymentToken) {
180
183
  spinner.fail(chalk.red("Payment succeeded but no payment_token returned"));
181
184
  console.error(chalk.dim(` Raw response: ${JSON.stringify(payResult.data).slice(0, 200)}`));
@@ -11,7 +11,7 @@ function buildPrompt(call, config) {
11
11
  .replace("{{skill}}", call.skill)
12
12
  .replace("{{input}}", JSON.stringify(call.input, null, 2));
13
13
  }
14
- return [
14
+ const lines = [
15
15
  "You received a paid service request via ClawMoney Hub.",
16
16
  `Skill: ${call.skill}`,
17
17
  `Category: ${call.category}`,
@@ -19,10 +19,13 @@ function buildPrompt(call, config) {
19
19
  `Price: $${call.price}`,
20
20
  `Input: ${JSON.stringify(call.input, null, 2)}`,
21
21
  "",
22
- "Execute this task and return the result as JSON.",
23
- "If you generate any files (images, videos, etc.), save them and include their file paths in the output.",
24
- "Return ONLY the JSON result, no other text.",
25
- ].join("\n");
22
+ ];
23
+ // Category-specific instructions
24
+ if (call.category?.startsWith("generation/image")) {
25
+ lines.push("IMPORTANT: You MUST use an image generation tool (e.g. Gemini/Nano Banana image generation) to create a real image file.", "Do NOT write SVG, HTML, or any code to fake an image. If you do not have an image generation tool available, return {\"success\": false, \"error\": \"No image generation tool available\"}.", "Save the generated image and include the file path in your output.");
26
+ }
27
+ lines.push("Execute this task and return the result as JSON.", "If you generate any files (images, videos, etc.), save them and include their file paths in the output.", "Return ONLY the JSON result, no other text.");
28
+ return lines.join("\n");
26
29
  }
27
30
  // ── CLI execution (openclaw agent / claude -p) ──
28
31
  function runCli(command, prompt, timeoutMs, orderId) {
@@ -192,18 +195,54 @@ export class Executor {
192
195
  // Parse OpenClaw's response format: { payloads, meta }
193
196
  const ocResult = parseOpenClawResponse(parsed);
194
197
  output = ocResult.result;
198
+ // Check if the agent explicitly reported failure
199
+ if (output.success === false && typeof output.error === "string") {
200
+ logger.error(`Agent reported failure for order=${call.order_id}: ${output.error}`);
201
+ this.send({
202
+ event: "deliver",
203
+ order_id: call.order_id,
204
+ error: output.error.slice(0, 2000),
205
+ });
206
+ return;
207
+ }
208
+ // Also extract file paths from nested result.files / result.primary_file
209
+ const allFiles = [...ocResult.files];
210
+ const nested = output.result;
211
+ if (nested && typeof nested === "object") {
212
+ const nestedFiles = nested.files;
213
+ if (Array.isArray(nestedFiles)) {
214
+ for (const f of nestedFiles) {
215
+ if (typeof f === "string" && f.startsWith("/") && !allFiles.includes(f)) {
216
+ allFiles.push(f);
217
+ }
218
+ }
219
+ }
220
+ for (const key of ["primary_file", "image_path", "file_path"]) {
221
+ const val = nested[key];
222
+ if (typeof val === "string" && val.startsWith("/") && !allFiles.includes(val)) {
223
+ allFiles.push(val);
224
+ }
225
+ }
226
+ }
195
227
  // Upload local files to R2
196
- for (const filePath of ocResult.files) {
228
+ for (const filePath of allFiles) {
197
229
  const cdnUrl = await uploadFile(filePath, this.config);
198
230
  if (cdnUrl) {
199
- // Replace local path with CDN URL in output
200
- const currentFiles = output.files ?? [];
201
- const idx = currentFiles.indexOf(filePath);
202
- if (idx >= 0) {
203
- currentFiles[idx] = cdnUrl;
204
- output.files = currentFiles;
231
+ // Replace local path with CDN URL in output (top-level and nested)
232
+ const replaceInArray = (arr) => {
233
+ const idx = arr.indexOf(filePath);
234
+ if (idx >= 0)
235
+ arr[idx] = cdnUrl;
236
+ };
237
+ if (Array.isArray(output.files))
238
+ replaceInArray(output.files);
239
+ if (nested && Array.isArray(nested.files)) {
240
+ replaceInArray(nested.files);
241
+ }
242
+ if (nested && nested.primary_file === filePath) {
243
+ nested.primary_file = cdnUrl;
205
244
  }
206
- // Also set a convenience url key
245
+ // Set convenience url key
207
246
  if (!output.image_url && filePath.match(/\.(png|jpg|jpeg|webp|gif)$/i)) {
208
247
  output.image_url = cdnUrl;
209
248
  }
@@ -212,6 +251,20 @@ export class Executor {
212
251
  }
213
252
  }
214
253
  }
254
+ // Validate: generation/image must produce real image files, not SVG/code
255
+ if (call.category?.startsWith("generation/image")) {
256
+ const hasRealImage = allFiles.some((f) => /\.(png|jpg|jpeg|webp|gif)$/i.test(f));
257
+ if (!hasRealImage) {
258
+ const errMsg = "No real image generated. Image generation tool may not be available.";
259
+ logger.error(`Validation failed for order=${call.order_id}: ${errMsg}`);
260
+ this.send({
261
+ event: "deliver",
262
+ order_id: call.order_id,
263
+ error: errMsg,
264
+ });
265
+ return;
266
+ }
267
+ }
215
268
  // Attach compact meta
216
269
  if (ocResult.meta) {
217
270
  output._meta = ocResult.meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {