@ai-sdk/harness-claude-code 1.0.168 → 1.0.169

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.
@@ -194,7 +194,14 @@ export function createEmitStreamEvent({
194
194
  // Emit `stream-start` once, on the first message, carrying the model the
195
195
  // CLI resolved to (the `system`/`init` message reports it — this is the
196
196
  // default model when none was configured).
197
- if (!streamStarted) {
197
+ /*
198
+ * `command_lifecycle` frames are skipped here. The CLI's stdin reader
199
+ * forwards them (e.g. `queued` and `started` for the prompt) straight to
200
+ * the output stream, independently of the engine that yields
201
+ * `system`/`init` at the start of each turn, so they can arrive before
202
+ * `init`. They produce no stream parts.
203
+ */
204
+ if (!streamStarted && type !== 'command_lifecycle') {
198
205
  const initModel =
199
206
  type === 'system' &&
200
207
  msg.subtype === 'init' &&
@@ -46,6 +46,7 @@ import {
46
46
  waitForBridgeReady,
47
47
  writeSkills,
48
48
  type BridgeHello,
49
+ type SandboxChannelDebugEvent,
49
50
  type SandboxChannelReconnectOptions,
50
51
  } from '@ai-sdk/harness/utils';
51
52
  import {
@@ -149,6 +150,14 @@ export type ClaudeCodeHarnessSettings = {
149
150
  * milliseconds up to 2 seconds.
150
151
  */
151
152
  readonly reconnect?: SandboxChannelReconnectOptions;
153
+ /**
154
+ * Called with bridge connection lifecycle events: reconnect attempts,
155
+ * successful reconnects, and `reconnect-failed` once the connection is
156
+ * closed for good. Hosts that cache idle sessions can use it to reattach
157
+ * before sending the next prompt. The `cause` of a failed reconnect can
158
+ * contain connection details, so avoid logging it as is.
159
+ */
160
+ readonly onDebug?: (event: SandboxChannelDebugEvent) => void;
152
161
  /**
153
162
  * Creates the authentication token used by the sandbox bridge. Defaults to
154
163
  * a random 32-byte hexadecimal token.
@@ -1028,6 +1037,7 @@ export function createClaudeCode(
1028
1037
  onDiagnostic,
1029
1038
  onBridgeError,
1030
1039
  reconnect: settings.reconnect,
1040
+ onDebug: settings.onDebug,
1031
1041
  });
1032
1042
  const finishListenerAttachment = isContinue
1033
1043
  ? attachChannel.beginListenerAttachment()
@@ -1191,6 +1201,7 @@ export function createClaudeCode(
1191
1201
  onDiagnostic,
1192
1202
  onBridgeError,
1193
1203
  reconnect: settings.reconnect,
1204
+ onDebug: settings.onDebug,
1194
1205
  // In replay mode the respawned bridge reloaded the finished turn from
1195
1206
  // disk; seed the cursor and resume so it streams the tail (incl.
1196
1207
  // `finish`) rather than starting empty.