clawmoney 0.9.4 → 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.
@@ -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) {
@@ -202,18 +205,44 @@ export class Executor {
202
205
  });
203
206
  return;
204
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
+ }
205
227
  // Upload local files to R2
206
- for (const filePath of ocResult.files) {
228
+ for (const filePath of allFiles) {
207
229
  const cdnUrl = await uploadFile(filePath, this.config);
208
230
  if (cdnUrl) {
209
- // Replace local path with CDN URL in output
210
- const currentFiles = output.files ?? [];
211
- const idx = currentFiles.indexOf(filePath);
212
- if (idx >= 0) {
213
- currentFiles[idx] = cdnUrl;
214
- 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;
215
244
  }
216
- // Also set a convenience url key
245
+ // Set convenience url key
217
246
  if (!output.image_url && filePath.match(/\.(png|jpg|jpeg|webp|gif)$/i)) {
218
247
  output.image_url = cdnUrl;
219
248
  }
@@ -222,6 +251,20 @@ export class Executor {
222
251
  }
223
252
  }
224
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
+ }
225
268
  // Attach compact meta
226
269
  if (ocResult.meta) {
227
270
  output._meta = ocResult.meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {