@hackerrank/astra-cli 0.1.4 → 0.1.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/README.md +2 -2
- package/package.json +1 -1
- package/src/agent.js +1 -1
- package/src/bench.js +1 -1
- package/src/cli.js +18 -15
- package/src/project.js +2 -2
package/README.md
CHANGED
|
@@ -228,7 +228,7 @@ credits — that's a quota issue, not a bug.
|
|
|
228
228
|
whatever runs already exist on disk, then exit
|
|
229
229
|
-C, --cwd <path> Working directory for commands (default: cwd)
|
|
230
230
|
-o, --output <path> Also write trajectory JSON here (autonomous mode)
|
|
231
|
-
-s, --steps <n>
|
|
231
|
+
-s, --steps <n> Turn limit (unset = no limit)
|
|
232
232
|
-w, --wall <seconds> Wall-clock limit (default: 0 = none)
|
|
233
233
|
--timeout <seconds> Per-command timeout (default: 60)
|
|
234
234
|
--max-output <n> Max chars of command output kept (default: 16000)
|
|
@@ -237,7 +237,7 @@ credits — that's a quota issue, not a bug.
|
|
|
237
237
|
--resume <id> Resume a saved session
|
|
238
238
|
--sessions List saved sessions and exit
|
|
239
239
|
-y, --yolo Auto-run commands (always on in autonomous mode)
|
|
240
|
-
-q, --quiet Do not stream
|
|
240
|
+
-q, --quiet Do not stream turns (autonomous mode)
|
|
241
241
|
-h, --help Show help
|
|
242
242
|
```
|
|
243
243
|
|
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -38,7 +38,7 @@ export class Agent {
|
|
|
38
38
|
this.model = model;
|
|
39
39
|
this.env = env;
|
|
40
40
|
this.mode = opts.mode === "interactive" ? "interactive" : "autonomous";
|
|
41
|
-
this.stepLimit = opts.stepLimit ??
|
|
41
|
+
this.stepLimit = opts.stepLimit ?? 0;
|
|
42
42
|
this.wallTimeLimitSeconds = opts.wallTimeLimitSeconds ?? 0;
|
|
43
43
|
this.maxConsecutiveFormatErrors = opts.maxConsecutiveFormatErrors ?? 3;
|
|
44
44
|
this.outputPath = opts.outputPath ?? null;
|
package/src/bench.js
CHANGED
package/src/cli.js
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* --bench-root <dir> Root folder for bench runs (default: ./bench)
|
|
46
46
|
* -C, --cwd <path> Working directory for commands (default: cwd)
|
|
47
47
|
* -o, --output <path> Also write trajectory JSON here (bench mode)
|
|
48
|
-
* -s, --steps <n>
|
|
48
|
+
* -s, --steps <n> Turn limit (unset = no limit)
|
|
49
49
|
* -w, --wall <seconds> Wall-clock limit (default: 0 = none)
|
|
50
50
|
* --timeout <seconds> Per-command timeout (default: 60)
|
|
51
51
|
* --max-output <n> Max chars of command output kept (default: 16000)
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
* --sessions List saved sessions and exit
|
|
56
56
|
* -y, --yolo Auto-run commands without confirmation
|
|
57
57
|
* (always on in bench mode)
|
|
58
|
-
* -q, --quiet Do not stream
|
|
58
|
+
* -q, --quiet Do not stream turns (bench mode)
|
|
59
59
|
* -h, --help Show this help
|
|
60
60
|
*
|
|
61
61
|
* API key resolution (first hit wins):
|
|
@@ -113,7 +113,7 @@ function reasoningKwargs(level) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function parseArgs(argv) {
|
|
116
|
-
const args = { steps:
|
|
116
|
+
const args = { steps: 0, wall: 0, timeout: 60, quiet: false, "max-output": 16000, _provided: new Set() };
|
|
117
117
|
const alias = {
|
|
118
118
|
"-m": "model", "--model": "model",
|
|
119
119
|
"-t": "task", "--task": "task",
|
|
@@ -419,11 +419,15 @@ async function main() {
|
|
|
419
419
|
if (benchRun) {
|
|
420
420
|
console.error(
|
|
421
421
|
`\x1b[2m[astra] bench · ${benchRun.slug}/${benchRun.runId} ` +
|
|
422
|
-
`· model=${modelId}${reasoning ? ` reasoning=${reasoning}` : ""}
|
|
422
|
+
`· model=${modelId}${reasoning ? ` reasoning=${reasoning}` : ""}` +
|
|
423
|
+
`${Number(args.steps) > 0 ? ` turns<=${args.steps}` : ""}\x1b[0m`
|
|
423
424
|
);
|
|
424
425
|
console.error(`\x1b[2m[astra] workspace -> ${benchRun.workspace}\x1b[0m`);
|
|
425
426
|
} else {
|
|
426
|
-
console.error(
|
|
427
|
+
console.error(
|
|
428
|
+
`\x1b[2m[astra] bench · model=${modelId} cwd=${cmdCwd}` +
|
|
429
|
+
`${Number(args.steps) > 0 ? ` turns<=${args.steps}` : ""}\x1b[0m`
|
|
430
|
+
);
|
|
427
431
|
}
|
|
428
432
|
}
|
|
429
433
|
|
|
@@ -451,7 +455,7 @@ async function main() {
|
|
|
451
455
|
const pt = model.totalPromptTokens;
|
|
452
456
|
const ct = model.totalCompletionTokens;
|
|
453
457
|
console.error(
|
|
454
|
-
`\n\x1b[1m[astra] exit=${result.exit_status}
|
|
458
|
+
`\n\x1b[1m[astra] exit=${result.exit_status} turns=${agent.nSteps}\x1b[0m`
|
|
455
459
|
);
|
|
456
460
|
console.error(
|
|
457
461
|
`\x1b[1m[astra] tokens: prompt=${fmt(pt)} completion=${fmt(ct)} total=${fmt(pt + ct)} ` +
|
|
@@ -576,7 +580,7 @@ async function runBenchMatrix({ args, apiKey, models, reasonings, repeat, task,
|
|
|
576
580
|
const status = r.error ? `model_error: ${r.error.split("\n")[0]}` : r.status;
|
|
577
581
|
console.error(
|
|
578
582
|
` ${mark} ${String(r.model).padEnd(20)} ${String(r.reasoning).padEnd(8)} ` +
|
|
579
|
-
`${String(status).padEnd(16)} ${String(r.steps).padStart(3)}
|
|
583
|
+
`${String(status).padEnd(16)} ${String(r.steps).padStart(3)} turns · ` +
|
|
580
584
|
`${fmt(r.total_tokens)} tok · ${fmtUsd(r.cost_usd)}` +
|
|
581
585
|
`${r.cost_source === "estimated" ? "~" : ""}`
|
|
582
586
|
);
|
|
@@ -620,7 +624,7 @@ function printLeaderboard(board) {
|
|
|
620
624
|
board.sort((a, b) => b.completion_rate - a.completion_rate || a.avg_steps - b.avg_steps);
|
|
621
625
|
console.error(
|
|
622
626
|
`\n\x1b[1m${"model".padEnd(20)} ${"reason".padEnd(8)} ${"complete".padEnd(8)} ` +
|
|
623
|
-
`${"
|
|
627
|
+
`${"turns".padStart(6)} ${"tokens".padStart(9)} ${"cost".padStart(9)} source\x1b[0m`
|
|
624
628
|
);
|
|
625
629
|
for (const g of board) {
|
|
626
630
|
const completed = `${g.completed}/${g.runs}`;
|
|
@@ -665,23 +669,22 @@ function printSessions() {
|
|
|
665
669
|
|
|
666
670
|
function printEvent(msg) {
|
|
667
671
|
// Bench mode keeps output compact: skip the verbose system/user/assistant
|
|
668
|
-
// message bodies (per-
|
|
672
|
+
// message bodies (per-turn progress is shown by printStep). Only surface a
|
|
669
673
|
// non-empty terminal exit event so the run's submission is still visible.
|
|
670
674
|
if (msg.role !== "exit" || !msg.content?.trim()) return;
|
|
671
675
|
console.error(`\x1b[35m--- SUBMISSION ---\x1b[0m\n${msg.content}\n`);
|
|
672
676
|
}
|
|
673
677
|
|
|
674
|
-
/** Compact per-
|
|
678
|
+
/** Compact per-turn status line with exact token usage from the API. */
|
|
675
679
|
function printStep(s) {
|
|
676
|
-
const limit = s.stepLimit > 0 ? `/${s.stepLimit}` : "";
|
|
677
680
|
const cached = s.usage.cached_tokens ? ` (cached ${fmt(s.usage.cached_tokens)})` : "";
|
|
678
681
|
const cost = s.costUsd != null
|
|
679
|
-
? `
|
|
682
|
+
? ` │ ${fmtUsd(s.costUsd)}${s.costKind === "estimated" ? "~" : ""}`
|
|
680
683
|
: "";
|
|
681
684
|
console.error(
|
|
682
|
-
`\x1b[36m[astra]
|
|
683
|
-
`↑${fmt(s.usage.prompt_tokens)} ↓${fmt(s.usage.completion_tokens)} tok
|
|
684
|
-
`ctx ${fmt(s.contextTokens)}${cached}${cost}
|
|
685
|
+
`\x1b[36m[astra] turn ${s.step} │ ` +
|
|
686
|
+
`↑${fmt(s.usage.prompt_tokens)} ↓${fmt(s.usage.completion_tokens)} tok │ ` +
|
|
687
|
+
`ctx ${fmt(s.contextTokens)}${cached}${cost} │ ${s.elapsedSeconds.toFixed(1)}s\x1b[0m`
|
|
685
688
|
);
|
|
686
689
|
}
|
|
687
690
|
|
package/src/project.js
CHANGED
|
@@ -14,7 +14,7 @@ const DEFAULT_BENCH = {
|
|
|
14
14
|
models: [],
|
|
15
15
|
reasoning: [""],
|
|
16
16
|
repeat: 1,
|
|
17
|
-
steps:
|
|
17
|
+
steps: 0,
|
|
18
18
|
wall_seconds: 0,
|
|
19
19
|
command_timeout_seconds: 60,
|
|
20
20
|
};
|
|
@@ -169,7 +169,7 @@ export function loadProject(projectPath) {
|
|
|
169
169
|
models: stringArray(bench.models, "bench.models", DEFAULT_BENCH.models),
|
|
170
170
|
reasoning: stringArray(bench.reasoning, "bench.reasoning", DEFAULT_BENCH.reasoning),
|
|
171
171
|
repeat: positiveInteger(bench.repeat, "bench.repeat", DEFAULT_BENCH.repeat),
|
|
172
|
-
steps: positiveInteger(bench.steps, "bench.steps", DEFAULT_BENCH.steps),
|
|
172
|
+
steps: positiveInteger(bench.steps, "bench.steps", DEFAULT_BENCH.steps, { allowZero: true }),
|
|
173
173
|
wall: positiveInteger(bench.wall_seconds, "bench.wall_seconds", DEFAULT_BENCH.wall_seconds, { allowZero: true }),
|
|
174
174
|
timeout: positiveInteger(bench.command_timeout_seconds, "bench.command_timeout_seconds", DEFAULT_BENCH.command_timeout_seconds),
|
|
175
175
|
},
|