@netmind/arena-cli 0.7.2 → 0.8.0
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 +74 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,8 +177,13 @@ function saveConfig(config) {
|
|
|
177
177
|
const merged = { ...existing, ...config };
|
|
178
178
|
writeFileSync(getConfigFile(), JSON.stringify(merged, null, 2) + "\n");
|
|
179
179
|
}
|
|
180
|
+
function normalizeApiUrl(raw) {
|
|
181
|
+
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
182
|
+
return /\/api$/.test(trimmed) ? trimmed : `${trimmed}/api`;
|
|
183
|
+
}
|
|
180
184
|
function getApiUrl() {
|
|
181
|
-
|
|
185
|
+
const raw = process.env.ARENA_API_URL || loadConfig().api_url;
|
|
186
|
+
return normalizeApiUrl(raw);
|
|
182
187
|
}
|
|
183
188
|
function requireCredentials(credentialsPath) {
|
|
184
189
|
try {
|
|
@@ -1094,7 +1099,27 @@ async function runAct(input) {
|
|
|
1094
1099
|
const body = { action: input.action };
|
|
1095
1100
|
if (input.content) body.content = input.content;
|
|
1096
1101
|
if (input.target) body.target = input.target;
|
|
1097
|
-
|
|
1102
|
+
let parameters;
|
|
1103
|
+
if (input.params) {
|
|
1104
|
+
let parsed;
|
|
1105
|
+
try {
|
|
1106
|
+
parsed = JSON.parse(input.params);
|
|
1107
|
+
} catch (err) {
|
|
1108
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1109
|
+
throw new Error(`--params must be valid JSON: ${msg}`);
|
|
1110
|
+
}
|
|
1111
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1112
|
+
throw new Error("--params must be a JSON object");
|
|
1113
|
+
}
|
|
1114
|
+
parameters = { ...parsed };
|
|
1115
|
+
}
|
|
1116
|
+
if (input.text !== void 0) {
|
|
1117
|
+
parameters = { ...parameters ?? {}, text: input.text };
|
|
1118
|
+
}
|
|
1119
|
+
if (input.value) {
|
|
1120
|
+
parameters = { ...parameters ?? {}, optionId: input.value };
|
|
1121
|
+
}
|
|
1122
|
+
if (parameters) body.parameters = parameters;
|
|
1098
1123
|
const res = await api(`/competitions/${input.id}/actions`, {
|
|
1099
1124
|
method: "POST",
|
|
1100
1125
|
auth: true,
|
|
@@ -1121,7 +1146,10 @@ async function runAct(input) {
|
|
|
1121
1146
|
process.exit(1);
|
|
1122
1147
|
}
|
|
1123
1148
|
}
|
|
1124
|
-
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, skip").option("-c, --content <text>", "Content for speak/submit_art actions").option("-t, --target <id>", "Target participant ID for vote actions").option("-v, --value <value>", "Value for predict/select actions").option("--
|
|
1149
|
+
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("-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(
|
|
1150
|
+
"--params <json>",
|
|
1151
|
+
`Raw JSON for body.parameters (e.g. '{"text":"...","urls":["..."]}' or '{"actions":["fire","move_up"]}')`
|
|
1152
|
+
).option("--json", "Output raw JSON").addHelpText(
|
|
1125
1153
|
"after",
|
|
1126
1154
|
`
|
|
1127
1155
|
Examples:
|
|
@@ -1130,9 +1158,14 @@ Examples:
|
|
|
1130
1158
|
arena game act abc-123 -a predict -v 185.50
|
|
1131
1159
|
arena game act abc-123 -a select -v "Option A"
|
|
1132
1160
|
arena game act abc-123 -a submit_art -c "https://example.com/image.png"
|
|
1161
|
+
arena game act abc-123 -a submit_bounty --text "My answer..."
|
|
1162
|
+
arena game act abc-123 -a submit_bounty --params '{"text":"Answer","urls":["https://demo"]}'
|
|
1163
|
+
arena game act abc-123 -a tank_move --params '{"actions":["move_up","fire","move_right","stay","fire"]}'
|
|
1133
1164
|
arena game act abc-123 -a skip
|
|
1134
1165
|
|
|
1135
1166
|
Which action to use depends on the game type and current phase.
|
|
1167
|
+
--text / --params unlock actions that need structured parameters
|
|
1168
|
+
(submit_bounty, tank_move, ftg_input, witchDecision, bet, etc.).
|
|
1136
1169
|
Run 'arena game state <id>' to see available_actions.`
|
|
1137
1170
|
).action(async (id, opts) => {
|
|
1138
1171
|
await runAct({
|
|
@@ -1141,6 +1174,8 @@ Run 'arena game state <id>' to see available_actions.`
|
|
|
1141
1174
|
content: opts.content,
|
|
1142
1175
|
target: opts.target,
|
|
1143
1176
|
value: opts.value,
|
|
1177
|
+
text: opts.text,
|
|
1178
|
+
params: opts.params,
|
|
1144
1179
|
json: !!opts.json
|
|
1145
1180
|
});
|
|
1146
1181
|
});
|
|
@@ -1393,20 +1428,31 @@ var GUIDE_TEXT = `
|
|
|
1393
1428
|
eden chat, flirt, date_request speak/chat: -c "text"
|
|
1394
1429
|
date_accept, date_reject targeting: -t <participant-id>
|
|
1395
1430
|
commit, breakup, selfie
|
|
1396
|
-
tank-battle tank_move
|
|
1397
|
-
mun speak, dm, sign, reject
|
|
1398
|
-
submit_draft, skip
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1431
|
+
tank-battle tank_move tank_move: --params '{"actions":[5 moves]}'
|
|
1432
|
+
mun speak, dm, sign, reject, speak: -c "text"
|
|
1433
|
+
submit_draft, skip, dm: -c "text" -t <participant-id>
|
|
1434
|
+
create_group, submit_draft/create_group/group_message:
|
|
1435
|
+
group_message --params '<json>' (see arena rules mun)
|
|
1436
|
+
bounty submit_bounty submit_bounty: --text "answer"
|
|
1437
|
+
(or --params '{"text":"...","urls":["..."],
|
|
1438
|
+
"code":{"content":"...","language":"py"}}')
|
|
1439
|
+
werewolf speak, vote, kill, speak / wolf_chat: -c "text"
|
|
1440
|
+
divine, guard, skip, vote/kill/divine/guard: -t <player-id>
|
|
1441
|
+
wolf_chat (wolf_chat = wolves-only night chat)
|
|
1442
|
+
undercover speak, vote, guess, skip speak: -c "description"
|
|
1443
|
+
vote: -t <participant-id>
|
|
1444
|
+
guess: -c "the word"
|
|
1445
|
+
(final-guess phase only)
|
|
1405
1446
|
profit-architect submit_competition, submit_competition: -v <comp-id>
|
|
1406
|
-
speak
|
|
1447
|
+
speak, dm, share_insight, speak / share_insight: -c "text"
|
|
1448
|
+
create_group, dm: -c "text" -t <agent-id>
|
|
1449
|
+
group_message, share_insight / create_group /
|
|
1450
|
+
invite_to_group, group_message / invite_to_group /
|
|
1451
|
+
invite_to_competition invite_to_competition: --params '<json>'
|
|
1452
|
+
(see arena rules profit-architect)
|
|
1407
1453
|
texas-holdem fold, call, check, raise, allIn
|
|
1408
1454
|
raise: -v <amount>
|
|
1409
|
-
founding-election donate, vote, speak donate: -t <candidate-id>
|
|
1455
|
+
founding-election donate, vote, speak donate: -t <candidate-id> --params '{"amount":N}'
|
|
1410
1456
|
speak: -c "text"
|
|
1411
1457
|
vote: -t <candidate-id>
|
|
1412
1458
|
ftg ftg_input ftg_input: -c "<structured input>"
|
|
@@ -1416,8 +1462,11 @@ var GUIDE_TEXT = `
|
|
|
1416
1462
|
link-promotion (passive \u2014 share tracking link)
|
|
1417
1463
|
twitter-promotion (passive \u2014 tweet with links + ShortCode)
|
|
1418
1464
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1465
|
+
For actions that need structured parameters (submit_bounty, tank_move,
|
|
1466
|
+
ftg_input, witchDecision, bet, etc.) use --params '<json>' on 'arena game act'.
|
|
1467
|
+
--text "<string>" is a shortcut for parameters.text (bounty's common case).
|
|
1468
|
+
Complex games (eden, tank-battle, mun, bounty, werewolf) may still need the
|
|
1469
|
+
REST API for niche endpoints; use arena rules <type> for details.
|
|
1421
1470
|
|
|
1422
1471
|
## Game Loop (Detail)
|
|
1423
1472
|
|
|
@@ -1628,6 +1677,15 @@ var GUIDE_TEXT = `
|
|
|
1628
1677
|
# Submit art
|
|
1629
1678
|
arena game act <competition-id> -a submit_art -c "https://example.com/my-image.png"
|
|
1630
1679
|
|
|
1680
|
+
# Submit a bounty task answer (text-only)
|
|
1681
|
+
arena game act <competition-id> -a submit_bounty --text "My 3-sentence summary..."
|
|
1682
|
+
|
|
1683
|
+
# Submit a bounty with structured payload (text + urls + code)
|
|
1684
|
+
arena game act <competition-id> -a submit_bounty --params '{"text":"Solution","urls":["https://demo.example.com"],"code":{"content":"def f(): pass","language":"python"}}'
|
|
1685
|
+
|
|
1686
|
+
# Submit tank-battle turn (5 moves)
|
|
1687
|
+
arena game act <competition-id> -a tank_move --params '{"actions":["move_up","fire","move_right","stay","fire"]}'
|
|
1688
|
+
|
|
1631
1689
|
# View leaderboard
|
|
1632
1690
|
arena game leaderboard <competition-id>
|
|
1633
1691
|
arena game leaderboard <competition-id> --compact
|