misoai-web 1.6.1 → 1.6.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/es/agent.js +4 -1
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode.js +6 -3
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +5 -2
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +320 -18
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +4 -1
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/playground.js +4 -1
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright.js +320 -18
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +320 -18
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +320 -18
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/lib/agent.js +4 -1
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode.js +6 -3
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +5 -2
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +320 -18
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +4 -1
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/playground.js +4 -1
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright.js +320 -18
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +320 -18
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +320 -18
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/types/agent.d.ts +1 -1
- package/dist/types/bridge-mode-browser.d.ts +2 -2
- package/dist/types/bridge-mode.d.ts +2 -2
- package/dist/types/{browser-9b472ffb.d.ts → browser-f205f69d.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/midscene-server.d.ts +1 -1
- package/dist/types/{page-ed0ecb44.d.ts → page-c5452809.d.ts} +45 -0
- package/dist/types/playground.d.ts +2 -2
- package/dist/types/playwright.d.ts +1 -1
- package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
- package/dist/types/puppeteer.d.ts +2 -2
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/yaml.d.ts +1 -1
- package/package.json +2 -2
package/dist/lib/puppeteer.js
CHANGED
@@ -1298,6 +1298,7 @@ var PageTaskExecutor = class {
|
|
1298
1298
|
actions: [],
|
1299
1299
|
more_actions_needed_by_instruction: false,
|
1300
1300
|
log: "",
|
1301
|
+
summary: "Loaded YAML workflow configuration",
|
1301
1302
|
yamlString
|
1302
1303
|
},
|
1303
1304
|
cache: {
|
@@ -1399,6 +1400,7 @@ var PageTaskExecutor = class {
|
|
1399
1400
|
actions: finalActions,
|
1400
1401
|
more_actions_needed_by_instruction,
|
1401
1402
|
log: log2,
|
1403
|
+
summary: planResult.summary || "Generated action plan from user instruction",
|
1402
1404
|
yamlFlow: planResult.yamlFlow
|
1403
1405
|
},
|
1404
1406
|
cache: {
|
@@ -1454,6 +1456,7 @@ var PageTaskExecutor = class {
|
|
1454
1456
|
actionType: actions[0].type,
|
1455
1457
|
more_actions_needed_by_instruction: true,
|
1456
1458
|
log: "",
|
1459
|
+
summary: action_summary || "Generated VLM action plan",
|
1457
1460
|
yamlFlow: planResult.yamlFlow
|
1458
1461
|
},
|
1459
1462
|
cache: {
|
@@ -2048,7 +2051,7 @@ var import_utils9 = require("misoai-shared/utils");
|
|
2048
2051
|
var import_semver = __toESM(require("semver"));
|
2049
2052
|
|
2050
2053
|
// package.json
|
2051
|
-
var version = "1.6.
|
2054
|
+
var version = "1.6.2";
|
2052
2055
|
|
2053
2056
|
// src/common/task-cache.ts
|
2054
2057
|
var debug3 = (0, import_logger3.getDebug)("cache");
|
@@ -3139,13 +3142,236 @@ var import_extractor2 = require("misoai-shared/extractor");
|
|
3139
3142
|
var import_fs = require("misoai-shared/fs");
|
3140
3143
|
var import_logger5 = require("misoai-shared/logger");
|
3141
3144
|
var import_utils16 = require("misoai-shared/utils");
|
3145
|
+
|
3146
|
+
// src/common/mouse-utils.ts
|
3147
|
+
function generateHumanMousePath(from, to, options = {}) {
|
3148
|
+
const {
|
3149
|
+
steps = 20,
|
3150
|
+
easing = "easeInOut"
|
3151
|
+
} = options;
|
3152
|
+
if (steps <= 1) {
|
3153
|
+
return [to];
|
3154
|
+
}
|
3155
|
+
const path = [];
|
3156
|
+
const controlPoint1 = {
|
3157
|
+
x: from.x + (to.x - from.x) * 0.25 + (Math.random() - 0.5) * 50,
|
3158
|
+
y: from.y + (to.y - from.y) * 0.25 + (Math.random() - 0.5) * 50
|
3159
|
+
};
|
3160
|
+
const controlPoint2 = {
|
3161
|
+
x: from.x + (to.x - from.x) * 0.75 + (Math.random() - 0.5) * 50,
|
3162
|
+
y: from.y + (to.y - from.y) * 0.75 + (Math.random() - 0.5) * 50
|
3163
|
+
};
|
3164
|
+
for (let i = 0; i <= steps; i++) {
|
3165
|
+
const t = i / steps;
|
3166
|
+
const easedT = applyEasing(t, easing);
|
3167
|
+
const point = calculateBezierPoint(from, controlPoint1, controlPoint2, to, easedT);
|
3168
|
+
path.push(point);
|
3169
|
+
}
|
3170
|
+
return path;
|
3171
|
+
}
|
3172
|
+
function calculateBezierPoint(p0, p1, p2, p3, t) {
|
3173
|
+
const oneMinusT = 1 - t;
|
3174
|
+
const oneMinusTSquared = oneMinusT * oneMinusT;
|
3175
|
+
const oneMinusTCubed = oneMinusTSquared * oneMinusT;
|
3176
|
+
const tSquared = t * t;
|
3177
|
+
const tCubed = tSquared * t;
|
3178
|
+
return {
|
3179
|
+
x: oneMinusTCubed * p0.x + 3 * oneMinusTSquared * t * p1.x + 3 * oneMinusT * tSquared * p2.x + tCubed * p3.x,
|
3180
|
+
y: oneMinusTCubed * p0.y + 3 * oneMinusTSquared * t * p1.y + 3 * oneMinusT * tSquared * p2.y + tCubed * p3.y
|
3181
|
+
};
|
3182
|
+
}
|
3183
|
+
function applyEasing(t, easing) {
|
3184
|
+
switch (easing) {
|
3185
|
+
case "linear":
|
3186
|
+
return t;
|
3187
|
+
case "easeIn":
|
3188
|
+
return t * t;
|
3189
|
+
case "easeOut":
|
3190
|
+
return 1 - (1 - t) * (1 - t);
|
3191
|
+
case "easeInOut":
|
3192
|
+
return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
|
3193
|
+
default:
|
3194
|
+
return t;
|
3195
|
+
}
|
3196
|
+
}
|
3197
|
+
function calculateStepDelay(totalDuration, currentStep, totalSteps) {
|
3198
|
+
const baseDelay = totalDuration / totalSteps;
|
3199
|
+
const variation = 0.3;
|
3200
|
+
const randomFactor = 1 + (Math.random() - 0.5) * variation;
|
3201
|
+
return Math.max(1, baseDelay * randomFactor);
|
3202
|
+
}
|
3203
|
+
|
3204
|
+
// src/common/visual-feedback.ts
|
3205
|
+
function getMousePointerScript(x, y, options = {}) {
|
3206
|
+
const {
|
3207
|
+
pointerSize = 20,
|
3208
|
+
pointerColor = "#ff4444",
|
3209
|
+
trailLength = 5,
|
3210
|
+
showTrail = true,
|
3211
|
+
animationDuration = 200
|
3212
|
+
} = options;
|
3213
|
+
return `
|
3214
|
+
(() => {
|
3215
|
+
// Create or update mouse pointer
|
3216
|
+
if (!window.misoaiMousePointer) {
|
3217
|
+
const pointer = document.createElement('div');
|
3218
|
+
pointer.id = 'misoai-mouse-pointer';
|
3219
|
+
pointer.style.cssText = \`
|
3220
|
+
position: fixed;
|
3221
|
+
width: ${pointerSize}px;
|
3222
|
+
height: ${pointerSize}px;
|
3223
|
+
background: ${pointerColor};
|
3224
|
+
border: 2px solid white;
|
3225
|
+
border-radius: 50%;
|
3226
|
+
pointer-events: none;
|
3227
|
+
z-index: 999999;
|
3228
|
+
box-shadow: 0 0 10px rgba(0,0,0,0.3);
|
3229
|
+
transition: all ${animationDuration}ms ease-out;
|
3230
|
+
transform: translate(-50%, -50%);
|
3231
|
+
\`;
|
3232
|
+
document.body.appendChild(pointer);
|
3233
|
+
window.misoaiMousePointer = pointer;
|
3234
|
+
|
3235
|
+
// Initialize trail array
|
3236
|
+
window.misoaiMouseTrail = [];
|
3237
|
+
}
|
3238
|
+
|
3239
|
+
const pointer = window.misoaiMousePointer;
|
3240
|
+
pointer.style.left = ${x}px;
|
3241
|
+
pointer.style.top = ${y}px;
|
3242
|
+
|
3243
|
+
${showTrail ? getTrailScript(x, y, trailLength, pointerColor) : ""}
|
3244
|
+
|
3245
|
+
// Auto-hide after 3 seconds of inactivity
|
3246
|
+
clearTimeout(window.misoaiMouseTimeout);
|
3247
|
+
pointer.style.opacity = '1';
|
3248
|
+
window.misoaiMouseTimeout = setTimeout(() => {
|
3249
|
+
if (pointer) pointer.style.opacity = '0.3';
|
3250
|
+
}, 3000);
|
3251
|
+
})();
|
3252
|
+
`;
|
3253
|
+
}
|
3254
|
+
function getTrailScript(x, y, trailLength, color) {
|
3255
|
+
return `
|
3256
|
+
// Add current position to trail
|
3257
|
+
window.misoaiMouseTrail.push({ x: ${x}, y: ${y}, timestamp: Date.now() });
|
3258
|
+
|
3259
|
+
// Keep only recent trail points
|
3260
|
+
if (window.misoaiMouseTrail.length > ${trailLength}) {
|
3261
|
+
window.misoaiMouseTrail.shift();
|
3262
|
+
}
|
3263
|
+
|
3264
|
+
// Remove old trail elements
|
3265
|
+
document.querySelectorAll('.misoai-mouse-trail').forEach(el => el.remove());
|
3266
|
+
|
3267
|
+
// Create new trail elements
|
3268
|
+
window.misoaiMouseTrail.forEach((point, index) => {
|
3269
|
+
if (index === window.misoaiMouseTrail.length - 1) return; // Skip current position
|
3270
|
+
|
3271
|
+
const trailElement = document.createElement('div');
|
3272
|
+
trailElement.className = 'misoai-mouse-trail';
|
3273
|
+
const opacity = (index + 1) / window.misoaiMouseTrail.length * 0.6;
|
3274
|
+
const size = 8 + (index + 1) / window.misoaiMouseTrail.length * 8;
|
3275
|
+
|
3276
|
+
trailElement.style.cssText = \`
|
3277
|
+
position: fixed;
|
3278
|
+
width: \${size}px;
|
3279
|
+
height: \${size}px;
|
3280
|
+
background: ${color};
|
3281
|
+
border-radius: 50%;
|
3282
|
+
pointer-events: none;
|
3283
|
+
z-index: 999998;
|
3284
|
+
opacity: \${opacity};
|
3285
|
+
transform: translate(-50%, -50%);
|
3286
|
+
left: \${point.x}px;
|
3287
|
+
top: \${point.y}px;
|
3288
|
+
\`;
|
3289
|
+
|
3290
|
+
document.body.appendChild(trailElement);
|
3291
|
+
|
3292
|
+
// Auto-remove trail element after animation
|
3293
|
+
setTimeout(() => {
|
3294
|
+
if (trailElement.parentNode) {
|
3295
|
+
trailElement.parentNode.removeChild(trailElement);
|
3296
|
+
}
|
3297
|
+
}, 1000);
|
3298
|
+
});
|
3299
|
+
`;
|
3300
|
+
}
|
3301
|
+
function getClickAnimationScript(x, y) {
|
3302
|
+
return `
|
3303
|
+
(() => {
|
3304
|
+
const clickRipple = document.createElement('div');
|
3305
|
+
clickRipple.style.cssText = \`
|
3306
|
+
position: fixed;
|
3307
|
+
left: ${x}px;
|
3308
|
+
top: ${y}px;
|
3309
|
+
width: 0;
|
3310
|
+
height: 0;
|
3311
|
+
border: 2px solid #ff4444;
|
3312
|
+
border-radius: 50%;
|
3313
|
+
pointer-events: none;
|
3314
|
+
z-index: 999999;
|
3315
|
+
transform: translate(-50%, -50%);
|
3316
|
+
animation: misoai-click-ripple 0.6s ease-out forwards;
|
3317
|
+
\`;
|
3318
|
+
|
3319
|
+
// Add CSS animation if not exists
|
3320
|
+
if (!document.getElementById('misoai-click-styles')) {
|
3321
|
+
const style = document.createElement('style');
|
3322
|
+
style.id = 'misoai-click-styles';
|
3323
|
+
style.textContent = \`
|
3324
|
+
@keyframes misoai-click-ripple {
|
3325
|
+
0% {
|
3326
|
+
width: 0;
|
3327
|
+
height: 0;
|
3328
|
+
opacity: 1;
|
3329
|
+
}
|
3330
|
+
100% {
|
3331
|
+
width: 40px;
|
3332
|
+
height: 40px;
|
3333
|
+
opacity: 0;
|
3334
|
+
}
|
3335
|
+
}
|
3336
|
+
\`;
|
3337
|
+
document.head.appendChild(style);
|
3338
|
+
}
|
3339
|
+
|
3340
|
+
document.body.appendChild(clickRipple);
|
3341
|
+
|
3342
|
+
// Remove after animation
|
3343
|
+
setTimeout(() => {
|
3344
|
+
if (clickRipple.parentNode) {
|
3345
|
+
clickRipple.parentNode.removeChild(clickRipple);
|
3346
|
+
}
|
3347
|
+
}, 600);
|
3348
|
+
})();
|
3349
|
+
`;
|
3350
|
+
}
|
3351
|
+
|
3352
|
+
// src/puppeteer/base-page.ts
|
3142
3353
|
var debugPage = (0, import_logger5.getDebug)("web:page");
|
3143
3354
|
var Page = class {
|
3144
3355
|
constructor(underlyingPage, pageType, opts) {
|
3356
|
+
this.currentMousePosition = { x: 0, y: 0 };
|
3357
|
+
this.mouseMovementOptions = {
|
3358
|
+
steps: 15,
|
3359
|
+
duration: 300,
|
3360
|
+
easing: "easeInOut",
|
3361
|
+
showVisualFeedback: true
|
3362
|
+
};
|
3363
|
+
this.visualFeedbackOptions = {
|
3364
|
+
pointerSize: 16,
|
3365
|
+
pointerColor: "#ff4444",
|
3366
|
+
trailLength: 4,
|
3367
|
+
showTrail: true,
|
3368
|
+
animationDuration: 150
|
3369
|
+
};
|
3145
3370
|
this.everMoved = false;
|
3146
3371
|
this.underlyingPage = underlyingPage;
|
3147
3372
|
this.pageType = pageType;
|
3148
3373
|
this.waitForNavigationTimeout = opts?.waitForNavigationTimeout ?? import_constants3.DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
3374
|
+
this.initializeMousePosition();
|
3149
3375
|
}
|
3150
3376
|
async evaluate(pageFunction, arg) {
|
3151
3377
|
let result;
|
@@ -3164,9 +3390,76 @@ var Page = class {
|
|
3164
3390
|
debugPage("evaluate function end");
|
3165
3391
|
return result;
|
3166
3392
|
}
|
3393
|
+
/**
|
3394
|
+
* Initialize mouse position to center of viewport
|
3395
|
+
*/
|
3396
|
+
async initializeMousePosition() {
|
3397
|
+
try {
|
3398
|
+
const size = await this.size();
|
3399
|
+
this.currentMousePosition = {
|
3400
|
+
x: Math.floor(size.width / 2),
|
3401
|
+
y: Math.floor(size.height / 2)
|
3402
|
+
};
|
3403
|
+
} catch (error) {
|
3404
|
+
this.currentMousePosition = { x: 400, y: 300 };
|
3405
|
+
}
|
3406
|
+
}
|
3167
3407
|
async evaluateJavaScript(script) {
|
3168
3408
|
return this.evaluate(script);
|
3169
3409
|
}
|
3410
|
+
/**
|
3411
|
+
* Show visual feedback for mouse pointer
|
3412
|
+
*/
|
3413
|
+
async showMousePointer(x, y) {
|
3414
|
+
if (!this.mouseMovementOptions.showVisualFeedback)
|
3415
|
+
return;
|
3416
|
+
const script = getMousePointerScript(x, y, this.visualFeedbackOptions);
|
3417
|
+
try {
|
3418
|
+
await this.evaluate(script);
|
3419
|
+
} catch (error) {
|
3420
|
+
debugPage("Visual feedback error:", error);
|
3421
|
+
}
|
3422
|
+
}
|
3423
|
+
/**
|
3424
|
+
* Show click animation
|
3425
|
+
*/
|
3426
|
+
async showClickAnimation(x, y) {
|
3427
|
+
if (!this.mouseMovementOptions.showVisualFeedback)
|
3428
|
+
return;
|
3429
|
+
const script = getClickAnimationScript(x, y);
|
3430
|
+
try {
|
3431
|
+
await this.evaluate(script);
|
3432
|
+
} catch (error) {
|
3433
|
+
debugPage("Click animation error:", error);
|
3434
|
+
}
|
3435
|
+
}
|
3436
|
+
/**
|
3437
|
+
* Move mouse with human-like movement and visual feedback
|
3438
|
+
*/
|
3439
|
+
async moveMouseHumanLike(toX, toY, options) {
|
3440
|
+
const moveOptions = { ...this.mouseMovementOptions, ...options };
|
3441
|
+
const path = generateHumanMousePath(
|
3442
|
+
this.currentMousePosition,
|
3443
|
+
{ x: toX, y: toY },
|
3444
|
+
moveOptions
|
3445
|
+
);
|
3446
|
+
for (let i = 0; i < path.length; i++) {
|
3447
|
+
const point = path[i];
|
3448
|
+
if (moveOptions.showVisualFeedback) {
|
3449
|
+
await this.showMousePointer(point.x, point.y);
|
3450
|
+
}
|
3451
|
+
await this.underlyingPage.mouse.move(point.x, point.y);
|
3452
|
+
this.currentMousePosition = point;
|
3453
|
+
if (i < path.length - 1) {
|
3454
|
+
const delay = calculateStepDelay(
|
3455
|
+
moveOptions.duration || 300,
|
3456
|
+
i,
|
3457
|
+
path.length
|
3458
|
+
);
|
3459
|
+
await (0, import_utils15.sleep)(delay);
|
3460
|
+
}
|
3461
|
+
}
|
3462
|
+
}
|
3170
3463
|
async waitForNavigation() {
|
3171
3464
|
if (this.pageType === "puppeteer" || this.pageType === "playwright") {
|
3172
3465
|
debugPage("waitForNavigation begin");
|
@@ -3256,7 +3549,8 @@ var Page = class {
|
|
3256
3549
|
return {
|
3257
3550
|
click: async (x, y, options) => {
|
3258
3551
|
await this.mouse.move(x, y);
|
3259
|
-
this.
|
3552
|
+
await this.showClickAnimation(x, y);
|
3553
|
+
await this.underlyingPage.mouse.click(x, y, {
|
3260
3554
|
button: options?.button || "left",
|
3261
3555
|
count: options?.count || 1
|
3262
3556
|
});
|
@@ -3276,27 +3570,23 @@ var Page = class {
|
|
3276
3570
|
},
|
3277
3571
|
move: async (x, y) => {
|
3278
3572
|
this.everMoved = true;
|
3279
|
-
|
3573
|
+
await this.moveMouseHumanLike(x, y);
|
3574
|
+
return Promise.resolve();
|
3280
3575
|
},
|
3281
3576
|
drag: async (from, to) => {
|
3282
3577
|
if (this.pageType === "puppeteer") {
|
3283
|
-
await this.
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3291
|
-
}
|
3292
|
-
);
|
3578
|
+
await this.mouse.move(from.x, from.y);
|
3579
|
+
await this.underlyingPage.mouse.down();
|
3580
|
+
await this.moveMouseHumanLike(to.x, to.y, {
|
3581
|
+
duration: 500,
|
3582
|
+
// Slower for drag operations
|
3583
|
+
steps: 25
|
3584
|
+
});
|
3585
|
+
await this.underlyingPage.mouse.up();
|
3293
3586
|
} else if (this.pageType === "playwright") {
|
3294
|
-
await this.
|
3295
|
-
from.x,
|
3296
|
-
from.y
|
3297
|
-
);
|
3587
|
+
await this.mouse.move(from.x, from.y);
|
3298
3588
|
await this.underlyingPage.mouse.down();
|
3299
|
-
await this.
|
3589
|
+
await this.mouse.move(to.x, to.y);
|
3300
3590
|
await this.underlyingPage.mouse.up();
|
3301
3591
|
}
|
3302
3592
|
}
|
@@ -3359,6 +3649,18 @@ var Page = class {
|
|
3359
3649
|
await this.mouse.move(targetX, targetY);
|
3360
3650
|
}
|
3361
3651
|
}
|
3652
|
+
/**
|
3653
|
+
* Configure mouse movement behavior
|
3654
|
+
*/
|
3655
|
+
configureMouseMovement(options) {
|
3656
|
+
this.mouseMovementOptions = { ...this.mouseMovementOptions, ...options };
|
3657
|
+
}
|
3658
|
+
/**
|
3659
|
+
* Configure visual feedback
|
3660
|
+
*/
|
3661
|
+
configureVisualFeedback(options) {
|
3662
|
+
this.visualFeedbackOptions = { ...this.visualFeedbackOptions, ...options };
|
3663
|
+
}
|
3362
3664
|
async scrollUntilTop(startingPoint) {
|
3363
3665
|
await this.moveToPointBeforeScroll(startingPoint);
|
3364
3666
|
return this.mouse.wheel(0, -9999999);
|