@autohq/cli 0.1.450 → 0.1.451

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.
@@ -30825,7 +30825,7 @@ Object.assign(lookup, {
30825
30825
  // package.json
30826
30826
  var package_default = {
30827
30827
  name: "@autohq/cli",
30828
- version: "0.1.450",
30828
+ version: "0.1.451",
30829
30829
  license: "SEE LICENSE IN README.md",
30830
30830
  publishConfig: {
30831
30831
  access: "public"
@@ -70697,8 +70697,7 @@ var AgentBridgeOutputBuffer = class {
70697
70697
  await this.emitUiMessagePartSnapshots(context, projection.chunk, {
70698
70698
  coveredSeq: this.outputSeq
70699
70699
  });
70700
- const toolEntry = legacyToolEntry(projection.chunk);
70701
- if (toolEntry) {
70700
+ for (const toolEntry of legacyToolEntries(projection.chunk)) {
70702
70701
  await this.enqueueProjectionAndDrain(context, {
70703
70702
  type: "entry",
70704
70703
  entry: toolEntry
@@ -71177,73 +71176,112 @@ var UiMessageAssembler = class {
71177
71176
  function isTerminalUiMessageChunk(chunk) {
71178
71177
  return chunk.type === "finish" || chunk.type === "error" || chunk.type === "abort";
71179
71178
  }
71180
- function legacyToolEntry(chunk) {
71179
+ function legacyToolEntries(chunk) {
71181
71180
  switch (chunk.type) {
71182
71181
  case "tool-input-available":
71183
71182
  if (chunk.toolName === ASK_USER_QUESTION_TOOL_NAME) {
71184
- return null;
71183
+ return [];
71185
71184
  }
71186
- return {
71187
- role: "assistant",
71188
- kind: "tool_call",
71189
- content: {
71190
- parts: [
71191
- {
71192
- type: "tool_call",
71193
- toolCallId: legacyToolCallId(chunk.toolCallId),
71194
- name: chunk.toolName,
71195
- input: toJsonValue(chunk.input)
71196
- }
71197
- ]
71185
+ return [
71186
+ {
71187
+ role: "assistant",
71188
+ kind: "tool_call",
71189
+ content: {
71190
+ parts: [
71191
+ {
71192
+ type: "tool_call",
71193
+ toolCallId: legacyToolCallId(chunk.toolCallId),
71194
+ name: chunk.toolName,
71195
+ input: toJsonValue(chunk.input)
71196
+ }
71197
+ ]
71198
+ }
71198
71199
  }
71199
- };
71200
+ ];
71201
+ case "tool-input-error":
71202
+ return [
71203
+ {
71204
+ role: "assistant",
71205
+ kind: "tool_call",
71206
+ content: {
71207
+ parts: [
71208
+ {
71209
+ type: "tool_call",
71210
+ toolCallId: legacyToolCallId(chunk.toolCallId),
71211
+ name: chunk.toolName,
71212
+ input: toJsonValue(chunk.input)
71213
+ }
71214
+ ]
71215
+ }
71216
+ },
71217
+ {
71218
+ role: "tool",
71219
+ kind: "tool_result",
71220
+ content: {
71221
+ parts: [
71222
+ {
71223
+ type: "tool_result",
71224
+ toolUseId: legacyToolCallId(chunk.toolCallId),
71225
+ output: chunk.errorText,
71226
+ isError: true
71227
+ }
71228
+ ]
71229
+ }
71230
+ }
71231
+ ];
71200
71232
  case "tool-output-available":
71201
- return {
71202
- role: "tool",
71203
- kind: "tool_result",
71204
- content: {
71205
- parts: [
71206
- {
71207
- type: "tool_result",
71208
- toolUseId: legacyToolCallId(chunk.toolCallId),
71209
- output: toJsonValue(chunk.output),
71210
- isError: false
71211
- }
71212
- ]
71233
+ return [
71234
+ {
71235
+ role: "tool",
71236
+ kind: "tool_result",
71237
+ content: {
71238
+ parts: [
71239
+ {
71240
+ type: "tool_result",
71241
+ toolUseId: legacyToolCallId(chunk.toolCallId),
71242
+ output: toJsonValue(chunk.output),
71243
+ isError: false
71244
+ }
71245
+ ]
71246
+ }
71213
71247
  }
71214
- };
71248
+ ];
71215
71249
  case "tool-output-error":
71216
- return {
71217
- role: "tool",
71218
- kind: "tool_result",
71219
- content: {
71220
- parts: [
71221
- {
71222
- type: "tool_result",
71223
- toolUseId: legacyToolCallId(chunk.toolCallId),
71224
- output: errorOutput(chunk.errorText),
71225
- isError: true
71226
- }
71227
- ]
71250
+ return [
71251
+ {
71252
+ role: "tool",
71253
+ kind: "tool_result",
71254
+ content: {
71255
+ parts: [
71256
+ {
71257
+ type: "tool_result",
71258
+ toolUseId: legacyToolCallId(chunk.toolCallId),
71259
+ output: errorOutput(chunk.errorText),
71260
+ isError: true
71261
+ }
71262
+ ]
71263
+ }
71228
71264
  }
71229
- };
71265
+ ];
71230
71266
  case "tool-output-denied":
71231
- return {
71232
- role: "tool",
71233
- kind: "tool_result",
71234
- content: {
71235
- parts: [
71236
- {
71237
- type: "tool_result",
71238
- toolUseId: legacyToolCallId(chunk.toolCallId),
71239
- output: { denied: true },
71240
- isError: true
71241
- }
71242
- ]
71267
+ return [
71268
+ {
71269
+ role: "tool",
71270
+ kind: "tool_result",
71271
+ content: {
71272
+ parts: [
71273
+ {
71274
+ type: "tool_result",
71275
+ toolUseId: legacyToolCallId(chunk.toolCallId),
71276
+ output: { denied: true },
71277
+ isError: true
71278
+ }
71279
+ ]
71280
+ }
71243
71281
  }
71244
- };
71282
+ ];
71245
71283
  default:
71246
- return null;
71284
+ return [];
71247
71285
  }
71248
71286
  }
71249
71287
  function legacyToolCallId(toolCallId) {
@@ -71500,13 +71538,17 @@ var ClaudeCodeProjector = class {
71500
71538
  });
71501
71539
  });
71502
71540
  if (parsed.result) {
71503
- outputs.push(...this.endActiveParts(), ...this.finishActiveToolInputs());
71504
- this.currentMessageId = null;
71505
- this.activeResponseMessageId = null;
71506
71541
  const interrupted = this.isInterruptCancellation(
71507
71542
  parsed.result,
71508
71543
  interruptContext
71509
71544
  );
71545
+ const failActiveInputs = parsed.result.isError && !interrupted;
71546
+ outputs.push(
71547
+ ...this.endActiveParts(),
71548
+ ...failActiveInputs ? this.failActiveToolInputs() : this.finishActiveToolInputs()
71549
+ );
71550
+ this.currentMessageId = null;
71551
+ this.activeResponseMessageId = null;
71510
71552
  if (interrupted) {
71511
71553
  this.input.writeOutput?.(
71512
71554
  `agent_bridge_claude_result_interrupt_cancellation gate=${interruptGate(interruptContext)}`
@@ -71531,6 +71573,7 @@ var ClaudeCodeProjector = class {
71531
71573
  flushPendingAssistantMessages() {
71532
71574
  const outputs = [
71533
71575
  ...this.endActiveParts(),
71576
+ ...this.failActiveToolInputs(),
71534
71577
  uiChunk({ type: "finish", finishReason: "stop" })
71535
71578
  ];
71536
71579
  this.currentMessageId = null;
@@ -71634,6 +71677,23 @@ var ClaudeCodeProjector = class {
71634
71677
  (index) => this.finishActiveToolInput(index)
71635
71678
  );
71636
71679
  }
71680
+ // Settle every still-active tool input as an error part that preserves the
71681
+ // partial input text. Used when the turn ends in an error before the tool
71682
+ // block completed: the tool was never dispatched, and persisting whatever
71683
+ // input streamed keeps the transcript diagnosable.
71684
+ failActiveToolInputs() {
71685
+ const outputs = [...this.activeToolInputs.values()].map(
71686
+ (active) => uiChunk({
71687
+ type: "tool-input-error",
71688
+ toolCallId: active.toolCallId,
71689
+ toolName: active.toolName,
71690
+ input: partialToolInput(active),
71691
+ errorText: truncatedToolInputErrorText(active)
71692
+ })
71693
+ );
71694
+ this.activeToolInputs.clear();
71695
+ return outputs;
71696
+ }
71637
71697
  // A never-streamed assistant snapshot (an SDK-internal stream retry can
71638
71698
  // reissue the in-flight message under a fresh id, so suppression misses it;
71639
71699
  // pure snapshot delivery has no stream at all). Its content must respect the
@@ -71810,6 +71870,21 @@ function completeToolInput(input) {
71810
71870
  }
71811
71871
  return input.initialInput ?? {};
71812
71872
  }
71873
+ function partialToolInput(input) {
71874
+ const inputText = input.inputText.trim();
71875
+ if (inputText.length === 0) {
71876
+ return input.initialInput ?? {};
71877
+ }
71878
+ try {
71879
+ return JSON.parse(inputText);
71880
+ } catch {
71881
+ return input.inputText;
71882
+ }
71883
+ }
71884
+ function truncatedToolInputErrorText(input) {
71885
+ const bytes = Buffer.byteLength(input.inputText, "utf8");
71886
+ return `Tool input streaming was interrupted before the call completed; the tool was never dispatched (${bytes.toString()} bytes of partial input preserved).`;
71887
+ }
71813
71888
  function sourceChunkFromDelta(delta, index) {
71814
71889
  if (delta.type !== "citations_delta") {
71815
71890
  return null;
package/dist/index.js CHANGED
@@ -49211,7 +49211,7 @@ var init_package = __esm({
49211
49211
  "package.json"() {
49212
49212
  package_default = {
49213
49213
  name: "@autohq/cli",
49214
- version: "0.1.450",
49214
+ version: "0.1.451",
49215
49215
  license: "SEE LICENSE IN README.md",
49216
49216
  publishConfig: {
49217
49217
  access: "public"
@@ -61297,8 +61297,7 @@ var AgentBridgeOutputBuffer = class {
61297
61297
  await this.emitUiMessagePartSnapshots(context, projection.chunk, {
61298
61298
  coveredSeq: this.outputSeq
61299
61299
  });
61300
- const toolEntry = legacyToolEntry(projection.chunk);
61301
- if (toolEntry) {
61300
+ for (const toolEntry of legacyToolEntries(projection.chunk)) {
61302
61301
  await this.enqueueProjectionAndDrain(context, {
61303
61302
  type: "entry",
61304
61303
  entry: toolEntry
@@ -61777,73 +61776,112 @@ var UiMessageAssembler = class {
61777
61776
  function isTerminalUiMessageChunk(chunk) {
61778
61777
  return chunk.type === "finish" || chunk.type === "error" || chunk.type === "abort";
61779
61778
  }
61780
- function legacyToolEntry(chunk) {
61779
+ function legacyToolEntries(chunk) {
61781
61780
  switch (chunk.type) {
61782
61781
  case "tool-input-available":
61783
61782
  if (chunk.toolName === ASK_USER_QUESTION_TOOL_NAME) {
61784
- return null;
61783
+ return [];
61785
61784
  }
61786
- return {
61787
- role: "assistant",
61788
- kind: "tool_call",
61789
- content: {
61790
- parts: [
61791
- {
61792
- type: "tool_call",
61793
- toolCallId: legacyToolCallId(chunk.toolCallId),
61794
- name: chunk.toolName,
61795
- input: toJsonValue(chunk.input)
61796
- }
61797
- ]
61785
+ return [
61786
+ {
61787
+ role: "assistant",
61788
+ kind: "tool_call",
61789
+ content: {
61790
+ parts: [
61791
+ {
61792
+ type: "tool_call",
61793
+ toolCallId: legacyToolCallId(chunk.toolCallId),
61794
+ name: chunk.toolName,
61795
+ input: toJsonValue(chunk.input)
61796
+ }
61797
+ ]
61798
+ }
61798
61799
  }
61799
- };
61800
+ ];
61801
+ case "tool-input-error":
61802
+ return [
61803
+ {
61804
+ role: "assistant",
61805
+ kind: "tool_call",
61806
+ content: {
61807
+ parts: [
61808
+ {
61809
+ type: "tool_call",
61810
+ toolCallId: legacyToolCallId(chunk.toolCallId),
61811
+ name: chunk.toolName,
61812
+ input: toJsonValue(chunk.input)
61813
+ }
61814
+ ]
61815
+ }
61816
+ },
61817
+ {
61818
+ role: "tool",
61819
+ kind: "tool_result",
61820
+ content: {
61821
+ parts: [
61822
+ {
61823
+ type: "tool_result",
61824
+ toolUseId: legacyToolCallId(chunk.toolCallId),
61825
+ output: chunk.errorText,
61826
+ isError: true
61827
+ }
61828
+ ]
61829
+ }
61830
+ }
61831
+ ];
61800
61832
  case "tool-output-available":
61801
- return {
61802
- role: "tool",
61803
- kind: "tool_result",
61804
- content: {
61805
- parts: [
61806
- {
61807
- type: "tool_result",
61808
- toolUseId: legacyToolCallId(chunk.toolCallId),
61809
- output: toJsonValue(chunk.output),
61810
- isError: false
61811
- }
61812
- ]
61833
+ return [
61834
+ {
61835
+ role: "tool",
61836
+ kind: "tool_result",
61837
+ content: {
61838
+ parts: [
61839
+ {
61840
+ type: "tool_result",
61841
+ toolUseId: legacyToolCallId(chunk.toolCallId),
61842
+ output: toJsonValue(chunk.output),
61843
+ isError: false
61844
+ }
61845
+ ]
61846
+ }
61813
61847
  }
61814
- };
61848
+ ];
61815
61849
  case "tool-output-error":
61816
- return {
61817
- role: "tool",
61818
- kind: "tool_result",
61819
- content: {
61820
- parts: [
61821
- {
61822
- type: "tool_result",
61823
- toolUseId: legacyToolCallId(chunk.toolCallId),
61824
- output: errorOutput(chunk.errorText),
61825
- isError: true
61826
- }
61827
- ]
61850
+ return [
61851
+ {
61852
+ role: "tool",
61853
+ kind: "tool_result",
61854
+ content: {
61855
+ parts: [
61856
+ {
61857
+ type: "tool_result",
61858
+ toolUseId: legacyToolCallId(chunk.toolCallId),
61859
+ output: errorOutput(chunk.errorText),
61860
+ isError: true
61861
+ }
61862
+ ]
61863
+ }
61828
61864
  }
61829
- };
61865
+ ];
61830
61866
  case "tool-output-denied":
61831
- return {
61832
- role: "tool",
61833
- kind: "tool_result",
61834
- content: {
61835
- parts: [
61836
- {
61837
- type: "tool_result",
61838
- toolUseId: legacyToolCallId(chunk.toolCallId),
61839
- output: { denied: true },
61840
- isError: true
61841
- }
61842
- ]
61867
+ return [
61868
+ {
61869
+ role: "tool",
61870
+ kind: "tool_result",
61871
+ content: {
61872
+ parts: [
61873
+ {
61874
+ type: "tool_result",
61875
+ toolUseId: legacyToolCallId(chunk.toolCallId),
61876
+ output: { denied: true },
61877
+ isError: true
61878
+ }
61879
+ ]
61880
+ }
61843
61881
  }
61844
- };
61882
+ ];
61845
61883
  default:
61846
- return null;
61884
+ return [];
61847
61885
  }
61848
61886
  }
61849
61887
  function legacyToolCallId(toolCallId) {
@@ -62101,13 +62139,17 @@ var ClaudeCodeProjector = class {
62101
62139
  });
62102
62140
  });
62103
62141
  if (parsed.result) {
62104
- outputs.push(...this.endActiveParts(), ...this.finishActiveToolInputs());
62105
- this.currentMessageId = null;
62106
- this.activeResponseMessageId = null;
62107
62142
  const interrupted = this.isInterruptCancellation(
62108
62143
  parsed.result,
62109
62144
  interruptContext
62110
62145
  );
62146
+ const failActiveInputs = parsed.result.isError && !interrupted;
62147
+ outputs.push(
62148
+ ...this.endActiveParts(),
62149
+ ...failActiveInputs ? this.failActiveToolInputs() : this.finishActiveToolInputs()
62150
+ );
62151
+ this.currentMessageId = null;
62152
+ this.activeResponseMessageId = null;
62111
62153
  if (interrupted) {
62112
62154
  this.input.writeOutput?.(
62113
62155
  `agent_bridge_claude_result_interrupt_cancellation gate=${interruptGate(interruptContext)}`
@@ -62132,6 +62174,7 @@ var ClaudeCodeProjector = class {
62132
62174
  flushPendingAssistantMessages() {
62133
62175
  const outputs = [
62134
62176
  ...this.endActiveParts(),
62177
+ ...this.failActiveToolInputs(),
62135
62178
  uiChunk({ type: "finish", finishReason: "stop" })
62136
62179
  ];
62137
62180
  this.currentMessageId = null;
@@ -62235,6 +62278,23 @@ var ClaudeCodeProjector = class {
62235
62278
  (index) => this.finishActiveToolInput(index)
62236
62279
  );
62237
62280
  }
62281
+ // Settle every still-active tool input as an error part that preserves the
62282
+ // partial input text. Used when the turn ends in an error before the tool
62283
+ // block completed: the tool was never dispatched, and persisting whatever
62284
+ // input streamed keeps the transcript diagnosable.
62285
+ failActiveToolInputs() {
62286
+ const outputs = [...this.activeToolInputs.values()].map(
62287
+ (active) => uiChunk({
62288
+ type: "tool-input-error",
62289
+ toolCallId: active.toolCallId,
62290
+ toolName: active.toolName,
62291
+ input: partialToolInput(active),
62292
+ errorText: truncatedToolInputErrorText(active)
62293
+ })
62294
+ );
62295
+ this.activeToolInputs.clear();
62296
+ return outputs;
62297
+ }
62238
62298
  // A never-streamed assistant snapshot (an SDK-internal stream retry can
62239
62299
  // reissue the in-flight message under a fresh id, so suppression misses it;
62240
62300
  // pure snapshot delivery has no stream at all). Its content must respect the
@@ -62411,6 +62471,21 @@ function completeToolInput(input) {
62411
62471
  }
62412
62472
  return input.initialInput ?? {};
62413
62473
  }
62474
+ function partialToolInput(input) {
62475
+ const inputText = input.inputText.trim();
62476
+ if (inputText.length === 0) {
62477
+ return input.initialInput ?? {};
62478
+ }
62479
+ try {
62480
+ return JSON.parse(inputText);
62481
+ } catch {
62482
+ return input.inputText;
62483
+ }
62484
+ }
62485
+ function truncatedToolInputErrorText(input) {
62486
+ const bytes = Buffer.byteLength(input.inputText, "utf8");
62487
+ return `Tool input streaming was interrupted before the call completed; the tool was never dispatched (${bytes.toString()} bytes of partial input preserved).`;
62488
+ }
62414
62489
  function sourceChunkFromDelta(delta, index) {
62415
62490
  if (delta.type !== "citations_delta") {
62416
62491
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.450",
3
+ "version": "0.1.451",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"