@autohq/cli 0.1.222 → 0.1.224

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.
@@ -23319,7 +23319,7 @@ Object.assign(lookup, {
23319
23319
  // package.json
23320
23320
  var package_default = {
23321
23321
  name: "@autohq/cli",
23322
- version: "0.1.222",
23322
+ version: "0.1.224",
23323
23323
  license: "SEE LICENSE IN README.md",
23324
23324
  publishConfig: {
23325
23325
  access: "public"
@@ -23455,9 +23455,10 @@ async function runAgentBridgeSocket(options) {
23455
23455
  token: options.token,
23456
23456
  onBootstrap: options.onBootstrap,
23457
23457
  createHandler: (bootstrap) => options.createHandler({
23458
- emitOutput: (output) => emitOutputWithAck(socket, output),
23458
+ emitOutput: (output) => emitOutputWithAck(socket, output, options.runtimeLogger),
23459
23459
  bootstrap,
23460
23460
  outputSeqStart: bootstrap.outputSeqStart,
23461
+ runtimeLogger: options.runtimeLogger,
23461
23462
  socketId: () => socket.id,
23462
23463
  writeOutput: options.writeOutput
23463
23464
  }),
@@ -23495,23 +23496,55 @@ async function runAgentBridgeSocket(options) {
23495
23496
  });
23496
23497
  });
23497
23498
  socket.on(RUNTIME_BRIDGE_COMMAND_EVENT, (rawDelivery, ack) => {
23499
+ const startedAt = Date.now();
23500
+ const logContext = runtimeCommandLogContext(rawDelivery, socket.id);
23501
+ options.runtimeLogger?.info("agent_bridge_command_received", logContext);
23498
23502
  if (!handler) {
23499
23503
  const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
23500
23504
  if (delivery.success) {
23501
- ack(
23502
- commandAck({
23503
- delivery: delivery.data,
23504
- socketId: socket.id,
23505
- status: "failed",
23506
- error: "Bridge command received before bootstrap completed"
23507
- })
23508
- );
23505
+ const response = commandAck({
23506
+ delivery: delivery.data,
23507
+ socketId: socket.id,
23508
+ status: "failed",
23509
+ error: "Bridge command received before bootstrap completed"
23510
+ });
23511
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
23512
+ ...logContext,
23513
+ duration_ms: Date.now() - startedAt,
23514
+ ack_status: response.status,
23515
+ error: response.error
23516
+ });
23517
+ ack(response);
23509
23518
  return;
23510
23519
  }
23511
- ack({ error: "Bridge command received before bootstrap completed" });
23520
+ const error51 = "Bridge command received before bootstrap completed";
23521
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
23522
+ ...logContext,
23523
+ duration_ms: Date.now() - startedAt,
23524
+ ack_status: "failed",
23525
+ error: error51
23526
+ });
23527
+ ack({ error: error51 });
23512
23528
  return;
23513
23529
  }
23514
- void handler.handleCommand(rawDelivery).then((response) => ack(response)).catch((error51) => {
23530
+ void handler.handleCommand(rawDelivery).then((response) => {
23531
+ const parsedResponse = RuntimeBridgeCommandAckSchema.safeParse(response);
23532
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
23533
+ ...logContext,
23534
+ duration_ms: Date.now() - startedAt,
23535
+ ack_parse_status: parsedResponse.success ? "succeeded" : "failed",
23536
+ ack_status: parsedResponse.success ? parsedResponse.data.status : void 0,
23537
+ ack_socket_id: parsedResponse.success ? parsedResponse.data.socketId : void 0,
23538
+ error: parsedResponse.success ? parsedResponse.data.error : parsedResponse.error.message
23539
+ });
23540
+ ack(response);
23541
+ }).catch((error51) => {
23542
+ options.runtimeLogger?.warn("agent_bridge_command_handler_failed", {
23543
+ ...logContext,
23544
+ duration_ms: Date.now() - startedAt,
23545
+ ack_status: "failed",
23546
+ error: errorMessage(error51)
23547
+ });
23515
23548
  const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
23516
23549
  if (!delivery.success) {
23517
23550
  ack({
@@ -23613,27 +23646,54 @@ function createSessiontimeBridgeBootstrapListener(input) {
23613
23646
  }
23614
23647
  };
23615
23648
  }
23616
- function emitOutputWithAck(socket, output) {
23649
+ function emitOutputWithAck(socket, output, runtimeLogger) {
23650
+ const startedAt = Date.now();
23651
+ runtimeLogger?.info(
23652
+ "agent_bridge_output_emit_started",
23653
+ outputLogContext(output, socket.id)
23654
+ );
23617
23655
  return new Promise((resolve, reject) => {
23618
23656
  socket.timeout(5e3).emit(
23619
23657
  RUNTIME_BRIDGE_OUTPUT_EVENT,
23620
23658
  output,
23621
23659
  (error51, rawAck) => {
23622
23660
  if (error51) {
23661
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_failed", {
23662
+ ...outputLogContext(output, socket.id),
23663
+ duration_ms: Date.now() - startedAt,
23664
+ error: error51.message
23665
+ });
23623
23666
  reject(error51);
23624
23667
  return;
23625
23668
  }
23626
23669
  const ack = RuntimeBridgeOutputAckSchema.safeParse(rawAck);
23627
23670
  if (!ack.success) {
23671
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_invalid", {
23672
+ ...outputLogContext(output, socket.id),
23673
+ duration_ms: Date.now() - startedAt,
23674
+ error: ack.error.message
23675
+ });
23628
23676
  reject(ack.error);
23629
23677
  return;
23630
23678
  }
23631
23679
  if (ack.data.status === "failed") {
23680
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_rejected", {
23681
+ ...outputLogContext(output, socket.id),
23682
+ duration_ms: Date.now() - startedAt,
23683
+ ack_status: ack.data.status,
23684
+ error: ack.data.error
23685
+ });
23632
23686
  reject(
23633
23687
  new Error(ack.data.error ?? "Bridge rejected runtime output")
23634
23688
  );
23635
23689
  return;
23636
23690
  }
23691
+ runtimeLogger?.info("agent_bridge_output_emit_ack_ready", {
23692
+ ...outputLogContext(output, socket.id),
23693
+ duration_ms: Date.now() - startedAt,
23694
+ ack_status: ack.data.status,
23695
+ cursor: ack.data.cursor
23696
+ });
23637
23697
  resolve(ack.data);
23638
23698
  }
23639
23699
  );
@@ -23678,6 +23738,42 @@ function isNgrokFreeUrl(url3) {
23678
23738
  return false;
23679
23739
  }
23680
23740
  }
