clawmoney 0.8.4 → 0.8.6

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.
@@ -41,15 +41,8 @@ export async function hubStartCommand(options) {
41
41
  const pid = readPid();
42
42
  if (pid && isPidAlive(pid)) {
43
43
  spinner.succeed(chalk.green(`Hub Provider started (PID ${pid})`));
44
- const mode = config.provider?.execution_mode || "webhook";
45
44
  console.log(chalk.dim(` Log file: ${LOG_FILE}`));
46
- console.log(chalk.dim(` Mode: ${mode}`));
47
- if (mode === "cli") {
48
- console.log(chalk.dim(` CLI command: ${options.cli || config.provider?.cli_command || "claude"}`));
49
- }
50
- else {
51
- console.log(chalk.dim(` Webhook: ${config.provider?.webhook_url || "http://127.0.0.1:18789/hooks/agent"}`));
52
- }
45
+ console.log(chalk.dim(` CLI: ${options.cli || config.provider?.cli_command || "openclaw"}`));
53
46
  console.log(chalk.dim(` API key: ${config.api_key.slice(0, 8)}...`));
54
47
  }
55
48
  else {
@@ -24,52 +24,19 @@ function buildPrompt(call, config) {
24
24
  "Return ONLY the JSON result, no other text.",
25
25
  ].join("\n");
26
26
  }
27
- // ── OpenClaw Webhook execution ──
28
- async function executeViaWebhook(call, config, prompt, timeoutS) {
29
- const { webhook_url, webhook_token } = config.provider;
30
- logger.info(`Executing via OpenClaw webhook: skill="${call.skill}" order=${call.order_id}`);
31
- const controller = new AbortController();
32
- const timer = setTimeout(() => controller.abort(), timeoutS * 1000);
33
- try {
34
- const resp = await fetch(webhook_url, {
35
- method: "POST",
36
- headers: {
37
- "Content-Type": "application/json",
38
- Authorization: `Bearer ${webhook_token}`,
39
- },
40
- body: JSON.stringify({
41
- message: prompt,
42
- name: `Hub: ${call.skill}`,
43
- deliver: false, // don't send to messaging channel
44
- timeoutSeconds: timeoutS,
45
- }),
46
- signal: controller.signal,
47
- });
48
- clearTimeout(timer);
49
- if (!resp.ok) {
50
- const text = await resp.text();
51
- throw new Error(`Webhook returned ${resp.status}: ${text}`);
27
+ // ── CLI execution (openclaw agent / claude -p) ──
28
+ function runCli(command, prompt, timeoutMs) {
29
+ return new Promise((resolve) => {
30
+ // Build args based on command
31
+ let args;
32
+ if (command === "openclaw") {
33
+ // openclaw agent --message "..." --local
34
+ args = ["agent", "--message", prompt, "--local"];
52
35
  }
53
- const text = await resp.text();
54
- // Try to parse JSON from response
55
- const parsed = parseJsonOutput(text);
56
- if (parsed)
57
- return parsed;
58
- // If response is not JSON, wrap as text result
59
- return { result: text.trim().slice(0, 5000) };
60
- }
61
- catch (err) {
62
- clearTimeout(timer);
63
- if (err instanceof Error && err.name === "AbortError") {
64
- throw new Error(`Webhook timed out after ${timeoutS}s`);
36
+ else {
37
+ // claude -p "..." --output-format json
38
+ args = ["-p", prompt, "--output-format", "json"];
65
39
  }
66
- throw err;
67
- }
68
- }
69
- // ── CLI (claude -p) execution — fallback ──
70
- function executeViaCli(command, prompt, timeoutMs) {
71
- return new Promise((resolve) => {
72
- const args = ["-p", prompt, "--output-format", "json"];
73
40
  const child = spawn(command, args, {
74
41
  stdio: ["ignore", "pipe", "pipe"],
75
42
  timeout: timeoutMs,
@@ -140,7 +107,7 @@ export class Executor {
140
107
  }
141
108
  markProcessed(call.order_id);
142
109
  this.activeTasks.add(call.order_id);
143
- logger.info(`Processing order=${call.order_id} skill="${call.skill}" from=${call.from} mode=${this.config.provider.execution_mode}`);
110
+ logger.info(`Processing order=${call.order_id} skill="${call.skill}" from=${call.from}`);
144
111
  this.executeTask(call).catch((err) => {
145
112
  logger.error(`Unhandled error in executeTask for ${call.order_id}:`, err);
146
113
  });
@@ -153,7 +120,6 @@ export class Executor {
153
120
  output: {
154
121
  echo: call.input,
155
122
  provider_status: "ok",
156
- execution_mode: this.config.provider.execution_mode,
157
123
  active_tasks: this.activeTasks.size,
158
124
  max_concurrent: this.config.provider.max_concurrent,
159
125
  },
@@ -164,29 +130,23 @@ export class Executor {
164
130
  try {
165
131
  const prompt = buildPrompt(call, this.config);
166
132
  const timeoutS = Math.max(call.timeout - TIMEOUT_BUFFER_S, 30);
167
- let output;
168
- if (this.config.provider.execution_mode === "webhook") {
169
- // Execute via OpenClaw webhook
170
- output = await executeViaWebhook(call, this.config, prompt, timeoutS);
171
- }
172
- else {
173
- // Execute via CLI (claude -p / openclaw -p)
174
- const command = this.config.provider.cli_command;
175
- logger.info(`Executing via CLI: ${command} for skill="${call.skill}" (timeout=${timeoutS}s)`);
176
- const { stdout, stderr, exitCode } = await executeViaCli(command, prompt, timeoutS * 1000);
177
- if (exitCode !== 0) {
178
- const errMsg = stderr.trim() || `CLI exited with code ${exitCode}`;
179
- logger.error(`CLI failed (code=${exitCode}):`, errMsg);
180
- this.send({
181
- event: "deliver",
182
- order_id: call.order_id,
183
- error: errMsg.slice(0, 2000),
184
- });
185
- return;
186
- }
187
- const parsed = parseJsonOutput(stdout);
188
- output = parsed ?? { result: stdout.trim().slice(0, 5000) };
133
+ const command = this.config.provider.cli_command;
134
+ logger.info(`Executing: ${command} for skill="${call.skill}" order=${call.order_id} (timeout=${timeoutS}s)`);
135
+ const { stdout, stderr, exitCode } = await runCli(command, prompt, timeoutS * 1000);
136
+ if (exitCode !== 0) {
137
+ const errMsg = stderr.trim() || `CLI exited with code ${exitCode}`;
138
+ logger.error(`CLI failed (code=${exitCode}):`, errMsg);
139
+ this.send({
140
+ event: "deliver",
141
+ order_id: call.order_id,
142
+ error: errMsg.slice(0, 2000),
143
+ });
144
+ return;
189
145
  }
146
+ const parsed = parseJsonOutput(stdout);
147
+ let output = parsed ?? {
148
+ result: stdout.trim().slice(0, 5000),
149
+ };
190
150
  // Upload local files to R2 if any
191
151
  output = await replaceLocalPaths(output, this.config);
192
152
  const sent = this.send({
@@ -11,10 +11,7 @@ const CONFIG_DIR = join(homedir(), ".clawmoney");
11
11
  const CONFIG_FILE = join(CONFIG_DIR, "config.yaml");
12
12
  const PID_FILE = join(CONFIG_DIR, "provider.pid");
13
13
  const DEFAULT_PROVIDER = {
14
- execution_mode: "webhook",
15
- cli_command: "claude",
16
- webhook_url: "http://127.0.0.1:18789/hooks/agent",
17
- webhook_token: "",
14
+ cli_command: "openclaw",
18
15
  max_concurrent: 3,
19
16
  ws_url: "wss://api.bnbot.ai/api/v1/ws/agent",
20
17
  api_base_url: "https://api.bnbot.ai/api/v1",
@@ -75,11 +72,9 @@ function loadProviderConfig(cliCommand) {
75
72
  process.exit(1);
76
73
  }
77
74
  const userProvider = (raw.provider ?? {});
75
+ logger.info(`Config raw provider: ${JSON.stringify(raw.provider)}, cliCommand arg: ${cliCommand}`);
78
76
  const provider = {
79
- execution_mode: userProvider.execution_mode ?? DEFAULT_PROVIDER.execution_mode,
80
77
  cli_command: cliCommand ?? userProvider.cli_command ?? DEFAULT_PROVIDER.cli_command,
81
- webhook_url: userProvider.webhook_url ?? DEFAULT_PROVIDER.webhook_url,
82
- webhook_token: userProvider.webhook_token ?? DEFAULT_PROVIDER.webhook_token,
83
78
  max_concurrent: userProvider.max_concurrent ?? DEFAULT_PROVIDER.max_concurrent,
84
79
  ws_url: userProvider.ws_url ?? DEFAULT_PROVIDER.ws_url,
85
80
  api_base_url: userProvider.api_base_url ?? DEFAULT_PROVIDER.api_base_url,
@@ -165,8 +160,5 @@ export function runProvider(cliCommand) {
165
160
  wsClient.start();
166
161
  poller.start();
167
162
  logger.info("Hub Provider running. Listening for service calls...");
168
- logger.info(`Config: mode=${config.provider.execution_mode}, max_concurrent=${config.provider.max_concurrent}` +
169
- (config.provider.execution_mode === "webhook"
170
- ? `, webhook=${config.provider.webhook_url}`
171
- : `, cli=${config.provider.cli_command}`));
163
+ logger.info(`Config: cli=${config.provider.cli_command}, max_concurrent=${config.provider.max_concurrent}`);
172
164
  }
@@ -38,10 +38,7 @@ export interface TestResponseEvent {
38
38
  }
39
39
  export type OutgoingEvent = DeliverEvent | TestResponseEvent;
40
40
  export interface ProviderSettings {
41
- execution_mode: "webhook" | "cli";
42
41
  cli_command: string;
43
- webhook_url: string;
44
- webhook_token: string;
45
42
  max_concurrent: number;
46
43
  ws_url: string;
47
44
  api_base_url: string;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ const program = new Command();
10
10
  program
11
11
  .name('clawmoney')
12
12
  .description('ClawMoney CLI -- Earn rewards with your AI agent')
13
- .version('0.8.2');
13
+ .version('0.8.6');
14
14
  // setup
15
15
  program
16
16
  .command('setup')
@@ -5,10 +5,7 @@ export interface ClawConfig {
5
5
  email?: string;
6
6
  wallet_address?: string;
7
7
  provider?: {
8
- execution_mode?: string;
9
8
  cli_command?: string;
10
- webhook_url?: string;
11
- webhook_token?: string;
12
9
  max_concurrent?: number;
13
10
  [key: string]: unknown;
14
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {