clawmoney 0.17.44 → 0.17.45

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.
@@ -23,6 +23,7 @@
23
23
  import { readFileSync, writeFileSync, unlinkSync, existsSync, appendFileSync, mkdirSync } from "node:fs";
24
24
  import { join } from "node:path";
25
25
  import { homedir } from "node:os";
26
+ import { fileURLToPath } from "node:url";
26
27
  import YAML from "yaml";
27
28
  const TASK_LOG_FILE = join(homedir(), ".clawmoney", "task.log");
28
29
  function tsLine(level, msg) {
@@ -40,11 +41,11 @@ function logToFile(level, ...args) {
40
41
  /* best effort */
41
42
  }
42
43
  }
43
- // Redirect console.* to the file so daemon log lines persist even when
44
- // the daemon is spawned with stdio:"ignore" by `clawmoney task start`.
45
- console.log = (...args) => logToFile("INFO", ...args);
46
- console.warn = (...args) => logToFile("WARN", ...args);
47
- console.error = (...args) => logToFile("ERROR", ...args);
44
+ function installFileLogger() {
45
+ console.log = (...args) => logToFile("INFO", ...args);
46
+ console.warn = (...args) => logToFile("WARN", ...args);
47
+ console.error = (...args) => logToFile("ERROR", ...args);
48
+ }
48
49
  import { TaskWsClient } from "./ws-client.js";
49
50
  import { getSkill, listSkills } from "./skills/index.js";
50
51
  const CONFIG_DIR = join(homedir(), ".clawmoney");
@@ -186,6 +187,9 @@ async function handleTaskRequest(ws, req) {
186
187
  }
187
188
  }
188
189
  function main() {
190
+ // Daemon was started as a script (stdio:"ignore"); from here on, all
191
+ // log lines should land in ~/.clawmoney/task.log.
192
+ installFileLogger();
189
193
  const existing = readTaskPid();
190
194
  if (existing !== null && isPidAlive(existing)) {
191
195
  console.error(`[task] already running (PID ${existing})`);
@@ -243,4 +247,9 @@ function main() {
243
247
  process.on("SIGTERM", () => shutdown("SIGTERM"));
244
248
  ws.start();
245
249
  }
246
- main();
250
+ // Only run main() when invoked as a script (`node daemon.js`), not when
251
+ // the module is imported (e.g. by src/commands/task.ts which only wants
252
+ // to use readTaskPid / isPidAlive helpers).
253
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
254
+ main();
255
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawmoney",
3
- "version": "0.17.44",
3
+ "version": "0.17.45",
4
4
  "description": "ClawMoney CLI -- Earn rewards with your AI agent",
5
5
  "type": "module",
6
6
  "bin": {