misoai-web 1.6.0 → 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 (71) hide show
  1. package/dist/es/agent.js +108 -50
  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-browser.js.map +1 -1
  5. package/dist/es/bridge-mode.js +110 -52
  6. package/dist/es/bridge-mode.js.map +1 -1
  7. package/dist/es/chrome-extension.js +109 -51
  8. package/dist/es/chrome-extension.js.map +1 -1
  9. package/dist/es/index.js +425 -68
  10. package/dist/es/index.js.map +1 -1
  11. package/dist/es/midscene-playground.js +111 -53
  12. package/dist/es/midscene-playground.js.map +1 -1
  13. package/dist/es/midscene-server.js +4 -4
  14. package/dist/es/midscene-server.js.map +1 -1
  15. package/dist/es/playground.js +108 -50
  16. package/dist/es/playground.js.map +1 -1
  17. package/dist/es/playwright-report.js +1 -1
  18. package/dist/es/playwright-report.js.map +1 -1
  19. package/dist/es/playwright.js +425 -68
  20. package/dist/es/playwright.js.map +1 -1
  21. package/dist/es/puppeteer-agent-launcher.js +424 -67
  22. package/dist/es/puppeteer-agent-launcher.js.map +1 -1
  23. package/dist/es/puppeteer.js +424 -67
  24. package/dist/es/puppeteer.js.map +1 -1
  25. package/dist/es/utils.js +1 -1
  26. package/dist/es/utils.js.map +1 -1
  27. package/dist/es/yaml.js +1 -1
  28. package/dist/es/yaml.js.map +1 -1
  29. package/dist/lib/agent.js +108 -50
  30. package/dist/lib/agent.js.map +1 -1
  31. package/dist/lib/bridge-mode-browser.js +3 -3
  32. package/dist/lib/bridge-mode-browser.js.map +1 -1
  33. package/dist/lib/bridge-mode.js +110 -52
  34. package/dist/lib/bridge-mode.js.map +1 -1
  35. package/dist/lib/chrome-extension.js +109 -51
  36. package/dist/lib/chrome-extension.js.map +1 -1
  37. package/dist/lib/index.js +425 -68
  38. package/dist/lib/index.js.map +1 -1
  39. package/dist/lib/midscene-playground.js +111 -53
  40. package/dist/lib/midscene-playground.js.map +1 -1
  41. package/dist/lib/midscene-server.js +4 -4
  42. package/dist/lib/midscene-server.js.map +1 -1
  43. package/dist/lib/playground.js +108 -50
  44. package/dist/lib/playground.js.map +1 -1
  45. package/dist/lib/playwright-report.js +1 -1
  46. package/dist/lib/playwright-report.js.map +1 -1
  47. package/dist/lib/playwright.js +425 -68
  48. package/dist/lib/playwright.js.map +1 -1
  49. package/dist/lib/puppeteer-agent-launcher.js +424 -67
  50. package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
  51. package/dist/lib/puppeteer.js +424 -67
  52. package/dist/lib/puppeteer.js.map +1 -1
  53. package/dist/lib/utils.js +1 -1
  54. package/dist/lib/utils.js.map +1 -1
  55. package/dist/lib/yaml.js +1 -1
  56. package/dist/lib/yaml.js.map +1 -1
  57. package/dist/types/agent.d.ts +1 -1
  58. package/dist/types/bridge-mode-browser.d.ts +2 -2
  59. package/dist/types/bridge-mode.d.ts +2 -2
  60. package/dist/types/{browser-9b472ffb.d.ts → browser-f205f69d.d.ts} +1 -1
  61. package/dist/types/chrome-extension.d.ts +2 -2
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/midscene-server.d.ts +1 -1
  64. package/dist/types/{page-ed0ecb44.d.ts → page-c5452809.d.ts} +45 -0
  65. package/dist/types/playground.d.ts +2 -2
  66. package/dist/types/playwright.d.ts +2 -2
  67. package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
  68. package/dist/types/puppeteer.d.ts +2 -2
  69. package/dist/types/utils.d.ts +1 -1
  70. package/dist/types/yaml.d.ts +1 -1
  71. package/package.json +18 -54
@@ -22,6 +22,7 @@ var __privateMethod = (obj, member, method) => {
22
22
  };
23
23
 
24
24
  // src/common/utils.ts
25
+ import dayjs from "dayjs";
25
26
  import { elementByPositionWithElementInfo } from "misoai-core/ai-model";
26
27
  import { uploadTestInfoToServer } from "misoai-core/utils";
27
28
  import { MIDSCENE_REPORT_TAG_NAME, getAIConfig } from "misoai-shared/env";
@@ -33,7 +34,6 @@ import {
33
34
  } from "misoai-shared/extractor";
34
35
  import { resizeImgBase64 } from "misoai-shared/img";
