haansi 0.1.99 → 0.1.100

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.
Files changed (2) hide show
  1. package/dist/haansi.js +67 -4
  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.99",
98
+ version: "0.1.100",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -86731,7 +86731,54 @@ function clipReason(text) {
86731
86731
  const t = text.replace(/\s+/g, " ").trim();
86732
86732
  return t.length > MAX_REASON_CHARS ? `${t.slice(0, MAX_REASON_CHARS - 1)}\u2026` : t;
86733
86733
  }
86734
- var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS;
86734
+ function mcpServersOf(output) {
86735
+ const init2 = jsonLines(output).find(
86736
+ (o) => o.type === "system" && o.subtype === "init"
86737
+ );
86738
+ if (!init2 || !Array.isArray(init2.mcp_servers)) return null;
86739
+ return init2.mcp_servers.map((s) => s ?? {}).filter(
86740
+ (s) => typeof s.name === "string"
86741
+ ).map((s) => ({
86742
+ name: s.name,
86743
+ status: typeof s.status === "string" ? s.status : "unknown"
86744
+ }));
86745
+ }
86746
+ function haansiServersDown(output) {
86747
+ const servers = mcpServersOf(output);
86748
+ if (!servers) return null;
86749
+ return servers.filter((s) => s.name.startsWith("haansi-") && s.status !== "connected").map((s) => `${s.name}: ${s.status}`);
86750
+ }
86751
+ function agentFailureLines(output, max2, scrub) {
86752
+ const out = [];
86753
+ for (const raw of output.trim().split(/\r?\n/)) {
86754
+ const line = raw.trim();
86755
+ if (!line) continue;
86756
+ if (line.startsWith("{") && line.endsWith("}")) {
86757
+ let event = null;
86758
+ try {
86759
+ event = JSON.parse(line);
86760
+ } catch {
86761
+ event = null;
86762
+ }
86763
+ if (event && typeof event === "object") {
86764
+ if (event.type !== "result") continue;
86765
+ const said = [
86766
+ typeof event.terminal_reason === "string" ? `terminal_reason=${event.terminal_reason}` : "",
86767
+ event.is_error === true ? "is_error" : "",
86768
+ typeof event.result === "string" ? event.result : ""
86769
+ ].filter(Boolean).join(" ");
86770
+ if (said) out.push(said);
86771
+ continue;
86772
+ }
86773
+ }
86774
+ out.push(line);
86775
+ }
86776
+ return out.slice(-max2).map((l) => {
86777
+ const clean = scrub(l.replace(/\s+/g, " "));
86778
+ return clean.length > MAX_LOGGED_LINE_CHARS ? `${clean.slice(0, MAX_LOGGED_LINE_CHARS - 1)}\u2026` : clean;
86779
+ });
86780
+ }
86781
+ var NONE, count2, MODEL_REFUSAL, MAX_REASON_CHARS, MAX_LOGGED_LINE_CHARS;
86735
86782
  var init_replay_usage = __esm({
86736
86783
  "src/commands/replay-usage.ts"() {
86737
86784
  "use strict";
@@ -86745,6 +86792,7 @@ var init_replay_usage = __esm({
86745
86792
  count2 = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
86746
86793
  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;
86747
86794
  MAX_REASON_CHARS = 200;
86795
+ MAX_LOGGED_LINE_CHARS = 300;
86748
86796
  }
86749
86797
  });
86750
86798
 
@@ -88971,7 +89019,11 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
88971
89019
  });
88972
89020
  if (agent.code !== 0) {
88973
89021
  deps.log(`\u2026 ${label}: the agent exited with code ${agent.code}`);
88974
- for (const line of agent.output.trim().split("\n").slice(-FAILURE_LINES2))
89022
+ for (const line of agentFailureLines(
89023
+ agent.output,
89024
+ FAILURE_LINES2,
89025
+ scrubSecrets
89026
+ ))
88975
89027
  deps.log(` ${line}`);
88976
89028
  }
88977
89029
  const unreachable2 = modelUnreachableOf(agent.output, agent.code);
@@ -88979,6 +89031,17 @@ async function replayArm(deps, options, task, arm, promptOf, inspect, agentEnv =
88979
89031
  throw new Error(
88980
89032
  `the agent could not reach its model (${unreachable2}); not graded, run it again`
88981
89033
  );
89034
+ if (arm === "haansi") {
89035
+ const down = haansiServersDown(agent.output);
89036
+ if (down === null)
89037
+ deps.log(
89038
+ `\u2026 ${label}: the agent did not report its MCP servers (use --output-format stream-json --verbose to check them)`
89039
+ );
89040
+ else if (down.length)
89041
+ throw new Error(
89042
+ `Haansi's servers did not load for the agent (${down.join(", ")}); not graded, run it again`
89043
+ );
89044
+ }
88982
89045
  const gradeSha = task.testNames?.length ? task.baseSha : task.targetSha;
88983
89046
  const own = new Map(files.map((f) => [f, deps.readFile((0, import_node_path16.join)(dir, f))]));
88984
89047
  for (const f of files) {
@@ -89368,7 +89431,7 @@ Run from a clone of the repository. Example (GitHub Actions):
89368
89431
  haansi replay run --setup-cmd 'npm ci' \\
89369
89432
  --container node:22 --container-env ANTHROPIC_API_KEY \\
89370
89433
  --container-setup 'npm install -g haansi @anthropic-ai/claude-code' \\
89371
- --agent-cmd 'claude -p "$HAANSI_REPLAY_PROMPT" --output-format json --permission-mode acceptEdits --mcp-config "$HAANSI_REPLAY_MCP_CONFIG" --allowedTools mcp__haansi-solutions,mcp__haansi-exchange,mcp__haansi-digests,mcp__haansi-onboarding,mcp__haansi-skills' \\
89434
+ --agent-cmd 'claude -p "$HAANSI_REPLAY_PROMPT" --output-format stream-json --verbose --permission-mode acceptEdits --mcp-config "$HAANSI_REPLAY_MCP_CONFIG" --allowedTools mcp__haansi-solutions,mcp__haansi-exchange,mcp__haansi-digests,mcp__haansi-onboarding,mcp__haansi-skills' \\
89372
89435
  --test-cmd 'npx vitest run $HAANSI_REPLAY_TEST_FILES -t "$HAANSI_REPLAY_TEST_PATTERN"' \\
89373
89436
  --agent-name claude-code --model claude-sonnet-5-5`;
89374
89437
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.99",
3
+ "version": "0.1.100",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"