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
@@ -311,8 +311,8 @@ var ScriptPlayer = class {
311
311
  import yaml from "js-yaml";
312
312
 
313
313
  // src/yaml/utils.ts
314
- import { assert as assert2 } from "misoai-shared/utils";
315
314
  import yaml2 from "js-yaml";
315
+ import { assert as assert2 } from "misoai-shared/utils";
316
316
  function interpolateEnvVars(content) {
317
317
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
318
318
  const value = process.env[envVar.trim()];
@@ -473,6 +473,7 @@ function paramStr(task) {
473
473
  }
474
474
 
475
475
  // src/common/utils.ts
476
+ import dayjs from "dayjs";
476
477
  import { elementByPositionWithElementInfo } from "misoai-core/ai-model";
477
478
  import { uploadTestInfoToServer } from "misoai-core/utils";
478
479
  import { MIDSCENE_REPORT_TAG_NAME, getAIConfig } from "misoai-shared/env";
@@ -484,7 +485,6 @@ import {
484
485
  } from "misoai-shared/extractor";
485
486
  import { resizeImgBase64 } from "misoai-shared/img";
486
487
  import { assert as assert3, logMsg, uuid } from "misoai-shared/utils";
487
- import dayjs from "dayjs";
488
488
 
489
489
  // src/web-element.ts
490
490
  var WebElementInfo = class {
@@ -653,8 +653,12 @@ var WorkflowMemory = class {
653
653
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
654
654
  workflow.memory = [...memory];
655
655
  workflow.metadata.totalSteps = workflow.steps.length;
656
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
657
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
656
+ workflow.metadata.completedSteps = workflow.steps.filter(
657
+ (s) => s.status === "completed"
658
+ ).length;
659
+ workflow.metadata.failedSteps = workflow.steps.filter(
660
+ (s) => s.status === "failed"
661
+ ).length;
658
662
  this.workflows.set(workflowId, workflow);
659
663
  this.enforceRetentionPolicy();
660
664
  }
@@ -665,7 +669,9 @@ var WorkflowMemory = class {
665
669
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
666
670
  workflow.context = { ...workflow.context, ...context };
667
671
  if (context.currentStep) {
668
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
672
+ const existingStep = workflow.steps.find(
673
+ (s) => s.stepName === context.currentStep
674
+ );
669
675
  if (!existingStep) {
670
676
  workflow.steps.push({
671
677
  stepId: `step_${workflow.steps.length + 1}`,
@@ -710,7 +716,9 @@ var WorkflowMemory = class {
710
716
  enforceRetentionPolicy() {
711
717
  const maxWorkflows = 10;
712
718
  if (this.workflows.size > maxWorkflows) {
713
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
719
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
720
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
721
+ );
714
722
  const toDelete = sortedWorkflows.slice(maxWorkflows);
715
723
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
716
724
  }
@@ -1449,7 +1457,9 @@ var PageTaskExecutor = class {
1449
1457
  */
1450
1458
  getPersistentExecutor() {
1451
1459
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1452
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1460
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1461
+ this.sessionContext.workflowId
1462
+ );
1453
1463
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1454
1464
  onTaskStart: this.onTaskStartCallback,
1455
1465
  initialMemory: previousMemory
@@ -1478,7 +1488,9 @@ var PageTaskExecutor = class {
1478
1488
  if (this.persistentExecutor) {
1479
1489
  this.persistentExecutor.clearMemory();
1480
1490
  }
1481
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1491
+ this.workflowMemory.clearWorkflow(
1492
+ this.sessionContext.workflowId || "default"
1493
+ );
1482
1494
  }
1483
1495
  /**
1484
1496
  * Mevcut hafızayı döndürür
@@ -1490,7 +1502,9 @@ var PageTaskExecutor = class {
1490
1502
  * İş akışı hafızasını döndürür
1491
1503
  */
1492
1504
  getWorkflowMemory() {
1493
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1505
+ return this.workflowMemory.getWorkflowData(
1506
+ this.sessionContext.workflowId || "default"
1507
+ );
1494
1508
  }
1495
1509
  /**
1496
1510
  * Hafıza istatistiklerini döndürür
@@ -1498,7 +1512,13 @@ var PageTaskExecutor = class {
1498
1512
  getMemoryStats() {
1499
1513
  return this.persistentExecutor?.getMemoryStats() || {
1500
1514
  totalItems: 0,
1501
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1515
+ analytics: {
1516
+ totalTasks: 0,
1517
+ memoryHits: 0,
1518
+ memoryMisses: 0,
1519
+ averageMemorySize: 0,
1520
+ memoryEffectiveness: 0
1521
+ },
1502
1522
  config: this.memoryConfig
1503
1523
  };
1504
1524
  }
@@ -1534,11 +1554,14 @@ var PageTaskExecutor = class {
1534
1554
  let taskExecutor;
1535
1555
  if (useMemory) {
1536
1556
  taskExecutor = this.getPersistentExecutor();
1537
- this.workflowMemory.updateWorkflowContext({
1538
- currentStep: title,
1539
- pageInfo: this.sessionContext.pageInfo,
1540
- timestamp: Date.now()
1541
- }, this.sessionContext.workflowId || "default");
1557
+ this.workflowMemory.updateWorkflowContext(
1558
+ {
1559
+ currentStep: title,
1560
+ pageInfo: this.sessionContext.pageInfo,
1561
+ timestamp: Date.now()
1562
+ },
1563
+ this.sessionContext.workflowId || "default"
1564
+ );
1542
1565
  } else {
1543
1566
  taskExecutor = new Executor(title, {
1544
1567
  onTaskStart: this.onTaskStartCallback
@@ -1904,14 +1927,19 @@ var PageTaskExecutor = class {
1904
1927
  */
1905
1928
  addToMemory(memoryItem) {
1906
1929
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1907
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1930
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1931
+ this.sessionContext.workflowId
1932
+ );
1908
1933
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1909
1934
  onTaskStart: this.onTaskStartCallback,
1910
1935
  initialMemory: previousMemory
1911
1936
  });
1912
1937
  }
1913
1938
  this.persistentExecutor.memoryStore?.add(memoryItem);
1914
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1939
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1940
+ "add",
1941
+ memoryItem
1942
+ );
1915
1943
  }
1916
1944
  };
1917
1945
 
@@ -2000,14 +2028,14 @@ function buildPlans(type, locateParam, param) {
2000
2028
  import assert6 from "assert";
2001
2029
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
2002
2030
  import { dirname as dirname2, join as join2 } from "path";
2031
+ import yaml3 from "js-yaml";
2003
2032
  import { getMidsceneRunSubDir as getMidsceneRunSubDir2 } from "misoai-shared/common";
2004
2033
  import { getDebug as getDebug3 } from "misoai-shared/logger";
2005
2034
  import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
2006
- import yaml3 from "js-yaml";
2007
2035
  import semver from "semver";
2008
2036
 
2009
2037
  // package.json
2010
- var version = "1.6.0";
2038
+ var version = "1.6.1";
2011
2039
 
2012
2040
  // src/common/task-cache.ts
2013
2041
  var debug3 = getDebug3("cache");
@@ -2302,22 +2330,28 @@ var PageAgent = class {
2302
2330
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2303
2331
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2304
2332
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2305
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2306
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2333
+ const planningTasks = executor.tasks.filter(
2334
+ (task) => task.type === "Planning"
2335
+ );
2336
+ const insightTasks = executor.tasks.filter(
2337
+ (task) => task.type === "Insight"
2338
+ );
2307
2339
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2308
2340
  const planning = planningTasks.length > 0 ? {
2309
2341
  type: "Planning",
2310
- description: `Planning for task execution`,
2342
+ description: "Planning for task execution",
2311
2343
  steps: planningTasks.map((task) => task.thought || "Planning step")
2312
2344
  } : void 0;
2313
2345
  const insight = insightTasks.length > 0 ? {
2314
2346
  type: "Insight",
2315
- description: `Insight for task execution`,
2316
- elements: insightTasks.map((task) => task.thought || "Insight element")
2347
+ description: "Insight for task execution",
2348
+ elements: insightTasks.map(
2349
+ (task) => task.thought || "Insight element"
2350
+ )
2317
2351
  } : void 0;
2318
2352
  const action = actionTasks.length > 0 ? {
2319
2353
  type: "Action",
2320
- description: `Action for task execution`,
2354
+ description: "Action for task execution",
2321
2355
  result: lastTask?.output
2322
2356
  } : void 0;
2323
2357
  const actionDetails = executor.tasks.map((task) => ({
@@ -2651,7 +2685,10 @@ ${memoryContext}` : void 0;
2651
2685
  }
2652
2686
  const memoryContext = this.getMemoryAsContext();
2653
2687
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2654
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2688
+ const { output, executor } = await this.taskExecutor.assert(
2689
+ assertionWithContext,
2690
+ memoryContext
2691
+ );
2655
2692
  const metadata = this.afterTaskRunning(executor, true);
2656
2693
  if (output && opt?.keepRawResponse) {
2657
2694
  return {
@@ -2690,7 +2727,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2690
2727
  Return only "complex" or "simple" based on your analysis.
2691
2728
  `;
2692
2729
  const complexityMsgs = [
2693
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2730
+ {
2731
+ role: "system",
2732
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2733
+ },
2694
2734
  {
2695
2735
  role: "user",
2696
2736
  content: [
@@ -2714,7 +2754,12 @@ Return only "complex" or "simple" based on your analysis.
2714
2754
  );
2715
2755
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2716
2756
  shouldUseDeepThink = responseText.includes("complex");
2717
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2757
+ debug4(
2758
+ "CAPTCHA complexity analysis:",
2759
+ responseText,
2760
+ "Using deep think:",
2761
+ shouldUseDeepThink
2762
+ );
2718
2763
  } catch (error) {
2719
2764
  debug4("Failed to analyze CAPTCHA complexity:", error);
2720
2765
  }
@@ -2731,7 +2776,9 @@ Return only "complex" or "simple" based on your analysis.
2731
2776
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2732
2777
  } else if (action.type === "input" && action.value) {
2733
2778
  if (action.target) {
2734
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2779
+ await this.aiInput(action.value, action.target, {
2780
+ deepThink: shouldUseDeepThink
2781
+ });
2735
2782
  }
2736
2783
  } else if (action.type === "verify" && action.target) {
2737
2784
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2743,7 +2790,9 @@ Return only "complex" or "simple" based on your analysis.
2743
2790
  if (action.coordinates) {
2744
2791
  const x = action.coordinates[0];
2745
2792
  const y = action.coordinates[1];
2746
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2793
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2794
+ deepThink: shouldUseDeepThink
2795
+ });
2747
2796
  } else if (action.target) {
2748
2797
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2749
2798
  }
@@ -2895,25 +2944,27 @@ ${errors}`);
2895
2944
  const executionDump = {
2896
2945
  name: screenshotTitle,
2897
2946
  description: content,
2898
- tasks: [{
2899
- type: "Screenshot",
2900
- subType: "log",
2901
- status: "finished",
2902
- executor: null,
2903
- param: {
2904
- title: screenshotTitle,
2905
- content
2906
- },
2907
- output: {
2908
- screenshot
2909
- },
2910
- thought: `Logged screenshot: ${screenshotTitle}`,
2911
- timing: {
2912
- start: Date.now(),
2913
- end: Date.now(),
2914
- cost: 0
2947
+ tasks: [
2948
+ {
2949
+ type: "Screenshot",
2950
+ subType: "log",
2951
+ status: "finished",
2952
+ executor: null,
2953
+ param: {
2954
+ title: screenshotTitle,
2955
+ content
2956
+ },
2957
+ output: {
2958
+ screenshot
2959
+ },
2960
+ thought: `Logged screenshot: ${screenshotTitle}`,
2961
+ timing: {
2962
+ start: Date.now(),
2963
+ end: Date.now(),
2964
+ cost: 0
2965
+ }
2915
2966
  }
2916
- }],
2967
+ ],
2917
2968
  sdkVersion: "1.0.0",
2918
2969
  logTime: Date.now(),
2919
2970
  model_name: "screenshot"
@@ -2965,7 +3016,9 @@ ${errors}`);
2965
3016
  totalTasks: stats.analytics.totalTasks,
2966
3017
  memoryHits: stats.analytics.memoryHits,
2967
3018
  memoryMisses: stats.analytics.memoryMisses,
2968
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
3019
+ memoryEffectiveness: Math.round(
3020
+ stats.analytics.memoryEffectiveness * 100
3021
+ ),
2969
3022
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2970
3023
  },
2971
3024
  config: stats.config,
@@ -3029,7 +3082,9 @@ ${errors}`);
3029
3082
  calculateSuccessRate(memory) {
3030
3083
  if (memory.length === 0)
3031
3084
  return 0;
3032
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3085
+ const successCount = memory.filter(
3086
+ (item) => item.metadata?.success !== false
3087
+ ).length;
3033
3088
  return Math.round(successCount / memory.length * 100);
3034
3089
  }
3035
3090
  calculateAverageExecutionTime(memory) {