35
36
  import { assert, logMsg, uuid } from "misoai-shared/utils";
36
- import dayjs from "dayjs";
37
37
 
38
38
  // src/web-element.ts
39
39
  var WebElementInfo = class {
@@ -452,8 +452,8 @@ var ScriptPlayer = class {
452
452
  import yaml from "js-yaml";
453
453
 
454
454
  // src/yaml/utils.ts
455
- import { assert as assert3 } from "misoai-shared/utils";
456
455
  import yaml2 from "js-yaml";
456
+ import { assert as assert3 } from "misoai-shared/utils";
457
457
  function interpolateEnvVars(content) {
458
458
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
459
459
  const value = process.env[envVar.trim()];
@@ -667,8 +667,12 @@ var WorkflowMemory = class {
667
667
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
668
668
  workflow.memory = [...memory];
669
669
  workflow.metadata.totalSteps = workflow.steps.length;
670
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
671
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
670
+ workflow.metadata.completedSteps = workflow.steps.filter(
671
+ (s) => s.status === "completed"
672
+ ).length;
673
+ workflow.metadata.failedSteps = workflow.steps.filter(
674
+ (s) => s.status === "failed"
675
+ ).length;
672
676
  this.workflows.set(workflowId, workflow);
673
677
  this.enforceRetentionPolicy();
674
678
  }
@@ -679,7 +683,9 @@ var WorkflowMemory = class {
679
683
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
680
684
  workflow.context = { ...workflow.context, ...context };
681
685
  if (context.currentStep) {
682
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
686
+ const existingStep = workflow.steps.find(
687
+ (s) => s.stepName === context.currentStep
688
+ );
683
689
  if (!existingStep) {
684
690
  workflow.steps.push({
685
691
  stepId: `step_${workflow.steps.length + 1}`,
@@ -724,7 +730,9 @@ var WorkflowMemory = class {
724
730
  enforceRetentionPolicy() {
725
731
  const maxWorkflows = 10;
726
732
  if (this.workflows.size > maxWorkflows) {
727
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
733
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
734
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
735
+ );
728
736
  const toDelete = sortedWorkflows.slice(maxWorkflows);
729
737
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
730
738
  }
@@ -1291,6 +1299,7 @@ var PageTaskExecutor = class {
1291
1299
  actions: [],
1292
1300
  more_actions_needed_by_instruction: false,
1293
1301
  log: "",
1302
+ summary: "Loaded YAML workflow configuration",
1294
1303
  yamlString
1295
1304
  },
1296
1305
  cache: {
@@ -1392,6 +1401,7 @@ var PageTaskExecutor = class {
1392
1401
  actions: finalActions,
1393
1402
  more_actions_needed_by_instruction,
1394
1403
  log: log2,
1404
+ summary: planResult.summary || "Generated action plan from user instruction",
1395
1405
  yamlFlow: planResult.yamlFlow
1396
1406
  },
1397
1407
  cache: {
@@ -1447,6 +1457,7 @@ var PageTaskExecutor = class {
1447
1457
  actionType: actions[0].type,
1448
1458
  more_actions_needed_by_instruction: true,
1449
1459
  log: "",
1460
+ summary: action_summary || "Generated VLM action plan",
1450
1461
  yamlFlow: planResult.yamlFlow
1451
1462
  },
1452
1463
  cache: {
@@ -1463,7 +1474,9 @@ var PageTaskExecutor = class {
1463
1474
  */
1464
1475
  getPersistentExecutor() {
1465
1476
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1466
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1477
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1478
+ this.sessionContext.workflowId
1479
+ );
1467
1480
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1468
1481
  onTaskStart: this.onTaskStartCallback,
1469
1482
  initialMemory: previousMemory
@@ -1492,7 +1505,9 @@ var PageTaskExecutor = class {
1492
1505
  if (this.persistentExecutor) {
1493
1506
  this.persistentExecutor.clearMemory();
1494
1507
  }
1495
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1508
+ this.workflowMemory.clearWorkflow(
1509
+ this.sessionContext.workflowId || "default"
1510
+ );
1496
1511
  }
1497
1512
  /**
1498
1513
  * Mevcut hafızayı döndürür
@@ -1504,7 +1519,9 @@ var PageTaskExecutor = class {
1504
1519
  * İş akışı hafızasını döndürür
1505
1520
  */
1506
1521
  getWorkflowMemory() {
1507
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1522
+ return this.workflowMemory.getWorkflowData(
1523
+ this.sessionContext.workflowId || "default"
1524
+ );
1508
1525
  }
1509
1526
  /**
1510
1527
  * Hafıza istatistiklerini döndürür
@@ -1512,7 +1529,13 @@ var PageTaskExecutor = class {
1512
1529
  getMemoryStats() {
1513
1530
  return this.persistentExecutor?.getMemoryStats() || {
1514
1531
  totalItems: 0,
1515
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1532
+ analytics: {
1533
+ totalTasks: 0,
1534
+ memoryHits: 0,
1535
+ memoryMisses: 0,
1536
+ averageMemorySize: 0,
1537
+ memoryEffectiveness: 0
1538
+ },
1516
1539
  config: this.memoryConfig
1517
1540
  };
1518
1541
  }
@@ -1548,11 +1571,14 @@ var PageTaskExecutor = class {
1548
1571
  let taskExecutor;
1549
1572
  if (useMemory) {
1550
1573
  taskExecutor = this.getPersistentExecutor();
1551
- this.workflowMemory.updateWorkflowContext({
1552
- currentStep: title,
1553
- pageInfo: this.sessionContext.pageInfo,
1554
- timestamp: Date.now()
1555
- }, this.sessionContext.workflowId || "default");
1574
+ this.workflowMemory.updateWorkflowContext(
1575
+ {
1576
+ currentStep: title,
1577
+ pageInfo: this.sessionContext.pageInfo,
1578
+ timestamp: Date.now()
1579
+ },
1580
+ this.sessionContext.workflowId || "default"
1581
+ );
1556
1582
  } else {
1557
1583
  taskExecutor = new Executor(title, {
1558
1584
  onTaskStart: this.onTaskStartCallback
@@ -1918,14 +1944,19 @@ var PageTaskExecutor = class {
1918
1944
  */
1919
1945
  addToMemory(memoryItem) {
1920
1946
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1921
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1947
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1948
+ this.sessionContext.workflowId
1949
+ );
1922
1950
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1923
1951
  onTaskStart: this.onTaskStartCallback,
1924
1952
  initialMemory: previousMemory
1925
1953
  });
1926
1954
  }
1927
1955
  this.persistentExecutor.memoryStore?.add(memoryItem);
1928
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1956
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1957
+ "add",
1958
+ memoryItem
1959
+ );
1929
1960
  }
1930
1961
  };
1931
1962
 
@@ -2014,14 +2045,14 @@ function buildPlans(type, locateParam, param) {
2014
2045
  import assert6 from "assert";
2015
2046
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
2016
2047
  import { dirname as dirname2, join as join2 } from "path";
2048
+ import yaml3 from "js-yaml";
2017
2049
  import { getMidsceneRunSubDir as getMidsceneRunSubDir2 } from "misoai-shared/common";
2018
2050
  import { getDebug as getDebug3 } from "misoai-shared/logger";
2019
2051
  import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
2020
- import yaml3 from "js-yaml";
2021
2052
  import semver from "semver";
2022
2053
 
2023
2054
  // package.json
2024
- var version = "1.6.0";
2055
+ var version = "1.6.2";
2025
2056
 
2026
2057
  // src/common/task-cache.ts
2027
2058
  var debug3 = getDebug3("cache");
@@ -2316,22 +2347,28 @@ var PageAgent = class {
2316
2347
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2317
2348
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2318
2349
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2319
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2320
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2350
+ const planningTasks = executor.tasks.filter(
2351
+ (task) => task.type === "Planning"
2352
+ );
2353
+ const insightTasks = executor.tasks.filter(
2354
+ (task) => task.type === "Insight"
2355
+ );
2321
2356
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2322
2357
  const planning = planningTasks.length > 0 ? {
2323
2358
  type: "Planning",
2324
- description: `Planning for task execution`,
2359
+ description: "Planning for task execution",
2325
2360
  steps: planningTasks.map((task) => task.thought || "Planning step")
2326
2361
  } : void 0;
2327
2362
  const insight = insightTasks.length > 0 ? {
2328
2363
  type: "Insight",
2329
- description: `Insight for task execution`,
2330
- elements: insightTasks.map((task) => task.thought || "Insight element")
2364
+ description: "Insight for task execution",
2365
+ elements: insightTasks.map(
2366
+ (task) => task.thought || "Insight element"
2367
+ )
2331
2368
  } : void 0;
2332
2369
  const action = actionTasks.length > 0 ? {
2333
2370
  type: "Action",
2334
- description: `Action for task execution`,
2371
+ description: "Action for task execution",
2335
2372
  result: lastTask?.output
2336
2373
  } : void 0;
2337
2374
  const actionDetails = executor.tasks.map((task) => ({
@@ -2665,7 +2702,10 @@ ${memoryContext}` : void 0;
2665
2702
  }
2666
2703
  const memoryContext = this.getMemoryAsContext();
2667
2704
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2668
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2705
+ const { output, executor } = await this.taskExecutor.assert(
2706
+ assertionWithContext,
2707
+ memoryContext
2708
+ );
2669
2709
  const metadata = this.afterTaskRunning(executor, true);
2670
2710
  if (output && opt?.keepRawResponse) {
2671
2711
  return {
@@ -2704,7 +2744,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2704
2744
  Return only "complex" or "simple" based on your analysis.
2705
2745
  `;
2706
2746
  const complexityMsgs = [
2707
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2747
+ {
2748
+ role: "system",
2749
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2750
+ },
2708
2751
  {
2709
2752
  role: "user",
2710
2753
  content: [
@@ -2728,7 +2771,12 @@ Return only "complex" or "simple" based on your analysis.
2728
2771
  );
2729
2772
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2730
2773
  shouldUseDeepThink = responseText.includes("complex");
2731
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2774
+ debug4(
2775
+ "CAPTCHA complexity analysis:",
2776
+ responseText,
2777
+ "Using deep think:",
2778
+ shouldUseDeepThink
2779
+ );
2732
2780
  } catch (error) {
2733
2781
  debug4("Failed to analyze CAPTCHA complexity:", error);
2734
2782
  }
@@ -2745,7 +2793,9 @@ Return only "complex" or "simple" based on your analysis.
2745
2793
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2746
2794
  } else if (action.type === "input" && action.value) {
2747
2795
  if (action.target) {
2748
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2796
+ await this.aiInput(action.value, action.target, {
2797
+ deepThink: shouldUseDeepThink
2798
+ });
2749
2799
  }
2750
2800
  } else if (action.type === "verify" && action.target) {
2751
2801
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2757,7 +2807,9 @@ Return only "complex" or "simple" based on your analysis.
2757
2807
  if (action.coordinates) {
2758
2808
  const x = action.coordinates[0];
2759
2809
  const y = action.coordinates[1];
2760
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2810
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2811
+ deepThink: shouldUseDeepThink
2812
+ });
2761
2813
  } else if (action.target) {
2762
2814
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2763
2815
  }
@@ -2909,25 +2961,27 @@ ${errors}`);
2909
2961
  const executionDump = {
2910
2962
  name: screenshotTitle,
2911
2963
  description: content,
2912
- tasks: [{
2913
- type: "Screenshot",
2914
- subType: "log",
2915
- status: "finished",
2916
- executor: null,
2917
- param: {
2918
- title: screenshotTitle,
2919
- content
2920
- },
2921
- output: {
2922
- screenshot
2923
- },
2924
- thought: `Logged screenshot: ${screenshotTitle}`,
2925
- timing: {
2926
- start: Date.now(),
2927
- end: Date.now(),
2928
- cost: 0
2964
+ tasks: [
2965
+ {
2966
+ type: "Screenshot",
2967
+ subType: "log",
2968
+ status: "finished",
2969
+ executor: null,
2970
+ param: {
2971
+ title: screenshotTitle,
2972
+ content
2973
+ },
2974
+ output: {
2975
+ screenshot
2976
+ },
2977
+ thought: `Logged screenshot: ${screenshotTitle}`,
2978
+ timing: {
2979
+ start: Date.now(),
2980
+ end: Date.now(),
2981
+ cost: 0
2982
+ }
2929
2983
  }
2930
- }],
2984
+ ],
2931
2985
  sdkVersion: "1.0.0",
2932
2986
  logTime: Date.now(),
2933
2987
  model_name: "screenshot"
@@ -2979,7 +3033,9 @@ ${errors}`);
2979
3033
  totalTasks: stats.analytics.totalTasks,
2980
3034
  memoryHits: stats.analytics.memoryHits,
2981
3035
  memoryMisses: stats.analytics.memoryMisses,
2982
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
3036
+ memoryEffectiveness: Math.round(
3037
+ stats.analytics.memoryEffectiveness * 100
3038
+ ),
2983
3039
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2984
3040
  },
2985
3041
  config: stats.config,
@@ -3043,7 +3099,9 @@ ${errors}`);
3043
3099
  calculateSuccessRate(memory) {
3044
3100
  if (memory.length === 0)
3045
3101
  return 0;
3046
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3102
+ const successCount = memory.filter(
3103
+ (item) => item.metadata?.success !== false
3104
+ ).length;
3047
3105
  return Math.round(successCount / memory.length * 100);
3048
3106
  }
3049
3107
  calculateAverageExecutionTime(memory) {
@@ -3289,7 +3347,7 @@ function sleep2(ms) {
3289
3347
  var ChromeExtensionProxyPage = class {
3290
3348
  constructor(forceSameTabNavigation) {
3291
3349
  this.pageType = "chrome-extension-proxy";
3292
- this.version = "1.6.0";
3350
+ this.version = "1.6.2";
3293
3351
  this.activeTabId = null;
3294
3352
  this.tabIdOfDebuggerAttached = null;
3295
3353
  this.attachingDebugger = null;