supercompat 3.17.1 → 3.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3395,6 +3395,310 @@ var models9 = function(param) {
3395
3395
  // src/adapters/client/googleClientAdapter/completions/post.ts
3396
3396
  import { createId } from "@paralleldrive/cuid2";
3397
3397
  import { uid as uid2 } from "radash";
3398
+ // src/adapters/client/googleClientAdapter/normalizeGeminiAction.ts
3399
+ var GEMINI_ACTION_NAMES = /* @__PURE__ */ new Set([
3400
+ "click_at",
3401
+ "single_click_at",
3402
+ "right_click_at",
3403
+ "double_click_at",
3404
+ "triple_click_at",
3405
+ "hover_at",
3406
+ "type_text_at",
3407
+ "key_combination",
3408
+ "scroll_at",
3409
+ "scroll_document",
3410
+ "drag_and_drop",
3411
+ "wait_5_seconds",
3412
+ "wait_for_load",
3413
+ "navigate",
3414
+ "go_back",
3415
+ "go_forward",
3416
+ "open_web_browser"
3417
+ ]);
3418
+ var isGeminiAction = function(name) {
3419
+ return GEMINI_ACTION_NAMES.has(name);
3420
+ };
3421
+ var normalizeGeminiKey = function(key) {
3422
+ var lower = key.toLowerCase();
3423
+ switch(lower){
3424
+ case "control":
3425
+ return "ctrl";
3426
+ case "command":
3427
+ case "cmd":
3428
+ return "meta";
3429
+ case "option":
3430
+ return "alt";
3431
+ default:
3432
+ return lower;
3433
+ }
3434
+ };
3435
+ var scrollFromDirection = function(direction, amount) {
3436
+ if (!direction) return {
3437
+ scroll_x: 0,
3438
+ scroll_y: 0
3439
+ };
3440
+ switch(direction.toLowerCase()){
3441
+ case "up":
3442
+ return {
3443
+ scroll_x: 0,
3444
+ scroll_y: -amount
3445
+ };
3446
+ case "down":
3447
+ return {
3448
+ scroll_x: 0,
3449
+ scroll_y: amount
3450
+ };
3451
+ case "left":
3452
+ return {
3453
+ scroll_x: -amount,
3454
+ scroll_y: 0
3455
+ };
3456
+ case "right":
3457
+ return {
3458
+ scroll_x: amount,
3459
+ scroll_y: 0
3460
+ };
3461
+ default:
3462
+ return {
3463
+ scroll_x: 0,
3464
+ scroll_y: 0
3465
+ };
3466
+ }
3467
+ };
3468
+ var normalizeGeminiAction = function(name, args) {
3469
+ var x = typeof args.x === "number" ? args.x : typeof args.coordinate_x === "number" ? args.coordinate_x : 0;
3470
+ var y = typeof args.y === "number" ? args.y : typeof args.coordinate_y === "number" ? args.coordinate_y : 0;
3471
+ switch(name){
3472
+ case "click_at":
3473
+ case "single_click_at":
3474
+ return {
3475
+ action: {
3476
+ type: "click",
3477
+ button: "left",
3478
+ x: x,
3479
+ y: y
3480
+ },
3481
+ pending_safety_checks: []
3482
+ };
3483
+ case "right_click_at":
3484
+ return {
3485
+ action: {
3486
+ type: "click",
3487
+ button: "right",
3488
+ x: x,
3489
+ y: y
3490
+ },
3491
+ pending_safety_checks: []
3492
+ };
3493
+ case "double_click_at":
3494
+ return {
3495
+ action: {
3496
+ type: "double_click",
3497
+ x: x,
3498
+ y: y
3499
+ },
3500
+ pending_safety_checks: []
3501
+ };
3502
+ case "triple_click_at":
3503
+ return {
3504
+ action: {
3505
+ type: "double_click",
3506
+ x: x,
3507
+ y: y,
3508
+ repetitions: 3
3509
+ },
3510
+ pending_safety_checks: []
3511
+ };
3512
+ case "hover_at":
3513
+ return {
3514
+ action: {
3515
+ type: "move",
3516
+ x: x,
3517
+ y: y
3518
+ },
3519
+ pending_safety_checks: []
3520
+ };
3521
+ case "type_text_at":
3522
+ {
3523
+ var text = typeof args.text === "string" ? args.text : "";
3524
+ var pendingActions = [
3525
+ {
3526
+ type: "type",
3527
+ text: text
3528
+ }
3529
+ ];
3530
+ if (args.submit_after_type === true) {
3531
+ pendingActions.push({
3532
+ type: "keypress",
3533
+ keys: [
3534
+ "Return"
3535
+ ]
3536
+ });
3537
+ }
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
+ };
3548
+ }
3549
+ case "key_combination":
3550
+ {
3551
+ var rawKeys = args.keys;
3552
+ var keys;
3553
+ if (Array.isArray(rawKeys)) {
3554
+ keys = rawKeys.map(String).map(normalizeGeminiKey);
3555
+ } else if (typeof rawKeys === "string") {
3556
+ keys = rawKeys.split(/[+\s]+/).map(function(k) {
3557
+ return k.trim();
3558
+ }).filter(Boolean).map(normalizeGeminiKey);
3559
+ } else {
3560
+ keys = [];
3561
+ }
3562
+ return {
3563
+ action: {
3564
+ type: "keypress",
3565
+ keys: keys
3566
+ },
3567
+ pending_safety_checks: []
3568
+ };
3569
+ }
3570
+ case "scroll_at":
3571
+ {
3572
+ var direction = typeof args.direction === "string" ? args.direction : void 0;
3573
+ var amount = typeof args.amount === "number" ? args.amount : 3;
3574
+ var _scrollFromDirection = scrollFromDirection(direction, amount), scroll_x = _scrollFromDirection.scroll_x, scroll_y = _scrollFromDirection.scroll_y;
3575
+ return {
3576
+ action: {
3577
+ type: "scroll",
3578
+ x: x,
3579
+ y: y,
3580
+ scroll_x: scroll_x,
3581
+ scroll_y: scroll_y
3582
+ },
3583
+ pending_safety_checks: []
3584
+ };
3585
+ }
3586
+ case "scroll_document":
3587
+ {
3588
+ var direction1 = typeof args.direction === "string" ? args.direction : void 0;
3589
+ var amount1 = typeof args.amount === "number" ? args.amount : 3;
3590
+ var _scrollFromDirection1 = scrollFromDirection(direction1, amount1), scroll_x1 = _scrollFromDirection1.scroll_x, scroll_y1 = _scrollFromDirection1.scroll_y;
3591
+ return {
3592
+ action: {
3593
+ type: "scroll",
3594
+ x: 640,
3595
+ y: 360,
3596
+ scroll_x: scroll_x1,
3597
+ scroll_y: scroll_y1
3598
+ },
3599
+ pending_safety_checks: []
3600
+ };
3601
+ }
3602
+ case "drag_and_drop":
3603
+ {
3604
+ var destX = typeof args.destination_x === "number" ? args.destination_x : 0;
3605
+ var destY = typeof args.destination_y === "number" ? args.destination_y : 0;
3606
+ return {
3607
+ action: {
3608
+ type: "drag",
3609
+ path: [
3610
+ {
3611
+ x: x,
3612
+ y: y
3613
+ },
3614
+ {
3615
+ x: destX,
3616
+ y: destY
3617
+ }
3618
+ ]
3619
+ },
3620
+ pending_safety_checks: []
3621
+ };
3622
+ }
3623
+ case "wait_5_seconds":
3624
+ case "wait_for_load":
3625
+ return {
3626
+ action: {
3627
+ type: "wait"
3628
+ },
3629
+ pending_safety_checks: []
3630
+ };
3631
+ case "navigate":
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
+ };
3692
+ default:
3693
+ return {
3694
+ action: _object_spread({
3695
+ type: name
3696
+ }, args),
3697
+ pending_safety_checks: []
3698
+ };
3699
+ }
3700
+ };
3701
+ // src/adapters/client/googleClientAdapter/completions/post.ts
3398
3702
  var stripFunctionPrefix = function(name) {
3399
3703
  return name.replace(/^default_api:/, "");
3400
3704
  };
