haansi 0.1.100 → 0.1.101
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/haansi.js +50 -12
- package/package.json +1 -1
package/dist/haansi.js
CHANGED
|
@@ -95,7 +95,7 @@ var require_package = __commonJS({
|
|
|
95
95
|
"package.json"(exports2, module2) {
|
|
96
96
|
module2.exports = {
|
|
97
97
|
name: "haansi",
|
|
98
|
-
version: "0.1.
|
|
98
|
+
version: "0.1.101",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -86710,8 +86710,6 @@ function usageOf(output) {
|
|
|
86710
86710
|
}
|
|
86711
86711
|
function modelUnreachableOf(output, exitCode) {
|
|
86712
86712
|
if (exitCode === 0) return null;
|
|
86713
|
-
const used = usageOf(output);
|
|
86714
|
-
if ((used.outputTokens ?? 0) > 0) return null;
|
|
86715
86713
|
const objects = jsonLines(output);
|
|
86716
86714
|
const result = [...objects].reverse().find((o) => o.type === "result");
|
|
86717
86715
|
if (result && result.is_error === true) {
|
|
@@ -86719,6 +86717,8 @@ function modelUnreachableOf(output, exitCode) {
|
|
|
86719
86717
|
if (result.terminal_reason === "api_error" || MODEL_REFUSAL.test(said))
|
|
86720
86718
|
return clipReason(said || "the model's API returned an error");
|
|
86721
86719
|
}
|
|
86720
|
+
const used = usageOf(output);
|
|
86721
|
+
if ((used.outputTokens ?? 0) > 0) return null;
|
|
86722
86722
|
for (const o of [...objects].reverse()) {
|
|
86723
86723
|
const message = typeof o.message === "string" ? o.message : typeof o.error?.message === "string" ? String(o.error.message) : "";
|
|
86724
86724
|
if ((o.type === "error" || o.type === "turn.failed") && MODEL_REFUSAL.test(message))
|
|
@@ -88412,6 +88412,7 @@ function configFingerprintOf(c) {
|
|
|
88412
88412
|
return (0, import_node_crypto6.createHash)("sha256").update(
|
|
88413
88413
|
JSON.stringify({
|
|
88414
88414
|
agentCmd: c.agentCmd,
|
|
88415
|
+
judgeCmd: c.judgeCmd ?? null,
|
|
88415
88416
|
testCmd: c.testCmd,
|
|
88416
88417
|
setupCmd: c.setupCmd,
|
|
88417
88418
|
attempts: c.attempts,
|
|
@@ -88501,7 +88502,7 @@ async function runStoredReplays(options, deps) {
|
|
|
88501
88502
|
);
|
|
88502
88503
|
} else if (valid.length) {
|
|
88503
88504
|
const gate = await gateOnContext(deps, valid, {
|
|
88504
|
-
agentCmd: options.agentCmd,
|
|
88505
|
+
agentCmd: options.judgeCmd || options.agentCmd,
|
|
88505
88506
|
timeoutMs: options.timeoutMs,
|
|
88506
88507
|
concurrency: options.concurrency ?? 1,
|
|
88507
88508
|
limit: options.limit,
|
|
@@ -88628,7 +88629,7 @@ async function runStoredReplays(options, deps) {
|
|
|
88628
88629
|
...await judgeUse(deps, {
|
|
88629
88630
|
label,
|
|
88630
88631
|
taskId: task.taskId,
|
|
88631
|
-
agentCmd: options.agentCmd,
|
|
88632
|
+
agentCmd: options.judgeCmd || options.agentCmd,
|
|
88632
88633
|
timeoutMs: options.timeoutMs,
|
|
88633
88634
|
card: cardPrompt(task, null),
|
|
88634
88635
|
calls,
|
|
@@ -88658,7 +88659,7 @@ async function runStoredReplays(options, deps) {
|
|
|
88658
88659
|
const judged = await judgeRelevance(deps, {
|
|
88659
88660
|
label,
|
|
88660
88661
|
taskId: task.taskId,
|
|
88661
|
-
agentCmd: options.agentCmd,
|
|
88662
|
+
agentCmd: options.judgeCmd || options.agentCmd,
|
|
88662
88663
|
timeoutMs: options.timeoutMs,
|
|
88663
88664
|
card: cardPrompt(task, null),
|
|
88664
88665
|
targetChange: targetText,
|
|
@@ -88788,12 +88789,15 @@ var init_replay_tasks = __esm({
|
|
|
88788
88789
|
// src/commands/replay.ts
|
|
88789
88790
|
var replay_exports = {};
|
|
88790
88791
|
__export(replay_exports, {
|
|
88792
|
+
OUTPUT_HEAD_CHARS: () => OUTPUT_HEAD_CHARS,
|
|
88793
|
+
OUTPUT_TAIL_CHARS: () => OUTPUT_TAIL_CHARS,
|
|
88791
88794
|
SHA: () => SHA,
|
|
88792
88795
|
cleanClone: () => cleanClone,
|
|
88793
88796
|
dropLinks: () => dropLinks,
|
|
88794
88797
|
ensureCommit: () => ensureCommit,
|
|
88795
88798
|
githubRunRef: () => githubRunRef,
|
|
88796
88799
|
localDeps: () => localDeps,
|
|
88800
|
+
outputKeeper: () => outputKeeper,
|
|
88797
88801
|
parseReplayArgs: () => parseReplayArgs,
|
|
88798
88802
|
replay: () => replay,
|
|
88799
88803
|
replayArm: () => replayArm,
|
|
@@ -88836,6 +88840,7 @@ function parseReplayArgs(argv) {
|
|
|
88836
88840
|
"--family is retired: replays run on the tasks selected on Impact \u2192 Replays."
|
|
88837
88841
|
);
|
|
88838
88842
|
} else if (a === "--agent-cmd") options.agentCmd = next();
|
|
88843
|
+
else if (a === "--judge-cmd") options.judgeCmd = next() || null;
|
|
88839
88844
|
else if (a === "--test-cmd") options.testCmd = next();
|
|
88840
88845
|
else if (a === "--setup-cmd") options.setupCmd = next() || null;
|
|
88841
88846
|
else if (a === "--attempts") options.attempts = Number(next());
|
|
@@ -89142,6 +89147,31 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
89142
89147
|
if (!agentEnv.HAANSI_REPLAY_MCP_CONFIG) deps.removeFile(`${dir}.mcp.json`);
|
|
89143
89148
|
}
|
|
89144
89149
|
}
|
|
89150
|
+
function outputKeeper(headChars = OUTPUT_HEAD_CHARS, tailChars = OUTPUT_TAIL_CHARS) {
|
|
89151
|
+
let head = "";
|
|
89152
|
+
let tail = "";
|
|
89153
|
+
let dropped = false;
|
|
89154
|
+
return {
|
|
89155
|
+
add(text) {
|
|
89156
|
+
if (head.length < headChars) {
|
|
89157
|
+
const room = headChars - head.length;
|
|
89158
|
+
head += text.slice(0, room);
|
|
89159
|
+
text = text.slice(room);
|
|
89160
|
+
}
|
|
89161
|
+
if (!text) return;
|
|
89162
|
+
tail += text;
|
|
89163
|
+
if (tail.length > tailChars) {
|
|
89164
|
+
tail = tail.slice(-tailChars);
|
|
89165
|
+
dropped = true;
|
|
89166
|
+
}
|
|
89167
|
+
},
|
|
89168
|
+
text() {
|
|
89169
|
+
return dropped ? `${head}
|
|
89170
|
+
\u2026 (output trimmed)
|
|
89171
|
+
${tail}` : head + tail;
|
|
89172
|
+
}
|
|
89173
|
+
};
|
|
89174
|
+
}
|
|
89145
89175
|
function runCommand(file2, args, cwd, env, timeoutMs, stdoutOnly = false) {
|
|
89146
89176
|
return new Promise((resolvePromise) => {
|
|
89147
89177
|
const child = (0, import_node_child_process5.spawn)(file2, args, {
|
|
@@ -89150,9 +89180,9 @@ function runCommand(file2, args, cwd, env, timeoutMs, stdoutOnly = false) {
|
|
|
89150
89180
|
stdio: ["ignore", "pipe", "pipe"]
|
|
89151
89181
|
});
|
|
89152
89182
|
let output = "";
|
|
89153
|
-
const
|
|
89154
|
-
|
|
89155
|
-
|
|
89183
|
+
const kept = outputKeeper();
|
|
89184
|
+
const keep = (chunk) => kept.add(chunk.toString());
|
|
89185
|
+
const finalOutput = () => stdoutOnly ? output : kept.text();
|
|
89156
89186
|
if (stdoutOnly) {
|
|
89157
89187
|
const chunks = [];
|
|
89158
89188
|
child.stdout.on("data", (chunk) => chunks.push(chunk));
|
|
@@ -89172,13 +89202,13 @@ function runCommand(file2, args, cwd, env, timeoutMs, stdoutOnly = false) {
|
|
|
89172
89202
|
clearTimeout(timer);
|
|
89173
89203
|
resolvePromise({
|
|
89174
89204
|
code: code ?? 1,
|
|
89175
|
-
output,
|
|
89205
|
+
output: finalOutput(),
|
|
89176
89206
|
...timedOut ? { timedOut } : {}
|
|
89177
89207
|
});
|
|
89178
89208
|
});
|
|
89179
89209
|
child.on("error", () => {
|
|
89180
89210
|
clearTimeout(timer);
|
|
89181
|
-
resolvePromise({ code: 1, output });
|
|
89211
|
+
resolvePromise({ code: 1, output: finalOutput() });
|
|
89182
89212
|
});
|
|
89183
89213
|
});
|
|
89184
89214
|
}
|
|
@@ -89360,7 +89390,7 @@ Baseline: ${arm("baseline")} passed \xB7 With Haansi: ${arm("haansi")} passed \x
|
|
|
89360
89390
|
(0, import_node_fs13.rmSync)(work, { recursive: true, force: true });
|
|
89361
89391
|
}
|
|
89362
89392
|
}
|
|
89363
|
-
var import_node_child_process5, import_node_fs13, import_node_os11, import_node_path16, SHA, ARMS, FEEDBACK_CHARS, FAILURE_LINES2, REPLAY_BRANCH, USAGE2;
|
|
89393
|
+
var import_node_child_process5, import_node_fs13, import_node_os11, import_node_path16, SHA, ARMS, FEEDBACK_CHARS, FAILURE_LINES2, REPLAY_BRANCH, OUTPUT_HEAD_CHARS, OUTPUT_TAIL_CHARS, USAGE2;
|
|
89364
89394
|
var init_replay = __esm({
|
|
89365
89395
|
"src/commands/replay.ts"() {
|
|
89366
89396
|
"use strict";
|
|
@@ -89382,9 +89412,12 @@ var init_replay = __esm({
|
|
|
89382
89412
|
FEEDBACK_CHARS = 6e3;
|
|
89383
89413
|
FAILURE_LINES2 = 8;
|
|
89384
89414
|
REPLAY_BRANCH = "replay";
|
|
89415
|
+
OUTPUT_HEAD_CHARS = 4e4;
|
|
89416
|
+
OUTPUT_TAIL_CHARS = 2e5;
|
|
89385
89417
|
USAGE2 = `Usage: haansi replay run --agent-cmd "<cmd>" --test-cmd "<cmd>"
|
|
89386
89418
|
[--setup-cmd "<cmd>"] [--attempts 3] [--arms baseline,haansi] [--limit n]
|
|
89387
89419
|
[--timeout-min 20] [--agent-name <name>] [--model <name>]
|
|
89420
|
+
[--judge-cmd "<cmd>"]
|
|
89388
89421
|
[--run-ref <url>] [--dry-run] [--repo-commands] [--no-diffs]
|
|
89389
89422
|
[--shard i/n] [--concurrency k] [--force] [--max-hours h] [--any-context]
|
|
89390
89423
|
[--setup-cache <files> --setup-cache-path <paths> [--setup-cache-dir <dir>]]
|
|
@@ -89419,6 +89452,11 @@ A task with nothing relevant Haansi can return is skipped, and checked again
|
|
|
89419
89452
|
once the organization gains new Haansi content. --any-context replays every
|
|
89420
89453
|
valid task without the check (diagnostics).
|
|
89421
89454
|
|
|
89455
|
+
--judge-cmd runs the judges (whether the agent used what Haansi returned,
|
|
89456
|
+
which of it was relevant, and the context check before replaying) with their
|
|
89457
|
+
own command, e.g. a stronger model than a cheap agent's; --agent-cmd when not
|
|
89458
|
+
given.
|
|
89459
|
+
|
|
89422
89460
|
--repo-commands uses the setup and test commands an org owner or admin saved for the
|
|
89423
89461
|
repository in Haansi (Impact \u2192 Replays) for any not given here.
|
|
89424
89462
|
|