supercompat 3.10.1 → 3.10.2
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 +50 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,
|
|
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_keys, firstKey, _toolUseIdArgumentBuffer_get, buffered, parsed, normalized, toolCallIndex, chunkIndex, _toolUseIdArgumentBuffer_get1, buffered1, toolCallIndex1, chunkIndex1, messageDelta, delta, toolUseId1, _toolUseIdArgumentBuffer_keys1, firstKey1, _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:
|
|
@@ -2572,6 +2572,10 @@ var post5 = function(param) {
|
|
|
2572
2572
|
chunk = _ref;
|
|
2573
2573
|
if (chunk.type === "content_block_stop") {
|
|
2574
2574
|
toolUseId = typeof chunk.index === "number" ? blockIndexToToolUseId.get(chunk.index) : void 0;
|
|
2575
|
+
if (!toolUseId && toolUseIdArgumentBuffer.size === 1) {
|
|
2576
|
+
_toolUseIdArgumentBuffer_keys = _sliced_to_array(toolUseIdArgumentBuffer.keys(), 1), firstKey = _toolUseIdArgumentBuffer_keys[0];
|
|
2577
|
+
toolUseId = firstKey;
|
|
2578
|
+
}
|
|
2575
2579
|
if (toolUseId && computerToolUseIds.has(toolUseId) && !normalizedComputerCalls.has(toolUseId)) {
|
|
2576
2580
|
;
|
|
2577
2581
|
buffered = (_toolUseIdArgumentBuffer_get = toolUseIdArgumentBuffer.get(toolUseId)) !== null && _toolUseIdArgumentBuffer_get !== void 0 ? _toolUseIdArgumentBuffer_get : "";
|
|
@@ -2588,6 +2592,35 @@ var post5 = function(param) {
|
|
|
2588
2592
|
normalizedComputerCalls.add(toolUseId);
|
|
2589
2593
|
}
|
|
2590
2594
|
}
|
|
2595
|
+
if (toolUseId && !computerToolUseIds.has(toolUseId)) {
|
|
2596
|
+
;
|
|
2597
|
+
buffered1 = (_toolUseIdArgumentBuffer_get1 = toolUseIdArgumentBuffer.get(toolUseId)) !== null && _toolUseIdArgumentBuffer_get1 !== void 0 ? _toolUseIdArgumentBuffer_get1 : "";
|
|
2598
|
+
if (!buffered1.trim()) {
|
|
2599
|
+
toolCallIndex1 = getOrCreateIndexForToolUseId(toolUseId);
|
|
2600
|
+
chunkIndex1 = typeof chunk.index === "number" ? chunk.index : 0;
|
|
2601
|
+
messageDelta = {
|
|
2602
|
+
id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
|
|
2603
|
+
object: "chat.completion.chunk",
|
|
2604
|
+
choices: [
|
|
2605
|
+
{
|
|
2606
|
+
index: chunkIndex1,
|
|
2607
|
+
delta: {
|
|
2608
|
+
content: null,
|
|
2609
|
+
tool_calls: [
|
|
2610
|
+
{
|
|
2611
|
+
index: toolCallIndex1,
|
|
2612
|
+
function: {
|
|
2613
|
+
arguments: "{}"
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
]
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
]
|
|
2620
|
+
};
|
|
2621
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2591
2624
|
if (toolUseId) {
|
|
2592
2625
|
toolUseIdArgumentBuffer.delete(toolUseId);
|
|
2593
2626
|
computerToolUseIds.delete(toolUseId);
|
|
@@ -2605,9 +2638,13 @@ var post5 = function(param) {
|
|
|
2605
2638
|
delta = void 0;
|
|
2606
2639
|
if (chunk.delta.type === "input_json_delta") {
|
|
2607
2640
|
toolUseId1 = typeof chunk.index === "number" ? blockIndexToToolUseId.get(chunk.index) : void 0;
|
|
2641
|
+
if (!toolUseId1 && toolUseIdArgumentBuffer.size === 1) {
|
|
2642
|
+
_toolUseIdArgumentBuffer_keys1 = _sliced_to_array(toolUseIdArgumentBuffer.keys(), 1), firstKey1 = _toolUseIdArgumentBuffer_keys1[0];
|
|
2643
|
+
toolUseId1 = firstKey1;
|
|
2644
|
+
}
|
|
2608
2645
|
if (toolUseId1 && computerToolUseIds.has(toolUseId1)) {
|
|
2609
2646
|
;
|
|
2610
|
-
existing = (
|
|
2647
|
+
existing = (_toolUseIdArgumentBuffer_get2 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get2 !== void 0 ? _toolUseIdArgumentBuffer_get2 : "";
|
|
2611
2648
|
;
|
|
2612
2649
|
updated = "".concat(existing).concat((_chunk_delta_partial_json = chunk.delta.partial_json) !== null && _chunk_delta_partial_json !== void 0 ? _chunk_delta_partial_json : "");
|
|
2613
2650
|
toolUseIdArgumentBuffer.set(toolUseId1, updated);
|
|
@@ -2615,12 +2652,12 @@ var post5 = function(param) {
|
|
|
2615
2652
|
parsed1 = parseJson2(updated);
|
|
2616
2653
|
if (parsed1 !== void 0) {
|
|
2617
2654
|
normalized1 = normalizeComputerToolCallPayload(parsed1);
|
|
2618
|
-
|
|
2619
|
-
|
|
2655
|
+
toolCallIndex2 = getOrCreateIndexForToolUseId(toolUseId1);
|
|
2656
|
+
chunkIndex2 = typeof chunk.index === "number" ? chunk.index : 0;
|
|
2620
2657
|
emitNormalizedToolCall({
|
|
2621
2658
|
normalized: normalized1,
|
|
2622
|
-
toolCallIndex:
|
|
2623
|
-
chunkIndex:
|
|
2659
|
+
toolCallIndex: toolCallIndex2,
|
|
2660
|
+
chunkIndex: chunkIndex2
|
|
2624
2661
|
});
|
|
2625
2662
|
normalizedComputerCalls.add(toolUseId1);
|
|
2626
2663
|
}
|
|
@@ -2632,7 +2669,7 @@ var post5 = function(param) {
|
|
|
2632
2669
|
}
|
|
2633
2670
|
if (toolUseId1) {
|
|
2634
2671
|
;
|
|
2635
|
-
existing1 = (
|
|
2672
|
+
existing1 = (_toolUseIdArgumentBuffer_get3 = toolUseIdArgumentBuffer.get(toolUseId1)) !== null && _toolUseIdArgumentBuffer_get3 !== void 0 ? _toolUseIdArgumentBuffer_get3 : "";
|
|
2636
2673
|
;
|
|
2637
2674
|
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
2675
|
}
|
|
@@ -2656,7 +2693,7 @@ var post5 = function(param) {
|
|
|
2656
2693
|
content: ""
|
|
2657
2694
|
};
|
|
2658
2695
|
}
|
|
2659
|
-
|
|
2696
|
+
messageDelta1 = {
|
|
2660
2697
|
id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
|
|
2661
2698
|
object: "chat.completion.chunk",
|
|
2662
2699
|
choices: [
|
|
@@ -2666,7 +2703,7 @@ var post5 = function(param) {
|
|
|
2666
2703
|
}
|
|
2667
2704
|
]
|
|
2668
2705
|
};
|
|
2669
|
-
controller.enqueue("data: ".concat(JSON.stringify(
|
|
2706
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
|
|
2670
2707
|
} else if (chunk.type === "content_block_start") {
|
|
2671
2708
|
delta1 = void 0;
|
|
2672
2709
|
if (chunk.content_block.type === "tool_use") {
|
|
@@ -2787,7 +2824,7 @@ var post5 = function(param) {
|
|
|
2787
2824
|
content: ""
|
|
2788
2825
|
};
|
|
2789
2826
|
}
|
|
2790
|
-
|
|
2827
|
+
messageDelta2 = {
|
|
2791
2828
|
id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
|
|
2792
2829
|
object: "chat.completion.chunk",
|
|
2793
2830
|
choices: [
|
|
@@ -2797,9 +2834,9 @@ var post5 = function(param) {
|
|
|
2797
2834
|
}
|
|
2798
2835
|
]
|
|
2799
2836
|
};
|
|
2800
|
-
controller.enqueue("data: ".concat(JSON.stringify(
|
|
2837
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
|
|
2801
2838
|
} else if (chunk.type === "message_start") {
|
|
2802
|
-
|
|
2839
|
+
messageDelta3 = {
|
|
2803
2840
|
id: "chatcmpl-".concat((0, import_radash4.uid)(29)),
|
|
2804
2841
|
object: "chat.completion.chunk",
|
|
2805
2842
|
choices: [
|
|
@@ -2811,7 +2848,7 @@ var post5 = function(param) {
|
|
|
2811
2848
|
}
|
|
2812
2849
|
]
|
|
2813
2850
|
};
|
|
2814
|
-
controller.enqueue("data: ".concat(JSON.stringify(
|
|
2851
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta3), "\n\n"));
|
|
2815
2852
|
}
|
|
2816
2853
|
_state.label = 4;
|
|
2817
2854
|
case 4:
|