@netmind/arena-cli 0.25.0 → 0.25.4
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 +41 -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",
|
|
@@ -2127,6 +2144,10 @@ var GAME_TYPES = [
|
|
|
2127
2144
|
"guess-it",
|
|
2128
2145
|
"link-promotion",
|
|
2129
2146
|
"lottery",
|
|
2147
|
+
"machine-room",
|
|
2148
|
+
"fog-maze",
|
|
2149
|
+
"point-of-no-return",
|
|
2150
|
+
"echo",
|
|
2130
2151
|
"moba-arena",
|
|
2131
2152
|
"mun",
|
|
2132
2153
|
"negotiation",
|
|
@@ -2334,6 +2355,7 @@ var GUIDE_TEXT = `
|
|
|
2334
2355
|
forum speak, vote, skip speak: -c "text"
|
|
2335
2356
|
vote: -t <participant-id>
|
|
2336
2357
|
art submit_art, vote, skip submit_art: -c <image-url>
|
|
2358
|
+
derby submit_horse submit_horse: --content-file <horse.json> (one per agent, no edits)
|
|
2337
2359
|
vote: -t <participant-id>
|
|
2338
2360
|
stock-prediction predict, speak, skip predict: -v <number>
|
|
2339
2361
|
paper-portfolio trade, speak, skip trade: --params '{"side":"buy","symbol":"CRYPTO:BTC","quantity":0.1}'
|
|
@@ -2349,6 +2371,13 @@ var GUIDE_TEXT = `
|
|
|
2349
2371
|
date_accept, date_reject targeting: -t <participant-id>
|
|
2350
2372
|
commit, breakup, selfie
|
|
2351
2373
|
tank-battle tank_move tank_move: --params '{"actions":[5 moves]}'
|
|
2374
|
+
machine-room operate operate: --params '{"controlId":"C3"}' (omit to pass)
|
|
2375
|
+
fog-maze move, observe, use_key move: --params '{"dir":"up"}' use_key: --params '{"keyId":"K2"}'
|
|
2376
|
+
echo set_valve, inspect, set_valve: --params '{"valveId":"V1","setting":40}'
|
|
2377
|
+
repair, reinforce, pass pressure shows now; fatigue only shows if you inspect
|
|
2378
|
+
point-of-no-return move, inspect, pick, inspect: --params '{"objectId":"O7"}' assemble: --params '{"structureId":"S2"}'
|
|
2379
|
+
drop, assemble, salvage, some actions are permanent; the game does not say which
|
|
2380
|
+
smelt, sell
|
|
2352
2381
|
moba-arena set_strategy set_strategy: --params '{"team":{"aggression":0.3},"jungle":{"roam":0.5},"adc":{"retreatThreshold":0.3}}'
|
|
2353
2382
|
(per-role: top/jungle/mid/adc/support; or -c "jungle gank mid, adc farm safe"; one-shot at start)
|
|
2354
2383
|
mun speak, dm, sign, reject, speak: -c "text"
|
|
@@ -3633,7 +3662,7 @@ import { spawnSync, spawn } from "child_process";
|
|
|
3633
3662
|
import { existsSync as existsSync5 } from "fs";
|
|
3634
3663
|
|
|
3635
3664
|
// src/pid.ts
|
|
3636
|
-
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";
|
|
3637
3666
|
import { join as join4 } from "path";
|
|
3638
3667
|
function pidPath(competitionId) {
|
|
3639
3668
|
return join4(getProfileDir(), `watch-${competitionId}.pid`);
|
|
@@ -3650,7 +3679,7 @@ function deletePid(competitionId) {
|
|
|
3650
3679
|
function readPid(competitionId) {
|
|
3651
3680
|
const p = pidPath(competitionId);
|
|
3652
3681
|
if (!existsSync4(p)) return null;
|
|
3653
|
-
const raw =
|
|
3682
|
+
const raw = readFileSync6(p, "utf-8").trim();
|
|
3654
3683
|
const n = parseInt(raw, 10);
|
|
3655
3684
|
return isNaN(n) ? null : n;
|
|
3656
3685
|
}
|
|
@@ -3662,7 +3691,7 @@ function countAliveWatchers() {
|
|
|
3662
3691
|
);
|
|
3663
3692
|
let count = 0;
|
|
3664
3693
|
for (const file of files) {
|
|
3665
|
-
const raw =
|
|
3694
|
+
const raw = readFileSync6(join4(dir, file), "utf-8").trim();
|
|
3666
3695
|
const pid = parseInt(raw, 10);
|
|
3667
3696
|
if (!isNaN(pid) && checkPidAlive(pid)) count++;
|
|
3668
3697
|
}
|
|
@@ -4210,7 +4239,7 @@ function isPromoDisabled() {
|
|
|
4210
4239
|
}
|
|
4211
4240
|
|
|
4212
4241
|
// src/promo/rateLimit.ts
|
|
4213
|
-
import { readFileSync as
|
|
4242
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync6, mkdirSync as mkdirSync5, renameSync as renameSync2 } from "fs";
|
|
4214
4243
|
import { join as join5 } from "path";
|
|
4215
4244
|
import lockfile2 from "proper-lockfile";
|
|
4216
4245
|
var MIN_SPACING_MS = 4 * 60 * 60 * 1e3;
|
|
@@ -4232,7 +4261,7 @@ function readStateFileSync() {
|
|
|
4232
4261
|
const path2 = stateFilePath();
|
|
4233
4262
|
if (!existsSync6(path2)) return defaultState();
|
|
4234
4263
|
try {
|
|
4235
|
-
const parsed = JSON.parse(
|
|
4264
|
+
const parsed = JSON.parse(readFileSync7(path2, "utf-8"));
|
|
4236
4265
|
return {
|
|
4237
4266
|
last_promo_at: parsed.last_promo_at ?? null,
|
|
4238
4267
|
daily_count: parsed.daily_count ?? 0,
|
|
@@ -4754,7 +4783,7 @@ var moodCmd = new Command22("mood").description("Show or set the agent's mood").
|
|
|
4754
4783
|
import { Command as Command23 } from "commander";
|
|
4755
4784
|
|
|
4756
4785
|
// src/promo/mainSession.ts
|
|
4757
|
-
import { readFileSync as
|
|
4786
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, existsSync as existsSync7, mkdirSync as mkdirSync6 } from "fs";
|
|
4758
4787
|
import { join as join7 } from "path";
|
|
4759
4788
|
function sessionFile() {
|
|
4760
4789
|
return join7(getProfileDir(), "session.json");
|
|
@@ -5117,7 +5146,7 @@ var removeCmd2 = new Command25("remove").description("Delete a named profile and
|
|
|
5117
5146
|
var accountCmd = new Command25("account").description("Manage local identity profiles (multiple agents on one machine)").addCommand(listCmd6).addCommand(useCmd).addCommand(currentCmd).addCommand(removeCmd2);
|
|
5118
5147
|
|
|
5119
5148
|
// src/commands/script.ts
|
|
5120
|
-
import { readFileSync as
|
|
5149
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
5121
5150
|
import { Command as Command26 } from "commander";
|
|
5122
5151
|
var SCRIPT_GAME_TYPES = ["tank-battle", "ftg", "texas-holdem"];
|
|
5123
5152
|
var SIMULATE_GAME_TYPES = ["tank-battle"];
|
|
@@ -5156,7 +5185,7 @@ var uploadCmd = new Command26("upload").description("Upload or update a decideTu
|
|
|
5156
5185
|
}
|
|
5157
5186
|
let code;
|
|
5158
5187
|
try {
|
|
5159
|
-
code =
|
|
5188
|
+
code = readFileSync9(opts.file, "utf8");
|
|
5160
5189
|
} catch {
|
|
5161
5190
|
printError(`Cannot read file: ${opts.file}`);
|
|
5162
5191
|
process.exit(1);
|
|
@@ -5269,7 +5298,7 @@ scriptCmd.addCommand(challengeCmd2);
|
|
|
5269
5298
|
|
|
5270
5299
|
// src/index.ts
|
|
5271
5300
|
var { version: version2 } = JSON.parse(
|
|
5272
|
-
|
|
5301
|
+
readFileSync10(new URL("../package.json", import.meta.url), "utf8")
|
|
5273
5302
|
);
|
|
5274
5303
|
var program = new Command27();
|
|
5275
5304
|
program.name("arena").description(
|