clawmoney 0.9.5 → 0.9.7

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.
@@ -141,6 +141,28 @@ export async function hubSearchCommand(options) {
141
141
  throw err;
142
142
  }
143
143
  }
144
+ // ── poll order result ──
145
+ async function pollOrderResult(orderId, apiKey, timeoutS, spinner) {
146
+ const POLL_INTERVAL = 3000;
147
+ const deadline = Date.now() + timeoutS * 1000;
148
+ while (Date.now() < deadline) {
149
+ const resp = await apiGet(`/api/v1/hub/orders/${orderId}`, apiKey);
150
+ if (!resp.ok) {
151
+ throw new Error(`Failed to poll order: ${resp.status}`);
152
+ }
153
+ const order = resp.data;
154
+ const status = order.status;
155
+ if (status === "completed") {
156
+ return order;
157
+ }
158
+ if (status === "failed" || status === "timeout") {
159
+ throw new Error(order.error_message || `Order ${status}`);
160
+ }
161
+ spinner.text = `Waiting for result... (${Math.round((deadline - Date.now()) / 1000)}s left)`;
162
+ await new Promise((r) => setTimeout(r, POLL_INTERVAL));
163
+ }
164
+ throw new Error("Timed out waiting for result");
165
+ }
144
166
  export async function hubCallCommand(options) {
145
167
  const config = requireConfig();
146
168
  let inputData = {};
@@ -202,7 +224,11 @@ export async function hubCallCommand(options) {
202
224
  spinner.fail(chalk.red(`Call failed (${resp.status}): ${detail}`));
203
225
  process.exit(1);
204
226
  }
205
- const result = resp.data;
227
+ const invokeResult = resp.data;
228
+ const orderId = invokeResult.id;
229
+ spinner.text = `Order ${orderId?.slice(0, 8)}... submitted, waiting for result...`;
230
+ // Poll for completion
231
+ const result = await pollOrderResult(orderId, config.api_key, timeout, spinner);
206
232
  spinner.succeed(chalk.green("Call completed (x402 paid)!"));
207
233
  console.log("");
208
234
  console.log(` ${chalk.bold("Order:")} ${result.id ?? "-"}`);
@@ -229,7 +255,11 @@ export async function hubCallCommand(options) {
229
255
  spinner.fail(chalk.red(`Call failed (${resp.status}): ${detail}`));
230
256
  process.exit(1);
231
257
  }
232
- const result = resp.data;
258
+ const invokeResult = resp.data;
259
+ const orderId = invokeResult.id;
260
+ spinner.text = `Order ${orderId?.slice(0, 8)}... submitted, waiting for result...`;
261
+ // Poll for completion
262
+ const result = await pollOrderResult(orderId, config.api_key, timeout, spinner);
233
263
  spinner.succeed(chalk.green("Call completed!"));
234
264
  console.log("");
235
265
  console.log(` ${chalk.bold("Order:")} ${result.id ?? "-"}`);
@@ -22,7 +22,7 @@ function buildPrompt(call, config) {
22
22
  ];
23
23
  // Category-specific instructions
24
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.");
25
+ lines.push("IMPORTANT: Use the nano-banana-pro skill (or any image generation tool) to generate a real PNG/JPG image.", "Do NOT write SVG, HTML, or any code to fake an image.", "If no image generation tool is available, return {\"success\": false, \"error\": \"No image generation tool available\"}.", "Save the generated image and include the file path in your output.");
26
26
  }
27
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
28
  return lines.join("\n");
package/dist/index.js CHANGED
@@ -7,11 +7,14 @@ import { walletStatusCommand, walletBalanceCommand, walletAddressCommand, wallet
7
7
  import { tweetCommand } from './commands/tweet.js';
8
8
  import { gigCreateCommand, gigBrowseCommand, gigDetailCommand, gigAcceptCommand, gigDeliverCommand, gigApproveCommand, gigDisputeCommand, } from './commands/gig.js';
9
9
  import { hubStartCommand, hubStopCommand, hubStatusCommand, hubSearchCommand, hubCallCommand, hubRegisterCommand, hubSkillsCommand, } from './commands/hub.js';
10
+ import { createRequire } from 'node:module';
11
+ const require = createRequire(import.meta.url);
12
+ const pkg = require('../package.json');
10
13
  const program = new Command();
11
14
  program
12
15
  .name('clawmoney')
13
16
  .description('ClawMoney CLI -- Earn rewards with your AI agent')
14
- .version('0.9.2');
17
+ .version(pkg.version);
15
18
  // setup
16
19
  program
17
20
  .command('setup')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {