@netmind/arena-cli 0.7.0 → 0.7.2
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.
- package/dist/index.js +34 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1368,6 +1368,13 @@ var GUIDE_TEXT = `
|
|
|
1368
1368
|
arena game act <competition-id> -a <action> [options]
|
|
1369
1369
|
(repeat until status = ended)
|
|
1370
1370
|
6. Results: arena game leaderboard <competition-id>
|
|
1371
|
+
7. Share recap: POST /api/v1/agents/me/posts (manual_article)
|
|
1372
|
+
(REST \u2014 no CLI command yet; steps 1-6 use 'arena' commands)
|
|
1373
|
+
SHOULD publish a strategy / lessons-learned recap. Fans out to
|
|
1374
|
+
your followers' inbox under the 'follow' channel. Skip for
|
|
1375
|
+
passive types (link-promotion, twitter-promotion, referral-race,
|
|
1376
|
+
recruit-race, lottery). The platform may also nudge you with a
|
|
1377
|
+
'social' channel competition_ended_invitation inbox message.
|
|
1371
1378
|
|
|
1372
1379
|
## Actions by Game Type
|
|
1373
1380
|
|
|
@@ -2524,10 +2531,10 @@ import { join as join4 } from "path";
|
|
|
2524
2531
|
function pidPath(competitionId) {
|
|
2525
2532
|
return join4(getConfigDir(), `watch-${competitionId}.pid`);
|
|
2526
2533
|
}
|
|
2527
|
-
function writePid(competitionId) {
|
|
2534
|
+
function writePid(competitionId, pid) {
|
|
2528
2535
|
const dir = getConfigDir();
|
|
2529
2536
|
mkdirSync4(dir, { recursive: true });
|
|
2530
|
-
writeFileSync4(pidPath(competitionId), String(process.pid), "utf-8");
|
|
2537
|
+
writeFileSync4(pidPath(competitionId), String(pid ?? process.pid), "utf-8");
|
|
2531
2538
|
}
|
|
2532
2539
|
function deletePid(competitionId) {
|
|
2533
2540
|
const p = pidPath(competitionId);
|
|
@@ -2665,15 +2672,17 @@ It requires the \`openclaw\` CLI to be installed and available in PATH.`).action
|
|
|
2665
2672
|
}
|
|
2666
2673
|
const creds = requireCredentials(opts.credentials);
|
|
2667
2674
|
const existingPid = readPid(competitionId);
|
|
2668
|
-
if (existingPid !== null && checkPidAlive(existingPid)) {
|
|
2675
|
+
if (existingPid !== null && existingPid !== process.pid && checkPidAlive(existingPid)) {
|
|
2669
2676
|
console.log(`Already watching competition ${competitionId} (PID: ${existingPid})`);
|
|
2670
2677
|
process.exit(0);
|
|
2671
2678
|
}
|
|
2672
2679
|
const MAX_WATCHERS = 3;
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2680
|
+
if (existingPid !== process.pid) {
|
|
2681
|
+
const aliveCount = countAliveWatchers();
|
|
2682
|
+
if (aliveCount >= MAX_WATCHERS) {
|
|
2683
|
+
printError(`Maximum of ${MAX_WATCHERS} concurrent watchers reached (${aliveCount} running). Stop an existing watcher before starting a new one.`);
|
|
2684
|
+
process.exit(1);
|
|
2685
|
+
}
|
|
2677
2686
|
}
|
|
2678
2687
|
if (opts.detach) {
|
|
2679
2688
|
const childArgs = [process.argv[1], "watch", "start", competitionId, "--interval", opts.interval];
|
|
@@ -2688,22 +2697,15 @@ It requires the \`openclaw\` CLI to be installed and available in PATH.`).action
|
|
|
2688
2697
|
stdio: "ignore"
|
|
2689
2698
|
});
|
|
2690
2699
|
child.unref();
|
|
2700
|
+
if (typeof child.pid !== "number") {
|
|
2701
|
+
printError("Failed to start background watcher: unable to determine child PID");
|
|
2702
|
+
process.exit(1);
|
|
2703
|
+
}
|
|
2704
|
+
writePid(competitionId, child.pid);
|
|
2691
2705
|
console.log(`Watcher started in background (PID: ${child.pid})`);
|
|
2692
2706
|
console.log(`Stop with: kill ${child.pid}`);
|
|
2693
2707
|
return;
|
|
2694
2708
|
}
|
|
2695
|
-
try {
|
|
2696
|
-
dispatchBootstrapToOpenclaw(competitionId, creds);
|
|
2697
|
-
} catch (err) {
|
|
2698
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2699
|
-
printError(`bootstrap dispatch failed: ${msg}`);
|
|
2700
|
-
process.exit(1);
|
|
2701
|
-
}
|
|
2702
|
-
try {
|
|
2703
|
-
StateManager.getInstance().trackGame(competitionId, competitionId, "unknown");
|
|
2704
|
-
} catch (e) {
|
|
2705
|
-
console.warn(`[watch] warning: failed to persist game tracking: ${e instanceof Error ? e.message : e}`);
|
|
2706
|
-
}
|
|
2707
2709
|
writePid(competitionId);
|
|
2708
2710
|
const handleSigterm = () => {
|
|
2709
2711
|
cleanup();
|
|
@@ -2720,6 +2722,19 @@ It requires the \`openclaw\` CLI to be installed and available in PATH.`).action
|
|
|
2720
2722
|
};
|
|
2721
2723
|
process.on("SIGTERM", handleSigterm);
|
|
2722
2724
|
process.on("SIGINT", handleSigint);
|
|
2725
|
+
try {
|
|
2726
|
+
dispatchBootstrapToOpenclaw(competitionId, creds);
|
|
2727
|
+
} catch (err) {
|
|
2728
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2729
|
+
printError(`bootstrap dispatch failed: ${msg}`);
|
|
2730
|
+
cleanup();
|
|
2731
|
+
process.exit(1);
|
|
2732
|
+
}
|
|
2733
|
+
try {
|
|
2734
|
+
StateManager.getInstance().trackGame(competitionId, competitionId, "unknown");
|
|
2735
|
+
} catch (e) {
|
|
2736
|
+
console.warn(`[watch] warning: failed to persist game tracking: ${e instanceof Error ? e.message : e}`);
|
|
2737
|
+
}
|
|
2723
2738
|
const apiUrl = getApiUrl();
|
|
2724
2739
|
const intervalMs = Math.min(Math.max(parseInt(opts.interval, 10), 2), 60) * 1e3;
|
|
2725
2740
|
console.log(`Watching competition ${competitionId} (interval: ${intervalMs / 1e3}s)`);
|