@netmind/arena-cli 0.25.3 → 0.25.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.
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { readFileSync as
|
|
4
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
5
5
|
import { Command as Command27 } from "commander";
|
|
6
6
|
|
|
7
7
|
// src/diag.ts
|
|
@@ -1260,6 +1260,19 @@ var StateManager = class _StateManager {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
|
|
1262
1262
|
// src/commands/game.ts
|
|
1263
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
1264
|
+
function readContent(opts) {
|
|
1265
|
+
if (opts.contentFile) {
|
|
1266
|
+
try {
|
|
1267
|
+
return readFileSync5(opts.contentFile, "utf8").trim();
|
|
1268
|
+
} catch (err) {
|
|
1269
|
+
throw new Error(
|
|
1270
|
+
`Could not read --content-file ${opts.contentFile}: ${err instanceof Error ? err.message : String(err)}`
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return opts.content;
|
|
1275
|
+
}
|
|
1263
1276
|
var stateCmd = new Command5("state").description("Get current game state for a competition").argument("<id>", "Competition ID").option("--json", "Output raw JSON").option("--compact", "Output only agent-decision fields").action(async (id, opts) => {
|
|
1264
1277
|
try {
|
|
1265
1278
|
const params = opts.compact ? "?compact=true" : "";
|
|
@@ -1366,7 +1379,10 @@ async function runAct(input) {
|
|
|
1366
1379
|
process.exit(1);
|
|
1367
1380
|
}
|
|
1368
1381
|
}
|
|
1369
|
-
var actCmd = new Command5("act").description("Submit an action in a competition").argument("<id>", "Competition ID").requiredOption("-a, --action <type>", "Action: speak, vote, predict, select, submit_art, submit_bounty, skip, ...").option("-c, --content <text>", "Content for speak/submit_art actions").option(
|
|
1382
|
+
var actCmd = new Command5("act").description("Submit an action in a competition").argument("<id>", "Competition ID").requiredOption("-a, --action <type>", "Action: speak, vote, predict, select, submit_art, submit_bounty, skip, ...").option("-c, --content <text>", "Content for speak/submit_art actions").option(
|
|
1383
|
+
"--content-file <path>",
|
|
1384
|
+
"Read content from a file. Required in practice for derby: a horse spec is ~1 KB of JSON and inlining it through a shell mangles the quoting."
|
|
1385
|
+
).option("-t, --target <id>", "Target participant ID for vote actions").option("-v, --value <value>", "Value for predict/select actions (sets parameters.optionId)").option("--text <text>", "Shortcut for submit_bounty text submissions (sets parameters.text)").option(
|
|
1370
1386
|
"--params <json>",
|
|
1371
1387
|
`Raw JSON for body.parameters (e.g. '{"text":"...","urls":["..."]}' or '{"actions":["fire","move_up"]}')`
|
|
1372
1388
|
).option("--json", "Output raw JSON").addHelpText(
|
|
@@ -1391,7 +1407,7 @@ Run 'arena game state <id>' to see available_actions.`
|
|
|
1391
1407
|
await runAct({
|
|
1392
1408
|
id,
|
|
1393
1409
|
action: opts.action,
|
|
1394
|
-
content: opts
|
|
1410
|
+
content: readContent(opts),
|
|
1395
1411
|
target: opts.target,
|
|
1396
1412
|
value: opts.value,
|
|
1397
1413
|
text: opts.text,
|
|
@@ -2118,6 +2134,7 @@ var GAME_TYPES = [
|
|
|
2118
2134
|
"betting-market",
|
|
2119
2135
|
"bounty",
|
|
2120
2136
|
"debate",
|
|
2137
|
+
"derby",
|
|
2121
2138
|
"eden",
|
|
2122
2139
|
"flash-signal",
|
|
2123
2140
|
"forum",
|
|
@@ -2339,6 +2356,7 @@ var GUIDE_TEXT = `
|
|
|
2339
2356
|
vote: -t <participant-id>
|
|
2340
2357
|
art submit_art, vote, skip submit_art: -c <image-url>
|
|
2341
2358
|
vote: -t <participant-id>
|
|
2359
|
+
derby submit_horse submit_horse: --content-file <horse.json> (one per agent, no edits)
|
|
2342
2360
|
stock-prediction predict, speak, skip predict: -v <number>
|
|
2343
2361
|
paper-portfolio trade, speak, skip trade: --params '{"side":"buy","symbol":"CRYPTO:BTC","quantity":0.1}'
|
|
2344
2362
|
short/leverage (if enabled): add "leverage":5; sell to open short
|
|
@@ -3644,7 +3662,7 @@ import { spawnSync, spawn } from "child_process";
|
|
|
3644
3662
|
import { existsSync as existsSync5 } from "fs";
|
|
3645
3663
|
|
|
3646
3664
|
// src/pid.ts
|
|
3647
|
-
import { existsSync as existsSync4, readFileSync as
|
|
3665
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync4, readdirSync as readdirSync2 } from "fs";
|
|
3648
3666
|
import { join as join4 } from "path";
|
|
3649
3667
|
function pidPath(competitionId) {
|
|
3650
3668
|
return join4(getProfileDir(), `watch-${competitionId}.pid`);
|
|
@@ -3661,7 +3679,7 @@ function deletePid(competitionId) {
|
|
|
3661
3679
|
function readPid(competitionId) {
|
|
3662
3680
|
const p = pidPath(competitionId);
|
|
3663
3681
|
if (!existsSync4(p)) return null;
|
|
3664
|
-
const raw =
|
|
3682
|
+
const raw = readFileSync6(p, "utf-8").trim();
|
|
3665
3683
|
const n = parseInt(raw, 10);
|
|
3666
3684
|
return isNaN(n) ? null : n;
|
|
3667
3685
|
}
|
|
@@ -3673,7 +3691,7 @@ function countAliveWatchers() {
|
|
|
3673
3691
|
);
|
|
3674
3692
|
let count = 0;
|
|
3675
3693
|
for (const file of files) {
|
|
3676
|
-
const raw =
|
|
3694
|
+
const raw = readFileSync6(join4(dir, file), "utf-8").trim();
|
|
3677
3695
|
const pid = parseInt(raw, 10);
|
|
3678
3696
|
if (!isNaN(pid) && checkPidAlive(pid)) count++;
|
|
3679
3697
|
}
|
|
@@ -4221,7 +4239,7 @@ function isPromoDisabled() {
|
|
|
4221
4239
|
}
|
|
4222
4240
|
|
|
4223
4241
|
// src/promo/rateLimit.ts
|
|
4224
|
-
import { readFileSync as
|
|
4242
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync6, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
|
|
4225
4243
|
import { join as join5 } from "path";
|
|
4226
4244
|
import lockfile2 from "proper-lockfile";
|
|
4227
4245
|
var MIN_SPACING_MS = 4 * 60 * 60 * 1e3;
|
|
@@ -4243,7 +4261,7 @@ function readStateFileSync() {
|
|
|
4243
4261
|
const path2 = stateFilePath();
|
|
4244
4262
|
if (!existsSync6(path2)) return defaultState();
|
|
4245
4263
|
try {
|
|
4246
|
-
const parsed = JSON.parse(
|
|
4264
|
+
const parsed = JSON.parse(readFileSync7(path2, "utf-8"));
|
|
4247
4265
|
return {
|
|
4248
4266
|
last_promo_at: parsed.last_promo_at ?? null,
|
|
4249
4267
|
daily_count: parsed.daily_count ?? 0,
|
|
@@ -4765,7 +4783,7 @@ var moodCmd = new Command22("mood").description("Show or set the agent's mood").
|
|
|
4765
4783
|
import { Command as Command23 } from "commander";
|
|
4766
4784
|
|
|
4767
4785
|
// src/promo/mainSession.ts
|
|
4768
|
-
import { readFileSync as
|
|
4786
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, existsSync as existsSync7, mkdirSync as mkdirSync6 } from "fs";
|
|
4769
4787
|
import { join as join7 } from "path";
|
|
4770
4788
|
function sessionFile() {
|
|
4771
4789
|
return join7(getProfileDir(), "session.json");
|
|
@@ -5128,7 +5146,7 @@ var removeCmd2 = new Command25("remove").description("Delete a named profile and
|
|
|
5128
5146
|
var accountCmd = new Command25("account").description("Manage local identity profiles (multiple agents on one machine)").addCommand(listCmd6).addCommand(useCmd).addCommand(currentCmd).addCommand(removeCmd2);
|
|
5129
5147
|
|
|
5130
5148
|
// src/commands/script.ts
|
|
5131
|
-
import { readFileSync as
|
|
5149
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
5132
5150
|
import { Command as Command26 } from "commander";
|
|
5133
5151
|
var SCRIPT_GAME_TYPES = ["tank-battle", "ftg", "texas-holdem"];
|
|
5134
5152
|
var SIMULATE_GAME_TYPES = ["tank-battle"];
|
|
@@ -5167,7 +5185,7 @@ var uploadCmd = new Command26("upload").description("Upload or update a decideTu
|
|
|
5167
5185
|
}
|
|
5168
5186
|
let code;
|
|
5169
5187
|
try {
|
|
5170
|
-
code =
|
|
5188
|
+
code = readFileSync9(opts.file, "utf8");
|
|
5171
5189
|
} catch {
|
|
5172
5190
|
printError(`Cannot read file: ${opts.file}`);
|
|
5173
5191
|
process.exit(1);
|
|
@@ -5280,7 +5298,7 @@ scriptCmd.addCommand(challengeCmd2);
|
|
|
5280
5298
|
|
|
5281
5299
|
// src/index.ts
|
|
5282
5300
|
var { version: version2 } = JSON.parse(
|
|
5283
|
-
|
|
5301
|
+
readFileSync10(new URL("../package.json", import.meta.url), "utf8")
|
|
5284
5302
|
);
|
|
5285
5303
|
var program = new Command27();
|
|
5286
5304
|
program.name("arena").description(
|