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.
Files changed (53) hide show
  1. package/dist/es/agent.js +4 -1
  2. package/dist/es/agent.js.map +1 -1
  3. package/dist/es/bridge-mode-browser.js +3 -3
  4. package/dist/es/bridge-mode.js +6 -3
  5. package/dist/es/bridge-mode.js.map +1 -1
  6. package/dist/es/chrome-extension.js +5 -2
  7. package/dist/es/chrome-extension.js.map +1 -1
  8. package/dist/es/index.js +320 -18
  9. package/dist/es/index.js.map +1 -1
  10. package/dist/es/midscene-playground.js +4 -1
  11. package/dist/es/midscene-playground.js.map +1 -1
  12. package/dist/es/playground.js +4 -1
  13. package/dist/es/playground.js.map +1 -1
  14. package/dist/es/playwright.js +320 -18
  15. package/dist/es/playwright.js.map +1 -1
  16. package/dist/es/puppeteer-agent-launcher.js +320 -18
  17. package/dist/es/puppeteer-agent-launcher.js.map +1 -1
  18. package/dist/es/puppeteer.js +320 -18
  19. package/dist/es/puppeteer.js.map +1 -1
  20. package/dist/lib/agent.js +4 -1
  21. package/dist/lib/agent.js.map +1 -1
  22. package/dist/lib/bridge-mode-browser.js +3 -3
  23. package/dist/lib/bridge-mode.js +6 -3
  24. package/dist/lib/bridge-mode.js.map +1 -1
  25. package/dist/lib/chrome-extension.js +5 -2
  26. package/dist/lib/chrome-extension.js.map +1 -1
  27. package/dist/lib/index.js +320 -18
  28. package/dist/lib/index.js.map +1 -1
  29. package/dist/lib/midscene-playground.js +4 -1
  30. package/dist/lib/midscene-playground.js.map +1 -1
  31. package/dist/lib/playground.js +4 -1
  32. package/dist/lib/playground.js.map +1 -1
  33. package/dist/lib/playwright.js +320 -18
  34. package/dist/lib/playwright.js.map +1 -1
  35. package/dist/lib/puppeteer-agent-launcher.js +320 -18
  36. package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
  37. package/dist/lib/puppeteer.js +320 -18
  38. package/dist/lib/puppeteer.js.map +1 -1
  39. package/dist/types/agent.d.ts +1 -1
  40. package/dist/types/bridge-mode-browser.d.ts +2 -2
  41. package/dist/types/bridge-mode.d.ts +2 -2
  42. package/dist/types/{browser-9b472ffb.d.ts → browser-f205f69d.d.ts} +1 -1
  43. package/dist/types/chrome-extension.d.ts +2 -2
  44. package/dist/types/index.d.ts +1 -1
  45. package/dist/types/midscene-server.d.ts +1 -1
  46. package/dist/types/{page-ed0ecb44.d.ts → page-c5452809.d.ts} +45 -0
  47. package/dist/types/playground.d.ts +2 -2
  48. package/dist/types/playwright.d.ts +1 -1
  49. package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
  50. package/dist/types/puppeteer.d.ts +2 -2
  51. package/dist/types/utils.d.ts +1 -1
  52. package/dist/types/yaml.d.ts +1 -1
  53. package/package.json +2 -2
@@ -1280,6 +1280,7 @@ var PageTaskExecutor = class {
1280
1280
  actions: [],
1281
1281
  more_actions_needed_by_instruction: false,
1282
1282
  log: "",
1283
+ summary: "Loaded YAML workflow configuration",
1283
1284
  yamlString
1284
1285
  },
