supercompat 3.16.1 → 3.17.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 +696 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +664 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3327,7 +3327,7 @@ var get8 = function(param) {
|
|
|
3327
3327
|
var google = param.google;
|
|
3328
3328
|
return function(_url, _options) {
|
|
3329
3329
|
return _async_to_generator(function() {
|
|
3330
|
-
var
|
|
3330
|
+
var pager, error;
|
|
3331
3331
|
return _ts_generator(this, function(_state) {
|
|
3332
3332
|
switch(_state.label){
|
|
3333
3333
|
case 0:
|
|
@@ -3342,14 +3342,15 @@ var get8 = function(param) {
|
|
|
3342
3342
|
google.models.list()
|
|
3343
3343
|
];
|
|
3344
3344
|
case 1:
|
|
3345
|
-
|
|
3345
|
+
pager = _state.sent();
|
|
3346
3346
|
return [
|
|
3347
3347
|
2,
|
|
3348
3348
|
new Response(JSON.stringify({
|
|
3349
3349
|
type: "list",
|
|
3350
|
-
data:
|
|
3350
|
+
data: pager.page.map(function(model) {
|
|
3351
|
+
var _model_name;
|
|
3351
3352
|
return {
|
|
3352
|
-
id: model.
|
|
3353
|
+
id: (_model_name = model.name) !== null && _model_name !== void 0 ? _model_name : "",
|
|
3353
3354
|
object: "model"
|
|
3354
3355
|
};
|
|
3355
3356
|
})
|
|
@@ -3393,37 +3394,502 @@ var models9 = function(param) {
|
|
|
3393
3394
|
};
|
|
3394
3395
|
// src/adapters/client/googleClientAdapter/completions/post.ts
|
|
3395
3396
|
import { createId } from "@paralleldrive/cuid2";
|
|
3397
|
+
import { uid as uid2 } from "radash";
|
|
3398
|
+
var stripFunctionPrefix = function(name) {
|
|
3399
|
+
return name.replace(/^default_api:/, "");
|
|
3400
|
+
};
|
|
3401
|
+
var getUserDefinedFunctionNames = function(tools) {
|
|
3402
|
+
var names = /* @__PURE__ */ new Set();
|
|
3403
|
+
if (!tools) return names;
|
|
3404
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3405
|
+
try {
|
|
3406
|
+
for(var _iterator = tools[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3407
|
+
var t = _step.value;
|
|
3408
|
+
var _t_function;
|
|
3409
|
+
if (t.type === "function" && ((_t_function = t.function) === null || _t_function === void 0 ? void 0 : _t_function.name)) {
|
|
3410
|
+
names.add(t.function.name);
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
} catch (err) {
|
|
3414
|
+
_didIteratorError = true;
|
|
3415
|
+
_iteratorError = err;
|
|
3416
|
+
} finally{
|
|
3417
|
+
try {
|
|
3418
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3419
|
+
_iterator.return();
|
|
3420
|
+
}
|
|
3421
|
+
} finally{
|
|
3422
|
+
if (_didIteratorError) {
|
|
3423
|
+
throw _iteratorError;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
return names;
|
|
3428
|
+
};
|
|
3429
|
+
var hasComputerUseTool = function(tools) {
|
|
3430
|
+
return !!(tools === null || tools === void 0 ? void 0 : tools.some(function(t) {
|
|
3431
|
+
return t.type === "computer_use_preview";
|
|
3432
|
+
}));
|
|
3433
|
+
};
|
|
3434
|
+
var serializeMessages2 = function(messages5) {
|
|
3435
|
+
var systemParts = [];
|
|
3436
|
+
var contents = [];
|
|
3437
|
+
var toolCallIdToName = /* @__PURE__ */ new Map();
|
|
3438
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3439
|
+
try {
|
|
3440
|
+
for(var _iterator = messages5[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3441
|
+
var msg = _step.value;
|
|
3442
|
+
if (msg.role === "system" || msg.role === "developer") {
|
|
3443
|
+
systemParts.push(typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content));
|
|
3444
|
+
continue;
|
|
3445
|
+
}
|
|
3446
|
+
if (msg.role === "user") {
|
|
3447
|
+
var parts = [];
|
|
3448
|
+
if (typeof msg.content === "string") {
|
|
3449
|
+
parts.push({
|
|
3450
|
+
text: msg.content
|
|
3451
|
+
});
|
|
3452
|
+
} else if (Array.isArray(msg.content)) {
|
|
3453
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3454
|
+
try {
|
|
3455
|
+
for(var _iterator1 = msg.content[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
3456
|
+
var part = _step1.value;
|
|
3457
|
+
if (part.type === "text") {
|
|
3458
|
+
parts.push({
|
|
3459
|
+
text: part.text
|
|
3460
|
+
});
|
|
3461
|
+
} else if (part.type === "image_url") {
|
|
3462
|
+
var _part_image_url;
|
|
3463
|
+
var url = typeof part.image_url === "string" ? part.image_url : (_part_image_url = part.image_url) === null || _part_image_url === void 0 ? void 0 : _part_image_url.url;
|
|
3464
|
+
if (url === null || url === void 0 ? void 0 : url.startsWith("data:")) {
|
|
3465
|
+
var match = url.match(/^data:([^;]+);base64,(.+)$/);
|
|
3466
|
+
if (match) {
|
|
3467
|
+
parts.push({
|
|
3468
|
+
inlineData: {
|
|
3469
|
+
mimeType: match[1],
|
|
3470
|
+
data: match[2]
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
} else if (url) {
|
|
3475
|
+
parts.push({
|
|
3476
|
+
fileData: {
|
|
3477
|
+
fileUri: url,
|
|
3478
|
+
mimeType: "image/png"
|
|
3479
|
+
}
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
} catch (err) {
|
|
3485
|
+
_didIteratorError1 = true;
|
|
3486
|
+
_iteratorError1 = err;
|
|
3487
|
+
} finally{
|
|
3488
|
+
try {
|
|
3489
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
3490
|
+
_iterator1.return();
|
|
3491
|
+
}
|
|
3492
|
+
} finally{
|
|
3493
|
+
if (_didIteratorError1) {
|
|
3494
|
+
throw _iteratorError1;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
if (parts.length > 0) {
|
|
3500
|
+
contents.push({
|
|
3501
|
+
role: "user",
|
|
3502
|
+
parts: parts
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
continue;
|
|
3506
|
+
}
|
|
3507
|
+
if (msg.role === "assistant") {
|
|
3508
|
+
var parts1 = [];
|
|
3509
|
+
if (msg.content) {
|
|
3510
|
+
var text = typeof msg.content === "string" ? msg.content : "";
|
|
3511
|
+
if (text) {
|
|
3512
|
+
parts1.push({
|
|
3513
|
+
text: text
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
if (msg.tool_calls) {
|
|
3518
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
3519
|
+
try {
|
|
3520
|
+
for(var _iterator2 = msg.tool_calls[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
3521
|
+
var tc = _step2.value;
|
|
3522
|
+
var _ref, _tc_id;
|
|
3523
|
+
var _tc_function;
|
|
3524
|
+
var name = (_ref = (_tc_function = tc.function) === null || _tc_function === void 0 ? void 0 : _tc_function.name) !== null && _ref !== void 0 ? _ref : "";
|
|
3525
|
+
var id = (_tc_id = tc.id) !== null && _tc_id !== void 0 ? _tc_id : "call_".concat(createId());
|
|
3526
|
+
var args = {};
|
|
3527
|
+
try {
|
|
3528
|
+
var _ref1;
|
|
3529
|
+
var _tc_function1;
|
|
3530
|
+
args = JSON.parse((_ref1 = (_tc_function1 = tc.function) === null || _tc_function1 === void 0 ? void 0 : _tc_function1.arguments) !== null && _ref1 !== void 0 ? _ref1 : "{}");
|
|
3531
|
+
} catch (unused) {}
|
|
3532
|
+
var geminiName = name;
|
|
3533
|
+
if (name === "computer_call" && args.action && _type_of(args.action) === "object") {
|
|
3534
|
+
var _args_action_type;
|
|
3535
|
+
geminiName = (_args_action_type = args.action.type) !== null && _args_action_type !== void 0 ? _args_action_type : name;
|
|
3536
|
+
}
|
|
3537
|
+
var thoughtSignature = args._thoughtSignature;
|
|
3538
|
+
var cleanArgs = _object_spread({}, args);
|
|
3539
|
+
delete cleanArgs._thoughtSignature;
|
|
3540
|
+
var geminiArgs = void 0;
|
|
3541
|
+
if (name === "computer_call" && cleanArgs.action && _type_of(cleanArgs.action) === "object") {
|
|
3542
|
+
var action = cleanArgs.action;
|
|
3543
|
+
var _type = action.type, rest = _object_without_properties(action, [
|
|
3544
|
+
"type"
|
|
3545
|
+
]);
|
|
3546
|
+
geminiArgs = rest;
|
|
3547
|
+
} else {
|
|
3548
|
+
geminiArgs = cleanArgs;
|
|
3549
|
+
}
|
|
3550
|
+
toolCallIdToName.set(id, geminiName);
|
|
3551
|
+
var fcPart = {
|
|
3552
|
+
functionCall: {
|
|
3553
|
+
name: geminiName,
|
|
3554
|
+
args: geminiArgs,
|
|
3555
|
+
id: id
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
if (thoughtSignature) {
|
|
3559
|
+
fcPart.thoughtSignature = thoughtSignature;
|
|
3560
|
+
}
|
|
3561
|
+
parts1.push(fcPart);
|
|
3562
|
+
}
|
|
3563
|
+
} catch (err) {
|
|
3564
|
+
_didIteratorError2 = true;
|
|
3565
|
+
_iteratorError2 = err;
|
|
3566
|
+
} finally{
|
|
3567
|
+
try {
|
|
3568
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
3569
|
+
_iterator2.return();
|
|
3570
|
+
}
|
|
3571
|
+
} finally{
|
|
3572
|
+
if (_didIteratorError2) {
|
|
3573
|
+
throw _iteratorError2;
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
if (parts1.length > 0) {
|
|
3579
|
+
contents.push({
|
|
3580
|
+
role: "model",
|
|
3581
|
+
parts: parts1
|
|
3582
|
+
});
|
|
3583
|
+
}
|
|
3584
|
+
continue;
|
|
3585
|
+
}
|
|
3586
|
+
if (msg.role === "tool") {
|
|
3587
|
+
var _msg_tool_call_id, _toolCallIdToName_get;
|
|
3588
|
+
var _lastContent_parts;
|
|
3589
|
+
var toolCallId = (_msg_tool_call_id = msg.tool_call_id) !== null && _msg_tool_call_id !== void 0 ? _msg_tool_call_id : "";
|
|
3590
|
+
var name1 = (_toolCallIdToName_get = toolCallIdToName.get(toolCallId)) !== null && _toolCallIdToName_get !== void 0 ? _toolCallIdToName_get : "";
|
|
3591
|
+
var parts2 = [];
|
|
3592
|
+
var imageContent = extractImageFromToolMessage(msg);
|
|
3593
|
+
if (imageContent) {
|
|
3594
|
+
var responseParts = [
|
|
3595
|
+
{
|
|
3596
|
+
inlineData: {
|
|
3597
|
+
mimeType: imageContent.mimeType,
|
|
3598
|
+
data: imageContent.data
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
];
|
|
3602
|
+
parts2.push({
|
|
3603
|
+
functionResponse: {
|
|
3604
|
+
id: toolCallId,
|
|
3605
|
+
name: name1,
|
|
3606
|
+
response: {
|
|
3607
|
+
output: "Screenshot captured."
|
|
3608
|
+
},
|
|
3609
|
+
parts: responseParts
|
|
3610
|
+
}
|
|
3611
|
+
});
|
|
3612
|
+
} else {
|
|
3613
|
+
var output = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
|
|
3614
|
+
parts2.push({
|
|
3615
|
+
functionResponse: {
|
|
3616
|
+
id: toolCallId,
|
|
3617
|
+
name: name1,
|
|
3618
|
+
response: {
|
|
3619
|
+
output: output
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
var lastContent = contents[contents.length - 1];
|
|
3625
|
+
if (lastContent && lastContent.role === "user" && ((_lastContent_parts = lastContent.parts) === null || _lastContent_parts === void 0 ? void 0 : _lastContent_parts.some(function(p) {
|
|
3626
|
+
return p.functionResponse;
|
|
3627
|
+
}))) {
|
|
3628
|
+
var _lastContent_parts1;
|
|
3629
|
+
(_lastContent_parts1 = lastContent.parts).push.apply(_lastContent_parts1, _to_consumable_array(parts2));
|
|
3630
|
+
} else {
|
|
3631
|
+
contents.push({
|
|
3632
|
+
role: "user",
|
|
3633
|
+
parts: parts2
|
|
3634
|
+
});
|
|
3635
|
+
}
|
|
3636
|
+
continue;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
} catch (err) {
|
|
3640
|
+
_didIteratorError = true;
|
|
3641
|
+
_iteratorError = err;
|
|
3642
|
+
} finally{
|
|
3643
|
+
try {
|
|
3644
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3645
|
+
_iterator.return();
|
|
3646
|
+
}
|
|
3647
|
+
} finally{
|
|
3648
|
+
if (_didIteratorError) {
|
|
3649
|
+
throw _iteratorError;
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
return _object_spread({
|
|
3654
|
+
contents: contents
|
|
3655
|
+
}, systemParts.length > 0 ? {
|
|
3656
|
+
systemInstruction: systemParts.join("\n")
|
|
3657
|
+
} : {});
|
|
3658
|
+
};
|
|
3659
|
+
var extractImageFromToolMessage = function(msg) {
|
|
3660
|
+
var content = msg.content;
|
|
3661
|
+
if (Array.isArray(content)) {
|
|
3662
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3663
|
+
try {
|
|
3664
|
+
for(var _iterator = content[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3665
|
+
var part = _step.value;
|
|
3666
|
+
if (part.type === "image_url") {
|
|
3667
|
+
var _part_image_url;
|
|
3668
|
+
var url = typeof part.image_url === "string" ? part.image_url : (_part_image_url = part.image_url) === null || _part_image_url === void 0 ? void 0 : _part_image_url.url;
|
|
3669
|
+
return parseDataUri(url);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
} catch (err) {
|
|
3673
|
+
_didIteratorError = true;
|
|
3674
|
+
_iteratorError = err;
|
|
3675
|
+
} finally{
|
|
3676
|
+
try {
|
|
3677
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3678
|
+
_iterator.return();
|
|
3679
|
+
}
|
|
3680
|
+
} finally{
|
|
3681
|
+
if (_didIteratorError) {
|
|
3682
|
+
throw _iteratorError;
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
return null;
|
|
3687
|
+
}
|
|
3688
|
+
if (typeof content === "string") {
|
|
3689
|
+
try {
|
|
3690
|
+
var parsed = JSON.parse(content);
|
|
3691
|
+
if (parsed.type === "computer_screenshot" && parsed.image_url) {
|
|
3692
|
+
return parseDataUri(parsed.image_url);
|
|
3693
|
+
}
|
|
3694
|
+
} catch (unused) {}
|
|
3695
|
+
}
|
|
3696
|
+
return null;
|
|
3697
|
+
};
|
|
3698
|
+
var parseDataUri = function(url) {
|
|
3699
|
+
if (!url) return null;
|
|
3700
|
+
var match = url.match(/^data:([^;]+);base64,(.+)$/);
|
|
3701
|
+
if (!match) return null;
|
|
3702
|
+
return {
|
|
3703
|
+
mimeType: match[1],
|
|
3704
|
+
data: match[2]
|
|
3705
|
+
};
|
|
3706
|
+
};
|
|
3707
|
+
var serializeTools2 = function(tools) {
|
|
3708
|
+
if (!tools || tools.length === 0) return [];
|
|
3709
|
+
var geminiTools = [];
|
|
3710
|
+
var functionDeclarations = [];
|
|
3711
|
+
var computerUseEnabled = false;
|
|
3712
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3713
|
+
try {
|
|
3714
|
+
for(var _iterator = tools[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3715
|
+
var tool = _step.value;
|
|
3716
|
+
if (tool.type === "computer_use_preview") {
|
|
3717
|
+
computerUseEnabled = true;
|
|
3718
|
+
continue;
|
|
3719
|
+
}
|
|
3720
|
+
if (tool.type === "function") {
|
|
3721
|
+
var fn = tool.function;
|
|
3722
|
+
if (!fn) continue;
|
|
3723
|
+
var decl = {
|
|
3724
|
+
name: fn.name
|
|
3725
|
+
};
|
|
3726
|
+
if (fn.description) {
|
|
3727
|
+
decl.description = fn.description;
|
|
3728
|
+
}
|
|
3729
|
+
if (fn.parameters) {
|
|
3730
|
+
decl.parameters = fn.parameters;
|
|
3731
|
+
}
|
|
3732
|
+
functionDeclarations.push(decl);
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
} catch (err) {
|
|
3736
|
+
_didIteratorError = true;
|
|
3737
|
+
_iteratorError = err;
|
|
3738
|
+
} finally{
|
|
3739
|
+
try {
|
|
3740
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3741
|
+
_iterator.return();
|
|
3742
|
+
}
|
|
3743
|
+
} finally{
|
|
3744
|
+
if (_didIteratorError) {
|
|
3745
|
+
throw _iteratorError;
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
if (computerUseEnabled) {
|
|
3750
|
+
geminiTools.push({
|
|
3751
|
+
computerUse: {
|
|
3752
|
+
environment: "ENVIRONMENT_BROWSER"
|
|
3753
|
+
}
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
if (functionDeclarations.length > 0) {
|
|
3757
|
+
geminiTools.push({
|
|
3758
|
+
functionDeclarations: functionDeclarations
|
|
3759
|
+
});
|
|
3760
|
+
}
|
|
3761
|
+
return geminiTools;
|
|
3762
|
+
};
|
|
3763
|
+
var denormalizeCoords = function(args, tools) {
|
|
3764
|
+
var _ref, _ref1;
|
|
3765
|
+
var _computerTool_computer_use_preview, _computerTool_computer_use_preview1;
|
|
3766
|
+
var computerTool = tools === null || tools === void 0 ? void 0 : tools.find(function(t) {
|
|
3767
|
+
return t.type === "computer_use_preview";
|
|
3768
|
+
});
|
|
3769
|
+
if (!computerTool) return args;
|
|
3770
|
+
var displayWidth = (_ref = (_computerTool_computer_use_preview = computerTool.computer_use_preview) === null || _computerTool_computer_use_preview === void 0 ? void 0 : _computerTool_computer_use_preview.display_width) !== null && _ref !== void 0 ? _ref : 1280;
|
|
3771
|
+
var displayHeight = (_ref1 = (_computerTool_computer_use_preview1 = computerTool.computer_use_preview) === null || _computerTool_computer_use_preview1 === void 0 ? void 0 : _computerTool_computer_use_preview1.display_height) !== null && _ref1 !== void 0 ? _ref1 : 720;
|
|
3772
|
+
var result = _object_spread({}, args);
|
|
3773
|
+
var denormX = function(v) {
|
|
3774
|
+
return Math.round(v / 1e3 * displayWidth);
|
|
3775
|
+
};
|
|
3776
|
+
var denormY = function(v) {
|
|
3777
|
+
return Math.round(v / 1e3 * displayHeight);
|
|
3778
|
+
};
|
|
3779
|
+
if (typeof result.x === "number") result.x = denormX(result.x);
|
|
3780
|
+
if (typeof result.y === "number") result.y = denormY(result.y);
|
|
3781
|
+
if (typeof result.coordinate_x === "number") result.coordinate_x = denormX(result.coordinate_x);
|
|
3782
|
+
if (typeof result.coordinate_y === "number") result.coordinate_y = denormY(result.coordinate_y);
|
|
3783
|
+
if (Array.isArray(result.coordinate) && result.coordinate.length === 2) {
|
|
3784
|
+
result.coordinate = [
|
|
3785
|
+
denormX(result.coordinate[0]),
|
|
3786
|
+
denormY(result.coordinate[1])
|
|
3787
|
+
];
|
|
3788
|
+
}
|
|
3789
|
+
if (Array.isArray(result.start_coordinate) && result.start_coordinate.length === 2) {
|
|
3790
|
+
result.start_coordinate = [
|
|
3791
|
+
denormX(result.start_coordinate[0]),
|
|
3792
|
+
denormY(result.start_coordinate[1])
|
|
3793
|
+
];
|
|
3794
|
+
}
|
|
3795
|
+
if (Array.isArray(result.end_coordinate) && result.end_coordinate.length === 2) {
|
|
3796
|
+
result.end_coordinate = [
|
|
3797
|
+
denormX(result.end_coordinate[0]),
|
|
3798
|
+
denormY(result.end_coordinate[1])
|
|
3799
|
+
];
|
|
3800
|
+
}
|
|
3801
|
+
return result;
|
|
3802
|
+
};
|
|
3803
|
+
var isComputerUseFunction = function(name, tools) {
|
|
3804
|
+
if (!hasComputerUseTool(tools)) return false;
|
|
3805
|
+
var userFns = getUserDefinedFunctionNames(tools);
|
|
3806
|
+
return !userFns.has(name);
|
|
3807
|
+
};
|
|
3808
|
+
var functionCallToToolCallDelta = function(fc, index, tools, thoughtSignature) {
|
|
3809
|
+
var _fc_name, _fc_args, _fc_id;
|
|
3810
|
+
var rawName = (_fc_name = fc.name) !== null && _fc_name !== void 0 ? _fc_name : "";
|
|
3811
|
+
var name = stripFunctionPrefix(rawName);
|
|
3812
|
+
if (isComputerUseFunction(name, tools)) {
|
|
3813
|
+
var _fc_args1, _fc_id1;
|
|
3814
|
+
var denormed = denormalizeCoords((_fc_args1 = fc.args) !== null && _fc_args1 !== void 0 ? _fc_args1 : {}, tools);
|
|
3815
|
+
var normalized = normalizeComputerToolCallPayload(_object_spread_props(_object_spread({}, denormed), {
|
|
3816
|
+
type: name
|
|
3817
|
+
}));
|
|
3818
|
+
var payload = _object_spread({}, normalized);
|
|
3819
|
+
if (thoughtSignature) {
|
|
3820
|
+
payload._thoughtSignature = thoughtSignature;
|
|
3821
|
+
}
|
|
3822
|
+
return {
|
|
3823
|
+
index: index,
|
|
3824
|
+
id: (_fc_id1 = fc.id) !== null && _fc_id1 !== void 0 ? _fc_id1 : "call_".concat(createId()),
|
|
3825
|
+
type: "function",
|
|
3826
|
+
function: {
|
|
3827
|
+
name: "computer_call",
|
|
3828
|
+
arguments: JSON.stringify(payload)
|
|
3829
|
+
}
|
|
3830
|
+
};
|
|
3831
|
+
}
|
|
3832
|
+
var args = (_fc_args = fc.args) !== null && _fc_args !== void 0 ? _fc_args : {};
|
|
3833
|
+
if (thoughtSignature) {
|
|
3834
|
+
args._thoughtSignature = thoughtSignature;
|
|
3835
|
+
}
|
|
3836
|
+
return {
|
|
3837
|
+
index: index,
|
|
3838
|
+
id: (_fc_id = fc.id) !== null && _fc_id !== void 0 ? _fc_id : "call_".concat(createId()),
|
|
3839
|
+
type: "function",
|
|
3840
|
+
function: {
|
|
3841
|
+
name: name,
|
|
3842
|
+
arguments: JSON.stringify(args)
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
};
|
|
3396
3846
|
var post7 = function(param) {
|
|
3397
3847
|
var google = param.google;
|
|
3398
3848
|
return function(_url, options) {
|
|
3399
3849
|
return _async_to_generator(function() {
|
|
3400
|
-
var body,
|
|
3850
|
+
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;
|
|
3401
3851
|
return _ts_generator(this, function(_state) {
|
|
3402
3852
|
switch(_state.label){
|
|
3403
3853
|
case 0:
|
|
3404
3854
|
body = JSON.parse(options.body);
|
|
3405
|
-
|
|
3406
|
-
messages:
|
|
3407
|
-
messages: body.messages
|
|
3408
|
-
})
|
|
3855
|
+
messages5 = nonEmptyMessages({
|
|
3856
|
+
messages: body.messages
|
|
3409
3857
|
});
|
|
3858
|
+
_serializeMessages2 = serializeMessages2(messages5), contents = _serializeMessages2.contents, systemInstruction = _serializeMessages2.systemInstruction;
|
|
3859
|
+
geminiTools = serializeTools2(body.tools);
|
|
3860
|
+
params = {
|
|
3861
|
+
model: body.model,
|
|
3862
|
+
contents: contents,
|
|
3863
|
+
config: _object_spread({}, systemInstruction ? {
|
|
3864
|
+
systemInstruction: systemInstruction
|
|
3865
|
+
} : {}, geminiTools.length > 0 ? {
|
|
3866
|
+
tools: geminiTools
|
|
3867
|
+
} : {}, typeof body.temperature === "number" ? {
|
|
3868
|
+
temperature: body.temperature
|
|
3869
|
+
} : {}, typeof body.top_p === "number" ? {
|
|
3870
|
+
topP: body.top_p
|
|
3871
|
+
} : {}, typeof body.max_tokens === "number" ? {
|
|
3872
|
+
maxOutputTokens: body.max_tokens
|
|
3873
|
+
} : {})
|
|
3874
|
+
};
|
|
3410
3875
|
if (!body.stream) return [
|
|
3411
3876
|
3,
|
|
3412
3877
|
2
|
|
3413
3878
|
];
|
|
3414
3879
|
return [
|
|
3415
3880
|
4,
|
|
3416
|
-
google.
|
|
3881
|
+
google.models.generateContentStream(params)
|
|
3417
3882
|
];
|
|
3418
3883
|
case 1:
|
|
3419
3884
|
response = _state.sent();
|
|
3420
3885
|
stream = new ReadableStream({
|
|
3421
3886
|
start: function start(controller) {
|
|
3422
3887
|
return _async_to_generator(function() {
|
|
3423
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk,
|
|
3888
|
+
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;
|
|
3424
3889
|
return _ts_generator(this, function(_state) {
|
|
3425
3890
|
switch(_state.label){
|
|
3426
3891
|
case 0:
|
|
3892
|
+
chunkIndex = 0;
|
|
3427
3893
|
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
3428
3894
|
_state.label = 1;
|
|
3429
3895
|
case 1:
|
|
@@ -3447,34 +3913,84 @@ var post7 = function(param) {
|
|
|
3447
3913
|
];
|
|
3448
3914
|
_value = _step.value;
|
|
3449
3915
|
chunk = _value;
|
|
3450
|
-
|
|
3451
|
-
if (
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3916
|
+
candidate = (_chunk_candidates = chunk.candidates) === null || _chunk_candidates === void 0 ? void 0 : _chunk_candidates[0];
|
|
3917
|
+
if (!(candidate === null || candidate === void 0 ? void 0 : (_candidate_content = candidate.content) === null || _candidate_content === void 0 ? void 0 : _candidate_content.parts)) return [
|
|
3918
|
+
3,
|
|
3919
|
+
4
|
|
3920
|
+
];
|
|
3921
|
+
_iteratorNormalCompletion = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
3922
|
+
try {
|
|
3923
|
+
for(_iterator1 = candidate.content.parts[Symbol.iterator](); !(_iteratorNormalCompletion = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion = true){
|
|
3924
|
+
part = _step1.value;
|
|
3925
|
+
if (part.thoughtSignature) {
|
|
3926
|
+
lastThoughtSignature = part.thoughtSignature;
|
|
3927
|
+
}
|
|
3928
|
+
if (part.thought && !part.functionCall) continue;
|
|
3929
|
+
if (part.text !== void 0 && part.text !== null && !part.thought) {
|
|
3930
|
+
messageDelta = {
|
|
3931
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
3932
|
+
object: "chat.completion.chunk",
|
|
3933
|
+
choices: [
|
|
3934
|
+
{
|
|
3935
|
+
index: 0,
|
|
3936
|
+
delta: {
|
|
3937
|
+
content: part.text
|
|
3462
3938
|
}
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
} else {
|
|
3468
|
-
return choice;
|
|
3939
|
+
}
|
|
3940
|
+
]
|
|
3941
|
+
};
|
|
3942
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta), "\n\n"));
|
|
3469
3943
|
}
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3944
|
+
if (part.functionCall) {
|
|
3945
|
+
toolCallDelta = functionCallToToolCallDelta(part.functionCall, chunkIndex, body.tools, lastThoughtSignature);
|
|
3946
|
+
messageDelta1 = {
|
|
3947
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
3948
|
+
object: "chat.completion.chunk",
|
|
3949
|
+
choices: [
|
|
3950
|
+
{
|
|
3951
|
+
index: 0,
|
|
3952
|
+
delta: {
|
|
3953
|
+
content: null,
|
|
3954
|
+
tool_calls: [
|
|
3955
|
+
toolCallDelta
|
|
3956
|
+
]
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
]
|
|
3960
|
+
};
|
|
3961
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta1), "\n\n"));
|
|
3962
|
+
chunkIndex++;
|
|
3963
|
+
lastThoughtSignature = void 0;
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
} catch (err) {
|
|
3967
|
+
_didIteratorError1 = true;
|
|
3968
|
+
_iteratorError1 = err;
|
|
3969
|
+
} finally{
|
|
3970
|
+
try {
|
|
3971
|
+
if (!_iteratorNormalCompletion && _iterator1.return != null) {
|
|
3972
|
+
_iterator1.return();
|
|
3973
|
+
}
|
|
3974
|
+
} finally{
|
|
3975
|
+
if (_didIteratorError1) {
|
|
3976
|
+
throw _iteratorError1;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
if (candidate.finishReason) {
|
|
3981
|
+
messageDelta2 = {
|
|
3982
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
3983
|
+
object: "chat.completion.chunk",
|
|
3984
|
+
choices: [
|
|
3985
|
+
{
|
|
3986
|
+
index: 0,
|
|
3987
|
+
delta: {},
|
|
3988
|
+
finish_reason: "stop"
|
|
3989
|
+
}
|
|
3990
|
+
]
|
|
3991
|
+
};
|
|
3992
|
+
controller.enqueue("data: ".concat(JSON.stringify(messageDelta2), "\n\n"));
|
|
3476
3993
|
}
|
|
3477
|
-
controller.enqueue("data: ".concat(JSON.stringify(resultChunk), "\n\n"));
|
|
3478
3994
|
_state.label = 4;
|
|
3479
3995
|
case 4:
|
|
3480
3996
|
_iteratorAbruptCompletion = false;
|
|
@@ -3488,9 +4004,9 @@ var post7 = function(param) {
|
|
|
3488
4004
|
12
|
|
3489
4005
|
];
|
|
3490
4006
|
case 6:
|
|
3491
|
-
|
|
4007
|
+
err1 = _state.sent();
|
|
3492
4008
|
_didIteratorError = true;
|
|
3493
|
-
_iteratorError =
|
|
4009
|
+
_iteratorError = err1;
|
|
3494
4010
|
return [
|
|
3495
4011
|
3,
|
|
3496
4012
|
12
|
|
@@ -3556,14 +4072,66 @@ var post7 = function(param) {
|
|
|
3556
4072
|
]);
|
|
3557
4073
|
return [
|
|
3558
4074
|
4,
|
|
3559
|
-
google.
|
|
4075
|
+
google.models.generateContent(params)
|
|
3560
4076
|
];
|
|
3561
4077
|
case 3:
|
|
3562
4078
|
data = _state.sent();
|
|
4079
|
+
candidate = (_data_candidates = data.candidates) === null || _data_candidates === void 0 ? void 0 : _data_candidates[0];
|
|
4080
|
+
parts = (_ref = candidate === null || candidate === void 0 ? void 0 : (_candidate_content = candidate.content) === null || _candidate_content === void 0 ? void 0 : _candidate_content.parts) !== null && _ref !== void 0 ? _ref : [];
|
|
4081
|
+
textParts = parts.filter(function(p) {
|
|
4082
|
+
return p.text && !p.thought;
|
|
4083
|
+
}).map(function(p) {
|
|
4084
|
+
return p.text;
|
|
4085
|
+
}).join("");
|
|
4086
|
+
toolCalls = [];
|
|
4087
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4088
|
+
try {
|
|
4089
|
+
for(_iterator = parts[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4090
|
+
p = _step.value;
|
|
4091
|
+
if (p.thoughtSignature) {
|
|
4092
|
+
lastSig = p.thoughtSignature;
|
|
4093
|
+
}
|
|
4094
|
+
if (p.functionCall) {
|
|
4095
|
+
toolCalls.push(functionCallToToolCallDelta(p.functionCall, toolCalls.length, body.tools, lastSig));
|
|
4096
|
+
lastSig = void 0;
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
} catch (err) {
|
|
4100
|
+
_didIteratorError = true;
|
|
4101
|
+
_iteratorError = err;
|
|
4102
|
+
} finally{
|
|
4103
|
+
try {
|
|
4104
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4105
|
+
_iterator.return();
|
|
4106
|
+
}
|
|
4107
|
+
} finally{
|
|
4108
|
+
if (_didIteratorError) {
|
|
4109
|
+
throw _iteratorError;
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
message = {
|
|
4114
|
+
role: "assistant",
|
|
4115
|
+
content: textParts || null
|
|
4116
|
+
};
|
|
4117
|
+
if (toolCalls.length > 0) {
|
|
4118
|
+
message.tool_calls = toolCalls;
|
|
4119
|
+
}
|
|
4120
|
+
result = {
|
|
4121
|
+
id: "chatcmpl-".concat(uid2(29)),
|
|
4122
|
+
object: "chat.completion",
|
|
4123
|
+
choices: [
|
|
4124
|
+
{
|
|
4125
|
+
index: 0,
|
|
4126
|
+
message: message,
|
|
4127
|
+
finish_reason: "stop"
|
|
4128
|
+
}
|
|
4129
|
+
]
|
|
4130
|
+
};
|
|
3563
4131
|
return [
|
|
3564
4132
|
2,
|
|
3565
4133
|
new Response(JSON.stringify({
|
|
3566
|
-
data:
|
|
4134
|
+
data: result
|
|
3567
4135
|
}), {
|
|
3568
4136
|
status: 200,
|
|
3569
4137
|
headers: {
|
|
@@ -4127,9 +4695,6 @@ var MODEL_QUIRKS = {
|
|
|
4127
4695
|
},
|
|
4128
4696
|
"qwen/": {
|
|
4129
4697
|
fuzzyFallback: true
|
|
4130
|
-
},
|
|
4131
|
-
"google/": {
|
|
4132
|
-
normalizedCoords: true
|
|
4133
4698
|
}
|
|
4134
4699
|
};
|
|
4135
4700
|
var getQuirks = function(model) {
|
|
@@ -4803,11 +5368,6 @@ var post10 = function(param) {
|
|
|
4803
5368
|
computerCallIndices.add(tc.index);
|
|
4804
5369
|
initialArgs = (_ref = (_tc_function1 = tc.function) === null || _tc_function1 === void 0 ? void 0 : _tc_function1.arguments) !== null && _ref !== void 0 ? _ref : "";
|
|
4805
5370
|
argumentBuffers.set(tc.index, initialArgs);
|
|
4806
|
-
passThrough.push(_object_spread_props(_object_spread({}, tc), {
|
|
4807
|
-
function: _object_spread_props(_object_spread({}, tc.function), {
|
|
4808
|
-
arguments: ""
|
|
4809
|
-
})
|
|
4810
|
-
}));
|
|
4811
5371
|
if (initialArgs) {
|
|
4812
5372
|
try {
|
|
4813
5373
|
JSON.parse(initialArgs);
|
|
@@ -4817,15 +5377,20 @@ var post10 = function(param) {
|
|
|
4817
5377
|
displayHeight: displayHeight,
|
|
4818
5378
|
model: model
|
|
4819
5379
|
});
|
|
4820
|
-
passThrough.push({
|
|
4821
|
-
|
|
4822
|
-
function: {
|
|
5380
|
+
passThrough.push(_object_spread_props(_object_spread({}, tc), {
|
|
5381
|
+
function: _object_spread_props(_object_spread({}, tc.function), {
|
|
4823
5382
|
arguments: denormalized
|
|
4824
|
-
}
|
|
4825
|
-
});
|
|
5383
|
+
})
|
|
5384
|
+
}));
|
|
4826
5385
|
emittedIndices.add(tc.index);
|
|
5386
|
+
continue;
|
|
4827
5387
|
} catch (unused) {}
|
|
4828
5388
|
}
|
|
5389
|
+
passThrough.push(_object_spread_props(_object_spread({}, tc), {
|
|
5390
|
+
function: _object_spread_props(_object_spread({}, tc.function), {
|
|
5391
|
+
arguments: ""
|
|
5392
|
+
})
|
|
5393
|
+
}));
|
|
4829
5394
|
continue;
|
|
4830
5395
|
}
|
|
4831
5396
|
if (computerCallIndices.has(tc.index)) {
|
|
@@ -5147,7 +5712,7 @@ var openRouterClientAdapter = function(param) {
|
|
|
5147
5712
|
};
|
|
5148
5713
|
// src/adapters/run/completionsRunAdapter/index.ts
|
|
5149
5714
|
import _ from "lodash";
|
|
5150
|
-
import { uid as
|
|
5715
|
+
import { uid as uid3, omit as omit4, isEmpty as isEmpty2 } from "radash";
|
|
5151
5716
|
import dayjs from "dayjs";
|
|
5152
5717
|
// src/adapters/run/completionsRunAdapter/messages/index.ts
|
|
5153
5718
|
import { flat } from "radash";
|
|
@@ -5155,6 +5720,7 @@ import { flat } from "radash";
|
|
|
5155
5720
|
import { isArray, isObject } from "radash";
|
|
5156
5721
|
var validToolCallContentTypes = [
|
|
5157
5722
|
"image",
|
|
5723
|
+
"image_url",
|
|
5158
5724
|
"text"
|
|
5159
5725
|
];
|
|
5160
5726
|
var serializeToolContent = function(param) {
|
|
@@ -5170,6 +5736,21 @@ var serializeToolContent = function(param) {
|
|
|
5170
5736
|
}
|
|
5171
5737
|
return JSON.stringify(toolCall.function.output);
|
|
5172
5738
|
}
|
|
5739
|
+
if (typeof toolCall.function.output === "string") {
|
|
5740
|
+
try {
|
|
5741
|
+
var parsed = JSON.parse(toolCall.function.output);
|
|
5742
|
+
if (parsed.type === "computer_screenshot" && parsed.image_url) {
|
|
5743
|
+
return [
|
|
5744
|
+
{
|
|
5745
|
+
type: "image_url",
|
|
5746
|
+
image_url: {
|
|
5747
|
+
url: parsed.image_url
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
];
|
|
5751
|
+
}
|
|
5752
|
+
} catch (unused) {}
|
|
5753
|
+
}
|
|
5173
5754
|
return (_toolCall_function_output = toolCall.function.output) !== null && _toolCall_function_output !== void 0 ? _toolCall_function_output : "";
|
|
5174
5755
|
};
|
|
5175
5756
|
var serializeToolCall = function(param) {
|
|
@@ -5308,7 +5889,7 @@ var toolCallsData = function(param) {
|
|
|
5308
5889
|
return delta.tool_calls.map(function(tc) {
|
|
5309
5890
|
var _tc_type;
|
|
5310
5891
|
return _object_spread({
|
|
5311
|
-
id:
|
|
5892
|
+
id: uid3(24),
|
|
5312
5893
|
type: (_tc_type = tc.type) !== null && _tc_type !== void 0 ? _tc_type : "function"
|
|
5313
5894
|
}, omit4(tc, [
|
|
5314
5895
|
"index"
|
|
@@ -5554,7 +6135,7 @@ var completionsRunAdapter = function() {
|
|
|
5554
6135
|
tool_calls: delta.tool_calls.map(function(tc) {
|
|
5555
6136
|
var _tc_type;
|
|
5556
6137
|
return _object_spread({
|
|
5557
|
-
id:
|
|
6138
|
+
id: uid3(24),
|
|
5558
6139
|
type: (_tc_type = tc.type) !== null && _tc_type !== void 0 ? _tc_type : "function"
|
|
5559
6140
|
}, tc);
|
|
5560
6141
|
})
|
|
@@ -7438,7 +8019,7 @@ var threads2 = function(param) {
|
|
|
7438
8019
|
import dayjs10 from "dayjs";
|
|
7439
8020
|
import { isArray as isArray3 } from "radash";
|
|
7440
8021
|
// src/lib/items/serializeItemAsMessage.ts
|
|
7441
|
-
import { uid as
|
|
8022
|
+
import { uid as uid4 } from "radash";
|
|
7442
8023
|
var serializeContent2 = function(param) {
|
|
7443
8024
|
var item = param.item;
|
|
7444
8025
|
if (item.type === "message") {
|
|
@@ -7514,7 +8095,7 @@ var serializeMetadata = function(param) {
|
|
|
7514
8095
|
var serializeItemAsMessage = function(param) {
|
|
7515
8096
|
var item = param.item, threadId = param.threadId, openaiAssistant = param.openaiAssistant, createdAt = param.createdAt, _param_runId = param.runId, runId = _param_runId === void 0 ? null : _param_runId, tmp = param.status, status3 = tmp === void 0 ? "completed" : tmp;
|
|
7516
8097
|
return {
|
|
7517
|
-
id: item.id ||
|
|
8098
|
+
id: item.id || uid4(24),
|
|
7518
8099
|
object: "thread.message",
|
|
7519
8100
|
created_at: createdAt,
|
|
7520
8101
|
thread_id: threadId,
|
|
@@ -7945,7 +8526,7 @@ var get17 = function() {
|
|
|
7945
8526
|
};
|
|
7946
8527
|
};
|
|
7947
8528
|
// src/adapters/storage/responsesStorageAdapter/threads/runs/post.ts
|
|
7948
|
-
import { uid as
|
|
8529
|
+
import { uid as uid5 } from "radash";
|
|
7949
8530
|
import dayjs11 from "dayjs";
|
|
7950
8531
|
import { assign as assign8 } from "radash";
|
|
7951
8532
|
// src/lib/responses/serializeResponseAsRun.ts
|
|
@@ -8385,7 +8966,7 @@ function saveResponseItemsToConversationMetadata(_0) {
|
|
|
8385
8966
|
}).apply(this, arguments);
|
|
8386
8967
|
}
|
|
8387
8968
|
// src/adapters/storage/responsesStorageAdapter/threads/runs/shared.ts
|
|
8388
|
-
var
|
|
8969
|
+
var serializeTools3 = function(param) {
|
|
8389
8970
|
var tools = param.tools;
|
|
8390
8971
|
if (!(tools === null || tools === void 0 ? void 0 : tools.length)) return {};
|
|
8391
8972
|
return {
|
|
@@ -8455,7 +9036,7 @@ var post18 = function(param) {
|
|
|
8455
9036
|
};
|
|
8456
9037
|
responseBody.model = model;
|
|
8457
9038
|
responseBody.metadata = metadata;
|
|
8458
|
-
Object.assign(responseBody,
|
|
9039
|
+
Object.assign(responseBody, serializeTools3({
|
|
8459
9040
|
tools: tools
|
|
8460
9041
|
}));
|
|
8461
9042
|
responseBody.truncation = truncation({
|
|
@@ -8518,7 +9099,7 @@ var post18 = function(param) {
|
|
|
8518
9099
|
event = {
|
|
8519
9100
|
event: "thread.run.failed",
|
|
8520
9101
|
data: {
|
|
8521
|
-
id:
|
|
9102
|
+
id: uid5(24),
|
|
8522
9103
|
failed_at: dayjs11().unix(),
|
|
8523
9104
|
last_error: {
|
|
8524
9105
|
code: "server_error",
|
|
@@ -8672,10 +9253,10 @@ var run2 = function(param) {
|
|
|
8672
9253
|
import { last as last2 } from "radash";
|
|
8673
9254
|
// src/lib/items/serializeItemAsMessageCreationRunStep.ts
|
|
8674
9255
|
import dayjs12 from "dayjs";
|
|
8675
|
-
import { uid as
|
|
9256
|
+
import { uid as uid6 } from "radash";
|
|
8676
9257
|
function serializeItemAsMessageCreationRunStep(param) {
|
|
8677
|
-
var item = param.item, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(
|
|
8678
|
-
var itemId = typeof item.id === "string" ? item.id : "item_".concat(
|
|
9258
|
+
var item = param.item, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(uid6(24)) : _param_runId, tmp = param.status, status3 = tmp === void 0 ? "completed" : tmp, _param_completedAt = param.completedAt, completedAt = _param_completedAt === void 0 ? dayjs12().unix() : _param_completedAt;
|
|
9259
|
+
var itemId = typeof item.id === "string" ? item.id : "item_".concat(uid6(18));
|
|
8679
9260
|
var base = {
|
|
8680
9261
|
id: itemId,
|
|
8681
9262
|
object: "thread.run.step",
|
|
@@ -8738,7 +9319,7 @@ function serializeItemAsMessageCreationRunStep(param) {
|
|
|
8738
9319
|
}
|
|
8739
9320
|
// src/lib/items/serializeItemAsFunctionCallRunStep.ts
|
|
8740
9321
|
import dayjs13 from "dayjs";
|
|
8741
|
-
import { uid as
|
|
9322
|
+
import { uid as uid7 } from "radash";
|
|
8742
9323
|
var serializeFunctionCallOutput = function(param) {
|
|
8743
9324
|
var functionCallOutput = param.functionCallOutput;
|
|
8744
9325
|
if (!functionCallOutput) return null;
|
|
@@ -8748,8 +9329,8 @@ var serializeFunctionCallOutput = function(param) {
|
|
|
8748
9329
|
return JSON.stringify(functionCallOutput.output);
|
|
8749
9330
|
};
|
|
8750
9331
|
var serializeItemAsFunctionCallRunStep = function(param) {
|
|
8751
|
-
var item = param.item, items = param.items, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(
|
|
8752
|
-
var itemId = typeof item.id === "string" ? item.id : "item_".concat(
|
|
9332
|
+
var item = param.item, items = param.items, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(uid7(24)) : _param_runId, tmp = param.status, status3 = tmp === void 0 ? "completed" : tmp, _param_completedAt = param.completedAt, completedAt = _param_completedAt === void 0 ? dayjs13().unix() : _param_completedAt;
|
|
9333
|
+
var itemId = typeof item.id === "string" ? item.id : "item_".concat(uid7(18));
|
|
8753
9334
|
var base = {
|
|
8754
9335
|
id: itemId,
|
|
8755
9336
|
object: "thread.run.step",
|
|
@@ -9079,10 +9660,10 @@ var serializeItemAsCodeInterpreterCallRunStep = function(param) {
|
|
|
9079
9660
|
};
|
|
9080
9661
|
// src/lib/items/serializeItemAsComputerCallRunStep.ts
|
|
9081
9662
|
import dayjs19 from "dayjs";
|
|
9082
|
-
import { uid as
|
|
9663
|
+
import { uid as uid8 } from "radash";
|
|
9083
9664
|
var serializeItemAsComputerCallRunStep = function(param) {
|
|
9084
|
-
var item = param.item, items = param.items, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(
|
|
9085
|
-
var itemId = typeof item.id === "string" ? item.id : "item_".concat(
|
|
9665
|
+
var item = param.item, items = param.items, threadId = param.threadId, openaiAssistant = param.openaiAssistant, _param_runId = param.runId, runId = _param_runId === void 0 ? "run_".concat(uid8(24)) : _param_runId, tmp = param.status, status3 = tmp === void 0 ? "completed" : tmp, _param_completedAt = param.completedAt, completedAt = _param_completedAt === void 0 ? dayjs19().unix() : _param_completedAt;
|
|
9666
|
+
var itemId = typeof item.id === "string" ? item.id : "item_".concat(uid8(18));
|
|
9086
9667
|
var base = {
|
|
9087
9668
|
id: itemId,
|
|
9088
9669
|
object: "thread.run.step",
|
|
@@ -9414,7 +9995,7 @@ var getToolCallOutputItems = function(param) {
|
|
|
9414
9995
|
computerCallOutputItems: computerCallOutputItems
|
|
9415
9996
|
};
|
|
9416
9997
|
};
|
|
9417
|
-
var
|
|
9998
|
+
var serializeTools4 = function(param) {
|
|
9418
9999
|
var tools = param.tools;
|
|
9419
10000
|
if (!(tools === null || tools === void 0 ? void 0 : tools.length)) return {};
|
|
9420
10001
|
return {
|
|
@@ -9469,7 +10050,7 @@ var post19 = function(param) {
|
|
|
9469
10050
|
input: input
|
|
9470
10051
|
};
|
|
9471
10052
|
responseBody.model = openaiAssistant.model;
|
|
9472
|
-
Object.assign(responseBody,
|
|
10053
|
+
Object.assign(responseBody, serializeTools4({
|
|
9473
10054
|
tools: openaiAssistant.tools
|
|
9474
10055
|
}));
|
|
9475
10056
|
responseBody.truncation = truncation2({
|
|
@@ -9697,7 +10278,7 @@ var responsesStorageAdapter = function() {
|
|
|
9697
10278
|
// src/lib/responses/responseRegexp.ts
|
|
9698
10279
|
var responseRegexp = "^/(?:v1|/?openai)/responses/([^/]+)$";
|
|
9699
10280
|
// src/adapters/storage/azureResponsesStorageAdapter/threads/runs/post.ts
|
|
9700
|
-
import { uid as
|
|
10281
|
+
import { uid as uid9 } from "radash";
|
|
9701
10282
|
import dayjs21 from "dayjs";
|
|
9702
10283
|
import { assign as assign9 } from "radash";
|
|
9703
10284
|
var post21 = function(param) {
|
|
@@ -9740,7 +10321,7 @@ var post21 = function(param) {
|
|
|
9740
10321
|
if (!azureAgentId) {
|
|
9741
10322
|
responseBody.model = model;
|
|
9742
10323
|
responseBody.metadata = metadata;
|
|
9743
|
-
Object.assign(responseBody,
|
|
10324
|
+
Object.assign(responseBody, serializeTools3({
|
|
9744
10325
|
tools: tools
|
|
9745
10326
|
}));
|
|
9746
10327
|
responseBody.truncation = truncation({
|
|
@@ -9806,7 +10387,7 @@ var post21 = function(param) {
|
|
|
9806
10387
|
event = {
|
|
9807
10388
|
event: "thread.run.failed",
|
|
9808
10389
|
data: {
|
|
9809
|
-
id:
|
|
10390
|
+
id: uid9(24),
|
|
9810
10391
|
failed_at: dayjs21().unix(),
|
|
9811
10392
|
last_error: {
|
|
9812
10393
|
code: "server_error",
|
|
@@ -9943,7 +10524,7 @@ var post22 = function(param) {
|
|
|
9943
10524
|
}
|
|
9944
10525
|
if (!azureAgentId) {
|
|
9945
10526
|
responseBody.model = openaiAssistant.model;
|
|
9946
|
-
Object.assign(responseBody,
|
|
10527
|
+
Object.assign(responseBody, serializeTools4({
|
|
9947
10528
|
tools: openaiAssistant.tools
|
|
9948
10529
|
}));
|
|
9949
10530
|
responseBody.truncation = truncation2({
|
|
@@ -10689,7 +11270,7 @@ var get23 = function() {
|
|
|
10689
11270
|
};
|
|
10690
11271
|
};
|
|
10691
11272
|
// src/adapters/storage/azureAgentsStorageAdapter/threads/runs/post.ts
|
|
10692
|
-
import { uid as
|
|
11273
|
+
import { uid as uid10 } from "radash";
|
|
10693
11274
|
import dayjs25 from "dayjs";
|
|
10694
11275
|
var post25 = function(param) {
|
|
10695
11276
|
var azureAiProject = param.azureAiProject, runAdapter = param.runAdapter;
|
|
@@ -10758,7 +11339,7 @@ var post25 = function(param) {
|
|
|
10758
11339
|
event = {
|
|
10759
11340
|
event: "thread.run.failed",
|
|
10760
11341
|
data: {
|
|
10761
|
-
id:
|
|
11342
|
+
id: uid10(24),
|
|
10762
11343
|
failed_at: dayjs25().unix(),
|
|
10763
11344
|
last_error: {
|
|
10764
11345
|
code: "server_error",
|
|
@@ -12302,7 +12883,7 @@ var azureAgentsStorageAdapter = function(param) {
|
|
|
12302
12883
|
};
|
|
12303
12884
|
// src/adapters/run/responsesRunAdapter/index.ts
|
|
12304
12885
|
import dayjs30 from "dayjs";
|
|
12305
|
-
import { uid as
|
|
12886
|
+
import { uid as uid11 } from "radash";
|
|
12306
12887
|
var serializeToolCalls2 = function(param) {
|
|
12307
12888
|
var toolCalls = param.toolCalls;
|
|
12308
12889
|
return toolCalls.map(function(toolCall) {
|
|
@@ -14239,7 +14820,7 @@ var responsesRunAdapter = function(param) {
|
|
|
14239
14820
|
event: "thread.run.failed"
|
|
14240
14821
|
};
|
|
14241
14822
|
_tmp102 = {
|
|
14242
|
-
id: (responseCreatedResponse === null || responseCreatedResponse === void 0 ? void 0 : responseCreatedResponse.id) || "run_".concat(
|
|
14823
|
+
id: (responseCreatedResponse === null || responseCreatedResponse === void 0 ? void 0 : responseCreatedResponse.id) || "run_".concat(uid11(18)),
|
|
14243
14824
|
object: "thread.run",
|
|
14244
14825
|
thread_id: threadId
|
|
14245
14826
|
};
|
|
@@ -14316,7 +14897,7 @@ var responsesRunAdapter = function(param) {
|
|
|
14316
14897
|
};
|
|
14317
14898
|
// src/adapters/run/azureAgentsRunAdapter/index.ts
|
|
14318
14899
|
import dayjs31 from "dayjs";
|
|
14319
|
-
import { uid as
|
|
14900
|
+
import { uid as uid12 } from "radash";
|
|
14320
14901
|
function transformAnnotations(annotations) {
|
|
14321
14902
|
return annotations.map(function(ann) {
|
|
14322
14903
|
if (ann.type === "file_citation") {
|
|
@@ -14820,7 +15401,7 @@ var azureAgentsRunAdapter = function(param) {
|
|
|
14820
15401
|
];
|
|
14821
15402
|
case 15:
|
|
14822
15403
|
e = _state.sent();
|
|
14823
|
-
errorRunId = "run_".concat(
|
|
15404
|
+
errorRunId = "run_".concat(uid12(18));
|
|
14824
15405
|
return [
|
|
14825
15406
|
4,
|
|
14826
15407
|
onEvent2({
|