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.js CHANGED
@@ -2358,7 +2358,7 @@ var post5 = function(param) {
2358
2358
  stream = new ReadableStream({
2359
2359
  start: function start(controller) {
2360
2360
  return _async_to_generator(function() {
2361
- 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;
2361
+ 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;
2362
2362
  return _ts_generator(this, function(_state) {
2363
2363
  switch(_state.label){
2364
2364
  case 0:
@@ -2479,6 +2479,35 @@ var post5 = function(param) {
2479
2479
  normalizedComputerCalls.add(toolUseId);
2480
2480
  }
2481
2481
  }
2482
+ if (toolUseId && !computerToolUseIds.has(toolUseId)) {
2483
+ ;
2484
+ buffered1 = (_toolUseIdArgumentBuffer_get1 = toolUseIdArgumentBuffer.get(toolUseId)) !== null && _toolUseIdArgumentBuffer_get1 !== void 0 ? _toolUseIdArgumentBuffer_get1 : "";
2485
+ if (!buffered1.trim()) {
2486
+ toolCallIndex1 = getOrCreateIndexForToolUseId(toolUseId);
2487
+ chunkIndex1 = typeof chunk.index === "number" ? chunk.index : 0;
2488
+ messageDelta = {
2489
+ id: "chatcmpl-".concat(uid(29)),
2490
+ object: "chat.completion.chunk",
2491
+ choices: [
2492
+ {
2493
+ index: chunkIndex1,
2494
+ delta: {
2495
+ content: null,
2496
+ tool_calls: [
2497
+ {
2498
+ index: toolCallIndex1,
2499
+ function: {
2500
+ arguments: "{}"
2501
+ }
2502
+ }
2503
+ ]
2504
+ }
2505
+ }
2506
+ ]
2507
+ };
2508
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
2509
+ }
2510
+ }
2482
2511
  if (toolUseId) {
2483
2512
  toolUseIdArgumentBuffer.delete(toolUseId);
2484
2513
  computerToolUseIds.delete(toolUseId);
@@ -2498,7 +2527,7 @@ var post5 = function(param) {
2498
2527
  toolUseId1 = typeof chunk.index === "number" ? blockIndexToToolUseId.get(chunk.index) : void 0;
2499
2528
  if (toolUseId1 && computerToolUseIds.has(toolUseId1)) {
2500
2529
  ;
2501
- existing = (_toolUseIdArgumentBuffer_get1 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get1 !== void 0 ? _toolUseIdArgumentBuffer_get1 : "";
2530
+ existing = (_toolUseIdArgumentBuffer_get2 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get2 !== void 0 ? _toolUseIdArgumentBuffer_get2 : "";
2502
2531
  ;
2503
2532
  updated = "".concat(existing).concat((_chunk_delta_partial_json = chunk.delta.partial_json) !== null && _chunk_delta_partial_json !== void 0 ? _chunk_delta_partial_json : "");
2504
2533
  toolUseIdArgumentBuffer.set(toolUseId1, updated);
@@ -2506,12 +2535,12 @@ var post5 = function(param) {
2506
2535
  parsed1 = parseJson2(updated);
2507
2536
  if (parsed1 !== void 0) {
2508
2537
  normalized1 = normalizeComputerToolCallPayload(parsed1);
2509
- toolCallIndex1 = getOrCreateIndexForToolUseId(toolUseId1);
2510
- chunkIndex1 = typeof chunk.index === "number" ? chunk.index : 0;
2538
+ toolCallIndex2 = getOrCreateIndexForToolUseId(toolUseId1);
2539
+ chunkIndex2 = typeof chunk.index === "number" ? chunk.index : 0;
2511
2540
  emitNormalizedToolCall({
2512
2541
  normalized: normalized1,
2513
- toolCallIndex: toolCallIndex1,
2514
- chunkIndex: chunkIndex1
2542
+ toolCallIndex: toolCallIndex2,
2543
+ chunkIndex: chunkIndex2
2515
2544
  });
2516
2545
  normalizedComputerCalls.add(toolUseId1);
2517
2546
  }
@@ -2523,7 +2552,7 @@ var post5 = function(param) {
2523
2552
  }
2524
2553
  if (toolUseId1) {
2525
2554
  ;
2526
- existing1 = (_toolUseIdArgumentBuffer_get2 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get2 !== void 0 ? _toolUseIdArgumentBuffer_get2 : "";
2555
+ existing1 = (_toolUseIdArgumentBuffer_get3 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get3 !== void 0 ? _toolUseIdArgumentBuffer_get3 : "";
2527
2556
  ;
2528
2557
  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 : ""));
2529
2558
  }
@@ -2547,7 +2576,7 @@ var post5 = function(param) {
2547
2576
  content: ""
2548
2577
  };
2549
2578
  }
2550
- messageDelta = {
2579
+ messageDelta1 = {
2551
2580
  id: "chatcmpl-".concat(uid(29)),
2552
2581
  object: "chat.completion.chunk",
2553
2582
  choices: [
@@ -2557,7 +2586,7 @@ var post5 = function(param) {
2557
2586
  }
2558
2587
  ]
2559
2588
  };
2560
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
2589
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
2561
2590
  } else if (chunk.type === "content_block_start") {
2562
2591
  delta1 = void 0;
2563
2592
  if (chunk.content_block.type === "tool_use") {
@@ -2678,7 +2707,7 @@ var post5 = function(param) {
2678
2707
  content: ""
2679
2708
  };
2680
2709
  }
2681
- messageDelta1 = {
2710
+ messageDelta2 = {
2682
2711
  id: "chatcmpl-".concat(uid(29)),
2683
2712
  object: "chat.completion.chunk",
2684
2713
  choices: [
@@ -2688,9 +2717,9 @@ var post5 = function(param) {
2688
2717
  }
2689
2718
  ]
2690
2719
  };
2691
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
2720
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
2692
2721
  } else if (chunk.type === "message_start") {
2693
- messageDelta2 = {
2722
+ messageDelta3 = {
2694
2723
  id: "chatcmpl-".concat(uid(29)),
2695
2724
  object: "chat.completion.chunk",
2696
2725
  choices: [
@@ -2702,7 +2731,7 @@ var post5 = function(param) {
2702
2731
  }
2703
2732
  ]
2704
2733
  };
2705
- controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
2734
+ controller.enqueue("data: ".concat(JSON.stringify(messageDelta3), "\n\n"));
2706
2735
  }
2707
2736
  _state.label = 4;
2708
2737
  case 4: