supercompat 3.10.1 → 3.10.3

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.
package/dist/index.cjs CHANGED
@@ -2467,7 +2467,7 @@ var post5 = function(param) {
2467
2467
  stream = new ReadableStream({
2468
2468
  start: function start(controller) {
2469
2469
  return _async_to_generator(function() {
2470
- var blockIndexToToolUseId, toolUseIdToIndex, toolUseIdArgumentBuffer, computerToolUseIds, normalizedComputerCalls, nextToolCallIndex, parseJson2, getOrCreateIndexForToolUseId, assignBlockToToolUse, markComputerToolUse, getToolUseIdFromBlock, emitNormalizedToolCall, getOrCreateIndexForBlock, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, _ref, chunk, toolUseId, _toolUseIdArgumentBuffer_get, buffered, parsed, normalized, toolCallIndex, chunkIndex, delta, toolUseId1, _toolUseIdArgumentBuffer_get1, existing, _chunk_delta_partial_json, updated, parsed1, normalized1, toolCallIndex1, chunkIndex1, _toolUseIdArgumentBuffer_get2, existing1, _chunk_delta_partial_json1, index, messageDelta, delta1, toolName, normalizedToolName, index1, index2, _chunk_content_block_content, outputPayload, _getToolUseIdFromBlock, toolCallId, index3, _getToolUseIdFromBlock1, toolCallId1, _chunk_content_block, _toolUseId, _type, _id, rest, index4, _chunk_content_block_content1, outputPayload1, messageDelta1, messageDelta2, err;
2470
+ var blockIndexToToolUseId, toolUseIdToIndex, toolUseIdArgumentBuffer, computerToolUseIds, normalizedComputerCalls, nextToolCallIndex, parseJson2, getOrCreateIndexForToolUseId, assignBlockToToolUse, markComputerToolUse, getToolUseIdFromBlock, emitNormalizedToolCall, getOrCreateIndexForBlock, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, _ref, chunk, toolUseId, _toolUseIdArgumentBuffer_get, buffered, parsed, normalized, toolCallIndex, chunkIndex, _toolUseIdArgumentBuffer_get1, buffered1, toolCallIndex1, chunkIndex1, messageDelta, delta, toolUseId1, _toolUseIdArgumentBuffer_get2, existing, _chunk_delta_partial_json, updated, parsed1, normalized1, toolCallIndex2, chunkIndex2, _toolUseIdArgumentBuffer_get3, existing1, _chunk_delta_partial_json1, index, messageDelta1, delta1, toolName, normalizedToolName, index1, index2, _chunk_content_block_content, outputPayload, _getToolUseIdFromBlock, toolCallId, index3, _getToolUseIdFromBlock1, toolCallId1, _chunk_content_block, _toolUseId, _type, _id, rest, index4, _chunk_content_block_content1, outputPayload1, messageDelta2, messageDelta3, err;
2471
2471
  return _ts_generator(this, function(_state) {
2472
2472
  switch(_state.label){
2473
2473
  case 0:
@@ -2588,6 +2588,35 @@ var post5 = function(param) {
2588
2588
  normalizedComputerCalls.add(toolUseId);
2589
2589
  }
2590
2590
  }
2591
+ if (toolUseId && !computerToolUseIds.has(toolUseId)) {
2592
+ ;
2593
+ buffered1 = (_toolUseIdArgumentBuffer_get1 = toolUseIdArgumentBuffer.get(toolUseId)) !== null && _toolUseIdArgumentBuffer_get1 !== void 0 ? _toolUseIdArgumentBuffer_get1 : "";
2594
+ if (!buffered1.trim()) {
2595
+ toolCallIndex1 = getOrCreateIndexForToolUseId(toolUseId);
2596
+ chunkIndex1 = typeof chunk.index === "number" ? chunk.index : 0;
2597
+ messageDelta = {
2598
+ id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
2599
+ object: "chat.completion.chunk",
2600
+ choices: [
2601
+ {
2602
+ index: chunkIndex1,
2603
+ delta: {
2604
+ content: null,
2605
+ tool_calls: [
2606
+ {
2607
+ index: toolCallIndex1,
2608
+ function: {
2609
+ arguments: "{}"
2610
+ }
2611
+ }
2612
+ ]
2613
+ }
2614
+ }
2615
+ ]
2616
+ };
2617
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
2618
+ }
2619
+ }
2591
2620
  if (toolUseId) {
2592
2621
  toolUseIdArgumentBuffer.delete(toolUseId);
2593
2622
  computerToolUseIds.delete(toolUseId);
@@ -2607,7 +2636,7 @@ var post5 = function(param) {
2607
2636
  toolUseId1 = typeof chunk.index === "number" ? blockIndexToToolUseId.get(chunk.index) : void 0;
2608
2637
  if (toolUseId1 && computerToolUseIds.has(toolUseId1)) {
2609
2638
  ;
2610
- existing = (_toolUseIdArgumentBuffer_get1 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get1 !== void 0 ? _toolUseIdArgumentBuffer_get1 : "";
2639
+ existing = (_toolUseIdArgumentBuffer_get2 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get2 !== void 0 ? _toolUseIdArgumentBuffer_get2 : "";
2611
2640
  ;
2612
2641
  updated = "".concat(existing).concat((_chunk_delta_partial_json = chunk.delta.partial_json) !== null && _chunk_delta_partial_json !== void 0 ? _chunk_delta_partial_json : "");
2613
2642
  toolUseIdArgumentBuffer.set(toolUseId1, updated);
@@ -2615,12 +2644,12 @@ var post5 = function(param) {
2615
2644
  parsed1 = parseJson2(updated);
2616
2645
  if (parsed1 !== void 0) {
2617
2646
  normalized1 = normalizeComputerToolCallPayload(parsed1);
2618
- toolCallIndex1 = getOrCreateIndexForToolUseId(toolUseId1);
2619
- chunkIndex1 = typeof chunk.index === "number" ? chunk.index : 0;
2647
+ toolCallIndex2 = getOrCreateIndexForToolUseId(toolUseId1);
2648
+ chunkIndex2 = typeof chunk.index === "number" ? chunk.index : 0;
2620
2649
  emitNormalizedToolCall({
2621
2650
  normalized: normalized1,
2622
- toolCallIndex: toolCallIndex1,
2623
- chunkIndex: chunkIndex1
2651
+ toolCallIndex: toolCallIndex2,
2652
+ chunkIndex: chunkIndex2
2624
2653
  });
2625
2654
  normalizedComputerCalls.add(toolUseId1);
2626
2655
  }
@@ -2632,7 +2661,7 @@ var post5 = function(param) {
2632
2661
  }
2633
2662
  if (toolUseId1) {
2634
2663
  ;
2635
- existing1 = (_toolUseIdArgumentBuffer_get2 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get2 !== void 0 ? _toolUseIdArgumentBuffer_get2 : "";
2664
+ existing1 = (_toolUseIdArgumentBuffer_get3 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get3 !== void 0 ? _toolUseIdArgumentBuffer_get3 : "";
2636
2665
  ;
2637
2666
  toolUseIdArgumentBuffer.set(toolUseId1, "".concat(existing1).concat((_chunk_delta_partial_json1 = chunk.delta.partial_json) !== null && _chunk_delta_partial_json1 !== void 0 ? _chunk_delta_partial_json1 : ""));
2638
2667
  }
@@ -2656,7 +2685,7 @@ var post5 = function(param) {
2656
2685
  content: ""
2657
2686
  };
2658
2687
  }
2659
- messageDelta = {
2688
+ messageDelta1 = {
2660
2689
  id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
2661
2690
  object: "chat.completion.chunk",
2662
2691
  choices: [
@@ -2666,7 +2695,7 @@ var post5 = function(param) {
2666
2695
  }
2667
2696
  ]
2668
2697
  };
2669
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
2698
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
2670
2699
  } else if (chunk.type === "content_block_start") {
2671
2700
  delta1 = void 0;
2672
2701
  if (chunk.content_block.type === "tool_use") {
@@ -2787,7 +2816,7 @@ var post5 = function(param) {
2787
2816
  content: ""
2788
2817
  };
2789
2818
  }
2790
- messageDelta1 = {
2819
+ messageDelta2 = {
2791
2820
  id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
2792
2821
  object: "chat.completion.chunk",
2793
2822
  choices: [
@@ -2797,9 +2826,9 @@ var post5 = function(param) {
2797
2826
  }
2798
2827
  ]
2799
2828
  };
2800
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
2829
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
2801
2830
  } else if (chunk.type === "message_start") {
2802
- messageDelta2 = {
2831
+ messageDelta3 = {
2803
2832
  id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
2804
2833
  object: "chat.completion.chunk",
2805
2834
  choices: [
@@ -2811,7 +2840,7 @@ var post5 = function(param) {
2811
2840
  }
2812
2841
  ]
2813
2842
  };
2814
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
2843
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta3), "\n\n"));
2815
2844
  }
2816
2845
  _state.label = 4;
2817
2846
  case 4: