@agentchatme/claude-code 0.0.1394114111111 → 0.0.139411411111111

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.
@@ -9525,6 +9525,7 @@ async function runDaemon(opts) {
9525
9525
 
9526
9526
  // src/adapter.ts
9527
9527
  import * as fs5 from "fs";
9528
+ import * as os from "os";
9528
9529
  import * as path6 from "path";
9529
9530
  import * as crypto2 from "crypto";
9530
9531
 
@@ -9560,7 +9561,7 @@ var spawnCommand = import_cross_spawn.default;
9560
9561
  var spawnCommandSync = import_cross_spawn.default.sync;
9561
9562
 
9562
9563
  // src/version.ts
9563
- var VERSION2 = "0.0.1394114111111";
9564
+ var VERSION2 = "0.0.139411411111111";
9564
9565
 
9565
9566
  // src/runtime-version.ts
9566
9567
  var MIN_CLAUDE_CODE_VERSION = "2.1.219";
@@ -9594,13 +9595,20 @@ var PARENT_ENV_KEYS = [
9594
9595
  "CLAUDE_EFFORT",
9595
9596
  "AI_AGENT"
9596
9597
  ];
9597
- function claudeIsLoggedIn(configDir) {
9598
+ function claudeProcessEnv(configDirOverride, source = process.env) {
9599
+ const env = { ...source };
9600
+ if (configDirOverride === void 0) delete env["CLAUDE_CONFIG_DIR"];
9601
+ else env["CLAUDE_CONFIG_DIR"] = configDirOverride;
9602
+ return env;
9603
+ }
9604
+ function claudeIsLoggedIn(configDirOverride) {
9598
9605
  const status = spawnCommandSync("claude", ["auth", "status"], {
9599
9606
  encoding: "utf-8",
9600
9607
  timeout: 1e4,
9601
- env: { ...process.env, CLAUDE_CONFIG_DIR: configDir }
9608
+ env: claudeProcessEnv(configDirOverride)
9602
9609
  });
9603
9610
  if (!status.error && status.status === 0) return true;
9611
+ const configDir = configDirOverride ?? path6.join(os.homedir(), ".claude");
9604
9612
  if (fs5.existsSync(path6.join(configDir, ".credentials.json"))) return true;
9605
9613
  if (process.platform !== "darwin") return false;
9606
9614
  const keychain = spawnCommandSync(
@@ -9610,10 +9618,9 @@ function claudeIsLoggedIn(configDir) {
9610
9618
  );
9611
9619
  return !keychain.error && keychain.status === 0;
9612
9620
  }
9613
- function buildClaudeEnv(configDir, source = process.env) {
9614
- const env = { ...source };
9621
+ function buildClaudeEnv(configDirOverride, source = process.env) {
9622
+ const env = claudeProcessEnv(configDirOverride, source);
9615
9623
  for (const key of PARENT_ENV_KEYS) delete env[key];
9616
- env["CLAUDE_CONFIG_DIR"] = configDir;
9617
9624
  env["DISABLE_AUTOUPDATER"] = "1";
9618
9625
  const configuredConnectTimeout = Number(env["MCP_CONNECT_TIMEOUT_MS"]);
9619
9626
  if (!Number.isFinite(configuredConnectTimeout) || configuredConnectTimeout < 3e4) {
@@ -9670,6 +9677,7 @@ var ClaudeTurnEvents = class {
9670
9677
  pending = /* @__PURE__ */ new Set();
9671
9678
  successfulSends = 0;
9672
9679
  sendFailure = null;
9680
+ runtimeAuthFailure = null;
9673
9681
  consume(event) {
9674
9682
  if (typeof event !== "object" || event === null) return;
9675
9683
  const record = event;
@@ -9699,6 +9707,9 @@ var ClaudeTurnEvents = class {
9699
9707
  for (const block of content) {
9700
9708
  if (typeof block !== "object" || block === null) continue;
9701
9709
  const tool = block;
9710
+ if (tool["type"] === "text" && typeof tool["text"] === "string" && fatalRuntimeError(tool["text"])) {
9711
+ this.runtimeAuthFailure = tool["text"].trim().slice(0, 500);
9712
+ }
9702
9713
  if (tool["type"] === "tool_use" && tool["name"] === SEND_TOOL && typeof tool["id"] === "string") {
9703
9714
  this.pending.add(tool["id"]);
9704
9715
  }
@@ -9761,6 +9772,12 @@ var ClaudeTurnEvents = class {
9761
9772
  }
9762
9773
  return { ok: true, sent: this.successfulSends > 0 };
9763
9774
  }
9775
+ /** Claude reports host-auth failures as assistant text on stdout rather than
9776
+ * stderr. Keep only the matching bounded diagnostic; ordinary model text is
9777
+ * never surfaced as a runtime error. */
9778
+ fatalDetail() {
9779
+ return this.runtimeAuthFailure;
9780
+ }
9764
9781
  };
9765
9782
  function killProcessTree(child) {
9766
9783
  if (child.pid === void 0) return;
@@ -9783,6 +9800,16 @@ function killProcessTree(child) {
9783
9800
  function fatalRuntimeError(detail) {
9784
9801
  return /not logged in|authentication|unauthorized|invalid api key|login required/i.test(detail);
9785
9802
  }
9803
+ function classifyClaudeExit(code, stderr, events) {
9804
+ const structured = events.fatalDetail();
9805
+ const diagnostic = structured ?? stderr.trim().slice(0, 500);
9806
+ const detail = `claude exited ${code ?? "without a status"}${diagnostic ? `: ${diagnostic}` : ""}`;
9807
+ return {
9808
+ ok: false,
9809
+ fatal: structured !== null || fatalRuntimeError(detail),
9810
+ detail
9811
+ };
9812
+ }
9786
9813
  var ClaudeAdapter = class {
9787
9814
  constructor(claudeConfigDir, identityHome2, workdir) {
9788
9815
  this.claudeConfigDir = claudeConfigDir;
@@ -9916,8 +9943,7 @@ var ClaudeAdapter = class {
9916
9943
  log.info(`claude turn done for ${ctx.conversationId} (sent=${outcome.sent})`);
9917
9944
  finish({ ok: true, detail: outcome.sent ? "replied" : "silent" });
9918
9945
  } else {
9919
- const detail = `claude exited ${code}${stderr ? `: ${stderr.slice(0, 500)}` : ""}`;
9920
- finish({ ok: false, fatal: fatalRuntimeError(detail), detail });
9946
+ finish(classifyClaudeExit(code, stderr, events));
9921
9947
  }
9922
9948
  });
9923
9949
  });
@@ -9933,12 +9959,14 @@ function buildPrompt(ctx) {
9933
9959
  }
9934
9960
 
9935
9961
  // src/host.ts
9936
- import * as os from "os";
9962
+ import * as os2 from "os";
9937
9963
  import * as path7 from "path";
9938
- function claudeHome() {
9964
+ function claudeConfigOverride() {
9939
9965
  const override = process.env["CLAUDE_CONFIG_DIR"];
9940
- if (override !== void 0 && override.trim().length > 0) return path7.resolve(override);
9941
- return path7.join(os.homedir(), ".claude");
9966
+ return override !== void 0 && override.trim().length > 0 ? path7.resolve(override) : void 0;
9967
+ }
9968
+ function claudeHome() {
9969
+ return claudeConfigOverride() ?? path7.join(os2.homedir(), ".claude");
9942
9970
  }
9943
9971
  function identityHome() {
9944
9972
  return path7.join(claudeHome(), "agentchat");
@@ -9964,7 +9992,7 @@ async function main(argv = process.argv.slice(2)) {
9964
9992
  return await runDaemon({
9965
9993
  home,
9966
9994
  workdir,
9967
- adapter: new ClaudeAdapter(claudeHome(), home, workdir)
9995
+ adapter: new ClaudeAdapter(claudeConfigOverride(), home, workdir)
9968
9996
  });
9969
9997
  }
9970
9998
  main().then(