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