23741
+ function runtimeCommandLogContext(rawDelivery, socketId) {
23742
+ const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
23743
+ if (!delivery.success) {
23744
+ return {
23745
+ socket_id: socketId,
23746
+ delivery_parse_status: "failed"
23747
+ };
23748
+ }
23749
+ return {
23750
+ socket_id: socketId,
23751
+ delivery_parse_status: "succeeded",
23752
+ session_id: delivery.data.sessionId,
23753
+ runtime_id: delivery.data.runtimeId,
23754
+ bridge_lease_id: delivery.data.bridgeLeaseId,
23755
+ delivery_id: delivery.data.deliveryId,
23756
+ command_id: delivery.data.commandId,
23757
+ command_kind: delivery.data.kind
23758
+ };
23759
+ }
23760
+ function outputLogContext(output, socketId) {
23761
+ return {
23762
+ socket_id: socketId,
23763
+ session_id: output.sessionId,
23764
+ runtime_id: output.runtimeId,
23765
+ bridge_lease_id: output.bridgeLeaseId,
23766
+ output_seq: output.outputSeq,
23767
+ output_type: output.type,
23768
+ role: "role" in output ? output.role : void 0,
23769
+ kind: "kind" in output ? output.kind : void 0,
23770
+ output_status: "status" in output ? output.status : void 0,
23771
+ message_id: "messageId" in output ? output.messageId : void 0
23772
+ };
23773
+ }
23774
+ function errorMessage(error51) {
23775
+ return error51 instanceof Error ? error51.message : String(error51);
23776
+ }
23681
23777
 
23682
23778
  // ../../packages/schemas/src/account.ts
23683
23779
  var AccountDeleteRequestSchema = external_exports.object({
@@ -23750,6 +23846,7 @@ var AuthScopeSchema = external_exports.enum([
23750
23846
  "secret-values:read",
23751
23847
  "github:mcp",
23752
23848
  "github:credentials",
23849
+ "mcp:connection",
23753
23850
  "projects:admin",
23754
23851
  "org:admin"
23755
23852
  ]);
@@ -24499,12 +24596,12 @@ function parseClaudeCodeStreamRecord(parsed) {
24499
24596
  }
24500
24597
  const isError = record2.is_error === true || record2.subtype === "error";
24501
24598
  const sdkErrorMessage = record2.errors?.map((error51) => error51.trim()).filter(Boolean).join("\n");
24502
- const errorMessage = isError ? record2.error ?? record2.result ?? (sdkErrorMessage || void 0) ?? "claude-code reported an error" : void 0;
24599
+ const errorMessage2 = isError ? record2.error ?? record2.result ?? (sdkErrorMessage || void 0) ?? "claude-code reported an error" : void 0;
24503
24600
  return {
24504
24601
  projections: [],
24505
24602
  result: {
24506
24603
  isError,
24507
- errorMessage
24604
+ errorMessage: errorMessage2
24508
24605
  }
24509
24606
  };
24510
24607
  }
@@ -27316,6 +27413,12 @@ var AgentBridgeOutputBuffer = class {
27316
27413
  this.outputSeq,
27317
27414
  buildOutputEnvelope(context, this.outputSeq, projection)
27318
27415
  );
27416
+ this.input.runtimeLogger?.info(
27417
+ "agent_bridge_output_buffer_enqueued",
27418
+ this.outputLogContext(this.pendingOutputs.get(this.outputSeq), {
27419
+ pending_count: this.pendingOutputs.size
27420
+ })
27421
+ );
27319
27422
  await this.drainPendingOutputs();
27320
27423
  }
