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