@autohq/cli 0.1.180 → 0.1.182

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.
@@ -19874,7 +19874,6 @@ var ProviderCredentialKindSchema = external_exports.enum([
19874
19874
  "github_app_installation",
19875
19875
  "oauth",
19876
19876
  "api_token",
19877
- "nango_connection",
19878
19877
  "webhook",
19879
19878
  "internal"
19880
19879
  ]);
@@ -26572,7 +26571,7 @@ Object.assign(lookup, {
26572
26571
  // package.json
26573
26572
  var package_default = {
26574
26573
  name: "@autohq/cli",
26575
- version: "0.1.180",
26574
+ version: "0.1.182",
26576
26575
  license: "SEE LICENSE IN README.md",
26577
26576
  publishConfig: {
26578
26577
  access: "public"
@@ -46910,6 +46909,14 @@ var ClaudeAgentBridgeSessionImpl = class {
46910
46909
  stderr;
46911
46910
  options;
46912
46911
  state = { kind: "idle" };
46912
+ // Turns sent to the SDK but not yet ended by a `result`. A bare boolean
46913
+ // cannot tell an interrupted turn's terminal `result` apart from the next
46914
+ // turn's: an out-of-order `result` could clear the flag while a fresh turn is
46915
+ // mid-flight and silently swallow a later interrupt. A counter is
46916
+ // order-independent — every sent message increments, every `result`
46917
+ // decrements — so interleaved interrupt/result deliveries stay balanced.
46918
+ activeTurnCount = 0;
46919
+ interruptInFlight = null;
46913
46920
  exitReported = false;
46914
46921
  constructor(input) {
46915
46922
  const optionsStartedAt = Date.now();
@@ -46954,7 +46961,9 @@ var ClaudeAgentBridgeSessionImpl = class {
46954
46961
  }
46955
46962
  }
46956
46963
  async sendMessage(message) {
46964
+ await this.interruptActiveTurnBeforeMessage();
46957
46965
  this.inputQueue.push(claudeAgentUserMessage(message));
46966
+ this.activeTurnCount += 1;
46958
46967
  void this.ensureRunningQuery().catch((error51) => {
46959
46968
  void this.input.onError(error51);
46960
46969
  });
@@ -46965,6 +46974,7 @@ var ClaudeAgentBridgeSessionImpl = class {
46965
46974
  return;
46966
46975
  }
46967
46976
  this.state = { kind: "closed" };
46977
+ this.activeTurnCount = 0;
46968
46978
  this.stderr.flush();
46969
46979
  this.inputQueue.close();
46970
46980
  if (previousState.kind === "started") {
@@ -47047,6 +47057,9 @@ var ClaudeAgentBridgeSessionImpl = class {
47047
47057
  void (async () => {
47048
47058
  try {
47049
47059
  for await (const message of query) {
47060
+ if (isClaudeAgentTurnResult(message)) {
47061
+ this.activeTurnCount = Math.max(0, this.activeTurnCount - 1);
47062
+ }
47050
47063
  const failure = probeClaudeAgentMessage(
47051
47064
  message,
47052
47065
  this.messageProbeContext()
@@ -47068,11 +47081,46 @@ var ClaudeAgentBridgeSessionImpl = class {
47068
47081
  await this.input.onError(error51);
47069
47082
  }
47070
47083
  } finally {
47084
+ this.activeTurnCount = 0;
47071
47085
  this.state = { kind: "closed" };
47072
47086
  this.reportExit();
47073
47087
  }
47074
47088
  })();
47075
47089
  }
47090
+ async interruptActiveTurnBeforeMessage() {
47091
+ if (this.activeTurnCount === 0 || this.state.kind !== "running") {
47092
+ return;
47093
+ }
47094
+ if (this.interruptInFlight) {
47095
+ await this.interruptInFlight;
47096
+ return;
47097
+ }
47098
+ const query = this.state.query;
47099
+ const startedAt = Date.now();
47100
+ this.input.writeOutput?.(
47101
+ `agent_bridge_claude_mid_turn_interrupt_started at=${new Date(startedAt).toISOString()}`
47102
+ );
47103
+ const interruptPromise = (async () => {
47104
+ try {
47105
+ await query.interrupt();
47106
+ this.input.writeOutput?.(
47107
+ `agent_bridge_claude_mid_turn_interrupt_ready duration_ms=${Date.now() - startedAt}`
47108
+ );
47109
+ } catch (error51) {
47110
+ this.input.writeOutput?.(
47111
+ `agent_bridge_claude_mid_turn_interrupt_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
47112
+ );
47113
+ }
47114
+ })();
47115
+ this.interruptInFlight = interruptPromise;
47116
+ try {
47117
+ await interruptPromise;
47118
+ } finally {
47119
+ if (this.interruptInFlight === interruptPromise) {
47120
+ this.interruptInFlight = null;
47121
+ }
47122
+ }
47123
+ }
47076
47124
  messageProbeContext() {
47077
47125
  return {
47078
47126
  configuredMcpServerNames: Object.keys(this.options.mcpServers ?? {}),
@@ -47217,6 +47265,9 @@ function claudeAgentUserMessage(message) {
47217
47265
  parent_tool_use_id: null
47218
47266
  };
47219
47267
  }
47268
+ function isClaudeAgentTurnResult(message) {
47269
+ return message.type === "result";
47270
+ }
47220
47271
 
47221
47272
  // src/commands/agent-bridge/harness/claude-code/index.ts
47222
47273
  async function runAgentBridgeClaudeCode(options) {
package/dist/index.js CHANGED
@@ -16306,7 +16306,6 @@ var init_provider_grants = __esm({
16306
16306
  "github_app_installation",
16307
16307
  "oauth",
16308
16308
  "api_token",
16309
- "nango_connection",
16310
16309
  "webhook",
16311
16310
  "internal"
16312
16311
  ]);
@@ -21682,7 +21681,7 @@ var init_package = __esm({
21682
21681
  "package.json"() {
21683
21682
  package_default = {
21684
21683
  name: "@autohq/cli",
21685
- version: "0.1.180",
21684
+ version: "0.1.182",
21686
21685
  license: "SEE LICENSE IN README.md",
21687
21686
  publishConfig: {
21688
21687
  access: "public"
@@ -31448,6 +31447,14 @@ var ClaudeAgentBridgeSessionImpl = class {
31448
31447
  stderr;
31449
31448
  options;
31450
31449
  state = { kind: "idle" };
31450
+ // Turns sent to the SDK but not yet ended by a `result`. A bare boolean
31451
+ // cannot tell an interrupted turn's terminal `result` apart from the next
31452
+ // turn's: an out-of-order `result` could clear the flag while a fresh turn is
31453
+ // mid-flight and silently swallow a later interrupt. A counter is
31454
+ // order-independent — every sent message increments, every `result`
31455
+ // decrements — so interleaved interrupt/result deliveries stay balanced.
31456
+ activeTurnCount = 0;
31457
+ interruptInFlight = null;
31451
31458
  exitReported = false;
31452
31459
  constructor(input) {
31453
31460
  const optionsStartedAt = Date.now();
@@ -31492,7 +31499,9 @@ var ClaudeAgentBridgeSessionImpl = class {
31492
31499
  }
31493
31500
  }
31494
31501
  async sendMessage(message) {
31502
+ await this.interruptActiveTurnBeforeMessage();
31495
31503
  this.inputQueue.push(claudeAgentUserMessage(message));
31504
+ this.activeTurnCount += 1;
31496
31505
  void this.ensureRunningQuery().catch((error51) => {
31497
31506
  void this.input.onError(error51);
31498
31507
  });
@@ -31503,6 +31512,7 @@ var ClaudeAgentBridgeSessionImpl = class {
31503
31512
  return;
31504
31513
  }
31505
31514
  this.state = { kind: "closed" };
31515
+ this.activeTurnCount = 0;
31506
31516
  this.stderr.flush();
31507
31517
  this.inputQueue.close();
31508
31518
  if (previousState.kind === "started") {
@@ -31585,6 +31595,9 @@ var ClaudeAgentBridgeSessionImpl = class {
31585
31595
  void (async () => {
31586
31596
  try {
31587
31597
  for await (const message of query) {
31598
+ if (isClaudeAgentTurnResult(message)) {
31599
+ this.activeTurnCount = Math.max(0, this.activeTurnCount - 1);
31600
+ }
31588
31601
  const failure = probeClaudeAgentMessage(
31589
31602
  message,
31590
31603
  this.messageProbeContext()
@@ -31606,11 +31619,46 @@ var ClaudeAgentBridgeSessionImpl = class {
31606
31619
  await this.input.onError(error51);
31607
31620
  }
31608
31621
  } finally {
31622
+ this.activeTurnCount = 0;
31609
31623
  this.state = { kind: "closed" };
31610
31624
  this.reportExit();
31611
31625
  }
31612
31626
  })();
31613
31627
  }
31628
+ async interruptActiveTurnBeforeMessage() {
31629
+ if (this.activeTurnCount === 0 || this.state.kind !== "running") {
31630
+ return;
31631
+ }
31632
+ if (this.interruptInFlight) {
31633
+ await this.interruptInFlight;
31634
+ return;
31635
+ }
31636
+ const query = this.state.query;
31637
+ const startedAt = Date.now();
31638
+ this.input.writeOutput?.(
31639
+ `agent_bridge_claude_mid_turn_interrupt_started at=${new Date(startedAt).toISOString()}`
31640
+ );
31641
+ const interruptPromise = (async () => {
31642
+ try {
31643
+ await query.interrupt();
31644
+ this.input.writeOutput?.(
31645
+ `agent_bridge_claude_mid_turn_interrupt_ready duration_ms=${Date.now() - startedAt}`
31646
+ );
31647
+ } catch (error51) {
31648
+ this.input.writeOutput?.(
31649
+ `agent_bridge_claude_mid_turn_interrupt_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
31650
+ );
31651
+ }
31652
+ })();
31653
+ this.interruptInFlight = interruptPromise;
31654
+ try {
31655
+ await interruptPromise;
31656
+ } finally {
31657
+ if (this.interruptInFlight === interruptPromise) {
31658
+ this.interruptInFlight = null;
31659
+ }
31660
+ }
31661
+ }
31614
31662
  messageProbeContext() {
31615
31663
  return {
31616
31664
  configuredMcpServerNames: Object.keys(this.options.mcpServers ?? {}),
@@ -31755,6 +31803,9 @@ function claudeAgentUserMessage(message) {
31755
31803
  parent_tool_use_id: null
31756
31804
  };
31757
31805
  }
31806
+ function isClaudeAgentTurnResult(message) {
31807
+ return message.type === "result";
31808
+ }
31758
31809
 
31759
31810
  // src/commands/agent-bridge/harness/claude-code/index.ts
31760
31811
  async function runAgentBridgeClaudeCode(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.180",
3
+ "version": "0.1.182",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"