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