1285
1286
  cache: {
@@ -1381,6 +1382,7 @@ var PageTaskExecutor = class {
1381
1382
  actions: finalActions,
1382
1383
  more_actions_needed_by_instruction,
1383
1384
  log: log2,
1385
+ summary: planResult.summary || "Generated action plan from user instruction",
1384
1386
  yamlFlow: planResult.yamlFlow
1385
1387
  },
1386
1388
  cache: {
@@ -1436,6 +1438,7 @@ var PageTaskExecutor = class {
1436
1438
  actionType: actions[0].type,
1437
1439
  more_actions_needed_by_instruction: true,
1438
1440
  log: "",
1441
+ summary: action_summary || "Generated VLM action plan",
1439
1442
  yamlFlow: planResult.yamlFlow
1440
1443
  },
1441
1444
  cache: {
@@ -2030,7 +2033,7 @@ import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
2030
2033
  import semver from "semver";
2031
2034
 
2032
2035
  // package.json
2033
- var version = "1.6.1";
2036
+ var version = "1.6.2";
2034
2037
 
2035
2038
  // src/common/task-cache.ts
2036
2039
  var debug3 = getDebug3("cache");
@@ -3129,13 +3132,236 @@ import {
3129
3132
  } from "misoai-shared/fs";
3130
3133
  import { getDebug as getDebug5 } from "misoai-shared/logger";
3131
3134
  import { assert as assert8 } from "misoai-shared/utils";
3135
+
3136
+ // src/common/mouse-utils.ts
3137
+ function generateHumanMousePath(from, to, options = {}) {
3138
+ const {
3139
+ steps = 20,
3140
+ easing = "easeInOut"
3141
+ } = options;
3142
+ if (steps <= 1) {
3143
+ return [to];
3144
+ }
3145
+ const path = [];
3146
+ const controlPoint1 = {
3147
+ x: from.x + (to.x - from.x) * 0.25 + (Math.random() - 0.5) * 50,
3148
+ y: from.y + (to.y - from.y) * 0.25 + (Math.random() - 0.5) * 50
3149
+ };
3150
+ const controlPoint2 = {
3151
+ x: from.x + (to.x - from.x) * 0.75 + (Math.random() - 0.5) * 50,
3152
+ y: from.y + (to.y - from.y) * 0.75 + (Math.random() - 0.5) * 50
3153
+ };
3154
+ for (let i = 0; i <= steps; i++) {
3155
+ const t = i / steps;
3156
+ const easedT = applyEasing(t, easing);
3157
+ const point = calculateBezierPoint(from, controlPoint1, controlPoint2, to, easedT);
3158
+ path.push(point);
3159
+ }
3160
+ return path;
3161
+ }
3162
+ function calculateBezierPoint(p0, p1, p2, p3, t) {
3163
+ const oneMinusT = 1 - t;
3164
+ const oneMinusTSquared = oneMinusT * oneMinusT;
3165
+ const oneMinusTCubed = oneMinusTSquared * oneMinusT;
3166
+ const tSquared = t * t;
3167
+ const tCubed = tSquared * t;
3168
+ return {
3169
+ x: oneMinusTCubed * p0.x + 3 * oneMinusTSquared * t * p1.x + 3 * oneMinusT * tSquared * p2.x + tCubed * p3.x,
3170
+ y: oneMinusTCubed * p0.y + 3 * oneMinusTSquared * t * p1.y + 3 * oneMinusT * tSquared * p2.y + tCubed * p3.y
3171
+ };
3172
+ }
3173
+ function applyEasing(t, easing) {
3174
+ switch (easing) {
3175
+ case "linear":
3176
+ return t;
3177
+ case "easeIn":
3178
+ return t * t;
3179
+ case "easeOut":
3180
+ return 1 - (1 - t) * (1 - t);
3181
+ case "easeInOut":
3182
+ return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
3183
+ default:
3184
+ return t;
3185
+ }
3186
+ }
3187
+ function calculateStepDelay(totalDuration, currentStep, totalSteps) {
3188
+ const baseDelay = totalDuration / totalSteps;
3189
+ const variation = 0.3;
3190
+ const randomFactor = 1 + (Math.random() - 0.5) * variation;
3191
+ return Math.max(1, baseDelay * randomFactor);
3192
+ }
3193
+
3194
+ // src/common/visual-feedback.ts
3195
+ function getMousePointerScript(x, y, options = {}) {
3196
+ const {
3197
+ pointerSize = 20,
3198
+ pointerColor = "#ff4444",
3199
+ trailLength = 5,
3200
+ showTrail = true,
3201
+ animationDuration = 200
3202
+ } = options;
3203
+ return `
3204
+ (() => {
3205
+ // Create or update mouse pointer
3206
+ if (!window.misoaiMousePointer) {
3207
+ const pointer = document.createElement('div');
3208
+ pointer.id = 'misoai-mouse-pointer';
3209
+ pointer.style.cssText = \`
3210
+ position: fixed;
3211
+ width: ${pointerSize}px;
3212
+ height: ${pointerSize}px;
3213
+ background: ${pointerColor};
3214
+ border: 2px solid white;
3215
+ border-radius: 50%;
3216
+ pointer-events: none;
3217
+ z-index: 999999;
3218
+ box-shadow: 0 0 10px rgba(0,0,0,0.3);
3219
+ transition: all ${animationDuration}ms ease-out;
3220
+ transform: translate(-50%, -50%);
3221
+ \`;
3222
+ document.body.appendChild(pointer);
3223
+ window.misoaiMousePointer = pointer;
3224
+
3225
+ // Initialize trail array
3226
+ window.misoaiMouseTrail = [];
3227
+ }
3228
+
3229
+ const pointer = window.misoaiMousePointer;
3230
+ pointer.style.left = ${x}px;
3231
+ pointer.style.top = ${y}px;
3232
+
3233
+ ${showTrail ? getTrailScript(x, y, trailLength, pointerColor) : ""}
3234
+
3235
+ // Auto-hide after 3 seconds of inactivity
3236
+ clearTimeout(window.misoaiMouseTimeout);
3237
+ pointer.style.opacity = '1';
3238
+ window.misoaiMouseTimeout = setTimeout(() => {
3239
+ if (pointer) pointer.style.opacity = '0.3';
3240
+ }, 3000);
3241
+ })();
3242
+ `;
3243
+ }
3244
+ function getTrailScript(x, y, trailLength, color) {
3245
+ return `
3246
+ // Add current position to trail
3247
+ window.misoaiMouseTrail.push({ x: ${x}, y: ${y}, timestamp: Date.now() });
3248
+
3249
+ // Keep only recent trail points
3250
+ if (window.misoaiMouseTrail.length > ${trailLength}) {
3251
+ window.misoaiMouseTrail.shift();
3252
+ }
3253
+
3254
+ // Remove old trail elements
3255
+ document.querySelectorAll('.misoai-mouse-trail').forEach(el => el.remove());
3256
+
3257
+ // Create new trail elements
3258
+ window.misoaiMouseTrail.forEach((point, index) => {
3259
+ if (index === window.misoaiMouseTrail.length - 1) return; // Skip current position
3260
+
3261
+ const trailElement = document.createElement('div');
3262
+ trailElement.className = 'misoai-mouse-trail';
3263
+ const opacity = (index + 1) / window.misoaiMouseTrail.length * 0.6;
3264
+ const size = 8 + (index + 1) / window.misoaiMouseTrail.length * 8;
3265
+
3266
+ trailElement.style.cssText = \`
3267
+ position: fixed;
3268
+ width: \${size}px;
3269
+ height: \${size}px;
3270
+ background: ${color};
3271
+ border-radius: 50%;
3272
+ pointer-events: none;
3273
+ z-index: 999998;
3274
+ opacity: \${opacity};
3275
+ transform: translate(-50%, -50%);
3276
+ left: \${point.x}px;
3277
+ top: \${point.y}px;
3278
+ \`;
3279
+
3280
+ document.body.appendChild(trailElement);
3281
+
3282
+ // Auto-remove trail element after animation
3283
+ setTimeout(() => {
3284
+ if (trailElement.parentNode) {
3285
+ trailElement.parentNode.removeChild(trailElement);
3286
+ }
3287
+ }, 1000);
3288
+ });
3289
+ `;
3290
+ }
3291
+ function getClickAnimationScript(x, y) {
3292
+ return `
3293
+ (() => {
3294
+ const clickRipple = document.createElement('div');
3295
+ clickRipple.style.cssText = \`
3296
+ position: fixed;
3297
+ left: ${x}px;
3298
+ top: ${y}px;
3299
+ width: 0;
3300
+ height: 0;
3301
+ border: 2px solid #ff4444;
3302
+ border-radius: 50%;
3303
+ pointer-events: none;
3304
+ z-index: 999999;
3305
+ transform: translate(-50%, -50%);
3306
+ animation: misoai-click-ripple 0.6s ease-out forwards;
3307
+ \`;
3308
+
3309
+ // Add CSS animation if not exists
3310
+ if (!document.getElementById('misoai-click-styles')) {
3311
+ const style = document.createElement('style');
3312
+ style.id = 'misoai-click-styles';
3313
+ style.textContent = \`
3314
+ @keyframes misoai-click-ripple {
3315
+ 0% {
3316
+ width: 0;
3317
+ height: 0;
3318
+ opacity: 1;
3319
+ }
3320
+ 100% {
3321
+ width: 40px;
3322
+ height: 40px;
3323
+ opacity: 0;
3324
+ }
3325
+ }
3326
+ \`;
3327
+ document.head.appendChild(style);
3328
+ }
3329
+
3330
+ document.body.appendChild(clickRipple);
3331
+
3332
+ // Remove after animation
3333
+ setTimeout(() => {
3334
+ if (clickRipple.parentNode) {
3335
+ clickRipple.parentNode.removeChild(clickRipple);
3336
+ }
3337
+ }, 600);
3338
+ })();
3339
+ `;
3340
+ }
3341
+
3342
+ // src/puppeteer/base-page.ts
3132
3343
  var debugPage = getDebug5("web:page");
3133
3344
  var Page = class {
3134
3345
  constructor(underlyingPage, pageType, opts) {
3346
+ this.currentMousePosition = { x: 0, y: 0 };
3347
+ this.mouseMovementOptions = {
3348
+ steps: 15,
3349
+ duration: 300,
3350
+ easing: "easeInOut",
3351
+ showVisualFeedback: true
3352
+ };
3353
+ this.visualFeedbackOptions = {
3354
+ pointerSize: 16,
3355
+ pointerColor: "#ff4444",
3356
+ trailLength: 4,
3357
+ showTrail: true,
3358
+ animationDuration: 150
3359
+ };
3135
3360
  this.everMoved = false;
3136
3361
  this.underlyingPage = underlyingPage;
3137
3362
  this.pageType = pageType;
3138
3363
  this.waitForNavigationTimeout = opts?.waitForNavigationTimeout ?? DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT2;
3364
+ this.initializeMousePosition();
3139
3365
  }
3140
3366
  async evaluate(pageFunction, arg) {
3141
3367
  let result;
@@ -3154,9 +3380,76 @@ var Page = class {
3154
3380
  debugPage("evaluate function end");
3155
3381
  return result;
3156
3382
  }
3383
+ /**
3384
+ * Initialize mouse position to center of viewport
3385
+ */
3386
+ async initializeMousePosition() {
3387
+ try {
3388
+ const size = await this.size();
3389
+ this.currentMousePosition = {
3390
+ x: Math.floor(size.width / 2),
3391
+ y: Math.floor(size.height / 2)
3392
+ };
3393
+ } catch (error) {
3394
+ this.currentMousePosition = { x: 400, y: 300 };
3395
+ }
3396
+ }
3157
3397
  async evaluateJavaScript(script) {
3158
3398
  return this.evaluate(script);
3159
3399
  }
3400
+ /**
3401
+ * Show visual feedback for mouse pointer
3402
+ */
3403
+ async showMousePointer(x, y) {
3404
+ if (!this.mouseMovementOptions.showVisualFeedback)
3405
+ return;
3406
+ const script = getMousePointerScript(x, y, this.visualFeedbackOptions);
3407
+ try {
3408
+ await this.evaluate(script);
3409
+ } catch (error) {
3410
+ debugPage("Visual feedback error:", error);
3411
+ }
3412
+ }
3413
+ /**
3414
+ * Show click animation
3415
+ */
3416
+ async showClickAnimation(x, y) {
3417
+ if (!this.mouseMovementOptions.showVisualFeedback)
3418
+ return;
3419
+ const script = getClickAnimationScript(x, y);
3420
+ try {
3421
+ await this.evaluate(script);
3422
+ } catch (error) {
3423
+ debugPage("Click animation error:", error);
3424
+ }
3425
+ }
3426
+ /**
3427
+ * Move mouse with human-like movement and visual feedback
3428
+ */
3429
+ async moveMouseHumanLike(toX, toY, options) {
3430
+ const moveOptions = { ...this.mouseMovementOptions, ...options };
3431
+ const path = generateHumanMousePath(
3432
+ this.currentMousePosition,
3433
+ { x: toX, y: toY },
3434
+ moveOptions
3435
+ );
3436
+ for (let i = 0; i < path.length; i++) {
3437
+ const point = path[i];
3438
+ if (moveOptions.showVisualFeedback) {
3439
+ await this.showMousePointer(point.x, point.y);
3440
+ }
3441
+ await this.underlyingPage.mouse.move(point.x, point.y);
3442
+ this.currentMousePosition = point;
3443
+ if (i < path.length - 1) {
3444
+ const delay = calculateStepDelay(
3445
+ moveOptions.duration || 300,
3446
+ i,
3447
+ path.length
3448
+ );
3449
+ await sleep2(delay);
3450
+ }
3451
+ }
3452
+ }
3160
3453
  async waitForNavigation() {
3161
3454
  if (this.pageType === "puppeteer" || this.pageType === "playwright") {
3162
3455
  debugPage("waitForNavigation begin");
@@ -3246,7 +3539,8 @@ var Page = class {
3246
3539
  return {
3247
3540
  click: async (x, y, options) => {
3248
3541
  await this.mouse.move(x, y);
3249
- this.underlyingPage.mouse.click(x, y, {
3542
+ await this.showClickAnimation(x, y);
3543
+ await this.underlyingPage.mouse.click(x, y, {
3250
3544
  button: options?.button || "left",
3251
3545
  count: options?.count || 1
3252
3546
  });
@@ -3266,27 +3560,23 @@ var Page = class {
3266
3560
  },
3267
3561
  move: async (x, y) => {
3268
3562
  this.everMoved = true;
3269
- return this.underlyingPage.mouse.move(x, y);
3563
+ await this.moveMouseHumanLike(x, y);
3564
+ return Promise.resolve();
3270
3565
  },
3271
3566
  drag: async (from, to) => {
3272
3567
  if (this.pageType === "puppeteer") {
3273
- await this.underlyingPage.mouse.drag(
3274
- {
3275
- x: from.x,
3276
- y: from.y
3277
- },
3278
- {
3279
- x: to.x,
3280
- y: to.y
3281
- }
3282
- );
3568
+ await this.mouse.move(from.x, from.y);
3569
+ await this.underlyingPage.mouse.down();
3570
+ await this.moveMouseHumanLike(to.x, to.y, {
3571
+ duration: 500,
3572
+ // Slower for drag operations
3573
+ steps: 25
3574
+ });
3575
+ await this.underlyingPage.mouse.up();
3283
3576
  } else if (this.pageType === "playwright") {
3284
- await this.underlyingPage.mouse.move(
3285
- from.x,
3286
- from.y
3287
- );
3577
+ await this.mouse.move(from.x, from.y);
3288
3578
  await this.underlyingPage.mouse.down();
3289
- await this.underlyingPage.mouse.move(to.x, to.y);
3579
+ await this.mouse.move(to.x, to.y);
3290
3580
  await this.underlyingPage.mouse.up();
3291
3581
  }
3292
3582
  }
@@ -3349,6 +3639,18 @@ var Page = class {
3349
3639
  await this.mouse.move(targetX, targetY);
3350
3640
  }
3351
3641
  }
3642
+ /**
3643
+ * Configure mouse movement behavior
3644
+ */
3645
+ configureMouseMovement(options) {
3646
+ this.mouseMovementOptions = { ...this.mouseMovementOptions, ...options };
3647
+ }
3648
+ /**
3649
+ * Configure visual feedback
3650
+ */
3651
+ configureVisualFeedback(options) {
3652
+ this.visualFeedbackOptions = { ...this.visualFeedbackOptions, ...options };
3653
+ }
3352
3654
  async scrollUntilTop(startingPoint) {
3353
3655
  await this.moveToPointBeforeScroll(startingPoint);
3354
3656
  return this.mouse.wheel(0, -9999999);