misoai-web 1.6.0 → 1.6.1

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 (59) hide show
  1. package/dist/es/agent.js +105 -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 +107 -52
  6. package/dist/es/bridge-mode.js.map +1 -1
  7. package/dist/es/chrome-extension.js +106 -51
  8. package/dist/es/chrome-extension.js.map +1 -1
  9. package/dist/es/index.js +106 -51
  10. package/dist/es/index.js.map +1 -1
  11. package/dist/es/midscene-playground.js +108 -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 +105 -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 +106 -51
  20. package/dist/es/playwright.js.map +1 -1
  21. package/dist/es/puppeteer-agent-launcher.js +105 -50
  22. package/dist/es/puppeteer-agent-launcher.js.map +1 -1
  23. package/dist/es/puppeteer.js +105 -50
  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 +105 -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 +107 -52
  34. package/dist/lib/bridge-mode.js.map +1 -1
  35. package/dist/lib/chrome-extension.js +106 -51
  36. package/dist/lib/chrome-extension.js.map +1 -1
  37. package/dist/lib/index.js +106 -51
  38. package/dist/lib/index.js.map +1 -1
  39. package/dist/lib/midscene-playground.js +108 -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 +105 -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 +106 -51
  48. package/dist/lib/playwright.js.map +1 -1
  49. package/dist/lib/puppeteer-agent-launcher.js +105 -50
  50. package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
  51. package/dist/lib/puppeteer.js +105 -50
  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/index.d.ts +1 -1
  58. package/dist/types/playwright.d.ts +1 -1
  59. package/package.json +18 -54
@@ -344,8 +344,8 @@ var ScriptPlayer = class {
344
344
  var import_js_yaml = __toESM(require("js-yaml"));
345
345
 
346
346
  // src/yaml/utils.ts
347
- var import_utils2 = require("misoai-shared/utils");
348
347
  var import_js_yaml2 = __toESM(require("js-yaml"));
348
+ var import_utils2 = require("misoai-shared/utils");
349
349
  function interpolateEnvVars(content) {
350
350
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
351
351
  const value = process.env[envVar.trim()];
@@ -491,13 +491,13 @@ function paramStr(task) {
491
491
  }
492
492
 
493
493
  // src/common/utils.ts
494
+ var import_dayjs = __toESM(require("dayjs"));
494
495
  var import_ai_model = require("misoai-core/ai-model");
495
496
  var import_utils3 = require("misoai-core/utils");
496
497
  var import_env = require("misoai-shared/env");
497
498
  var import_extractor = require("misoai-shared/extractor");
498
499
  var import_img = require("misoai-shared/img");
499
500
  var import_utils4 = require("misoai-shared/utils");
500
- var import_dayjs = __toESM(require("dayjs"));
501
501
 
502
502
  // src/web-element.ts
503
503
  var WebElementInfo = class {
@@ -666,8 +666,12 @@ var WorkflowMemory = class {
666
666
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
667
667
  workflow.memory = [...memory];
668
668
  workflow.metadata.totalSteps = workflow.steps.length;
669
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
670
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
669
+ workflow.metadata.completedSteps = workflow.steps.filter(
670
+ (s) => s.status === "completed"
671
+ ).length;
672
+ workflow.metadata.failedSteps = workflow.steps.filter(
673
+ (s) => s.status === "failed"
674
+ ).length;
671
675
  this.workflows.set(workflowId, workflow);
672
676
  this.enforceRetentionPolicy();
673
677
  }
@@ -678,7 +682,9 @@ var WorkflowMemory = class {
678
682
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
679
683
  workflow.context = { ...workflow.context, ...context };
680
684
  if (context.currentStep) {
681
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
685
+ const existingStep = workflow.steps.find(
686
+ (s) => s.stepName === context.currentStep
687
+ );
682
688
  if (!existingStep) {
683
689
  workflow.steps.push({
684
690
  stepId: `step_${workflow.steps.length + 1}`,
@@ -723,7 +729,9 @@ var WorkflowMemory = class {
723
729
  enforceRetentionPolicy() {
724
730
  const maxWorkflows = 10;
725
731
  if (this.workflows.size > maxWorkflows) {
726
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
732
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
733
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
734
+ );
727
735
  const toDelete = sortedWorkflows.slice(maxWorkflows);
728
736
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
729
737
  }
@@ -1462,7 +1470,9 @@ var PageTaskExecutor = class {
1462
1470
  */
1463
1471
  getPersistentExecutor() {
1464
1472
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1465
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1473
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1474
+ this.sessionContext.workflowId
1475
+ );
1466
1476
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1467
1477
  onTaskStart: this.onTaskStartCallback,
1468
1478
  initialMemory: previousMemory
@@ -1491,7 +1501,9 @@ var PageTaskExecutor = class {
1491
1501
  if (this.persistentExecutor) {
1492
1502
  this.persistentExecutor.clearMemory();
1493
1503
  }
1494
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1504
+ this.workflowMemory.clearWorkflow(
1505
+ this.sessionContext.workflowId || "default"
1506
+ );
1495
1507
  }
1496
1508
  /**
1497
1509
  * Mevcut hafızayı döndürür
@@ -1503,7 +1515,9 @@ var PageTaskExecutor = class {
1503
1515
  * İş akışı hafızasını döndürür
1504
1516
  */
1505
1517
  getWorkflowMemory() {
1506
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1518
+ return this.workflowMemory.getWorkflowData(
1519
+ this.sessionContext.workflowId || "default"
1520
+ );
1507
1521
  }
1508
1522
  /**
1509
1523
  * Hafıza istatistiklerini döndürür
@@ -1511,7 +1525,13 @@ var PageTaskExecutor = class {
1511
1525
  getMemoryStats() {
1512
1526
  return this.persistentExecutor?.getMemoryStats() || {
1513
1527
  totalItems: 0,
1514
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1528
+ analytics: {
1529
+ totalTasks: 0,
1530
+ memoryHits: 0,
1531
+ memoryMisses: 0,
1532
+ averageMemorySize: 0,
1533
+ memoryEffectiveness: 0
1534
+ },
1515
1535
  config: this.memoryConfig
1516
1536
  };
1517
1537
  }
@@ -1547,11 +1567,14 @@ var PageTaskExecutor = class {
1547
1567
  let taskExecutor;
1548
1568
  if (useMemory) {
1549
1569
  taskExecutor = this.getPersistentExecutor();
1550
- this.workflowMemory.updateWorkflowContext({
1551
- currentStep: title,
1552
- pageInfo: this.sessionContext.pageInfo,
1553
- timestamp: Date.now()
1554
- }, this.sessionContext.workflowId || "default");
1570
+ this.workflowMemory.updateWorkflowContext(
1571
+ {
1572
+ currentStep: title,
1573
+ pageInfo: this.sessionContext.pageInfo,
1574
+ timestamp: Date.now()
1575
+ },
1576
+ this.sessionContext.workflowId || "default"
1577
+ );
1555
1578
  } else {
1556
1579
  taskExecutor = new import_misoai_core.Executor(title, {
1557
1580
  onTaskStart: this.onTaskStartCallback
@@ -1917,14 +1940,19 @@ var PageTaskExecutor = class {
1917
1940
  */
1918
1941
  addToMemory(memoryItem) {
1919
1942
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1920
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1943
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1944
+ this.sessionContext.workflowId
1945
+ );
1921
1946
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1922
1947
  onTaskStart: this.onTaskStartCallback,
1923
1948
  initialMemory: previousMemory
1924
1949
  });
1925
1950
  }
1926
1951
  this.persistentExecutor.memoryStore?.add(memoryItem);
1927
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1952
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1953
+ "add",
1954
+ memoryItem
1955
+ );
1928
1956
  }
1929
1957
  };
1930
1958
 
@@ -2013,14 +2041,14 @@ function buildPlans(type, locateParam, param) {
2013
2041
  var import_node_assert = __toESM(require("assert"));
2014
2042
  var import_node_fs2 = require("fs");
2015
2043
  var import_node_path2 = require("path");
2044
+ var import_js_yaml3 = __toESM(require("js-yaml"));
2016
2045
  var import_common2 = require("misoai-shared/common");
2017
2046
  var import_logger3 = require("misoai-shared/logger");
2018
2047
  var import_utils9 = require("misoai-shared/utils");
2019
- var import_js_yaml3 = __toESM(require("js-yaml"));
2020
2048
  var import_semver = __toESM(require("semver"));
2021
2049
 
2022
2050
  // package.json
2023
- var version = "1.6.0";
2051
+ var version = "1.6.1";
2024
2052
 
2025
2053
  // src/common/task-cache.ts
2026
2054
  var debug3 = (0, import_logger3.getDebug)("cache");
@@ -2315,22 +2343,28 @@ var PageAgent = class {
2315
2343
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2316
2344
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2317
2345
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2318
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2319
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2346
+ const planningTasks = executor.tasks.filter(
2347
+ (task) => task.type === "Planning"
2348
+ );
2349
+ const insightTasks = executor.tasks.filter(
2350
+ (task) => task.type === "Insight"
2351
+ );
2320
2352
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2321
2353
  const planning = planningTasks.length > 0 ? {
2322
2354
  type: "Planning",
2323
- description: `Planning for task execution`,
2355
+ description: "Planning for task execution",
2324
2356
  steps: planningTasks.map((task) => task.thought || "Planning step")
2325
2357
  } : void 0;
2326
2358
  const insight = insightTasks.length > 0 ? {
2327
2359
  type: "Insight",
2328
- description: `Insight for task execution`,
2329
- elements: insightTasks.map((task) => task.thought || "Insight element")
2360
+ description: "Insight for task execution",
2361
+ elements: insightTasks.map(
2362
+ (task) => task.thought || "Insight element"
2363
+ )
2330
2364
  } : void 0;
2331
2365
  const action = actionTasks.length > 0 ? {
2332
2366
  type: "Action",
2333
- description: `Action for task execution`,
2367
+ description: "Action for task execution",
2334
2368
  result: lastTask?.output
2335
2369
  } : void 0;
2336
2370
  const actionDetails = executor.tasks.map((task) => ({
@@ -2664,7 +2698,10 @@ ${memoryContext}` : void 0;
2664
2698
  }
2665
2699
  const memoryContext = this.getMemoryAsContext();
2666
2700
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2667
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2701
+ const { output, executor } = await this.taskExecutor.assert(
2702
+ assertionWithContext,
2703
+ memoryContext
2704
+ );
2668
2705
  const metadata = this.afterTaskRunning(executor, true);
2669
2706
  if (output && opt?.keepRawResponse) {
2670
2707
  return {
@@ -2703,7 +2740,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2703
2740
  Return only "complex" or "simple" based on your analysis.
2704
2741
  `;
2705
2742
  const complexityMsgs = [
2706
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2743
+ {
2744
+ role: "system",
2745
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2746
+ },
2707
2747
  {
2708
2748
  role: "user",
2709
2749
  content: [
@@ -2727,7 +2767,12 @@ Return only "complex" or "simple" based on your analysis.
2727
2767
  );
2728
2768
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2729
2769
  shouldUseDeepThink = responseText.includes("complex");
2730
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2770
+ debug4(
2771
+ "CAPTCHA complexity analysis:",
2772
+ responseText,
2773
+ "Using deep think:",
2774
+ shouldUseDeepThink
2775
+ );
2731
2776
  } catch (error) {
2732
2777
  debug4("Failed to analyze CAPTCHA complexity:", error);
2733
2778
  }
@@ -2744,7 +2789,9 @@ Return only "complex" or "simple" based on your analysis.
2744
2789
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2745
2790
  } else if (action.type === "input" && action.value) {
2746
2791
  if (action.target) {
2747
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2792
+ await this.aiInput(action.value, action.target, {
2793
+ deepThink: shouldUseDeepThink
2794
+ });
2748
2795
  }
2749
2796
  } else if (action.type === "verify" && action.target) {
2750
2797
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2756,7 +2803,9 @@ Return only "complex" or "simple" based on your analysis.
2756
2803
  if (action.coordinates) {
2757
2804
  const x = action.coordinates[0];
2758
2805
  const y = action.coordinates[1];
2759
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2806
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2807
+ deepThink: shouldUseDeepThink
2808
+ });
2760
2809
  } else if (action.target) {
2761
2810
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2762
2811
  }
@@ -2908,25 +2957,27 @@ ${errors}`);
2908
2957
  const executionDump = {
2909
2958
  name: screenshotTitle,
2910
2959
  description: content,
2911
- tasks: [{
2912
- type: "Screenshot",
2913
- subType: "log",
2914
- status: "finished",
2915
- executor: null,
2916
- param: {
2917
- title: screenshotTitle,
2918
- content
2919
- },
2920
- output: {
2921
- screenshot
2922
- },
2923
- thought: `Logged screenshot: ${screenshotTitle}`,
2924
- timing: {
2925
- start: Date.now(),
2926
- end: Date.now(),
2927
- cost: 0
2960
+ tasks: [
2961
+ {
2962
+ type: "Screenshot",
2963
+ subType: "log",
2964
+ status: "finished",
2965
+ executor: null,
2966
+ param: {
2967
+ title: screenshotTitle,
2968
+ content
2969
+ },
2970
+ output: {
2971
+ screenshot
2972
+ },
2973
+ thought: `Logged screenshot: ${screenshotTitle}`,
2974
+ timing: {
2975
+ start: Date.now(),
2976
+ end: Date.now(),
2977
+ cost: 0
2978
+ }
2928
2979
  }
2929
- }],
2980
+ ],
2930
2981
  sdkVersion: "1.0.0",
2931
2982
  logTime: Date.now(),
2932
2983
  model_name: "screenshot"
@@ -2978,7 +3029,9 @@ ${errors}`);
2978
3029
  totalTasks: stats.analytics.totalTasks,
2979
3030
  memoryHits: stats.analytics.memoryHits,
2980
3031
  memoryMisses: stats.analytics.memoryMisses,
2981
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
3032
+ memoryEffectiveness: Math.round(
3033
+ stats.analytics.memoryEffectiveness * 100
3034
+ ),
2982
3035
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2983
3036
  },
2984
3037
  config: stats.config,
@@ -3042,7 +3095,9 @@ ${errors}`);
3042
3095
  calculateSuccessRate(memory) {
3043
3096
  if (memory.length === 0)
3044
3097
  return 0;
3045
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3098
+ const successCount = memory.filter(
3099
+ (item) => item.metadata?.success !== false
3100
+ ).length;
3046
3101
  return Math.round(successCount / memory.length * 100);
3047
3102
  }
3048
3103
  calculateAverageExecutionTime(memory) {