supercompat 3.17.2 → 3.18.0
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 +800 -235
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +800 -235
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,6 +9,80 @@ function _array_with_holes(arr) {
|
|
|
9
9
|
function _array_without_holes(arr) {
|
|
10
10
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
11
|
}
|
|
12
|
+
function _async_generator(gen) {
|
|
13
|
+
var front, back;
|
|
14
|
+
function send(key, arg) {
|
|
15
|
+
return new Promise(function(resolve, reject) {
|
|
16
|
+
var request = {
|
|
17
|
+
key: key,
|
|
18
|
+
arg: arg,
|
|
19
|
+
resolve: resolve,
|
|
20
|
+
reject: reject,
|
|
21
|
+
next: null
|
|
22
|
+
};
|
|
23
|
+
if (back) back = back.next = request;
|
|
24
|
+
else {
|
|
25
|
+
front = back = request;
|
|
26
|
+
resume(key, arg);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function resume(key, arg) {
|
|
31
|
+
try {
|
|
32
|
+
var result = gen[key](arg);
|
|
33
|
+
var value = result.value;
|
|
34
|
+
var overloaded = value instanceof _overload_yield;
|
|
35
|
+
Promise.resolve(overloaded ? value.v : value).then(function(arg) {
|
|
36
|
+
if (overloaded) {
|
|
37
|
+
var nextKey = key === "return" ? "return" : "next";
|
|
38
|
+
if (!value.k || arg.done) return resume(nextKey, arg);
|
|
39
|
+
else arg = gen[nextKey](arg).value;
|
|
40
|
+
}
|
|
41
|
+
settle(result.done ? "return" : "normal", arg);
|
|
42
|
+
}, function(err) {
|
|
43
|
+
resume("throw", err);
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
settle("throw", err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function settle(type, value) {
|
|
50
|
+
switch(type){
|
|
51
|
+
case "return":
|
|
52
|
+
front.resolve({
|
|
53
|
+
value: value,
|
|
54
|
+
done: true
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
case "throw":
|
|
58
|
+
front.reject(value);
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
front.resolve({
|
|
62
|
+
value: value,
|
|
63
|
+
done: false
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
front = front.next;
|
|
68
|
+
if (front) resume(front.key, front.arg);
|
|
69
|
+
else back = null;
|
|
70
|
+
}
|
|
71
|
+
this._invoke = send;
|
|
72
|
+
if (typeof gen.return !== "function") this.return = undefined;
|
|
73
|
+
}
|
|
74
|
+
_async_generator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
75
|
+
return this;
|
|
76
|
+
};
|
|
77
|
+
_async_generator.prototype.next = function(arg) {
|
|
78
|
+
return this._invoke("next", arg);
|
|
79
|
+
};
|
|
80
|
+
_async_generator.prototype.throw = function(arg) {
|
|
81
|
+
return this._invoke("throw", arg);
|
|
82
|
+
};
|
|
83
|
+
_async_generator.prototype.return = function(arg) {
|
|
84
|
+
return this._invoke("return", arg);
|
|
85
|
+
};
|
|
12
86
|
function _async_iterator(iterable) {
|
|
13
87
|
var method, async, sync, retry = 2;
|
|
14
88
|
for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
|
|
@@ -79,6 +153,9 @@ function _async_to_generator(fn) {
|
|
|
79
153
|
});
|
|
80
154
|
};
|
|
81
155
|
}
|
|
156
|
+
function _await_async_generator(value) {
|
|
157
|
+
return new _overload_yield(value, 0);
|
|
158
|
+
}
|
|
82
159
|
function _define_property(obj, key, value) {
|
|
83
160
|
if (key in obj) {
|
|
84
161
|
Object.defineProperty(obj, key, {
|
|
@@ -207,6 +284,10 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
207
284
|
}
|
|
208
285
|
return target;
|
|
209
286
|
}
|
|
287
|
+
function _overload_yield(value, kind) {
|
|
288
|
+
this.v = value;
|
|
289
|
+
this.k = kind;
|
|
290
|
+
}
|
|
210
291
|
function _sliced_to_array(arr, i) {
|
|
211
292
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
212
293
|
}
|
|
@@ -225,6 +306,11 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
225
306
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
226
307
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
227
308
|
}
|
|
309
|
+
function _wrap_async_generator(fn) {
|
|
310
|
+
return function() {
|
|
311
|
+
return new _async_generator(fn.apply(this, arguments));
|
|
312
|
+
};
|
|
313
|
+
}
|
|
228
314
|
function _ts_generator(thisArg, body) {
|
|
229
315
|
var f, y, t, _ = {
|
|
230
316
|
label: 0,
|
|
@@ -3409,15 +3495,17 @@ var GEMINI_ACTION_NAMES = /* @__PURE__ */ new Set([
|
|
|
3409
3495
|
"scroll_document",
|
|
3410
3496
|
"drag_and_drop",
|
|
3411
3497
|
"wait_5_seconds",
|
|
3412
|
-
"wait_for_load"
|
|
3413
|
-
"navigate",
|
|
3414
|
-
"go_back",
|
|
3415
|
-
"go_forward",
|
|
3416
|
-
"open_web_browser"
|
|
3498
|
+
"wait_for_load"
|
|
3417
3499
|
]);
|
|
3418
3500
|
var isGeminiAction = function(name) {
|
|
3419
3501
|
return GEMINI_ACTION_NAMES.has(name);
|
|
3420
3502
|
};
|
|
3503
|
+
var act = function(action) {
|
|
3504
|
+
return {
|
|
3505
|
+
action: action,
|
|
3506
|
+
pending_safety_checks: []
|
|
3507
|
+
};
|
|
3508
|
+
};
|
|
3421
3509
|
var normalizeGeminiKey = function(key) {
|
|
3422
3510
|
var lower = key.toLowerCase();
|
|
3423
3511
|
switch(lower){
|
|
@@ -3471,80 +3559,89 @@ var normalizeGeminiAction = function(name, args) {
|
|
|
3471
3559
|
switch(name){
|
|
3472
3560
|
case "click_at":
|
|
3473
3561
|
case "single_click_at":
|
|
3474
|
-
return
|
|
3475
|
-
|
|
3562
|
+
return [
|
|
3563
|
+
act({
|
|
3476
3564
|
type: "click",
|
|
3477
3565
|
button: "left",
|
|
3478
3566
|
x: x,
|
|
3479
3567
|
y: y
|
|
3480
|
-
}
|
|
3481
|
-
|
|
3482
|
-
};
|
|
3568
|
+
})
|
|
3569
|
+
];
|
|
3483
3570
|
case "right_click_at":
|
|
3484
|
-
return
|
|
3485
|
-
|
|
3571
|
+
return [
|
|
3572
|
+
act({
|
|
3486
3573
|
type: "click",
|
|
3487
3574
|
button: "right",
|
|
3488
3575
|
x: x,
|
|
3489
3576
|
y: y
|
|
3490
|
-
}
|
|
3491
|
-
|
|
3492
|
-
};
|
|
3577
|
+
})
|
|
3578
|
+
];
|
|
3493
3579
|
case "double_click_at":
|
|
3494
|
-
return
|
|
3495
|
-
|
|
3580
|
+
return [
|
|
3581
|
+
act({
|
|
3496
3582
|
type: "double_click",
|
|
3497
3583
|
x: x,
|
|
3498
3584
|
y: y
|
|
3499
|
-
}
|
|
3500
|
-
|
|
3501
|
-
};
|
|
3585
|
+
})
|
|
3586
|
+
];
|
|
3502
3587
|
case "triple_click_at":
|
|
3503
|
-
return
|
|
3504
|
-
|
|
3588
|
+
return [
|
|
3589
|
+
act({
|
|
3505
3590
|
type: "double_click",
|
|
3506
3591
|
x: x,
|
|
3507
3592
|
y: y,
|
|
3508
3593
|
repetitions: 3
|
|
3509
|
-
}
|
|
3510
|
-
|
|
3511
|
-
};
|
|
3594
|
+
})
|
|
3595
|
+
];
|
|
3512
3596
|
case "hover_at":
|
|
3513
|
-
return
|
|
3514
|
-
|
|
3597
|
+
return [
|
|
3598
|
+
act({
|
|
3515
3599
|
type: "move",
|
|
3516
3600
|
x: x,
|
|
3517
3601
|
y: y
|
|
3518
|
-
}
|
|
3519
|
-
|
|
3520
|
-
};
|
|
3602
|
+
})
|
|
3603
|
+
];
|
|
3521
3604
|
case "type_text_at":
|
|
3522
3605
|
{
|
|
3523
3606
|
var text = typeof args.text === "string" ? args.text : "";
|
|
3524
|
-
var
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3607
|
+
var clearBeforeTyping = args.clear_before_typing !== false;
|
|
3608
|
+
var pressEnter = args.press_enter !== false;
|
|
3609
|
+
var actions = [
|
|
3610
|
+
act({
|
|
3611
|
+
type: "click",
|
|
3612
|
+
button: "left",
|
|
3613
|
+
x: x,
|
|
3614
|
+
y: y
|
|
3615
|
+
})
|
|
3529
3616
|
];
|
|
3530
|
-
if (
|
|
3531
|
-
|
|
3617
|
+
if (clearBeforeTyping) {
|
|
3618
|
+
actions.push(act({
|
|
3619
|
+
type: "keypress",
|
|
3620
|
+
keys: [
|
|
3621
|
+
"ctrl",
|
|
3622
|
+
"a"
|
|
3623
|
+
]
|
|
3624
|
+
}));
|
|
3625
|
+
actions.push(act({
|
|
3626
|
+
type: "keypress",
|
|
3627
|
+
keys: [
|
|
3628
|
+
"Backspace"
|
|
3629
|
+
]
|
|
3630
|
+
}));
|
|
3631
|
+
}
|
|
3632
|
+
actions.push(act({
|
|
3633
|
+
type: "type",
|
|
3634
|
+
text: text
|
|
3635
|
+
}));
|
|
3636
|
+
if (pressEnter) {
|
|
3637
|
+
actions.push(act({
|
|
3532
3638
|
type: "keypress",
|
|
3533
3639
|
keys: [
|
|
3534
3640
|
"Return"
|
|
3535
3641
|
]
|
|
3536
|
-
});
|
|
3642
|
+
}));
|
|
3537
3643
|
}
|
|
3538
|
-
return
|
|
3539
|
-
action: {
|
|
3540
|
-
type: "click",
|
|
3541
|
-
button: "left",
|
|
3542
|
-
x: x,
|
|
3543
|
-
y: y,
|
|
3544
|
-
pending_actions: pendingActions
|
|
3545
|
-
},
|
|
3546
|
-
pending_safety_checks: []
|
|
3547
|
-
};
|
|
3644
|
+
return actions;
|
|
3548
3645
|
}
|
|
3549
3646
|
case "key_combination":
|
|
3550
3647
|
{
|
|
@@ -3559,52 +3656,49 @@ var normalizeGeminiAction = function(name, args) {
|
|
|
3559
3656
|
} else {
|
|
3560
3657
|
keys = [];
|
|
3561
3658
|
}
|
|
3562
|
-
return
|
|
3563
|
-
|
|
3659
|
+
return [
|
|
3660
|
+
act({
|
|
3564
3661
|
type: "keypress",
|
|
3565
3662
|
keys: keys
|
|
3566
|
-
}
|
|
3567
|
-
|
|
3568
|
-
};
|
|
3663
|
+
})
|
|
3664
|
+
];
|
|
3569
3665
|
}
|
|
3570
3666
|
case "scroll_at":
|
|
3571
3667
|
{
|
|
3572
3668
|
var direction = typeof args.direction === "string" ? args.direction : void 0;
|
|
3573
3669
|
var amount = typeof args.amount === "number" ? args.amount : 3;
|
|
3574
3670
|
var _scrollFromDirection = scrollFromDirection(direction, amount), scroll_x = _scrollFromDirection.scroll_x, scroll_y = _scrollFromDirection.scroll_y;
|
|
3575
|
-
return
|
|
3576
|
-
|
|
3671
|
+
return [
|
|
3672
|
+
act({
|
|
3577
3673
|
type: "scroll",
|
|
3578
3674
|
x: x,
|
|
3579
3675
|
y: y,
|
|
3580
3676
|
scroll_x: scroll_x,
|
|
3581
3677
|
scroll_y: scroll_y
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3584
|
-
};
|
|
3678
|
+
})
|
|
3679
|
+
];
|
|
3585
3680
|
}
|
|
3586
3681
|
case "scroll_document":
|
|
3587
3682
|
{
|
|
3588
3683
|
var direction1 = typeof args.direction === "string" ? args.direction : void 0;
|
|
3589
3684
|
var amount1 = typeof args.amount === "number" ? args.amount : 3;
|
|
3590
3685
|
var _scrollFromDirection1 = scrollFromDirection(direction1, amount1), scroll_x1 = _scrollFromDirection1.scroll_x, scroll_y1 = _scrollFromDirection1.scroll_y;
|
|
3591
|
-
return
|
|
3592
|
-
|
|
3686
|
+
return [
|
|
3687
|
+
act({
|
|
3593
3688
|
type: "scroll",
|
|
3594
3689
|
x: 640,
|
|
3595
3690
|
y: 360,
|
|
3596
3691
|
scroll_x: scroll_x1,
|
|
3597
3692
|
scroll_y: scroll_y1
|
|
3598
|
-
}
|
|
3599
|
-
|
|
3600
|
-
};
|
|
3693
|
+
})
|
|
3694
|
+
];
|
|
3601
3695
|
}
|
|
3602
3696
|
case "drag_and_drop":
|
|
3603
3697
|
{
|
|
3604
3698
|
var destX = typeof args.destination_x === "number" ? args.destination_x : 0;
|
|
3605
3699
|
var destY = typeof args.destination_y === "number" ? args.destination_y : 0;
|
|
3606
|
-
return
|
|
3607
|
-
|
|
3700
|
+
return [
|
|
3701
|
+
act({
|
|
3608
3702
|
type: "drag",
|
|
3609
3703
|
path: [
|
|
3610
3704
|
{
|
|
@@ -3616,86 +3710,24 @@ var normalizeGeminiAction = function(name, args) {
|
|
|
3616
3710
|
y: destY
|
|
3617
3711
|
}
|
|
3618
3712
|
]
|
|
3619
|
-
}
|
|
3620
|
-
|
|
3621
|
-
};
|
|
3713
|
+
})
|
|
3714
|
+
];
|
|
3622
3715
|
}
|
|
3623
3716
|
case "wait_5_seconds":
|
|
3624
3717
|
case "wait_for_load":
|
|
3625
|
-
return
|
|
3626
|
-
|
|
3718
|
+
return [
|
|
3719
|
+
act({
|
|
3627
3720
|
type: "wait"
|
|
3628
|
-
}
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
{
|
|
3633
|
-
var url = typeof args.url === "string" ? args.url : "";
|
|
3634
|
-
return {
|
|
3635
|
-
action: {
|
|
3636
|
-
type: "keypress",
|
|
3637
|
-
keys: [
|
|
3638
|
-
"ctrl",
|
|
3639
|
-
"l"
|
|
3640
|
-
],
|
|
3641
|
-
pending_actions: [
|
|
3642
|
-
{
|
|
3643
|
-
type: "wait"
|
|
3644
|
-
},
|
|
3645
|
-
{
|
|
3646
|
-
type: "type",
|
|
3647
|
-
text: url
|
|
3648
|
-
},
|
|
3649
|
-
{
|
|
3650
|
-
type: "keypress",
|
|
3651
|
-
keys: [
|
|
3652
|
-
"Return"
|
|
3653
|
-
]
|
|
3654
|
-
},
|
|
3655
|
-
{
|
|
3656
|
-
type: "wait"
|
|
3657
|
-
}
|
|
3658
|
-
]
|
|
3659
|
-
},
|
|
3660
|
-
pending_safety_checks: []
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
case "go_back":
|
|
3664
|
-
return {
|
|
3665
|
-
action: {
|
|
3666
|
-
type: "keypress",
|
|
3667
|
-
keys: [
|
|
3668
|
-
"alt",
|
|
3669
|
-
"left"
|
|
3670
|
-
]
|
|
3671
|
-
},
|
|
3672
|
-
pending_safety_checks: []
|
|
3673
|
-
};
|
|
3674
|
-
case "go_forward":
|
|
3675
|
-
return {
|
|
3676
|
-
action: {
|
|
3677
|
-
type: "keypress",
|
|
3678
|
-
keys: [
|
|
3679
|
-
"alt",
|
|
3680
|
-
"right"
|
|
3681
|
-
]
|
|
3682
|
-
},
|
|
3683
|
-
pending_safety_checks: []
|
|
3684
|
-
};
|
|
3685
|
-
case "open_web_browser":
|
|
3686
|
-
return {
|
|
3687
|
-
action: {
|
|
3688
|
-
type: "screenshot"
|
|
3689
|
-
},
|
|
3690
|
-
pending_safety_checks: []
|
|
3691
|
-
};
|
|
3721
|
+
})
|
|
3722
|
+
];
|
|
3723
|
+
// navigate, go_back, go_forward, open_web_browser, search are excluded
|
|
3724
|
+
// via excludedPredefinedFunctions in the tool config
|
|
3692
3725
|
default:
|
|
3693
|
-
return
|
|
3694
|
-
|
|
3726
|
+
return [
|
|
3727
|
+
act(_object_spread({
|
|
3695
3728
|
type: name
|
|
3696
|
-
}, args)
|
|
3697
|
-
|
|
3698
|
-
};
|
|
3729
|
+
}, args))
|
|
3730
|
+
];
|
|
3699
3731
|
}
|
|
3700
3732
|
};
|
|
3701
3733
|
// src/adapters/client/googleClientAdapter/completions/post.ts
|
|
@@ -3739,6 +3771,9 @@ var serializeMessages2 = function(messages5) {
|
|
|
3739
3771
|
var systemParts = [];
|
|
3740
3772
|
var contents = [];
|
|
3741
3773
|
var toolCallIdToName = /* @__PURE__ */ new Map();
|
|
3774
|
+
var geminiCallGroups = /* @__PURE__ */ new Map();
|
|
3775
|
+
var skipToolResultIds = /* @__PURE__ */ new Set();
|
|
3776
|
+
var lastSubActionMap = /* @__PURE__ */ new Map();
|
|
3742
3777
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3743
3778
|
try {
|
|
3744
3779
|
for(var _iterator = messages5[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -3835,9 +3870,42 @@ var serializeMessages2 = function(messages5) {
|
|
|
3835
3870
|
} catch (unused) {}
|
|
3836
3871
|
var thoughtSignature = args._thoughtSignature;
|
|
3837
3872
|
var geminiActionName = args._geminiAction;
|
|
3873
|
+
var geminiCallId = args._geminiCallId;
|
|
3874
|
+
var subActionIndex = args._subActionIndex;
|
|
3875
|
+
var subActionTotal = args._subActionTotal;
|
|
3876
|
+
var geminiOrigArgs = args._geminiArgs;
|
|
3838
3877
|
var cleanArgs = _object_spread({}, args);
|
|
3839
3878
|
delete cleanArgs._thoughtSignature;
|
|
3840
3879
|
delete cleanArgs._geminiAction;
|
|
3880
|
+
delete cleanArgs._geminiCallId;
|
|
3881
|
+
delete cleanArgs._subActionIndex;
|
|
3882
|
+
delete cleanArgs._subActionTotal;
|
|
3883
|
+
delete cleanArgs._geminiArgs;
|
|
3884
|
+
if (geminiCallId && typeof subActionIndex === "number" && typeof subActionTotal === "number") {
|
|
3885
|
+
if (subActionIndex === 0) {
|
|
3886
|
+
var fcName = geminiActionName !== null && geminiActionName !== void 0 ? geminiActionName : name;
|
|
3887
|
+
geminiCallGroups.set(geminiCallId, {
|
|
3888
|
+
name: fcName,
|
|
3889
|
+
primaryId: id
|
|
3890
|
+
});
|
|
3891
|
+
toolCallIdToName.set(id, fcName);
|
|
3892
|
+
if (subActionTotal > 1) skipToolResultIds.add(id);
|
|
3893
|
+
var fcPart2 = {
|
|
3894
|
+
functionCall: {
|
|
3895
|
+
name: fcName,
|
|
3896
|
+
args: geminiOrigArgs !== null && geminiOrigArgs !== void 0 ? geminiOrigArgs : {},
|
|
3897
|
+
id: id
|
|
3898
|
+
}
|
|
3899
|
+
};
|
|
3900
|
+
if (thoughtSignature) fcPart2.thoughtSignature = thoughtSignature;
|
|
3901
|
+
parts1.push(fcPart2);
|
|
3902
|
+
} else if (subActionIndex === subActionTotal - 1) {
|
|
3903
|
+
lastSubActionMap.set(id, geminiCallId);
|
|
3904
|
+
} else {
|
|
3905
|
+
skipToolResultIds.add(id);
|
|
3906
|
+
}
|
|
3907
|
+
continue;
|
|
3908
|
+
}
|
|
3841
3909
|
var geminiName = name;
|
|
3842
3910
|
if (name === "computer_call" && args.action && _type_of(args.action) === "object") {
|
|
3843
3911
|
var _ref2;
|
|
@@ -3846,9 +3914,8 @@ var serializeMessages2 = function(messages5) {
|
|
|
3846
3914
|
var geminiArgs = void 0;
|
|
3847
3915
|
if (name === "computer_call" && cleanArgs.action && _type_of(cleanArgs.action) === "object") {
|
|
3848
3916
|
var action = cleanArgs.action;
|
|
3849
|
-
var _type = action.type,
|
|
3850
|
-
"type"
|
|
3851
|
-
"pending_actions"
|
|
3917
|
+
var _type = action.type, rest = _object_without_properties(action, [
|
|
3918
|
+
"type"
|
|
3852
3919
|
]);
|
|
3853
3920
|
geminiArgs = rest;
|
|
3854
3921
|
} else {
|
|
@@ -3891,10 +3958,22 @@ var serializeMessages2 = function(messages5) {
|
|
|
3891
3958
|
continue;
|
|
3892
3959
|
}
|
|
3893
3960
|
if (msg.role === "tool") {
|
|
3894
|
-
var _msg_tool_call_id
|
|
3961
|
+
var _msg_tool_call_id;
|
|
3895
3962
|
var _lastContent_parts;
|
|
3896
3963
|
var toolCallId = (_msg_tool_call_id = msg.tool_call_id) !== null && _msg_tool_call_id !== void 0 ? _msg_tool_call_id : "";
|
|
3897
|
-
|
|
3964
|
+
if (skipToolResultIds.has(toolCallId)) continue;
|
|
3965
|
+
var responseName = void 0;
|
|
3966
|
+
var responseId2 = void 0;
|
|
3967
|
+
if (lastSubActionMap.has(toolCallId)) {
|
|
3968
|
+
var gcId = lastSubActionMap.get(toolCallId);
|
|
3969
|
+
var group = geminiCallGroups.get(gcId);
|
|
3970
|
+
responseName = group.name;
|
|
3971
|
+
responseId2 = group.primaryId;
|
|
3972
|
+
} else {
|
|
3973
|
+
var _toolCallIdToName_get;
|
|
3974
|
+
responseName = (_toolCallIdToName_get = toolCallIdToName.get(toolCallId)) !== null && _toolCallIdToName_get !== void 0 ? _toolCallIdToName_get : "";
|
|
3975
|
+
responseId2 = toolCallId;
|
|
3976
|
+
}
|
|
3898
3977
|
var parts2 = [];
|
|
3899
3978
|
var imageContent = extractImageFromToolMessage(msg);
|
|
3900
3979
|
if (imageContent) {
|
|
@@ -3908,8 +3987,8 @@ var serializeMessages2 = function(messages5) {
|
|
|
3908
3987
|
];
|
|
3909
3988
|
parts2.push({
|
|
3910
3989
|
functionResponse: {
|
|
3911
|
-
id:
|
|
3912
|
-
name:
|
|
3990
|
+
id: responseId2,
|
|
3991
|
+
name: responseName,
|
|
3913
3992
|
response: {
|
|
3914
3993
|
output: "Screenshot captured."
|
|
3915
3994
|
},
|
|
@@ -3920,8 +3999,8 @@ var serializeMessages2 = function(messages5) {
|
|
|
3920
3999
|
var output = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
|
|
3921
4000
|
parts2.push({
|
|
3922
4001
|
functionResponse: {
|
|
3923
|
-
id:
|
|
3924
|
-
name:
|
|
4002
|
+
id: responseId2,
|
|
4003
|
+
name: responseName,
|
|
3925
4004
|
response: {
|
|
3926
4005
|
output: output
|
|
3927
4006
|
}
|
|
@@ -4056,7 +4135,14 @@ var serializeTools2 = function(tools) {
|
|
|
4056
4135
|
if (computerUseEnabled) {
|
|
4057
4136
|
geminiTools.push({
|
|
4058
4137
|
computerUse: {
|
|
4059
|
-
environment: "ENVIRONMENT_BROWSER"
|
|
4138
|
+
environment: "ENVIRONMENT_BROWSER",
|
|
4139
|
+
excludedPredefinedFunctions: [
|
|
4140
|
+
"navigate",
|
|
4141
|
+
"go_back",
|
|
4142
|
+
"go_forward",
|
|
4143
|
+
"search",
|
|
4144
|
+
"open_web_browser"
|
|
4145
|
+
]
|
|
4060
4146
|
}
|
|
4061
4147
|
});
|
|
4062
4148
|
}
|
|
@@ -4114,56 +4200,194 @@ var isComputerUseFunction = function(name, tools) {
|
|
|
4114
4200
|
var userFns = getUserDefinedFunctionNames(tools);
|
|
4115
4201
|
return !userFns.has(name);
|
|
4116
4202
|
};
|
|
4117
|
-
var
|
|
4203
|
+
var functionCallToToolCallDeltas = function(fc, startIndex, tools, thoughtSignature) {
|
|
4118
4204
|
var _fc_name, _fc_args, _fc_id;
|
|
4119
4205
|
var rawName = (_fc_name = fc.name) !== null && _fc_name !== void 0 ? _fc_name : "";
|
|
4120
4206
|
var name = stripFunctionPrefix(rawName);
|
|
4121
4207
|
if (isComputerUseFunction(name, tools)) {
|
|
4122
4208
|
var _fc_args1, _fc_id1;
|
|
4123
4209
|
var denormed = denormalizeCoords((_fc_args1 = fc.args) !== null && _fc_args1 !== void 0 ? _fc_args1 : {}, tools);
|
|
4124
|
-
|
|
4210
|
+
if (isGeminiAction(name)) {
|
|
4211
|
+
var normalizedActions = normalizeGeminiAction(name, denormed);
|
|
4212
|
+
if (normalizedActions.length === 1) {
|
|
4213
|
+
var _fc_id2;
|
|
4214
|
+
var payload2 = _object_spread({}, normalizedActions[0]);
|
|
4215
|
+
payload2._geminiAction = name;
|
|
4216
|
+
if (thoughtSignature) payload2._thoughtSignature = thoughtSignature;
|
|
4217
|
+
return [
|
|
4218
|
+
{
|
|
4219
|
+
index: startIndex,
|
|
4220
|
+
id: (_fc_id2 = fc.id) !== null && _fc_id2 !== void 0 ? _fc_id2 : "call_".concat(createId()),
|
|
4221
|
+
type: "function",
|
|
4222
|
+
function: {
|
|
4223
|
+
name: "computer_call",
|
|
4224
|
+
arguments: JSON.stringify(payload2)
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
];
|
|
4228
|
+
}
|
|
4229
|
+
var geminiCallId = "gcall_".concat(createId());
|
|
4230
|
+
return normalizedActions.map(function(normalized2, i) {
|
|
4231
|
+
var _fc_id;
|
|
4232
|
+
var payload2 = _object_spread({}, normalized2);
|
|
4233
|
+
payload2._geminiCallId = geminiCallId;
|
|
4234
|
+
payload2._geminiAction = name;
|
|
4235
|
+
payload2._subActionIndex = i;
|
|
4236
|
+
payload2._subActionTotal = normalizedActions.length;
|
|
4237
|
+
if (i === 0) {
|
|
4238
|
+
payload2._geminiArgs = denormed;
|
|
4239
|
+
if (thoughtSignature) payload2._thoughtSignature = thoughtSignature;
|
|
4240
|
+
}
|
|
4241
|
+
return {
|
|
4242
|
+
index: startIndex + i,
|
|
4243
|
+
id: i === 0 ? (_fc_id = fc.id) !== null && _fc_id !== void 0 ? _fc_id : "call_".concat(createId()) : "call_".concat(createId()),
|
|
4244
|
+
type: "function",
|
|
4245
|
+
function: {
|
|
4246
|
+
name: "computer_call",
|
|
4247
|
+
arguments: JSON.stringify(payload2)
|
|
4248
|
+
}
|
|
4249
|
+
};
|
|
4250
|
+
});
|
|
4251
|
+
}
|
|
4252
|
+
var normalized = normalizeComputerToolCallPayload(_object_spread_props(_object_spread({}, denormed), {
|
|
4125
4253
|
type: name
|
|
4126
4254
|
}));
|
|
4127
4255
|
var payload = _object_spread({}, normalized);
|
|
4128
|
-
if (thoughtSignature)
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
function: {
|
|
4139
|
-
name: "computer_call",
|
|
4140
|
-
arguments: JSON.stringify(payload)
|
|
4256
|
+
if (thoughtSignature) payload._thoughtSignature = thoughtSignature;
|
|
4257
|
+
return [
|
|
4258
|
+
{
|
|
4259
|
+
index: startIndex,
|
|
4260
|
+
id: (_fc_id1 = fc.id) !== null && _fc_id1 !== void 0 ? _fc_id1 : "call_".concat(createId()),
|
|
4261
|
+
type: "function",
|
|
4262
|
+
function: {
|
|
4263
|
+
name: "computer_call",
|
|
4264
|
+
arguments: JSON.stringify(payload)
|
|
4265
|
+
}
|
|
4141
4266
|
}
|
|
4142
|
-
|
|
4267
|
+
];
|
|
4143
4268
|
}
|
|
4144
4269
|
var args = (_fc_args = fc.args) !== null && _fc_args !== void 0 ? _fc_args : {};
|
|
4145
4270
|
if (thoughtSignature) {
|
|
4146
4271
|
args._thoughtSignature = thoughtSignature;
|
|
4147
4272
|
}
|
|
4148
|
-
return
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4273
|
+
return [
|
|
4274
|
+
{
|
|
4275
|
+
index: startIndex,
|
|
4276
|
+
id: (_fc_id = fc.id) !== null && _fc_id !== void 0 ? _fc_id : "call_".concat(createId()),
|
|
4277
|
+
type: "function",
|
|
4278
|
+
function: {
|
|
4279
|
+
name: name,
|
|
4280
|
+
arguments: JSON.stringify(args)
|
|
4281
|
+
}
|
|
4155
4282
|
}
|
|
4156
|
-
|
|
4283
|
+
];
|
|
4284
|
+
};
|
|
4285
|
+
var syntheticToolCallResponse = function(toolCallDelta, stream) {
|
|
4286
|
+
var delta = _object_spread_props(_object_spread({}, toolCallDelta), {
|
|
4287
|
+
index: 0
|
|
4288
|
+
});
|
|
4289
|
+
var encoder = new TextEncoder();
|
|
4290
|
+
if (stream) {
|
|
4291
|
+
var chunks = [
|
|
4292
|
+
"data: ".concat(JSON.stringify({
|
|
4293
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
4294
|
+
object: "chat.completion.chunk",
|
|
4295
|
+
choices: [
|
|
4296
|
+
{
|
|
4297
|
+
index: 0,
|
|
4298
|
+
delta: {
|
|
4299
|
+
content: null,
|
|
4300
|
+
tool_calls: [
|
|
4301
|
+
delta
|
|
4302
|
+
]
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
]
|
|
4306
|
+
}), "\n\n"),
|
|
4307
|
+
"data: ".concat(JSON.stringify({
|
|
4308
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
4309
|
+
object: "chat.completion.chunk",
|
|
4310
|
+
choices: [
|
|
4311
|
+
{
|
|
4312
|
+
index: 0,
|
|
4313
|
+
delta: {},
|
|
4314
|
+
finish_reason: "stop"
|
|
4315
|
+
}
|
|
4316
|
+
]
|
|
4317
|
+
}), "\n\n")
|
|
4318
|
+
];
|
|
4319
|
+
return new Response(new ReadableStream({
|
|
4320
|
+
start: function start(controller) {
|
|
4321
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4322
|
+
try {
|
|
4323
|
+
for(var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4324
|
+
var chunk = _step.value;
|
|
4325
|
+
controller.enqueue(encoder.encode(chunk));
|
|
4326
|
+
}
|
|
4327
|
+
} catch (err) {
|
|
4328
|
+
_didIteratorError = true;
|
|
4329
|
+
_iteratorError = err;
|
|
4330
|
+
} finally{
|
|
4331
|
+
try {
|
|
4332
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4333
|
+
_iterator.return();
|
|
4334
|
+
}
|
|
4335
|
+
} finally{
|
|
4336
|
+
if (_didIteratorError) {
|
|
4337
|
+
throw _iteratorError;
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
controller.close();
|
|
4342
|
+
}
|
|
4343
|
+
}), {
|
|
4344
|
+
headers: {
|
|
4345
|
+
"Content-Type": "text/event-stream"
|
|
4346
|
+
}
|
|
4347
|
+
});
|
|
4348
|
+
}
|
|
4349
|
+
return new Response(JSON.stringify({
|
|
4350
|
+
data: {
|
|
4351
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
4352
|
+
object: "chat.completion",
|
|
4353
|
+
choices: [
|
|
4354
|
+
{
|
|
4355
|
+
index: 0,
|
|
4356
|
+
message: {
|
|
4357
|
+
role: "assistant",
|
|
4358
|
+
content: null,
|
|
4359
|
+
tool_calls: [
|
|
4360
|
+
delta
|
|
4361
|
+
]
|
|
4362
|
+
},
|
|
4363
|
+
finish_reason: "stop"
|
|
4364
|
+
}
|
|
4365
|
+
]
|
|
4366
|
+
}
|
|
4367
|
+
}), {
|
|
4368
|
+
status: 200,
|
|
4369
|
+
headers: {
|
|
4370
|
+
"Content-Type": "application/json"
|
|
4371
|
+
}
|
|
4372
|
+
});
|
|
4157
4373
|
};
|
|
4158
4374
|
var post7 = function(param) {
|
|
4159
4375
|
var google = param.google;
|
|
4376
|
+
var pendingSubActions = [];
|
|
4160
4377
|
return function(_url, options) {
|
|
4161
4378
|
return _async_to_generator(function() {
|
|
4162
|
-
var body, messages5, _serializeMessages2, contents, systemInstruction, geminiTools, params, response, stream, _ref, _data_candidates, _candidate_content, data, candidate, parts, textParts, lastSig, toolCalls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, p, message, result, error;
|
|
4379
|
+
var body, next, messages5, _serializeMessages2, contents, systemInstruction, geminiTools, params, response, stream, _ref, _data_candidates, _candidate_content, data, candidate, parts, textParts, lastSig, toolCalls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, p, deltas, _pendingSubActions, _toolCalls, message, result, error;
|
|
4163
4380
|
return _ts_generator(this, function(_state) {
|
|
4164
4381
|
switch(_state.label){
|
|
4165
4382
|
case 0:
|
|
4166
4383
|
body = JSON.parse(options.body);
|
|
4384
|
+
if (pendingSubActions.length > 0) {
|
|
4385
|
+
next = pendingSubActions.shift();
|
|
4386
|
+
return [
|
|
4387
|
+
2,
|
|
4388
|
+
syntheticToolCallResponse(next, !!body.stream)
|
|
4389
|
+
];
|
|
4390
|
+
}
|
|
4167
4391
|
messages5 = nonEmptyMessages({
|
|
4168
4392
|
messages: body.messages
|
|
4169
4393
|
});
|
|
@@ -4197,7 +4421,7 @@ var post7 = function(param) {
|
|
|
4197
4421
|
stream = new ReadableStream({
|
|
4198
4422
|
start: function start(controller) {
|
|
4199
4423
|
return _async_to_generator(function() {
|
|
4200
|
-
var chunkIndex, lastThoughtSignature, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_candidates, _candidate_content, candidate, _iteratorNormalCompletion, _didIteratorError1, _iteratorError1, _iterator1, _step1, part, messageDelta, toolCallDelta, messageDelta1, messageDelta2, err1;
|
|
4424
|
+
var chunkIndex, lastThoughtSignature, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_candidates, _candidate_content, candidate, _iteratorNormalCompletion, _didIteratorError1, _iteratorError1, _iterator1, _step1, part, messageDelta, deltas, emitDeltas, _pendingSubActions, _iteratorNormalCompletion1, _didIteratorError2, _iteratorError2, _iterator2, _step2, toolCallDelta, messageDelta1, messageDelta2, err1;
|
|
4201
4425
|
return _ts_generator(this, function(_state) {
|
|
4202
4426
|
switch(_state.label){
|
|
4203
4427
|
case 0:
|
|
@@ -4254,24 +4478,50 @@ var post7 = function(param) {
|
|
|
4254
4478
|
controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
|
|
4255
4479
|
}
|
|
4256
4480
|
if (part.functionCall) {
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4481
|
+
deltas = functionCallToToolCallDeltas(part.functionCall, chunkIndex, body.tools, lastThoughtSignature);
|
|
4482
|
+
emitDeltas = deltas.length > 1 ? [
|
|
4483
|
+
deltas[0]
|
|
4484
|
+
] : deltas;
|
|
4485
|
+
if (deltas.length > 1) {
|
|
4486
|
+
;
|
|
4487
|
+
(_pendingSubActions = pendingSubActions).push.apply(_pendingSubActions, _to_consumable_array(deltas.slice(1)));
|
|
4488
|
+
}
|
|
4489
|
+
_iteratorNormalCompletion1 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
4490
|
+
try {
|
|
4491
|
+
for(_iterator2 = emitDeltas[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion1 = true){
|
|
4492
|
+
toolCallDelta = _step2.value;
|
|
4493
|
+
messageDelta1 = {
|
|
4494
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
4495
|
+
object: "chat.completion.chunk",
|
|
4496
|
+
choices: [
|
|
4497
|
+
{
|
|
4498
|
+
index: 0,
|
|
4499
|
+
delta: {
|
|
4500
|
+
content: null,
|
|
4501
|
+
tool_calls: [
|
|
4502
|
+
toolCallDelta
|
|
4503
|
+
]
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
]
|
|
4507
|
+
};
|
|
4508
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
|
|
4509
|
+
}
|
|
4510
|
+
} catch (err) {
|
|
4511
|
+
_didIteratorError2 = true;
|
|
4512
|
+
_iteratorError2 = err;
|
|
4513
|
+
} finally{
|
|
4514
|
+
try {
|
|
4515
|
+
if (!_iteratorNormalCompletion1 && _iterator2.return != null) {
|
|
4516
|
+
_iterator2.return();
|
|
4270
4517
|
}
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4518
|
+
} finally{
|
|
4519
|
+
if (_didIteratorError2) {
|
|
4520
|
+
throw _iteratorError2;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
chunkIndex += emitDeltas.length;
|
|
4275
4525
|
lastThoughtSignature = void 0;
|
|
4276
4526
|
}
|
|
4277
4527
|
}
|
|
@@ -4404,7 +4654,15 @@ var post7 = function(param) {
|
|
|
4404
4654
|
lastSig = p.thoughtSignature;
|
|
4405
4655
|
}
|
|
4406
4656
|
if (p.functionCall) {
|
|
4407
|
-
|
|
4657
|
+
deltas = functionCallToToolCallDeltas(p.functionCall, toolCalls.length, body.tools, lastSig);
|
|
4658
|
+
if (deltas.length > 1) {
|
|
4659
|
+
;
|
|
4660
|
+
toolCalls.push(deltas[0]);
|
|
4661
|
+
(_pendingSubActions = pendingSubActions).push.apply(_pendingSubActions, _to_consumable_array(deltas.slice(1)));
|
|
4662
|
+
} else {
|
|
4663
|
+
;
|
|
4664
|
+
(_toolCalls = toolCalls).push.apply(_toolCalls, _to_consumable_array(deltas));
|
|
4665
|
+
}
|
|
4408
4666
|
lastSig = void 0;
|
|
4409
4667
|
}
|
|
4410
4668
|
}
|
|
@@ -4943,7 +5201,7 @@ var get11 = function(param) {
|
|
|
4943
5201
|
var openRouter = param.openRouter;
|
|
4944
5202
|
return function(_url, _options) {
|
|
4945
5203
|
return _async_to_generator(function() {
|
|
4946
|
-
var data, error;
|
|
5204
|
+
var data, openaiModels, error;
|
|
4947
5205
|
return _ts_generator(this, function(_state) {
|
|
4948
5206
|
switch(_state.label){
|
|
4949
5207
|
case 0:
|
|
@@ -4959,9 +5217,20 @@ var get11 = function(param) {
|
|
|
4959
5217
|
];
|
|
4960
5218
|
case 1:
|
|
4961
5219
|
data = _state.sent();
|
|
5220
|
+
openaiModels = {
|
|
5221
|
+
object: "list",
|
|
5222
|
+
data: data.data.map(function(m) {
|
|
5223
|
+
return {
|
|
5224
|
+
id: m.id,
|
|
5225
|
+
object: "model",
|
|
5226
|
+
created: m.created,
|
|
5227
|
+
owned_by: m.id.split("/")[0] || "openrouter"
|
|
5228
|
+
};
|
|
5229
|
+
})
|
|
5230
|
+
};
|
|
4962
5231
|
return [
|
|
4963
5232
|
2,
|
|
4964
|
-
new Response(JSON.stringify(
|
|
5233
|
+
new Response(JSON.stringify(openaiModels), {
|
|
4965
5234
|
status: 200,
|
|
4966
5235
|
headers: {
|
|
4967
5236
|
"Content-Type": "application/json"
|
|
@@ -5007,6 +5276,12 @@ var MODEL_QUIRKS = {
|
|
|
5007
5276
|
},
|
|
5008
5277
|
"qwen/": {
|
|
5009
5278
|
fuzzyFallback: true
|
|
5279
|
+
},
|
|
5280
|
+
"moonshotai/kimi-k2.5": {
|
|
5281
|
+
relativeCoords: {
|
|
5282
|
+
referenceWidth: 1920,
|
|
5283
|
+
referenceHeight: 1080
|
|
5284
|
+
}
|
|
5010
5285
|
}
|
|
5011
5286
|
};
|
|
5012
5287
|
var getQuirks = function(model) {
|
|
@@ -5235,6 +5510,32 @@ var denormalizeAction = function(action, displayWidth, displayHeight) {
|
|
|
5235
5510
|
}
|
|
5236
5511
|
return result;
|
|
5237
5512
|
};
|
|
5513
|
+
var rescaleCoord = function(value, displayDim, referenceDim) {
|
|
5514
|
+
if (value <= 1) return Math.round(value * displayDim);
|
|
5515
|
+
return Math.round(value / referenceDim * displayDim);
|
|
5516
|
+
};
|
|
5517
|
+
var rescaleRelativeAction = function(action, displayWidth, displayHeight, referenceWidth, referenceHeight) {
|
|
5518
|
+
var result = _object_spread({}, action);
|
|
5519
|
+
if (typeof result.x === "number") {
|
|
5520
|
+
result.x = rescaleCoord(result.x, displayWidth, referenceWidth);
|
|
5521
|
+
}
|
|
5522
|
+
if (typeof result.y === "number") {
|
|
5523
|
+
result.y = rescaleCoord(result.y, displayHeight, referenceHeight);
|
|
5524
|
+
}
|
|
5525
|
+
if (Array.isArray(result.path)) {
|
|
5526
|
+
result.path = result.path.map(function(point) {
|
|
5527
|
+
if (point && (typeof point === "undefined" ? "undefined" : _type_of(point)) === "object") {
|
|
5528
|
+
return _object_spread({}, point, typeof point.x === "number" ? {
|
|
5529
|
+
x: rescaleCoord(point.x, displayWidth, referenceWidth)
|
|
5530
|
+
} : {}, typeof point.y === "number" ? {
|
|
5531
|
+
y: rescaleCoord(point.y, displayHeight, referenceHeight)
|
|
5532
|
+
} : {});
|
|
5533
|
+
}
|
|
5534
|
+
return point;
|
|
5535
|
+
});
|
|
5536
|
+
}
|
|
5537
|
+
return result;
|
|
5538
|
+
};
|
|
5238
5539
|
var COORD_FIELDS = [
|
|
5239
5540
|
"x",
|
|
5240
5541
|
"y",
|
|
@@ -5347,14 +5648,19 @@ var denormalizeComputerCallArguments = function(param) {
|
|
|
5347
5648
|
action: denormalizeAction(normalized.action, displayWidth, displayHeight)
|
|
5348
5649
|
}));
|
|
5349
5650
|
}
|
|
5651
|
+
if (quirks.relativeCoords && normalized.action && _type_of(normalized.action) === "object") {
|
|
5652
|
+
return JSON.stringify(_object_spread_props(_object_spread({}, normalized), {
|
|
5653
|
+
action: rescaleRelativeAction(normalized.action, displayWidth, displayHeight, quirks.relativeCoords.referenceWidth, quirks.relativeCoords.referenceHeight)
|
|
5654
|
+
}));
|
|
5655
|
+
}
|
|
5350
5656
|
return JSON.stringify(normalized);
|
|
5351
5657
|
};
|
|
5352
5658
|
// src/adapters/client/openRouterClientAdapter/completions/computerUseTool.ts
|
|
5353
5659
|
var buildComputerCallFunction = function(model, displayWidth, displayHeight) {
|
|
5354
5660
|
var quirks = getQuirks(model);
|
|
5355
|
-
var coordDesc = quirks.normalizedCoords ? "Coordinates use 0-1000 normalized scale (0,0=top-left, 1000,1000=bottom-right)." : "Coordinates are in pixels (screen is ".concat(displayWidth, "x").concat(displayHeight, ").");
|
|
5356
|
-
var xDesc = quirks.normalizedCoords ? "X coordinate (0-1000 normalized)" : "X coordinate in pixels (0-".concat(displayWidth, ")");
|
|
5357
|
-
var yDesc = quirks.normalizedCoords ? "Y coordinate (0-1000 normalized)" : "Y coordinate in pixels (0-".concat(displayHeight, ")");
|
|
5661
|
+
var coordDesc = quirks.normalizedCoords ? "Coordinates use 0-1000 normalized scale (0,0=top-left, 1000,1000=bottom-right)." : quirks.relativeCoords ? "Coordinates are relative (0.0-1.0) where 0.0,0.0 is top-left and 1.0,1.0 is bottom-right. Screen is ".concat(displayWidth, "x").concat(displayHeight, ".") : "Coordinates are in pixels (screen is ".concat(displayWidth, "x").concat(displayHeight, ").");
|
|
5662
|
+
var xDesc = quirks.normalizedCoords ? "X coordinate (0-1000 normalized)" : quirks.relativeCoords ? "X coordinate (0.0-1.0 relative, where 0.0=left edge, 1.0=right edge)" : "X coordinate in pixels (0-".concat(displayWidth, ")");
|
|
5663
|
+
var yDesc = quirks.normalizedCoords ? "Y coordinate (0-1000 normalized)" : quirks.relativeCoords ? "Y coordinate (0.0-1.0 relative, where 0.0=top edge, 1.0=bottom edge)" : "Y coordinate in pixels (0-".concat(displayHeight, ")");
|
|
5358
5664
|
return {
|
|
5359
5665
|
name: "computer_call",
|
|
5360
5666
|
description: "Perform a computer action. ".concat(coordDesc),
|
|
@@ -5509,11 +5815,230 @@ var convertScreenshotToolMessages = function(messages5) {
|
|
|
5509
5815
|
return msg;
|
|
5510
5816
|
});
|
|
5511
5817
|
};
|
|
5818
|
+
var resolveApiKey = function(apiKey) {
|
|
5819
|
+
return _async_to_generator(function() {
|
|
5820
|
+
var _tmp;
|
|
5821
|
+
return _ts_generator(this, function(_state) {
|
|
5822
|
+
switch(_state.label){
|
|
5823
|
+
case 0:
|
|
5824
|
+
if (!apiKey) return [
|
|
5825
|
+
2,
|
|
5826
|
+
""
|
|
5827
|
+
];
|
|
5828
|
+
if (!(typeof apiKey === "function")) return [
|
|
5829
|
+
3,
|
|
5830
|
+
2
|
|
5831
|
+
];
|
|
5832
|
+
return [
|
|
5833
|
+
4,
|
|
5834
|
+
apiKey()
|
|
5835
|
+
];
|
|
5836
|
+
case 1:
|
|
5837
|
+
_tmp = _state.sent();
|
|
5838
|
+
return [
|
|
5839
|
+
3,
|
|
5840
|
+
3
|
|
5841
|
+
];
|
|
5842
|
+
case 2:
|
|
5843
|
+
_tmp = apiKey;
|
|
5844
|
+
_state.label = 3;
|
|
5845
|
+
case 3:
|
|
5846
|
+
return [
|
|
5847
|
+
2,
|
|
5848
|
+
_tmp
|
|
5849
|
+
];
|
|
5850
|
+
}
|
|
5851
|
+
});
|
|
5852
|
+
})();
|
|
5853
|
+
};
|
|
5854
|
+
function parseSSE(response) {
|
|
5855
|
+
return _wrap_async_generator(function() {
|
|
5856
|
+
var reader, decoder, buffer, _lines_pop, _ref, done, value, lines, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, trimmed, data, unused, err;
|
|
5857
|
+
return _ts_generator(this, function(_state) {
|
|
5858
|
+
switch(_state.label){
|
|
5859
|
+
case 0:
|
|
5860
|
+
reader = response.body.getReader();
|
|
5861
|
+
decoder = new TextDecoder();
|
|
5862
|
+
buffer = "";
|
|
5863
|
+
_state.label = 1;
|
|
5864
|
+
case 1:
|
|
5865
|
+
_state.trys.push([
|
|
5866
|
+
1,
|
|
5867
|
+
,
|
|
5868
|
+
15,
|
|
5869
|
+
16
|
|
5870
|
+
]);
|
|
5871
|
+
_state.label = 2;
|
|
5872
|
+
case 2:
|
|
5873
|
+
if (!true) return [
|
|
5874
|
+
3,
|
|
5875
|
+
14
|
|
5876
|
+
];
|
|
5877
|
+
return [
|
|
5878
|
+
4,
|
|
5879
|
+
_await_async_generator(reader.read())
|
|
5880
|
+
];
|
|
5881
|
+
case 3:
|
|
5882
|
+
_ref = _state.sent(), done = _ref.done, value = _ref.value;
|
|
5883
|
+
if (done) return [
|
|
5884
|
+
3,
|
|
5885
|
+
14
|
|
5886
|
+
];
|
|
5887
|
+
buffer += decoder.decode(value, {
|
|
5888
|
+
stream: true
|
|
5889
|
+
});
|
|
5890
|
+
lines = buffer.split("\n");
|
|
5891
|
+
buffer = (_lines_pop = lines.pop()) !== null && _lines_pop !== void 0 ? _lines_pop : "";
|
|
5892
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
5893
|
+
_state.label = 4;
|
|
5894
|
+
case 4:
|
|
5895
|
+
_state.trys.push([
|
|
5896
|
+
4,
|
|
5897
|
+
11,
|
|
5898
|
+
12,
|
|
5899
|
+
13
|
|
5900
|
+
]);
|
|
5901
|
+
_iterator = lines[Symbol.iterator]();
|
|
5902
|
+
_state.label = 5;
|
|
5903
|
+
case 5:
|
|
5904
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
5905
|
+
3,
|
|
5906
|
+
10
|
|
5907
|
+
];
|
|
5908
|
+
line = _step.value;
|
|
5909
|
+
trimmed = line.trim();
|
|
5910
|
+
if (!trimmed.startsWith("data: ")) return [
|
|
5911
|
+
3,
|
|
5912
|
+
9
|
|
5913
|
+
];
|
|
5914
|
+
data = trimmed.slice(6);
|
|
5915
|
+
if (data === "[DONE]") return [
|
|
5916
|
+
2
|
|
5917
|
+
];
|
|
5918
|
+
_state.label = 6;
|
|
5919
|
+
case 6:
|
|
5920
|
+
_state.trys.push([
|
|
5921
|
+
6,
|
|
5922
|
+
8,
|
|
5923
|
+
,
|
|
5924
|
+
9
|
|
5925
|
+
]);
|
|
5926
|
+
return [
|
|
5927
|
+
4,
|
|
5928
|
+
JSON.parse(data)
|
|
5929
|
+
];
|
|
5930
|
+
case 7:
|
|
5931
|
+
_state.sent();
|
|
5932
|
+
return [
|
|
5933
|
+
3,
|
|
5934
|
+
9
|
|
5935
|
+
];
|
|
5936
|
+
case 8:
|
|
5937
|
+
unused = _state.sent();
|
|
5938
|
+
return [
|
|
5939
|
+
3,
|
|
5940
|
+
9
|
|
5941
|
+
];
|
|
5942
|
+
case 9:
|
|
5943
|
+
_iteratorNormalCompletion = true;
|
|
5944
|
+
return [
|
|
5945
|
+
3,
|
|
5946
|
+
5
|
|
5947
|
+
];
|
|
5948
|
+
case 10:
|
|
5949
|
+
return [
|
|
5950
|
+
3,
|
|
5951
|
+
13
|
|
5952
|
+
];
|
|
5953
|
+
case 11:
|
|
5954
|
+
err = _state.sent();
|
|
5955
|
+
_didIteratorError = true;
|
|
5956
|
+
_iteratorError = err;
|
|
5957
|
+
return [
|
|
5958
|
+
3,
|
|
5959
|
+
13
|
|
5960
|
+
];
|
|
5961
|
+
case 12:
|
|
5962
|
+
try {
|
|
5963
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
5964
|
+
_iterator.return();
|
|
5965
|
+
}
|
|
5966
|
+
} finally{
|
|
5967
|
+
if (_didIteratorError) {
|
|
5968
|
+
throw _iteratorError;
|
|
5969
|
+
}
|
|
5970
|
+
}
|
|
5971
|
+
return [
|
|
5972
|
+
7
|
|
5973
|
+
];
|
|
5974
|
+
case 13:
|
|
5975
|
+
return [
|
|
5976
|
+
3,
|
|
5977
|
+
2
|
|
5978
|
+
];
|
|
5979
|
+
case 14:
|
|
5980
|
+
return [
|
|
5981
|
+
3,
|
|
5982
|
+
16
|
|
5983
|
+
];
|
|
5984
|
+
case 15:
|
|
5985
|
+
reader.releaseLock();
|
|
5986
|
+
return [
|
|
5987
|
+
7
|
|
5988
|
+
];
|
|
5989
|
+
case 16:
|
|
5990
|
+
return [
|
|
5991
|
+
2
|
|
5992
|
+
];
|
|
5993
|
+
}
|
|
5994
|
+
});
|
|
5995
|
+
})();
|
|
5996
|
+
}
|
|
5997
|
+
var rawFetch = function(openRouter, body) {
|
|
5998
|
+
return _async_to_generator(function() {
|
|
5999
|
+
var _ref, _openRouter__baseURL, apiKey, baseURL, headers, request, httpClient;
|
|
6000
|
+
return _ts_generator(this, function(_state) {
|
|
6001
|
+
switch(_state.label){
|
|
6002
|
+
case 0:
|
|
6003
|
+
return [
|
|
6004
|
+
4,
|
|
6005
|
+
resolveApiKey(openRouter._options.apiKey)
|
|
6006
|
+
];
|
|
6007
|
+
case 1:
|
|
6008
|
+
apiKey = _state.sent();
|
|
6009
|
+
baseURL = ((_ref = (_openRouter__baseURL = openRouter._baseURL) === null || _openRouter__baseURL === void 0 ? void 0 : _openRouter__baseURL.toString()) !== null && _ref !== void 0 ? _ref : "https://openrouter.ai/api/v1").replace(/\/+$/, "");
|
|
6010
|
+
headers = {
|
|
6011
|
+
"Content-Type": "application/json",
|
|
6012
|
+
"Authorization": "Bearer ".concat(apiKey)
|
|
6013
|
+
};
|
|
6014
|
+
if (body.stream) {
|
|
6015
|
+
headers["Accept"] = "text/event-stream";
|
|
6016
|
+
}
|
|
6017
|
+
if (openRouter._options.httpReferer) {
|
|
6018
|
+
headers["HTTP-Referer"] = openRouter._options.httpReferer;
|
|
6019
|
+
}
|
|
6020
|
+
if (openRouter._options.xTitle) {
|
|
6021
|
+
headers["X-Title"] = openRouter._options.xTitle;
|
|
6022
|
+
}
|
|
6023
|
+
request = new Request("".concat(baseURL, "/chat/completions"), {
|
|
6024
|
+
method: "POST",
|
|
6025
|
+
headers: headers,
|
|
6026
|
+
body: JSON.stringify(body)
|
|
6027
|
+
});
|
|
6028
|
+
httpClient = openRouter._options.httpClient;
|
|
6029
|
+
return [
|
|
6030
|
+
2,
|
|
6031
|
+
httpClient ? httpClient.request(request) : fetch(request)
|
|
6032
|
+
];
|
|
6033
|
+
}
|
|
6034
|
+
});
|
|
6035
|
+
})();
|
|
6036
|
+
};
|
|
5512
6037
|
var post10 = function(param) {
|
|
5513
6038
|
var openRouter = param.openRouter;
|
|
5514
6039
|
return function(_url, options) {
|
|
5515
6040
|
return _async_to_generator(function() {
|
|
5516
|
-
var body, model, _transformTools, transformedTools, computerUseConfig, resultOptions, response, shouldCleanArtifacts,
|
|
6041
|
+
var body, model, _transformTools, transformedTools, computerUseConfig, resultOptions, response, _response_headers_get, shouldCleanArtifacts, readableStream2, displayWidth, displayHeight, readableStream, response1, _response_headers_get1, data, _data_choices, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, choice, _ref, message, toolCalls, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, fn, _data_choices1, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, choice1, message1, error;
|
|
5517
6042
|
return _ts_generator(this, function(_state) {
|
|
5518
6043
|
switch(_state.label){
|
|
5519
6044
|
case 0:
|
|
@@ -5531,16 +6056,39 @@ var post10 = function(param) {
|
|
|
5531
6056
|
];
|
|
5532
6057
|
return [
|
|
5533
6058
|
4,
|
|
5534
|
-
openRouter
|
|
6059
|
+
rawFetch(openRouter, resultOptions)
|
|
5535
6060
|
];
|
|
5536
6061
|
case 1:
|
|
5537
6062
|
response = _state.sent();
|
|
6063
|
+
if (!response.ok) {
|
|
6064
|
+
;
|
|
6065
|
+
return [
|
|
6066
|
+
2,
|
|
6067
|
+
new Response(response.body, {
|
|
6068
|
+
status: response.status,
|
|
6069
|
+
headers: {
|
|
6070
|
+
"Content-Type": (_response_headers_get = response.headers.get("Content-Type")) !== null && _response_headers_get !== void 0 ? _response_headers_get : "application/json"
|
|
6071
|
+
}
|
|
6072
|
+
})
|
|
6073
|
+
];
|
|
6074
|
+
}
|
|
5538
6075
|
shouldCleanArtifacts = getQuirks(model).cleanArtifacts;
|
|
6076
|
+
if (!computerUseConfig && !shouldCleanArtifacts) {
|
|
6077
|
+
return [
|
|
6078
|
+
2,
|
|
6079
|
+
new Response(response.body, {
|
|
6080
|
+
status: response.status,
|
|
6081
|
+
headers: {
|
|
6082
|
+
"Content-Type": "text/event-stream"
|
|
6083
|
+
}
|
|
6084
|
+
})
|
|
6085
|
+
];
|
|
6086
|
+
}
|
|
5539
6087
|
if (!computerUseConfig) {
|
|
5540
|
-
|
|
6088
|
+
readableStream2 = new ReadableStream({
|
|
5541
6089
|
start: function start(controller) {
|
|
5542
6090
|
return _async_to_generator(function() {
|
|
5543
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk,
|
|
6091
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_choices, delta, d, err;
|
|
5544
6092
|
return _ts_generator(this, function(_state) {
|
|
5545
6093
|
switch(_state.label){
|
|
5546
6094
|
case 0:
|
|
@@ -5553,7 +6101,7 @@ var post10 = function(param) {
|
|
|
5553
6101
|
7,
|
|
5554
6102
|
12
|
|
5555
6103
|
]);
|
|
5556
|
-
_iterator = _async_iterator(response);
|
|
6104
|
+
_iterator = _async_iterator(parseSSE(response));
|
|
5557
6105
|
_state.label = 2;
|
|
5558
6106
|
case 2:
|
|
5559
6107
|
return [
|
|
@@ -5567,12 +6115,10 @@ var post10 = function(param) {
|
|
|
5567
6115
|
];
|
|
5568
6116
|
_value = _step.value;
|
|
5569
6117
|
chunk = _value;
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
delta.content = sanitizeContent(delta.content);
|
|
5575
|
-
}
|
|
6118
|
+
delta = (_chunk_choices = chunk.choices) === null || _chunk_choices === void 0 ? void 0 : _chunk_choices[0];
|
|
6119
|
+
d = delta === null || delta === void 0 ? void 0 : delta.delta;
|
|
6120
|
+
if ((d === null || d === void 0 ? void 0 : d.content) && typeof d.content === "string") {
|
|
6121
|
+
d.content = sanitizeContent(d.content);
|
|
5576
6122
|
}
|
|
5577
6123
|
controller.enqueue("data: ".concat(JSON.stringify(chunk), "\n\n"));
|
|
5578
6124
|
_state.label = 4;
|
|
@@ -5641,7 +6187,7 @@ var post10 = function(param) {
|
|
|
5641
6187
|
});
|
|
5642
6188
|
return [
|
|
5643
6189
|
2,
|
|
5644
|
-
new Response(
|
|
6190
|
+
new Response(readableStream2, {
|
|
5645
6191
|
headers: {
|
|
5646
6192
|
"Content-Type": "text/event-stream"
|
|
5647
6193
|
}
|
|
@@ -5649,10 +6195,10 @@ var post10 = function(param) {
|
|
|
5649
6195
|
];
|
|
5650
6196
|
}
|
|
5651
6197
|
displayWidth = computerUseConfig.displayWidth, displayHeight = computerUseConfig.displayHeight;
|
|
5652
|
-
|
|
6198
|
+
readableStream = new ReadableStream({
|
|
5653
6199
|
start: function start(controller) {
|
|
5654
6200
|
return _async_to_generator(function() {
|
|
5655
|
-
var computerCallIndices, argumentBuffers, emittedIndices, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_choices,
|
|
6201
|
+
var computerCallIndices, argumentBuffers, emittedIndices, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, _chunk_choices, choices, choice, delta, toolCalls, passThrough, _iteratorNormalCompletion, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, fn, _ref, initialArgs, denormalized, _argumentBuffers_get, _ref1, buf, denormalized1, modifiedChunk, err1, _iteratorNormalCompletion1, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, index, buf1, denormalized2, flushChunk;
|
|
5656
6202
|
return _ts_generator(this, function(_state) {
|
|
5657
6203
|
switch(_state.label){
|
|
5658
6204
|
case 0:
|
|
@@ -5668,7 +6214,7 @@ var post10 = function(param) {
|
|
|
5668
6214
|
7,
|
|
5669
6215
|
12
|
|
5670
6216
|
]);
|
|
5671
|
-
_iterator = _async_iterator(response);
|
|
6217
|
+
_iterator = _async_iterator(parseSSE(response));
|
|
5672
6218
|
_state.label = 2;
|
|
5673
6219
|
case 2:
|
|
5674
6220
|
return [
|
|
@@ -5684,7 +6230,9 @@ var post10 = function(param) {
|
|
|
5684
6230
|
chunk = _value;
|
|
5685
6231
|
choices = (_chunk_choices = chunk.choices) !== null && _chunk_choices !== void 0 ? _chunk_choices : [];
|
|
5686
6232
|
choice = choices[0];
|
|
5687
|
-
|
|
6233
|
+
delta = choice === null || choice === void 0 ? void 0 : choice.delta;
|
|
6234
|
+
toolCalls = delta === null || delta === void 0 ? void 0 : delta.tool_calls;
|
|
6235
|
+
if (!toolCalls) {
|
|
5688
6236
|
controller.enqueue("data: ".concat(JSON.stringify(chunk), "\n\n"));
|
|
5689
6237
|
return [
|
|
5690
6238
|
3,
|
|
@@ -5694,14 +6242,13 @@ var post10 = function(param) {
|
|
|
5694
6242
|
passThrough = [];
|
|
5695
6243
|
_iteratorNormalCompletion = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
5696
6244
|
try {
|
|
5697
|
-
for(_iterator1 =
|
|
6245
|
+
for(_iterator1 = toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion = true){
|
|
5698
6246
|
tc = _step1.value;
|
|
5699
|
-
;
|
|
5700
|
-
if ((
|
|
5701
|
-
;
|
|
6247
|
+
fn = tc.function;
|
|
6248
|
+
if ((fn === null || fn === void 0 ? void 0 : fn.name) === "computer_call") {
|
|
5702
6249
|
;
|
|
5703
6250
|
computerCallIndices.add(tc.index);
|
|
5704
|
-
initialArgs = (_ref =
|
|
6251
|
+
initialArgs = (_ref = fn === null || fn === void 0 ? void 0 : fn.arguments) !== null && _ref !== void 0 ? _ref : "";
|
|
5705
6252
|
argumentBuffers.set(tc.index, initialArgs);
|
|
5706
6253
|
if (initialArgs) {
|
|
5707
6254
|
try {
|
|
@@ -5713,7 +6260,7 @@ var post10 = function(param) {
|
|
|
5713
6260
|
model: model
|
|
5714
6261
|
});
|
|
5715
6262
|
passThrough.push(_object_spread_props(_object_spread({}, tc), {
|
|
5716
|
-
function: _object_spread_props(_object_spread({},
|
|
6263
|
+
function: _object_spread_props(_object_spread({}, fn), {
|
|
5717
6264
|
arguments: denormalized
|
|
5718
6265
|
})
|
|
5719
6266
|
}));
|
|
@@ -5722,7 +6269,7 @@ var post10 = function(param) {
|
|
|
5722
6269
|
} catch (unused) {}
|
|
5723
6270
|
}
|
|
5724
6271
|
passThrough.push(_object_spread_props(_object_spread({}, tc), {
|
|
5725
|
-
function: _object_spread_props(_object_spread({},
|
|
6272
|
+
function: _object_spread_props(_object_spread({}, fn), {
|
|
5726
6273
|
arguments: ""
|
|
5727
6274
|
})
|
|
5728
6275
|
}));
|
|
@@ -5730,8 +6277,7 @@ var post10 = function(param) {
|
|
|
5730
6277
|
}
|
|
5731
6278
|
if (computerCallIndices.has(tc.index)) {
|
|
5732
6279
|
;
|
|
5733
|
-
;
|
|
5734
|
-
buf = ((_argumentBuffers_get = argumentBuffers.get(tc.index)) !== null && _argumentBuffers_get !== void 0 ? _argumentBuffers_get : "") + ((_ref1 = (_tc_function2 = tc.function) === null || _tc_function2 === void 0 ? void 0 : _tc_function2.arguments) !== null && _ref1 !== void 0 ? _ref1 : "");
|
|
6280
|
+
buf = ((_argumentBuffers_get = argumentBuffers.get(tc.index)) !== null && _argumentBuffers_get !== void 0 ? _argumentBuffers_get : "") + ((_ref1 = fn === null || fn === void 0 ? void 0 : fn.arguments) !== null && _ref1 !== void 0 ? _ref1 : "");
|
|
5735
6281
|
argumentBuffers.set(tc.index, buf);
|
|
5736
6282
|
if (!emittedIndices.has(tc.index)) {
|
|
5737
6283
|
try {
|
|
@@ -5773,7 +6319,7 @@ var post10 = function(param) {
|
|
|
5773
6319
|
modifiedChunk = _object_spread_props(_object_spread({}, chunk), {
|
|
5774
6320
|
choices: [
|
|
5775
6321
|
_object_spread_props(_object_spread({}, choice), {
|
|
5776
|
-
delta: _object_spread_props(_object_spread({},
|
|
6322
|
+
delta: _object_spread_props(_object_spread({}, delta), {
|
|
5777
6323
|
tool_calls: passThrough
|
|
5778
6324
|
})
|
|
5779
6325
|
})
|
|
@@ -5893,7 +6439,7 @@ var post10 = function(param) {
|
|
|
5893
6439
|
});
|
|
5894
6440
|
return [
|
|
5895
6441
|
2,
|
|
5896
|
-
new Response(
|
|
6442
|
+
new Response(readableStream, {
|
|
5897
6443
|
headers: {
|
|
5898
6444
|
"Content-Type": "text/event-stream"
|
|
5899
6445
|
}
|
|
@@ -5902,15 +6448,33 @@ var post10 = function(param) {
|
|
|
5902
6448
|
case 2:
|
|
5903
6449
|
_state.trys.push([
|
|
5904
6450
|
2,
|
|
5905
|
-
|
|
6451
|
+
5,
|
|
5906
6452
|
,
|
|
5907
|
-
|
|
6453
|
+
6
|
|
5908
6454
|
]);
|
|
5909
6455
|
return [
|
|
5910
6456
|
4,
|
|
5911
|
-
openRouter
|
|
6457
|
+
rawFetch(openRouter, resultOptions)
|
|
5912
6458
|
];
|
|
5913
6459
|
case 3:
|
|
6460
|
+
response1 = _state.sent();
|
|
6461
|
+
if (!response1.ok) {
|
|
6462
|
+
;
|
|
6463
|
+
return [
|
|
6464
|
+
2,
|
|
6465
|
+
new Response(response1.body, {
|
|
6466
|
+
status: response1.status,
|
|
6467
|
+
headers: {
|
|
6468
|
+
"Content-Type": (_response_headers_get1 = response1.headers.get("Content-Type")) !== null && _response_headers_get1 !== void 0 ? _response_headers_get1 : "application/json"
|
|
6469
|
+
}
|
|
6470
|
+
})
|
|
6471
|
+
];
|
|
6472
|
+
}
|
|
6473
|
+
return [
|
|
6474
|
+
4,
|
|
6475
|
+
response1.json()
|
|
6476
|
+
];
|
|
6477
|
+
case 4:
|
|
5914
6478
|
data = _state.sent();
|
|
5915
6479
|
if (computerUseConfig) {
|
|
5916
6480
|
;
|
|
@@ -5919,10 +6483,11 @@ var post10 = function(param) {
|
|
|
5919
6483
|
for(_iterator = ((_data_choices = data.choices) !== null && _data_choices !== void 0 ? _data_choices : [])[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
5920
6484
|
choice = _step.value;
|
|
5921
6485
|
;
|
|
5922
|
-
;
|
|
6486
|
+
message = choice.message;
|
|
6487
|
+
toolCalls = (_ref = message === null || message === void 0 ? void 0 : message.tool_calls) !== null && _ref !== void 0 ? _ref : [];
|
|
5923
6488
|
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
5924
6489
|
try {
|
|
5925
|
-
for(_iterator1 =
|
|
6490
|
+
for(_iterator1 = toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
5926
6491
|
tc = _step1.value;
|
|
5927
6492
|
fn = tc.function;
|
|
5928
6493
|
if ((fn === null || fn === void 0 ? void 0 : fn.name) === "computer_call") {
|
|
@@ -5970,9 +6535,9 @@ var post10 = function(param) {
|
|
|
5970
6535
|
try {
|
|
5971
6536
|
for(_iterator2 = ((_data_choices1 = data.choices) !== null && _data_choices1 !== void 0 ? _data_choices1 : [])[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
5972
6537
|
choice1 = _step2.value;
|
|
5973
|
-
;
|
|
5974
|
-
if ((
|
|
5975
|
-
|
|
6538
|
+
message1 = choice1.message;
|
|
6539
|
+
if ((message1 === null || message1 === void 0 ? void 0 : message1.content) && typeof message1.content === "string") {
|
|
6540
|
+
message1.content = sanitizeContent(message1.content);
|
|
5976
6541
|
}
|
|
5977
6542
|
}
|
|
5978
6543
|
} catch (err) {
|
|
@@ -5999,7 +6564,7 @@ var post10 = function(param) {
|
|
|
5999
6564
|
}
|
|
6000
6565
|
})
|
|
6001
6566
|
];
|
|
6002
|
-
case
|
|
6567
|
+
case 5:
|
|
6003
6568
|
error = _state.sent();
|
|
6004
6569
|
return [
|
|
6005
6570
|
2,
|
|
@@ -6012,7 +6577,7 @@ var post10 = function(param) {
|
|
|
6012
6577
|
}
|
|
6013
6578
|
})
|
|
6014
6579
|
];
|
|
6015
|
-
case
|
|
6580
|
+
case 6:
|
|
6016
6581
|
return [
|
|
6017
6582
|
2
|
|
6018
6583
|
];
|