@@ -3529,19 +3833,22 @@ var serializeMessages2 = function(messages5) {
3529
3833
  var _tc_function1;
3530
3834
  args = JSON.parse((_ref1 = (_tc_function1 = tc.function) === null || _tc_function1 === void 0 ? void 0 : _tc_function1.arguments) !== null && _ref1 !== void 0 ? _ref1 : "{}");
3531
3835
  } 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
3836
  var thoughtSignature = args._thoughtSignature;
3837
+ var geminiActionName = args._geminiAction;
3538
3838
  var cleanArgs = _object_spread({}, args);
3539
3839
  delete cleanArgs._thoughtSignature;
3840
+ delete cleanArgs._geminiAction;
3841
+ var geminiName = name;
3842
+ if (name === "computer_call" && args.action && _type_of(args.action) === "object") {
3843
+ var _ref2;
3844
+ geminiName = (_ref2 = geminiActionName !== null && geminiActionName !== void 0 ? geminiActionName : args.action.type) !== null && _ref2 !== void 0 ? _ref2 : name;
3845
+ }
3540
3846
  var geminiArgs = void 0;
3541
3847
  if (name === "computer_call" && cleanArgs.action && _type_of(cleanArgs.action) === "object") {
3542
3848
  var action = cleanArgs.action;
3543
- var _type = action.type, rest = _object_without_properties(action, [
3544
- "type"
3849
+ var _type = action.type, _pa = action.pending_actions, rest = _object_without_properties(action, [
3850
+ "type",
3851
+ "pending_actions"
3545
3852
  ]);
3546
3853
  geminiArgs = rest;
3547
3854
  } else {
@@ -3798,6 +4105,8 @@ var denormalizeCoords = function(args, tools) {
3798
4105
  denormY(result.end_coordinate[1])
3799
4106
  ];
3800
4107
  }
4108
+ if (typeof result.destination_x === "number") result.destination_x = denormX(result.destination_x);
4109
+ if (typeof result.destination_y === "number") result.destination_y = denormY(result.destination_y);
3801
4110
  return result;
3802
4111
  };
3803
4112
  var isComputerUseFunction = function(name, tools) {
@@ -3812,13 +4121,16 @@ var functionCallToToolCallDelta = function(fc, index, tools, thoughtSignature) {
3812
4121
  if (isComputerUseFunction(name, tools)) {
3813
4122
  var _fc_args1, _fc_id1;
3814
4123
  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), {
4124
+ var normalized = isGeminiAction(name) ? normalizeGeminiAction(name, denormed) : normalizeComputerToolCallPayload(_object_spread_props(_object_spread({}, denormed), {
3816
4125
  type: name
3817
4126
  }));
3818
4127
  var payload = _object_spread({}, normalized);
3819
4128
  if (thoughtSignature) {
3820
4129
  payload._thoughtSignature = thoughtSignature;
3821
4130
  }
4131
+ if (isGeminiAction(name)) {
4132
+ payload._geminiAction = name;
4133
+ }
3822
4134
  return {
3823
4135
  index: index,
3824
4136
  id: (_fc_id1 = fc.id) !== null && _fc_id1 !== void 0 ? _fc_id1 : "call_".concat(createId()),