@midscene/shared 1.17.4-beta-20261030030502.0 → 1.17.4
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/es/agent-tools/agent-context.mjs +1 -0
- package/dist/es/env/parse-model-config.mjs +1 -1
- package/dist/es/img/box-select.mjs +35 -101
- package/dist/lib/agent-tools/agent-context.js +1 -0
- package/dist/lib/env/parse-model-config.js +1 -1
- package/dist/lib/img/box-select.js +35 -101
- package/dist/types/agent-tools/agent-behavior-init-args.d.ts +1 -1
- package/dist/types/agent-tools/agent-context.d.ts +2 -2
- package/dist/types/agent-tools/agent-context.d.ts.map +1 -1
- package/dist/types/img/box-select.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agent-tools/agent-context.ts +1 -0
- package/src/img/box-select.ts +38 -153
|
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
|
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-api-setup.html';
|
|
8
|
-
const getCurrentVersion = ()=>"1.17.4
|
|
8
|
+
const getCurrentVersion = ()=>"1.17.4";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
locate: LOCATE_MODEL_CONFIG_KEYS,
|
|
@@ -599,27 +599,6 @@ function drawCircle(pixels, width, height, center, radius, color, options = {})
|
|
|
599
599
|
pixels[idx + 3] = color.a;
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
function drawEllipse(pixels, width, height, center, radiusX, radiusY, color, thickness = 2) {
|
|
603
|
-
const cx = Math.round(center.x);
|
|
604
|
-
const cy = Math.round(center.y);
|
|
605
|
-
const outerRadiusX = Math.max(Math.round(radiusX), 1);
|
|
606
|
-
const outerRadiusY = Math.max(Math.round(radiusY), 1);
|
|
607
|
-
const innerRadiusX = Math.max(outerRadiusX - Math.round(thickness), 0);
|
|
608
|
-
const innerRadiusY = Math.max(outerRadiusY - Math.round(thickness), 0);
|
|
609
|
-
for(let py = cy - outerRadiusY; py <= cy + outerRadiusY; py++)for(let px = cx - outerRadiusX; px <= cx + outerRadiusX; px++){
|
|
610
|
-
if (px < 0 || py < 0 || px >= width || py >= height) continue;
|
|
611
|
-
const dx = px - cx;
|
|
612
|
-
const dy = py - cy;
|
|
613
|
-
const outer = dx * dx / (outerRadiusX * outerRadiusX) + dy * dy / (outerRadiusY * outerRadiusY);
|
|
614
|
-
const inner = 0 === innerRadiusX || 0 === innerRadiusY ? 0 : dx * dx / (innerRadiusX * innerRadiusX) + dy * dy / (innerRadiusY * innerRadiusY);
|
|
615
|
-
if (outer > 1 || inner < 1) continue;
|
|
616
|
-
const idx = (py * width + px) * 4;
|
|
617
|
-
pixels[idx + 0] = color.r;
|
|
618
|
-
pixels[idx + 1] = color.g;
|
|
619
|
-
pixels[idx + 2] = color.b;
|
|
620
|
-
pixels[idx + 3] = color.a;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
602
|
function drawLine(pixels, width, height, from, to, color, thickness = 2) {
|
|
624
603
|
const x0 = Math.round(from.x);
|
|
625
604
|
const y0 = Math.round(from.y);
|
|
@@ -642,72 +621,6 @@ function drawLine(pixels, width, height, from, to, color, thickness = 2) {
|
|
|
642
621
|
}
|
|
643
622
|
}
|
|
644
623
|
}
|
|
645
|
-
function drawCallout(pixels, width, height, targetPoint, markerRadius, style) {
|
|
646
|
-
const cx = Math.round(targetPoint.x);
|
|
647
|
-
const cy = Math.round(targetPoint.y);
|
|
648
|
-
const gap = Math.max(markerRadius + 18, 30);
|
|
649
|
-
const candidates = [
|
|
650
|
-
{
|
|
651
|
-
x: cx + gap,
|
|
652
|
-
y: cy - gap
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
x: cx + gap,
|
|
656
|
-
y: cy + gap
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
x: cx - gap,
|
|
660
|
-
y: cy - gap
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
x: cx - gap,
|
|
664
|
-
y: cy + gap
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
x: cx,
|
|
668
|
-
y: cy - gap
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
x: cx,
|
|
672
|
-
y: cy + gap
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
x: cx + gap,
|
|
676
|
-
y: cy
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
x: cx - gap,
|
|
680
|
-
y: cy
|
|
681
|
-
}
|
|
682
|
-
];
|
|
683
|
-
const calloutCenter = candidates.find((candidate)=>candidate.x - markerRadius >= 0 && candidate.x + markerRadius < width && candidate.y - markerRadius >= 0 && candidate.y + markerRadius < height) || {
|
|
684
|
-
x: Math.min(Math.max(cx + gap, markerRadius), width - markerRadius - 1),
|
|
685
|
-
y: Math.min(Math.max(cy - gap, markerRadius), height - markerRadius - 1)
|
|
686
|
-
};
|
|
687
|
-
const lineAngle = Math.atan2(cy - calloutCenter.y, cx - calloutCenter.x);
|
|
688
|
-
const lineStart = {
|
|
689
|
-
x: calloutCenter.x + Math.cos(lineAngle) * (markerRadius + 1),
|
|
690
|
-
y: calloutCenter.y + Math.sin(lineAngle) * (markerRadius + 1)
|
|
691
|
-
};
|
|
692
|
-
const targetRadiusX = 30;
|
|
693
|
-
const targetRadiusY = 15;
|
|
694
|
-
const ellipseBoundaryDistance = 1 / Math.sqrt(Math.cos(lineAngle) ** 2 / targetRadiusX ** 2 + Math.sin(lineAngle) ** 2 / targetRadiusY ** 2);
|
|
695
|
-
const lineEnd = {
|
|
696
|
-
x: cx - Math.cos(lineAngle) * ellipseBoundaryDistance,
|
|
697
|
-
y: cy - Math.sin(lineAngle) * ellipseBoundaryDistance
|
|
698
|
-
};
|
|
699
|
-
drawLine(pixels, width, height, lineStart, lineEnd, style.callout, 2);
|
|
700
|
-
drawCircle(pixels, width, height, calloutCenter, markerRadius + 2, style.calloutBorder, {
|
|
701
|
-
thickness: 3
|
|
702
|
-
});
|
|
703
|
-
drawCircle(pixels, width, height, calloutCenter, markerRadius, style.callout, {
|
|
704
|
-
fill: true
|
|
705
|
-
});
|
|
706
|
-
drawEllipse(pixels, width, height, targetPoint, targetRadiusX, targetRadiusY, style.callout, 2);
|
|
707
|
-
const textWidth = getNumberWidth(style.indexId);
|
|
708
|
-
const textHeight = FONT_HEIGHT * FONT_SCALE;
|
|
709
|
-
drawNumber(pixels, width, height, style.indexId, Math.round(calloutCenter.x - textWidth / 2), Math.round(calloutCenter.y - textHeight / 2), style.calloutText);
|
|
710
|
-
}
|
|
711
624
|
function drawPointMarker(pixels, width, height, point, radius, indexId = 1) {
|
|
712
625
|
const markerColors = [
|
|
713
626
|
{
|
|
@@ -723,26 +636,47 @@ function drawPointMarker(pixels, width, height, point, radius, indexId = 1) {
|
|
|
723
636
|
a: 0xee
|
|
724
637
|
}
|
|
725
638
|
];
|
|
726
|
-
const
|
|
727
|
-
const
|
|
639
|
+
const marker = markerColors[(indexId - 1) % markerColors.length];
|
|
640
|
+
const markerBorder = {
|
|
728
641
|
r: 0xff,
|
|
729
642
|
g: 0xff,
|
|
730
643
|
b: 0xff,
|
|
731
644
|
a: 0xff
|
|
732
645
|
};
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
b: 0xff,
|
|
737
|
-
a: 0xff
|
|
738
|
-
};
|
|
739
|
-
const markerRadius = Math.max(Math.round(radius), 10);
|
|
740
|
-
drawCallout(pixels, width, height, point, markerRadius, {
|
|
741
|
-
callout,
|
|
742
|
-
calloutBorder,
|
|
743
|
-
calloutText,
|
|
744
|
-
indexId
|
|
646
|
+
const ringRadius = Math.max(Math.round(radius), 10);
|
|
647
|
+
drawCircle(pixels, width, height, point, ringRadius + 2, markerBorder, {
|
|
648
|
+
thickness: 3
|
|
745
649
|
});
|
|
650
|
+
drawCircle(pixels, width, height, point, ringRadius, marker, {
|
|
651
|
+
thickness: 3
|
|
652
|
+
});
|
|
653
|
+
const tickInner = ringRadius + 5;
|
|
654
|
+
const tickOuter = ringRadius + 12;
|
|
655
|
+
const tickDirections = [
|
|
656
|
+
{
|
|
657
|
+
x: 0,
|
|
658
|
+
y: -1
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
x: 0,
|
|
662
|
+
y: 1
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
x: -1,
|
|
666
|
+
y: 0
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
x: 1,
|
|
670
|
+
y: 0
|
|
671
|
+
}
|
|
672
|
+
];
|
|
673
|
+
for (const direction of tickDirections)drawLine(pixels, width, height, {
|
|
674
|
+
x: point.x + direction.x * tickInner,
|
|
675
|
+
y: point.y + direction.y * tickInner
|
|
676
|
+
}, {
|
|
677
|
+
x: point.x + direction.x * tickOuter,
|
|
678
|
+
y: point.y + direction.y * tickOuter
|
|
679
|
+
}, markerBorder, 3);
|
|
746
680
|
}
|
|
747
681
|
function blendPixels(basePixels, overlayPixels, width, height) {
|
|
748
682
|
const result = new Uint8Array(basePixels.length);
|
|
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
|
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-api-setup.html';
|
|
40
|
-
const getCurrentVersion = ()=>"1.17.4
|
|
40
|
+
const getCurrentVersion = ()=>"1.17.4";
|
|
41
41
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
locate: external_constants_js_namespaceObject.LOCATE_MODEL_CONFIG_KEYS,
|
|
@@ -642,27 +642,6 @@ function drawCircle(pixels, width, height, center, radius, color, options = {})
|
|
|
642
642
|
pixels[idx + 3] = color.a;
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
|
-
function drawEllipse(pixels, width, height, center, radiusX, radiusY, color, thickness = 2) {
|
|
646
|
-
const cx = Math.round(center.x);
|
|
647
|
-
const cy = Math.round(center.y);
|
|
648
|
-
const outerRadiusX = Math.max(Math.round(radiusX), 1);
|
|
649
|
-
const outerRadiusY = Math.max(Math.round(radiusY), 1);
|
|
650
|
-
const innerRadiusX = Math.max(outerRadiusX - Math.round(thickness), 0);
|
|
651
|
-
const innerRadiusY = Math.max(outerRadiusY - Math.round(thickness), 0);
|
|
652
|
-
for(let py = cy - outerRadiusY; py <= cy + outerRadiusY; py++)for(let px = cx - outerRadiusX; px <= cx + outerRadiusX; px++){
|
|
653
|
-
if (px < 0 || py < 0 || px >= width || py >= height) continue;
|
|
654
|
-
const dx = px - cx;
|
|
655
|
-
const dy = py - cy;
|
|
656
|
-
const outer = dx * dx / (outerRadiusX * outerRadiusX) + dy * dy / (outerRadiusY * outerRadiusY);
|
|
657
|
-
const inner = 0 === innerRadiusX || 0 === innerRadiusY ? 0 : dx * dx / (innerRadiusX * innerRadiusX) + dy * dy / (innerRadiusY * innerRadiusY);
|
|
658
|
-
if (outer > 1 || inner < 1) continue;
|
|
659
|
-
const idx = (py * width + px) * 4;
|
|
660
|
-
pixels[idx + 0] = color.r;
|
|
661
|
-
pixels[idx + 1] = color.g;
|
|
662
|
-
pixels[idx + 2] = color.b;
|
|
663
|
-
pixels[idx + 3] = color.a;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
645
|
function drawLine(pixels, width, height, from, to, color, thickness = 2) {
|
|
667
646
|
const x0 = Math.round(from.x);
|
|
668
647
|
const y0 = Math.round(from.y);
|
|
@@ -685,72 +664,6 @@ function drawLine(pixels, width, height, from, to, color, thickness = 2) {
|
|
|
685
664
|
}
|
|
686
665
|
}
|
|
687
666
|
}
|
|
688
|
-
function drawCallout(pixels, width, height, targetPoint, markerRadius, style) {
|
|
689
|
-
const cx = Math.round(targetPoint.x);
|
|
690
|
-
const cy = Math.round(targetPoint.y);
|
|
691
|
-
const gap = Math.max(markerRadius + 18, 30);
|
|
692
|
-
const candidates = [
|
|
693
|
-
{
|
|
694
|
-
x: cx + gap,
|
|
695
|
-
y: cy - gap
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
x: cx + gap,
|
|
699
|
-
y: cy + gap
|
|
700
|
-
},
|
|
701
|
-
{
|
|
702
|
-
x: cx - gap,
|
|
703
|
-
y: cy - gap
|
|
704
|
-
},
|
|
705
|
-
{
|
|
706
|
-
x: cx - gap,
|
|
707
|
-
y: cy + gap
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
x: cx,
|
|
711
|
-
y: cy - gap
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
x: cx,
|
|
715
|
-
y: cy + gap
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
x: cx + gap,
|
|
719
|
-
y: cy
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
x: cx - gap,
|
|
723
|
-
y: cy
|
|
724
|
-
}
|
|
725
|
-
];
|
|
726
|
-
const calloutCenter = candidates.find((candidate)=>candidate.x - markerRadius >= 0 && candidate.x + markerRadius < width && candidate.y - markerRadius >= 0 && candidate.y + markerRadius < height) || {
|
|
727
|
-
x: Math.min(Math.max(cx + gap, markerRadius), width - markerRadius - 1),
|
|
728
|
-
y: Math.min(Math.max(cy - gap, markerRadius), height - markerRadius - 1)
|
|
729
|
-
};
|
|
730
|
-
const lineAngle = Math.atan2(cy - calloutCenter.y, cx - calloutCenter.x);
|
|
731
|
-
const lineStart = {
|
|
732
|
-
x: calloutCenter.x + Math.cos(lineAngle) * (markerRadius + 1),
|
|
733
|
-
y: calloutCenter.y + Math.sin(lineAngle) * (markerRadius + 1)
|
|
734
|
-
};
|
|
735
|
-
const targetRadiusX = 30;
|
|
736
|
-
const targetRadiusY = 15;
|
|
737
|
-
const ellipseBoundaryDistance = 1 / Math.sqrt(Math.cos(lineAngle) ** 2 / targetRadiusX ** 2 + Math.sin(lineAngle) ** 2 / targetRadiusY ** 2);
|
|
738
|
-
const lineEnd = {
|
|
739
|
-
x: cx - Math.cos(lineAngle) * ellipseBoundaryDistance,
|
|
740
|
-
y: cy - Math.sin(lineAngle) * ellipseBoundaryDistance
|
|
741
|
-
};
|
|
742
|
-
drawLine(pixels, width, height, lineStart, lineEnd, style.callout, 2);
|
|
743
|
-
drawCircle(pixels, width, height, calloutCenter, markerRadius + 2, style.calloutBorder, {
|
|
744
|
-
thickness: 3
|
|
745
|
-
});
|
|
746
|
-
drawCircle(pixels, width, height, calloutCenter, markerRadius, style.callout, {
|
|
747
|
-
fill: true
|
|
748
|
-
});
|
|
749
|
-
drawEllipse(pixels, width, height, targetPoint, targetRadiusX, targetRadiusY, style.callout, 2);
|
|
750
|
-
const textWidth = getNumberWidth(style.indexId);
|
|
751
|
-
const textHeight = FONT_HEIGHT * FONT_SCALE;
|
|
752
|
-
drawNumber(pixels, width, height, style.indexId, Math.round(calloutCenter.x - textWidth / 2), Math.round(calloutCenter.y - textHeight / 2), style.calloutText);
|
|
753
|
-
}
|
|
754
667
|
function drawPointMarker(pixels, width, height, point, radius, indexId = 1) {
|
|
755
668
|
const markerColors = [
|
|
756
669
|
{
|
|
@@ -766,26 +679,47 @@ function drawPointMarker(pixels, width, height, point, radius, indexId = 1) {
|
|
|
766
679
|
a: 0xee
|
|
767
680
|
}
|
|
768
681
|
];
|
|
769
|
-
const
|
|
770
|
-
const
|
|
682
|
+
const marker = markerColors[(indexId - 1) % markerColors.length];
|
|
683
|
+
const markerBorder = {
|
|
771
684
|
r: 0xff,
|
|
772
685
|
g: 0xff,
|
|
773
686
|
b: 0xff,
|
|
774
687
|
a: 0xff
|
|
775
688
|
};
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
b: 0xff,
|
|
780
|
-
a: 0xff
|
|
781
|
-
};
|
|
782
|
-
const markerRadius = Math.max(Math.round(radius), 10);
|
|
783
|
-
drawCallout(pixels, width, height, point, markerRadius, {
|
|
784
|
-
callout,
|
|
785
|
-
calloutBorder,
|
|
786
|
-
calloutText,
|
|
787
|
-
indexId
|
|
689
|
+
const ringRadius = Math.max(Math.round(radius), 10);
|
|
690
|
+
drawCircle(pixels, width, height, point, ringRadius + 2, markerBorder, {
|
|
691
|
+
thickness: 3
|
|
788
692
|
});
|
|
693
|
+
drawCircle(pixels, width, height, point, ringRadius, marker, {
|
|
694
|
+
thickness: 3
|
|
695
|
+
});
|
|
696
|
+
const tickInner = ringRadius + 5;
|
|
697
|
+
const tickOuter = ringRadius + 12;
|
|
698
|
+
const tickDirections = [
|
|
699
|
+
{
|
|
700
|
+
x: 0,
|
|
701
|
+
y: -1
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
x: 0,
|
|
705
|
+
y: 1
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
x: -1,
|
|
709
|
+
y: 0
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
x: 1,
|
|
713
|
+
y: 0
|
|
714
|
+
}
|
|
715
|
+
];
|
|
716
|
+
for (const direction of tickDirections)drawLine(pixels, width, height, {
|
|
717
|
+
x: point.x + direction.x * tickInner,
|
|
718
|
+
y: point.y + direction.y * tickInner
|
|
719
|
+
}, {
|
|
720
|
+
x: point.x + direction.x * tickOuter,
|
|
721
|
+
y: point.y + direction.y * tickOuter
|
|
722
|
+
}, markerBorder, 3);
|
|
789
723
|
}
|
|
790
724
|
function blendPixels(basePixels, overlayPixels, width, height) {
|
|
791
725
|
const result = new Uint8Array(basePixels.length);
|
|
@@ -23,7 +23,7 @@ export interface AgentBehaviorInitArgs {
|
|
|
23
23
|
screenshotShrinkFactor?: number;
|
|
24
24
|
}
|
|
25
25
|
export declare const agentBehaviorInitArgShape: {
|
|
26
|
-
aiContexts: z.ZodOptional<z.ZodRecord<z.ZodEnum<["default", "aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"]>, z.ZodString>>;
|
|
26
|
+
aiContexts: z.ZodOptional<z.ZodRecord<z.ZodEnum<["default", "aiAct", "aiTap", "aiRightClick", "aiMiddleClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"]>, z.ZodString>>;
|
|
27
27
|
aiActContext: z.ZodOptional<z.ZodString>;
|
|
28
28
|
replanningCycleLimit: z.ZodOptional<z.ZodNumber>;
|
|
29
29
|
waitAfterAction: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const AI_API_NAMES: readonly ["aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
|
|
1
|
+
export declare const AI_API_NAMES: readonly ["aiAct", "aiTap", "aiRightClick", "aiMiddleClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
|
|
2
2
|
export type AiApiName = (typeof AI_API_NAMES)[number];
|
|
3
|
-
export declare const AGENT_AI_CONTEXT_KEYS: readonly ["default", "aiAct", "aiTap", "aiRightClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
|
|
3
|
+
export declare const AGENT_AI_CONTEXT_KEYS: readonly ["default", "aiAct", "aiTap", "aiRightClick", "aiMiddleClick", "aiDoubleClick", "aiHover", "aiInput", "aiKeyboardPress", "aiScroll", "aiPinch", "aiLongPress", "aiClearInput", "aiLocate", "aiQuery", "aiBoolean", "aiNumber", "aiString", "aiAsk", "aiAssert", "aiWaitFor"];
|
|
4
4
|
export type AgentAIContextKey = (typeof AGENT_AI_CONTEXT_KEYS)[number];
|
|
5
5
|
/**
|
|
6
6
|
* Additional AI guidance configured at Agent level. Values may contain
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-context.d.ts","sourceRoot":"","sources":["../../../src/agent-tools/agent-context.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"agent-context.d.ts","sourceRoot":"","sources":["../../../src/agent-tools/agent-context.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,4QAqBf,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,eAAO,MAAM,qBAAqB,uRAAwC,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEnD,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,KACb,KAAK,IAAI,iBAEkD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box-select.d.ts","sourceRoot":"","sources":["../../../src/img/box-select.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AA6GlD,UAAU,iBAAiB;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"box-select.d.ts","sourceRoot":"","sources":["../../../src/img/box-select.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AA6GlD,UAAU,iBAAiB;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuhBD,eAAO,MAAM,uBAAuB,GAAU,SAAS;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,oBAwFA,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,SAAS;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChC,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,oBA6EA,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,SAAS;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACzC,+BAA+B,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CACrD;;;EAuBA,CAAC;AAEF,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,IAAI,EAAE,EACb,MAAM,CAAC,EAAE,MAAM,mBAkBhB"}
|
package/package.json
CHANGED
package/src/img/box-select.ts
CHANGED
|
@@ -267,48 +267,6 @@ function drawCircle(
|
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
function drawEllipse(
|
|
271
|
-
pixels: Uint8Array,
|
|
272
|
-
width: number,
|
|
273
|
-
height: number,
|
|
274
|
-
center: { x: number; y: number },
|
|
275
|
-
radiusX: number,
|
|
276
|
-
radiusY: number,
|
|
277
|
-
color: { r: number; g: number; b: number; a: number },
|
|
278
|
-
thickness = 2,
|
|
279
|
-
) {
|
|
280
|
-
const cx = Math.round(center.x);
|
|
281
|
-
const cy = Math.round(center.y);
|
|
282
|
-
const outerRadiusX = Math.max(Math.round(radiusX), 1);
|
|
283
|
-
const outerRadiusY = Math.max(Math.round(radiusY), 1);
|
|
284
|
-
const innerRadiusX = Math.max(outerRadiusX - Math.round(thickness), 0);
|
|
285
|
-
const innerRadiusY = Math.max(outerRadiusY - Math.round(thickness), 0);
|
|
286
|
-
|
|
287
|
-
for (let py = cy - outerRadiusY; py <= cy + outerRadiusY; py++) {
|
|
288
|
-
for (let px = cx - outerRadiusX; px <= cx + outerRadiusX; px++) {
|
|
289
|
-
if (px < 0 || py < 0 || px >= width || py >= height) continue;
|
|
290
|
-
|
|
291
|
-
const dx = px - cx;
|
|
292
|
-
const dy = py - cy;
|
|
293
|
-
const outer =
|
|
294
|
-
(dx * dx) / (outerRadiusX * outerRadiusX) +
|
|
295
|
-
(dy * dy) / (outerRadiusY * outerRadiusY);
|
|
296
|
-
const inner =
|
|
297
|
-
innerRadiusX === 0 || innerRadiusY === 0
|
|
298
|
-
? 0
|
|
299
|
-
: (dx * dx) / (innerRadiusX * innerRadiusX) +
|
|
300
|
-
(dy * dy) / (innerRadiusY * innerRadiusY);
|
|
301
|
-
if (outer > 1 || inner < 1) continue;
|
|
302
|
-
|
|
303
|
-
const idx = (py * width + px) * 4;
|
|
304
|
-
pixels[idx + 0] = color.r;
|
|
305
|
-
pixels[idx + 1] = color.g;
|
|
306
|
-
pixels[idx + 2] = color.b;
|
|
307
|
-
pixels[idx + 3] = color.a;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
270
|
function drawLine(
|
|
313
271
|
pixels: Uint8Array,
|
|
314
272
|
width: number,
|
|
@@ -343,108 +301,6 @@ function drawLine(
|
|
|
343
301
|
}
|
|
344
302
|
}
|
|
345
303
|
|
|
346
|
-
function drawCallout(
|
|
347
|
-
pixels: Uint8Array,
|
|
348
|
-
width: number,
|
|
349
|
-
height: number,
|
|
350
|
-
targetPoint: { x: number; y: number },
|
|
351
|
-
markerRadius: number,
|
|
352
|
-
style: {
|
|
353
|
-
callout: { r: number; g: number; b: number; a: number };
|
|
354
|
-
calloutBorder: { r: number; g: number; b: number; a: number };
|
|
355
|
-
calloutText: { r: number; g: number; b: number; a: number };
|
|
356
|
-
indexId: number;
|
|
357
|
-
},
|
|
358
|
-
) {
|
|
359
|
-
const cx = Math.round(targetPoint.x);
|
|
360
|
-
const cy = Math.round(targetPoint.y);
|
|
361
|
-
const gap = Math.max(markerRadius + 18, 30);
|
|
362
|
-
const candidates = [
|
|
363
|
-
{ x: cx + gap, y: cy - gap },
|
|
364
|
-
{ x: cx + gap, y: cy + gap },
|
|
365
|
-
{ x: cx - gap, y: cy - gap },
|
|
366
|
-
{ x: cx - gap, y: cy + gap },
|
|
367
|
-
{ x: cx, y: cy - gap },
|
|
368
|
-
{ x: cx, y: cy + gap },
|
|
369
|
-
{ x: cx + gap, y: cy },
|
|
370
|
-
{ x: cx - gap, y: cy },
|
|
371
|
-
];
|
|
372
|
-
const calloutCenter = candidates.find(
|
|
373
|
-
(candidate) =>
|
|
374
|
-
candidate.x - markerRadius >= 0 &&
|
|
375
|
-
candidate.x + markerRadius < width &&
|
|
376
|
-
candidate.y - markerRadius >= 0 &&
|
|
377
|
-
candidate.y + markerRadius < height,
|
|
378
|
-
) || {
|
|
379
|
-
x: Math.min(Math.max(cx + gap, markerRadius), width - markerRadius - 1),
|
|
380
|
-
y: Math.min(Math.max(cy - gap, markerRadius), height - markerRadius - 1),
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const lineAngle = Math.atan2(cy - calloutCenter.y, cx - calloutCenter.x);
|
|
384
|
-
const lineStart = {
|
|
385
|
-
x: calloutCenter.x + Math.cos(lineAngle) * (markerRadius + 1),
|
|
386
|
-
y: calloutCenter.y + Math.sin(lineAngle) * (markerRadius + 1),
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const targetRadiusX = 30;
|
|
390
|
-
const targetRadiusY = 15;
|
|
391
|
-
const ellipseBoundaryDistance =
|
|
392
|
-
1 /
|
|
393
|
-
Math.sqrt(
|
|
394
|
-
Math.cos(lineAngle) ** 2 / targetRadiusX ** 2 +
|
|
395
|
-
Math.sin(lineAngle) ** 2 / targetRadiusY ** 2,
|
|
396
|
-
);
|
|
397
|
-
const lineEnd = {
|
|
398
|
-
x: cx - Math.cos(lineAngle) * ellipseBoundaryDistance,
|
|
399
|
-
y: cy - Math.sin(lineAngle) * ellipseBoundaryDistance,
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
drawLine(pixels, width, height, lineStart, lineEnd, style.callout, 2);
|
|
403
|
-
drawCircle(
|
|
404
|
-
pixels,
|
|
405
|
-
width,
|
|
406
|
-
height,
|
|
407
|
-
calloutCenter,
|
|
408
|
-
markerRadius + 2,
|
|
409
|
-
style.calloutBorder,
|
|
410
|
-
{
|
|
411
|
-
thickness: 3,
|
|
412
|
-
},
|
|
413
|
-
);
|
|
414
|
-
drawCircle(
|
|
415
|
-
pixels,
|
|
416
|
-
width,
|
|
417
|
-
height,
|
|
418
|
-
calloutCenter,
|
|
419
|
-
markerRadius,
|
|
420
|
-
style.callout,
|
|
421
|
-
{
|
|
422
|
-
fill: true,
|
|
423
|
-
},
|
|
424
|
-
);
|
|
425
|
-
drawEllipse(
|
|
426
|
-
pixels,
|
|
427
|
-
width,
|
|
428
|
-
height,
|
|
429
|
-
targetPoint,
|
|
430
|
-
targetRadiusX,
|
|
431
|
-
targetRadiusY,
|
|
432
|
-
style.callout,
|
|
433
|
-
2,
|
|
434
|
-
);
|
|
435
|
-
const textWidth = getNumberWidth(style.indexId);
|
|
436
|
-
const textHeight = FONT_HEIGHT * FONT_SCALE;
|
|
437
|
-
drawNumber(
|
|
438
|
-
pixels,
|
|
439
|
-
width,
|
|
440
|
-
height,
|
|
441
|
-
style.indexId,
|
|
442
|
-
Math.round(calloutCenter.x - textWidth / 2),
|
|
443
|
-
Math.round(calloutCenter.y - textHeight / 2),
|
|
444
|
-
style.calloutText,
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
304
|
function drawPointMarker(
|
|
449
305
|
pixels: Uint8Array,
|
|
450
306
|
width: number,
|
|
@@ -457,16 +313,45 @@ function drawPointMarker(
|
|
|
457
313
|
{ r: 0xc6, g: 0x23, b: 0x00, a: 0xee },
|
|
458
314
|
{ r: 0x00, g: 0x00, b: 0xff, a: 0xee },
|
|
459
315
|
];
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
316
|
+
const marker = markerColors[(indexId - 1) % markerColors.length];
|
|
317
|
+
const markerBorder = { r: 0xff, g: 0xff, b: 0xff, a: 0xff };
|
|
318
|
+
const ringRadius = Math.max(Math.round(radius), 10);
|
|
319
|
+
|
|
320
|
+
// Draw a hollow target reticle centered on the point instead of an offset
|
|
321
|
+
// numbered callout bubble. The red filled circle with a white digit looked
|
|
322
|
+
// like a notification badge and was often reported as part of the page UI.
|
|
323
|
+
drawCircle(pixels, width, height, point, ringRadius + 2, markerBorder, {
|
|
324
|
+
thickness: 3,
|
|
325
|
+
});
|
|
326
|
+
drawCircle(pixels, width, height, point, ringRadius, marker, {
|
|
327
|
+
thickness: 3,
|
|
469
328
|
});
|
|
329
|
+
|
|
330
|
+
const tickInner = ringRadius + 5;
|
|
331
|
+
const tickOuter = ringRadius + 12;
|
|
332
|
+
const tickDirections = [
|
|
333
|
+
{ x: 0, y: -1 },
|
|
334
|
+
{ x: 0, y: 1 },
|
|
335
|
+
{ x: -1, y: 0 },
|
|
336
|
+
{ x: 1, y: 0 },
|
|
337
|
+
];
|
|
338
|
+
for (const direction of tickDirections) {
|
|
339
|
+
drawLine(
|
|
340
|
+
pixels,
|
|
341
|
+
width,
|
|
342
|
+
height,
|
|
343
|
+
{
|
|
344
|
+
x: point.x + direction.x * tickInner,
|
|
345
|
+
y: point.y + direction.y * tickInner,
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
x: point.x + direction.x * tickOuter,
|
|
349
|
+
y: point.y + direction.y * tickOuter,
|
|
350
|
+
},
|
|
351
|
+
markerBorder,
|
|
352
|
+
3,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
470
355
|
}
|
|
471
356
|
|
|
472
357
|
function blendPixels(
|