haansi 0.1.97 → 0.1.98
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 +32 -2
- 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.98",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -86676,7 +86676,30 @@ function usageOf(output) {
|
|
|
86676
86676
|
}
|
|
86677
86677
|
return NONE;
|
|
86678
86678
|
}
|
|
86679
|
-
|
|
86679
|
+
function modelUnreachableOf(output, exitCode) {
|
|
86680
|
+
if (exitCode === 0) return null;
|
|
86681
|
+
const used = usageOf(output);
|
|
86682
|
+
if ((used.outputTokens ?? 0) > 0) return null;
|
|
86683
|
+
const objects = jsonLines(output);
|
|
86684
|
+
const result = [...objects].reverse().find((o) => o.type === "result");
|
|
86685
|
+
if (result && result.is_error === true) {
|
|
86686
|
+
const said = typeof result.result === "string" ? result.result : "";
|
|
86687
|
+
if (result.terminal_reason === "api_error" || MODEL_REFUSAL.test(said))
|
|
86688
|
+
return clipReason(said || "the model's API returned an error");
|
|
86689
|
+
}
|
|
86690
|
+
for (const o of [...objects].reverse()) {
|
|
86691
|
+
const message = typeof o.message === "string" ? o.message : typeof o.error?.message === "string" ? String(o.error.message) : "";
|
|
86692
|
+
if ((o.type === "error" || o.type === "turn.failed") && MODEL_REFUSAL.test(message))
|
|
86693
|
+
return clipReason(message);
|
|
86694
|
+
}
|
|
86695
|
+
const line = output.split(/\r?\n/).reverse().find((l) => MODEL_REFUSAL.test(l) && !l.trim().startsWith("{"));
|
|
86696
|
+
return line ? clipReason(line) : null;
|
|
86697
|
+
}
|
|
86698
|
+
function clipReason(text) {
|
|
86699
|
+
const t = text.replace(/\s+/g, " ").trim();
|
|
86700
|
+
return t.length > MAX_REASON_CHARS ? `${t.slice(0, MAX_REASON_CHARS - 1)}\u2026` : t;
|
|
86701
|
+
}
|
|
86702
|
+
var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS;
|
|
86680
86703
|
var init_replay_usage = __esm({
|
|
86681
86704
|
"src/commands/replay-usage.ts"() {
|
|
86682
86705
|
"use strict";
|
|
@@ -86688,6 +86711,8 @@ var init_replay_usage = __esm({
|
|
|
86688
86711
|
turns: null
|
|
86689
86712
|
};
|
|
86690
86713
|
count2 = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
86714
|
+
MODEL_REFUSAL = /credit balance is too low|insufficient[_ ](?:credit|quota|balance|funds)|quota (?:exceeded|exhausted)|exceeded your (?:current )?quota|invalid (?:x-)?api[_ -]?key|authentication[_ ]error|rate[_ ]limit(?:_error| exceeded| reached)|overloaded[_ ]error|api[_ ]error/i;
|
|
86715
|
+
MAX_REASON_CHARS = 200;
|
|
86691
86716
|
}
|
|
86692
86717
|
});
|
|
86693
86718
|
|
|
@@ -88698,6 +88723,11 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
|
|
|
88698
88723
|
for (const line of agent.output.trim().split("\n").slice(-FAILURE_LINES2))
|
|
88699
88724
|
deps.log(` ${line}`);
|
|
88700
88725
|
}
|
|
88726
|
+
const unreachable2 = modelUnreachableOf(agent.output, agent.code);
|
|
88727
|
+
if (unreachable2)
|
|
88728
|
+
throw new Error(
|
|
88729
|
+
`the agent could not reach its model (${unreachable2}); not graded, run it again`
|
|
88730
|
+
);
|
|
88701
88731
|
const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
|
|
88702
88732
|
const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path16.join)(dir, f))]));
|
|
88703
88733
|
for (const f of files) {
|