27321
27424
  async replayPendingOutputs() {
@@ -27334,8 +27437,16 @@ var AgentBridgeOutputBuffer = class {
27334
27437
  }
27335
27438
  if (options.force) {
27336
27439
  this.drainBlocked = false;
27440
+ this.input.runtimeLogger?.info(
27441
+ "agent_bridge_output_buffer_replay_started",
27442
+ { pending_count: this.pendingOutputs.size }
27443
+ );
27337
27444
  }
27338
27445
  if (this.drainBlocked) {
27446
+ this.input.runtimeLogger?.warn(
27447
+ "agent_bridge_output_buffer_drain_blocked",
27448
+ { pending_count: this.pendingOutputs.size }
27449
+ );
27339
27450
  return;
27340
27451
  }
27341
27452
  this.drainPromise ??= (async () => {
@@ -27355,11 +27466,36 @@ var AgentBridgeOutputBuffer = class {
27355
27466
  await this.drainPromise;
27356
27467
  }
27357
27468
  async emitUntilAcked(output) {
27469
+ const startedAt = Date.now();
27470
+ this.input.runtimeLogger?.info(
27471
+ "agent_bridge_output_buffer_emit_started",
27472
+ this.outputLogContext(output, {
27473
+ pending_count: this.pendingOutputs.size
27474
+ })
27475
+ );
27358
27476
  const ack = await this.input.emitOutput(output);
27359
27477
  if (isSuccessfulOutputAck(ack)) {
27360
27478
  this.pendingOutputs.delete(output.outputSeq);
27479
+ this.input.runtimeLogger?.info(
27480
+ "agent_bridge_output_buffer_emit_ready",
27481
+ this.outputLogContext(output, {
27482
+ duration_ms: Date.now() - startedAt,
27483
+ ack_status: ack.status,
27484
+ cursor: ack.cursor,
27485
+ pending_count: this.pendingOutputs.size
27486
+ })
27487
+ );
27361
27488
  return;
27362
27489
  }
27490
+ this.input.runtimeLogger?.warn(
27491
+ "agent_bridge_output_buffer_emit_rejected",
27492
+ this.outputLogContext(output, {
27493
+ duration_ms: Date.now() - startedAt,
27494
+ ack_status: ack.status,
27495
+ error: ack.error,
27496
+ pending_count: this.pendingOutputs.size
27497
+ })
27498
+ );
27363
27499
  throw new Error(ack.error ?? `Bridge rejected output: ${ack.status}`);
27364
27500
  }
27365
27501
  nextPendingOutput() {
@@ -27367,6 +27503,17 @@ var AgentBridgeOutputBuffer = class {
27367
27503
  (left, right) => left.outputSeq - right.outputSeq
27368
27504
  )[0] ?? null;
27369
27505
  }
27506
+ outputLogContext(output, fields = {}) {
27507
+ return {
27508
+ output_seq: output?.outputSeq,
27509
+ output_type: output?.type,
27510
+ role: output && "role" in output ? output.role : void 0,
27511
+ kind: output && "kind" in output ? output.kind : void 0,
27512
+ output_status: output && "status" in output ? output.status : void 0,
27513
+ message_id: output && "messageId" in output ? output.messageId : void 0,
27514
+ ...fields
27515
+ };
27516
+ }
27370
27517
  };
27371
27518
  function buildOutputEnvelope(context, outputSeq, projection) {
27372
27519
  if (projection.type === "delta") {
@@ -47347,15 +47494,33 @@ var ClaudeAgentBridgeSessionImpl = class {
47347
47494
  }
47348
47495
  async sendMessage(message, options) {
47349
47496
  const mode = options?.mode ?? "interrupt";
47497
+ const startedAt = Date.now();
47498
+ this.input.runtimeLogger?.info("agent_bridge_claude_send_message_started", {
47499
+ delivery_mode: mode,
47500
+ state: this.state.kind,
47501
+ active_turn_count: this.activeTurnCount,
47502
+ pending_tool_use_count: this.pendingToolUseIds.size,
47503
+ deferred_count: this.deferredMessages.length
47504
+ });
47350
47505
  if (mode === "deferred" && this.hasInterruptibleTurn()) {
47351
47506
  this.deferredMessages.push(message);
47352
- this.input.writeOutput?.(
47353
- `agent_bridge_claude_message_deferred active_turn_count=${this.activeTurnCount}`
47354
- );
47507
+ this.input.runtimeLogger?.info("agent_bridge_claude_message_deferred", {
47508
+ active_turn_count: this.activeTurnCount,
47509
+ pending_tool_use_count: this.pendingToolUseIds.size,
47510
+ deferred_count: this.deferredMessages.length
47511
+ });
47355
47512
  return;
47356
47513
  }
47357
47514
  await this.interruptActiveTurnBeforeMessage();
47358
47515
  this.enqueueUserMessage(message);
47516
+ this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
47517
+ delivery_mode: mode,
47518
+ duration_ms: Date.now() - startedAt,
47519
+ state: this.state.kind,
47520
+ active_turn_count: this.activeTurnCount,
47521
+ pending_tool_use_count: this.pendingToolUseIds.size,
47522
+ deferred_count: this.deferredMessages.length
47523
+ });
47359
47524
  }
47360
47525
  close() {
47361
47526
  const previousState = this.state;
@@ -47460,6 +47625,12 @@ var ClaudeAgentBridgeSessionImpl = class {
47460
47625
  this.pendingToolUseIds.clear();
47461
47626
  this.turnResultCount += 1;
47462
47627
  this.resolveTurnSettlement(true);
47628
+ this.input.runtimeLogger?.info("agent_bridge_claude_turn_result", {
47629
+ active_turn_count: this.activeTurnCount,
47630
+ pending_tool_use_count: this.pendingToolUseIds.size,
47631
+ turn_result_count: this.turnResultCount,
47632
+ deferred_count: this.deferredMessages.length
47633
+ });
47463
47634
  if (this.activeTurnCount === 0) {
47464
47635
  this.flushDeferredMessages();
47465
47636
  }
@@ -47500,6 +47671,12 @@ var ClaudeAgentBridgeSessionImpl = class {
47500
47671
  enqueueUserMessage(message) {
47501
47672
  this.inputQueue.push(claudeAgentUserMessage(message));
47502
47673
  this.activeTurnCount += 1;
47674
+ this.input.runtimeLogger?.info("agent_bridge_claude_message_enqueued", {
47675
+ state: this.state.kind,
47676
+ active_turn_count: this.activeTurnCount,
47677
+ pending_tool_use_count: this.pendingToolUseIds.size,
47678
+ deferred_count: this.deferredMessages.length
47679
+ });
47503
47680
  void this.ensureRunningQuery().catch((error51) => {
47504
47681
  void this.input.onError(error51);
47505
47682
  });
@@ -47873,10 +48050,25 @@ var ClaudeCodeCommandHandler = class {
47873
48050
  this.settlePendingQuestions("Runtime is shutting down");
47874
48051
  }
47875
48052
  async handleCommand(rawDelivery) {
48053
+ const startedAt = Date.now();
47876
48054
  const delivery = RuntimeBridgeCommandDeliverySchema.parse(rawDelivery);
47877
48055
  const socketId = this.input.socketId?.();
48056
+ this.input.runtimeLogger?.info(
48057
+ "agent_bridge_claude_command_started",
48058
+ commandLogContext(delivery, {
48059
+ socket_id: socketId
48060
+ })
48061
+ );
47878
48062
  const activeContext = this.context;
47879
48063
  if (!activeContext || delivery.sessionId !== activeContext.sessionId || delivery.runtimeId !== activeContext.runtimeId || delivery.bridgeLeaseId !== activeContext.bridgeLeaseId) {
48064
+ this.input.runtimeLogger?.warn(
48065
+ "agent_bridge_claude_command_stale",
48066
+ commandLogContext(delivery, {
48067
+ socket_id: socketId,
48068
+ duration_ms: Date.now() - startedAt,
48069
+ active_bridge_lease_id: activeContext?.bridgeLeaseId
48070
+ })
48071
+ );
47880
48072
  return commandAck({
47881
48073
  delivery,
47882
48074
  socketId,
@@ -47884,6 +48076,13 @@ var ClaudeCodeCommandHandler = class {
47884
48076
  });
47885
48077
  }
47886
48078
  if (this.injectedCommands.has(delivery.commandId)) {
48079
+ this.input.runtimeLogger?.info(
48080
+ "agent_bridge_claude_command_duplicate",
48081
+ commandLogContext(delivery, {
48082
+ socket_id: socketId,
48083
+ duration_ms: Date.now() - startedAt
48084
+ })
48085
+ );
47887
48086
  return commandAck({
47888
48087
  delivery,
47889
48088
  socketId,
@@ -47896,6 +48095,13 @@ var ClaudeCodeCommandHandler = class {
47896
48095
  if (delivery.kind === "stop") {
47897
48096
  this.injectedCommands.add(delivery.commandId);
47898
48097
  this.shutdown();
48098
+ this.input.runtimeLogger?.info(
48099
+ "agent_bridge_claude_command_stop_ready",
48100
+ commandLogContext(delivery, {
48101
+ socket_id: socketId,
48102
+ duration_ms: Date.now() - startedAt
48103
+ })
48104
+ );
47899
48105
  return commandAck({
47900
48106
  delivery,
47901
48107
  socketId,
@@ -47903,6 +48109,13 @@ var ClaudeCodeCommandHandler = class {
47903
48109
  });
47904
48110
  }
47905
48111
  if (delivery.kind !== "message") {
48112
+ this.input.runtimeLogger?.warn(
48113
+ "agent_bridge_claude_command_unsupported",
48114
+ commandLogContext(delivery, {
48115
+ socket_id: socketId,
48116
+ duration_ms: Date.now() - startedAt
48117
+ })
48118
+ );
47906
48119
  return commandAck({
47907
48120
  delivery,
47908
48121
  socketId,
@@ -47921,6 +48134,11 @@ var ClaudeCodeCommandHandler = class {
47921
48134
  }
47922
48135
  this.injectedCommands.add(delivery.commandId);
47923
48136
  try {
48137
+ const emitStartedAt = Date.now();
48138
+ this.input.runtimeLogger?.info(
48139
+ "agent_bridge_claude_command_user_entry_emit_started",
48140
+ commandLogContext(delivery, { socket_id: socketId })
48141
+ );
47924
48142
  await this.emitBridgeOutput(activeContext, {
47925
48143
  type: "entry",
47926
48144
  entry: {
@@ -47933,11 +48151,43 @@ var ClaudeCodeCommandHandler = class {
47933
48151
  }
47934
48152
  }
47935
48153
  });
48154
+ this.input.runtimeLogger?.info(
48155
+ "agent_bridge_claude_command_user_entry_emit_ready",
48156
+ commandLogContext(delivery, {
48157
+ socket_id: socketId,
48158
+ duration_ms: Date.now() - emitStartedAt
48159
+ })
48160
+ );
48161
+ const sendStartedAt = Date.now();
48162
+ const mode = deliveryMode(delivery);
48163
+ this.input.runtimeLogger?.info(
48164
+ "agent_bridge_claude_command_send_message_started",
48165
+ commandLogContext(delivery, {
48166
+ socket_id: socketId,
48167
+ delivery_mode: mode
48168
+ })
48169
+ );
47936
48170
  await this.ensureAgentSession().sendMessage(message, {
47937
- mode: deliveryMode(delivery)
48171
+ mode
47938
48172
  });
48173
+ this.input.runtimeLogger?.info(
48174
+ "agent_bridge_claude_command_send_message_ready",
48175
+ commandLogContext(delivery, {
48176
+ socket_id: socketId,
48177
+ delivery_mode: mode,
48178
+ duration_ms: Date.now() - sendStartedAt
48179
+ })
48180
+ );
47939
48181
  } catch (error51) {
47940
48182
  this.injectedCommands.delete(delivery.commandId);
48183
+ this.input.runtimeLogger?.warn(
48184
+ "agent_bridge_claude_command_failed",
48185
+ commandLogContext(delivery, {
48186
+ socket_id: socketId,
48187
+ duration_ms: Date.now() - startedAt,
48188
+ error: error51 instanceof Error ? error51.message : String(error51)
48189
+ })
48190
+ );
47941
48191
  return commandAck({
47942
48192
  delivery,
47943
48193
  socketId,
@@ -47945,6 +48195,13 @@ var ClaudeCodeCommandHandler = class {
47945
48195
  error: error51 instanceof Error ? error51.message : String(error51)
47946
48196
  });
47947
48197
  }
48198
+ this.input.runtimeLogger?.info(
48199
+ "agent_bridge_claude_command_injected",
48200
+ commandLogContext(delivery, {
48201
+ socket_id: socketId,
48202
+ duration_ms: Date.now() - startedAt
48203
+ })
48204
+ );
47948
48205
  return commandAck({
47949
48206
  delivery,
47950
48207
  socketId,
@@ -48159,6 +48416,7 @@ var ClaudeCodeCommandHandler = class {
48159
48416
  }
48160
48417
  this.input.writeOutput?.("agent_bridge_claude_sdk_exited");
48161
48418
  },
48419
+ runtimeLogger: this.input.runtimeLogger,
48162
48420
  writeOutput: this.input.writeOutput
48163
48421
  });
48164
48422
  this.agentSession = session;
@@ -48191,6 +48449,17 @@ function deliveryMode(delivery) {
48191
48449
  }
48192
48450
  return "interrupt";
48193
48451
  }
48452
+ function commandLogContext(delivery, fields = {}) {
48453
+ return {
48454
+ session_id: delivery.sessionId,
48455
+ runtime_id: delivery.runtimeId,
48456
+ bridge_lease_id: delivery.bridgeLeaseId,
48457
+ delivery_id: delivery.deliveryId,
48458
+ command_id: delivery.commandId,
48459
+ command_kind: delivery.kind,
48460
+ ...fields
48461
+ };
48462
+ }
48194
48463
 
48195
48464
  // src/commands/agent-bridge/harness/index.ts
48196
48465
  async function runAgentBridgeHarness(options) {
@@ -48204,6 +48473,7 @@ function createHarnessCommandHandler(input) {
48204
48473
  const base = {
48205
48474
  emitOutput: input.emitOutput,
48206
48475
  ...input.outputSeqStart !== void 0 ? { outputSeqStart: input.outputSeqStart } : {},
48476
+ ...input.runtimeLogger ? { runtimeLogger: input.runtimeLogger } : {},
48207
48477
  socketId: input.socketId,
48208
48478
  ...input.writeOutput ? { writeOutput: input.writeOutput } : {}
48209
48479
  };
@@ -48271,6 +48541,7 @@ async function runAgentBridgeProcess(input) {
48271
48541
  try {
48272
48542
  await runAgentBridge({
48273
48543
  ...agentBridgeOptionsFromEnv(input),
48544
+ runtimeLogger: log,
48274
48545
  onBootstrap: createGitCredentialRelayStarter(input.writeOutput, log)
48275
48546
  });
48276
48547
  } catch (error51) {
package/dist/index.js CHANGED
@@ -15260,6 +15260,7 @@ var init_auth = __esm({
15260
15260
  "secret-values:read",
15261
15261
  "github:mcp",
15262
15262
  "github:credentials",
15263
+ "mcp:connection",
15263
15264
  "projects:admin",
15264
15265
  "org:admin"
15265
15266
  ]);
@@ -15964,12 +15965,12 @@ function parseClaudeCodeStreamRecord(parsed) {
15964
15965
  }
15965
15966
  const isError = record2.is_error === true || record2.subtype === "error";
15966
15967
  const sdkErrorMessage = record2.errors?.map((error51) => error51.trim()).filter(Boolean).join("\n");
15967
- const errorMessage3 = isError ? record2.error ?? record2.result ?? (sdkErrorMessage || void 0) ?? "claude-code reported an error" : void 0;
15968
+ const errorMessage4 = isError ? record2.error ?? record2.result ?? (sdkErrorMessage || void 0) ?? "claude-code reported an error" : void 0;
15968
15969
  return {
15969
15970
  projections: [],
15970
15971
  result: {
15971
15972
  isError,
15972
- errorMessage: errorMessage3
15973
+ errorMessage: errorMessage4
15973
15974
  }
15974
15975
  };
15975
15976
  }
@@ -21996,7 +21997,7 @@ var init_package = __esm({
21996
21997
  "package.json"() {
21997
21998
  package_default = {
21998
21999
  name: "@autohq/cli",
21999
- version: "0.1.222",
22000
+ version: "0.1.224",
22000
22001
  license: "SEE LICENSE IN README.md",
22001
22002
  publishConfig: {
22002
22003
  access: "public"
@@ -27985,7 +27986,7 @@ function SessionsView({
27985
27986
  visibleSessions.map((session, vi) => {
27986
27987
  const i = scrollOffset + vi;
27987
27988
  const title = sessionDisplayTitle(session);
27988
- const err = session.status === "failed" ? errorMessage(session) : null;
27989
+ const err = session.status === "failed" ? errorMessage2(session) : null;
27989
27990
  const isSelected = i === safeIndex;
27990
27991
  const isMarked = selectedSessionIds.has(session.id);
27991
27992
  return /* @__PURE__ */ jsxs10(Box11, { flexDirection: "column", children: [
@@ -28123,7 +28124,7 @@ function truncateToWidth(value, width) {
28123
28124
  function agentNameForRun(session) {
28124
28125
  return session.snapshot.metadata.name;
28125
28126
  }
28126
- function errorMessage(session) {
28127
+ function errorMessage2(session) {
28127
28128
  if (session.error == null) return null;
28128
28129
  if (typeof session.error === "string") return session.error;
28129
28130
  const msg = readField(session.error, "message");
@@ -29545,7 +29546,7 @@ function HomeView({ apiUrl, notice, returnToAgent }) {
29545
29546
  if (inspectedResource) {
29546
29547
  sectionTitle = `Inspect ${inspectedResource.kind}/${inspectedResource.name}`;
29547
29548
  }
29548
- const runError = errorMessage2(triggerSession.error) ?? errorMessage2(archiveSessions.error) ?? errorMessage2(unarchiveSessions.error) ?? errorMessage2(stopSessions.error);
29549
+ const runError = errorMessage3(triggerSession.error) ?? errorMessage3(archiveSessions.error) ?? errorMessage3(unarchiveSessions.error) ?? errorMessage3(stopSessions.error);
29549
29550
  const isRunMutationPending = triggerSession.isPending || archiveSessions.isPending || unarchiveSessions.isPending || stopSessions.isPending;
29550
29551
  const isConnectionMutationPending = startConnection.isPending || allowConnection.isPending || removeConnection.isPending || createGithubSyncBinding.isPending;
29551
29552
  const serviceAccountStatus = createServiceAccount2.error instanceof Error ? createServiceAccount2.error.message : rotateServiceAccount2.error instanceof Error ? rotateServiceAccount2.error.message : removeServiceAccount2.error instanceof Error ? removeServiceAccount2.error.message : serviceAccountNotice;
@@ -29958,7 +29959,7 @@ function runActionTargetLabel(sessionIds, markedRunCount) {
29958
29959
  function pluralizeRunCount(count) {
29959
29960
  return `${count} ${count === 1 ? "session" : "sessions"}`;
29960
29961
  }
29961
- function errorMessage2(error51) {
29962
+ function errorMessage3(error51) {
29962
29963
  if (error51 instanceof Error) return error51.message;
29963
29964
  return error51 ? String(error51) : null;
29964
29965
  }
@@ -31779,9 +31780,10 @@ async function runAgentBridgeSocket(options) {
31779
31780
  token: options.token,
31780
31781
  onBootstrap: options.onBootstrap,
31781
31782
  createHandler: (bootstrap) => options.createHandler({
31782
- emitOutput: (output) => emitOutputWithAck(socket, output),
31783
+ emitOutput: (output) => emitOutputWithAck(socket, output, options.runtimeLogger),
31783
31784
  bootstrap,
31784
31785
  outputSeqStart: bootstrap.outputSeqStart,
31786
+ runtimeLogger: options.runtimeLogger,
31785
31787
  socketId: () => socket.id,
31786
31788
  writeOutput: options.writeOutput
31787
31789
  }),
@@ -31819,23 +31821,55 @@ async function runAgentBridgeSocket(options) {
31819
31821
  });
31820
31822
  });
31821
31823
  socket.on(RUNTIME_BRIDGE_COMMAND_EVENT, (rawDelivery, ack) => {
31824
+ const startedAt = Date.now();
31825
+ const logContext = runtimeCommandLogContext(rawDelivery, socket.id);
31826
+ options.runtimeLogger?.info("agent_bridge_command_received", logContext);
31822
31827
  if (!handler) {
31823
31828
  const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
31824
31829
  if (delivery.success) {
31825
- ack(
31826
- commandAck({
31827
- delivery: delivery.data,
31828
- socketId: socket.id,
31829
- status: "failed",
31830
- error: "Bridge command received before bootstrap completed"
31831
- })
31832
- );
31830
+ const response = commandAck({
31831
+ delivery: delivery.data,
31832
+ socketId: socket.id,
31833
+ status: "failed",
31834
+ error: "Bridge command received before bootstrap completed"
31835
+ });
31836
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
31837
+ ...logContext,
31838
+ duration_ms: Date.now() - startedAt,
31839
+ ack_status: response.status,
31840
+ error: response.error
31841
+ });
31842
+ ack(response);
31833
31843
  return;
31834
31844
  }
31835
- ack({ error: "Bridge command received before bootstrap completed" });
31845
+ const error51 = "Bridge command received before bootstrap completed";
31846
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
31847
+ ...logContext,
31848
+ duration_ms: Date.now() - startedAt,
31849
+ ack_status: "failed",
31850
+ error: error51
31851
+ });
31852
+ ack({ error: error51 });
31836
31853
  return;
31837
31854
  }
31838
- void handler.handleCommand(rawDelivery).then((response) => ack(response)).catch((error51) => {
31855
+ void handler.handleCommand(rawDelivery).then((response) => {
31856
+ const parsedResponse = RuntimeBridgeCommandAckSchema.safeParse(response);
31857
+ options.runtimeLogger?.info("agent_bridge_command_ack_ready", {
31858
+ ...logContext,
31859
+ duration_ms: Date.now() - startedAt,
31860
+ ack_parse_status: parsedResponse.success ? "succeeded" : "failed",
31861
+ ack_status: parsedResponse.success ? parsedResponse.data.status : void 0,
31862
+ ack_socket_id: parsedResponse.success ? parsedResponse.data.socketId : void 0,
31863
+ error: parsedResponse.success ? parsedResponse.data.error : parsedResponse.error.message
31864
+ });
31865
+ ack(response);
31866
+ }).catch((error51) => {
31867
+ options.runtimeLogger?.warn("agent_bridge_command_handler_failed", {
31868
+ ...logContext,
31869
+ duration_ms: Date.now() - startedAt,
31870
+ ack_status: "failed",
31871
+ error: errorMessage(error51)
31872
+ });
31839
31873
  const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
31840
31874
  if (!delivery.success) {
31841
31875
  ack({
@@ -31937,27 +31971,54 @@ function createSessiontimeBridgeBootstrapListener(input) {
31937
31971
  }
31938
31972
  };
31939
31973
  }
31940
- function emitOutputWithAck(socket, output) {
31974
+ function emitOutputWithAck(socket, output, runtimeLogger) {
31975
+ const startedAt = Date.now();
31976
+ runtimeLogger?.info(
31977
+ "agent_bridge_output_emit_started",
31978
+ outputLogContext(output, socket.id)
31979
+ );
31941
31980
  return new Promise((resolve4, reject) => {
31942
31981
  socket.timeout(5e3).emit(
31943
31982
  RUNTIME_BRIDGE_OUTPUT_EVENT,
31944
31983
  output,
31945
31984
  (error51, rawAck) => {
31946
31985
  if (error51) {
31986
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_failed", {
31987
+ ...outputLogContext(output, socket.id),
31988
+ duration_ms: Date.now() - startedAt,
31989
+ error: error51.message
31990
+ });
31947
31991
  reject(error51);
31948
31992
  return;
31949
31993
  }
31950
31994
  const ack = RuntimeBridgeOutputAckSchema.safeParse(rawAck);
31951
31995
  if (!ack.success) {
31996
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_invalid", {
31997
+ ...outputLogContext(output, socket.id),
31998
+ duration_ms: Date.now() - startedAt,
31999
+ error: ack.error.message
32000
+ });
31952
32001
  reject(ack.error);
31953
32002
  return;
31954
32003
  }
31955
32004
  if (ack.data.status === "failed") {
32005
+ runtimeLogger?.warn("agent_bridge_output_emit_ack_rejected", {
32006
+ ...outputLogContext(output, socket.id),
32007
+ duration_ms: Date.now() - startedAt,
32008
+ ack_status: ack.data.status,
32009
+ error: ack.data.error
32010
+ });
31956
32011
  reject(
31957
32012
  new Error(ack.data.error ?? "Bridge rejected runtime output")
31958
32013
  );
31959
32014
  return;
31960
32015
  }
32016
+ runtimeLogger?.info("agent_bridge_output_emit_ack_ready", {
32017
+ ...outputLogContext(output, socket.id),
32018
+ duration_ms: Date.now() - startedAt,
32019
+ ack_status: ack.data.status,
32020
+ cursor: ack.data.cursor
32021
+ });
31961
32022
  resolve4(ack.data);
31962
32023
  }
31963
32024
  );
@@ -32002,6 +32063,42 @@ function isNgrokFreeUrl(url2) {
32002
32063
  return false;
32003
32064
  }
32004
32065
  }
32066
+ function runtimeCommandLogContext(rawDelivery, socketId) {
32067
+ const delivery = RuntimeBridgeCommandDeliverySchema.safeParse(rawDelivery);
32068
+ if (!delivery.success) {
32069
+ return {
32070
+ socket_id: socketId,
32071
+ delivery_parse_status: "failed"
32072
+ };
32073
+ }
32074
+ return {
32075
+ socket_id: socketId,
32076
+ delivery_parse_status: "succeeded",
32077
+ session_id: delivery.data.sessionId,
32078
+ runtime_id: delivery.data.runtimeId,
32079
+ bridge_lease_id: delivery.data.bridgeLeaseId,
32080
+ delivery_id: delivery.data.deliveryId,
32081
+ command_id: delivery.data.commandId,
32082
+ command_kind: delivery.data.kind
32083
+ };
32084
+ }
32085
+ function outputLogContext(output, socketId) {
32086
+ return {
32087
+ socket_id: socketId,
32088
+ session_id: output.sessionId,
32089
+ runtime_id: output.runtimeId,
32090
+ bridge_lease_id: output.bridgeLeaseId,
32091
+ output_seq: output.outputSeq,
32092
+ output_type: output.type,
32093
+ role: "role" in output ? output.role : void 0,
32094
+ kind: "kind" in output ? output.kind : void 0,
32095
+ output_status: "status" in output ? output.status : void 0,
32096
+ message_id: "messageId" in output ? output.messageId : void 0
32097
+ };
32098
+ }
32099
+ function errorMessage(error51) {
32100
+ return error51 instanceof Error ? error51.message : String(error51);
32101
+ }
32005
32102
 
32006
32103
  // src/commands/agent-bridge/harness/claude-code/index.ts
32007
32104
  init_src();
@@ -32026,6 +32123,12 @@ var AgentBridgeOutputBuffer = class {
32026
32123
  this.outputSeq,
32027
32124
  buildOutputEnvelope(context, this.outputSeq, projection)
32028
32125
  );
32126
+ this.input.runtimeLogger?.info(
32127
+ "agent_bridge_output_buffer_enqueued",
32128
+ this.outputLogContext(this.pendingOutputs.get(this.outputSeq), {
32129
+ pending_count: this.pendingOutputs.size
32130
+ })
32131
+ );
32029
32132
  await this.drainPendingOutputs();
32030
32133
  }
32031
32134
  async replayPendingOutputs() {
@@ -32044,8 +32147,16 @@ var AgentBridgeOutputBuffer = class {
32044
32147
  }
32045
32148
  if (options.force) {
32046
32149
  this.drainBlocked = false;
32150
+ this.input.runtimeLogger?.info(
32151
+ "agent_bridge_output_buffer_replay_started",
32152
+ { pending_count: this.pendingOutputs.size }
32153
+ );
32047
32154
  }
32048
32155
  if (this.drainBlocked) {
32156
+ this.input.runtimeLogger?.warn(
32157
+ "agent_bridge_output_buffer_drain_blocked",
32158
+ { pending_count: this.pendingOutputs.size }
32159
+ );
32049
32160
  return;
32050
32161
  }
32051
32162
  this.drainPromise ??= (async () => {
@@ -32065,11 +32176,36 @@ var AgentBridgeOutputBuffer = class {
32065
32176
  await this.drainPromise;
32066
32177
  }
32067
32178
  async emitUntilAcked(output) {
32179
+ const startedAt = Date.now();
32180
+ this.input.runtimeLogger?.info(
32181
+ "agent_bridge_output_buffer_emit_started",
32182
+ this.outputLogContext(output, {
32183
+ pending_count: this.pendingOutputs.size
32184
+ })
32185
+ );
32068
32186
  const ack = await this.input.emitOutput(output);
32069
32187
  if (isSuccessfulOutputAck(ack)) {
32070
32188
  this.pendingOutputs.delete(output.outputSeq);
32189
+ this.input.runtimeLogger?.info(
32190
+ "agent_bridge_output_buffer_emit_ready",
32191
+ this.outputLogContext(output, {
32192
+ duration_ms: Date.now() - startedAt,
32193
+ ack_status: ack.status,
32194
+ cursor: ack.cursor,
32195
+ pending_count: this.pendingOutputs.size
32196
+ })
32197
+ );
32071
32198
  return;
32072
32199
  }
32200
+ this.input.runtimeLogger?.warn(
32201
+ "agent_bridge_output_buffer_emit_rejected",
32202
+ this.outputLogContext(output, {
32203
+ duration_ms: Date.now() - startedAt,
32204
+ ack_status: ack.status,
32205
+ error: ack.error,
32206
+ pending_count: this.pendingOutputs.size
32207
+ })
32208
+ );
32073
32209
  throw new Error(ack.error ?? `Bridge rejected output: ${ack.status}`);
32074
32210
  }
32075
32211
  nextPendingOutput() {
@@ -32077,6 +32213,17 @@ var AgentBridgeOutputBuffer = class {
32077
32213
  (left, right) => left.outputSeq - right.outputSeq
32078
32214
  )[0] ?? null;
32079
32215
  }
32216
+ outputLogContext(output, fields = {}) {
32217
+ return {
32218
+ output_seq: output?.outputSeq,
32219
+ output_type: output?.type,
32220
+ role: output && "role" in output ? output.role : void 0,
32221
+ kind: output && "kind" in output ? output.kind : void 0,
32222
+ output_status: output && "status" in output ? output.status : void 0,
32223
+ message_id: output && "messageId" in output ? output.messageId : void 0,
32224
+ ...fields
32225
+ };
32226
+ }
32080
32227
  };
32081
32228
  function buildOutputEnvelope(context, outputSeq, projection) {
32082
32229
  if (projection.type === "delta") {
@@ -32486,15 +32633,33 @@ var ClaudeAgentBridgeSessionImpl = class {
32486
32633
  }
32487
32634
  async sendMessage(message, options) {
32488
32635
  const mode = options?.mode ?? "interrupt";
32636
+ const startedAt = Date.now();
32637
+ this.input.runtimeLogger?.info("agent_bridge_claude_send_message_started", {
32638
+ delivery_mode: mode,
32639
+ state: this.state.kind,
32640
+ active_turn_count: this.activeTurnCount,
32641
+ pending_tool_use_count: this.pendingToolUseIds.size,
32642
+ deferred_count: this.deferredMessages.length
32643
+ });
32489
32644
  if (mode === "deferred" && this.hasInterruptibleTurn()) {
32490
32645
  this.deferredMessages.push(message);
32491
- this.input.writeOutput?.(
32492
- `agent_bridge_claude_message_deferred active_turn_count=${this.activeTurnCount}`
32493
- );
32646
+ this.input.runtimeLogger?.info("agent_bridge_claude_message_deferred", {
32647
+ active_turn_count: this.activeTurnCount,
32648
+ pending_tool_use_count: this.pendingToolUseIds.size,
32649
+ deferred_count: this.deferredMessages.length
32650
+ });
32494
32651
  return;
32495
32652
  }
32496
32653
  await this.interruptActiveTurnBeforeMessage();
32497
32654
  this.enqueueUserMessage(message);
32655
+ this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
32656
+ delivery_mode: mode,
32657
+ duration_ms: Date.now() - startedAt,
32658
+ state: this.state.kind,
32659
+ active_turn_count: this.activeTurnCount,
32660
+ pending_tool_use_count: this.pendingToolUseIds.size,
32661
+ deferred_count: this.deferredMessages.length
32662
+ });
32498
32663
  }
32499
32664
  close() {
32500
32665
  const previousState = this.state;
@@ -32599,6 +32764,12 @@ var ClaudeAgentBridgeSessionImpl = class {
32599
32764
  this.pendingToolUseIds.clear();
32600
32765
  this.turnResultCount += 1;
32601
32766
  this.resolveTurnSettlement(true);
32767
+ this.input.runtimeLogger?.info("agent_bridge_claude_turn_result", {
32768
+ active_turn_count: this.activeTurnCount,
32769
+ pending_tool_use_count: this.pendingToolUseIds.size,
32770
+ turn_result_count: this.turnResultCount,
32771
+ deferred_count: this.deferredMessages.length
32772
+ });
32602
32773
  if (this.activeTurnCount === 0) {
32603
32774
  this.flushDeferredMessages();
32604
32775
  }
@@ -32639,6 +32810,12 @@ var ClaudeAgentBridgeSessionImpl = class {
32639
32810
  enqueueUserMessage(message) {
32640
32811
  this.inputQueue.push(claudeAgentUserMessage(message));
32641
32812
  this.activeTurnCount += 1;
32813
+ this.input.runtimeLogger?.info("agent_bridge_claude_message_enqueued", {
32814
+ state: this.state.kind,
32815
+ active_turn_count: this.activeTurnCount,
32816
+ pending_tool_use_count: this.pendingToolUseIds.size,
32817
+ deferred_count: this.deferredMessages.length
32818
+ });
32642
32819
  void this.ensureRunningQuery().catch((error51) => {
32643
32820
  void this.input.onError(error51);
32644
32821
  });
@@ -33012,10 +33189,25 @@ var ClaudeCodeCommandHandler = class {
33012
33189
  this.settlePendingQuestions("Runtime is shutting down");
33013
33190
  }
33014
33191
  async handleCommand(rawDelivery) {
33192
+ const startedAt = Date.now();
33015
33193
  const delivery = RuntimeBridgeCommandDeliverySchema.parse(rawDelivery);
33016
33194
  const socketId = this.input.socketId?.();
33195
+ this.input.runtimeLogger?.info(
33196
+ "agent_bridge_claude_command_started",
33197
+ commandLogContext(delivery, {
33198
+ socket_id: socketId
33199
+ })
33200
+ );
33017
33201
  const activeContext = this.context;
33018
33202
  if (!activeContext || delivery.sessionId !== activeContext.sessionId || delivery.runtimeId !== activeContext.runtimeId || delivery.bridgeLeaseId !== activeContext.bridgeLeaseId) {
33203
+ this.input.runtimeLogger?.warn(
33204
+ "agent_bridge_claude_command_stale",
33205
+ commandLogContext(delivery, {
33206
+ socket_id: socketId,
33207
+ duration_ms: Date.now() - startedAt,
33208
+ active_bridge_lease_id: activeContext?.bridgeLeaseId
33209
+ })
33210
+ );
33019
33211
  return commandAck({
33020
33212
  delivery,
33021
33213
  socketId,
@@ -33023,6 +33215,13 @@ var ClaudeCodeCommandHandler = class {
33023
33215
  });
33024
33216
  }
33025
33217
  if (this.injectedCommands.has(delivery.commandId)) {
33218
+ this.input.runtimeLogger?.info(
33219
+ "agent_bridge_claude_command_duplicate",
33220
+ commandLogContext(delivery, {
33221
+ socket_id: socketId,
33222
+ duration_ms: Date.now() - startedAt
33223
+ })
33224
+ );
33026
33225
  return commandAck({
33027
33226
  delivery,
33028
33227
  socketId,
@@ -33035,6 +33234,13 @@ var ClaudeCodeCommandHandler = class {
33035
33234
  if (delivery.kind === "stop") {
33036
33235
  this.injectedCommands.add(delivery.commandId);
33037
33236
  this.shutdown();
33237
+ this.input.runtimeLogger?.info(
33238
+ "agent_bridge_claude_command_stop_ready",
33239
+ commandLogContext(delivery, {
33240
+ socket_id: socketId,
33241
+ duration_ms: Date.now() - startedAt
33242
+ })
33243
+ );
33038
33244
  return commandAck({
33039
33245
  delivery,
33040
33246
  socketId,
@@ -33042,6 +33248,13 @@ var ClaudeCodeCommandHandler = class {
33042
33248
  });
33043
33249
  }
33044
33250
  if (delivery.kind !== "message") {
33251
+ this.input.runtimeLogger?.warn(
33252
+ "agent_bridge_claude_command_unsupported",
33253
+ commandLogContext(delivery, {
33254
+ socket_id: socketId,
33255
+ duration_ms: Date.now() - startedAt
33256
+ })
33257
+ );
33045
33258
  return commandAck({
33046
33259
  delivery,
33047
33260
  socketId,
@@ -33060,6 +33273,11 @@ var ClaudeCodeCommandHandler = class {
33060
33273
  }
33061
33274
  this.injectedCommands.add(delivery.commandId);
33062
33275
  try {
33276
+ const emitStartedAt = Date.now();
33277
+ this.input.runtimeLogger?.info(
33278
+ "agent_bridge_claude_command_user_entry_emit_started",
33279
+ commandLogContext(delivery, { socket_id: socketId })
33280
+ );
33063
33281
  await this.emitBridgeOutput(activeContext, {
33064
33282
  type: "entry",
33065
33283
  entry: {
@@ -33072,11 +33290,43 @@ var ClaudeCodeCommandHandler = class {
33072
33290
  }
33073
33291
  }
33074
33292
  });
33293
+ this.input.runtimeLogger?.info(
33294
+ "agent_bridge_claude_command_user_entry_emit_ready",
33295
+ commandLogContext(delivery, {
33296
+ socket_id: socketId,
33297
+ duration_ms: Date.now() - emitStartedAt
33298
+ })
33299
+ );
33300
+ const sendStartedAt = Date.now();
33301
+ const mode = deliveryMode(delivery);
33302
+ this.input.runtimeLogger?.info(
33303
+ "agent_bridge_claude_command_send_message_started",
33304
+ commandLogContext(delivery, {
33305
+ socket_id: socketId,
33306
+ delivery_mode: mode
33307
+ })
33308
+ );
33075
33309
  await this.ensureAgentSession().sendMessage(message, {
33076
- mode: deliveryMode(delivery)
33310
+ mode
33077
33311
  });
33312
+ this.input.runtimeLogger?.info(
33313
+ "agent_bridge_claude_command_send_message_ready",
33314
+ commandLogContext(delivery, {
33315
+ socket_id: socketId,
33316
+ delivery_mode: mode,
33317
+ duration_ms: Date.now() - sendStartedAt
33318
+ })
33319
+ );
33078
33320
  } catch (error51) {
33079
33321
  this.injectedCommands.delete(delivery.commandId);
33322
+ this.input.runtimeLogger?.warn(
33323
+ "agent_bridge_claude_command_failed",
33324
+ commandLogContext(delivery, {
33325
+ socket_id: socketId,
33326
+ duration_ms: Date.now() - startedAt,
33327
+ error: error51 instanceof Error ? error51.message : String(error51)
33328
+ })
33329
+ );
33080
33330
  return commandAck({
33081
33331
  delivery,
33082
33332
  socketId,
@@ -33084,6 +33334,13 @@ var ClaudeCodeCommandHandler = class {
33084
33334
  error: error51 instanceof Error ? error51.message : String(error51)
33085
33335
  });
33086
33336
  }
33337
+ this.input.runtimeLogger?.info(
33338
+ "agent_bridge_claude_command_injected",
33339
+ commandLogContext(delivery, {
33340
+ socket_id: socketId,
33341
+ duration_ms: Date.now() - startedAt
33342
+ })
33343
+ );
33087
33344
  return commandAck({
33088
33345
  delivery,
33089
33346
  socketId,
@@ -33298,6 +33555,7 @@ var ClaudeCodeCommandHandler = class {
33298
33555
  }
33299
33556
  this.input.writeOutput?.("agent_bridge_claude_sdk_exited");
33300
33557
  },
33558
+ runtimeLogger: this.input.runtimeLogger,
33301
33559
  writeOutput: this.input.writeOutput
33302
33560
  });
33303
33561
  this.agentSession = session;
@@ -33330,6 +33588,17 @@ function deliveryMode(delivery) {
33330
33588
  }
33331
33589
  return "interrupt";
33332
33590
  }
33591
+ function commandLogContext(delivery, fields = {}) {
33592
+ return {
33593
+ session_id: delivery.sessionId,
33594
+ runtime_id: delivery.runtimeId,
33595
+ bridge_lease_id: delivery.bridgeLeaseId,
33596
+ delivery_id: delivery.deliveryId,
33597
+ command_id: delivery.commandId,
33598
+ command_kind: delivery.kind,
33599
+ ...fields
33600
+ };
33601
+ }
33333
33602
 
33334
33603
  // src/commands/agent-bridge/harness/index.ts
33335
33604
  async function runAgentBridgeHarness(options) {
@@ -33343,6 +33612,7 @@ function createHarnessCommandHandler(input) {
33343
33612
  const base = {
33344
33613
  emitOutput: input.emitOutput,
33345
33614
  ...input.outputSeqStart !== void 0 ? { outputSeqStart: input.outputSeqStart } : {},
33615
+ ...input.runtimeLogger ? { runtimeLogger: input.runtimeLogger } : {},
33346
33616
  socketId: input.socketId,
33347
33617
  ...input.writeOutput ? { writeOutput: input.writeOutput } : {}
33348
33618
  };
@@ -33411,6 +33681,7 @@ async function runAgentBridgeProcess(input) {
33411
33681
  try {
33412
33682
  await runAgentBridge({
33413
33683
  ...agentBridgeOptionsFromEnv(input),
33684
+ runtimeLogger: log,
33414
33685
  onBootstrap: createGitCredentialRelayStarter(input.writeOutput, log)
33415
33686
  });
33416
33687
  } catch (error51) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.222",
3
+ "version": "0.1.224",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"