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
@@ -23,13 +23,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  ));
24
24
 
25
25
  // src/common/utils.ts
26
+ var import_dayjs = __toESM(require("dayjs"));
26
27
  var import_ai_model = require("misoai-core/ai-model");
27
28
  var import_utils = require("misoai-core/utils");
28
29
  var import_env = require("misoai-shared/env");
29
30
  var import_extractor = require("misoai-shared/extractor");
30
31
  var import_img = require("misoai-shared/img");
31
32
  var import_utils2 = require("misoai-shared/utils");
32
- var import_dayjs = __toESM(require("dayjs"));
33
33
 
34
34
  // src/web-element.ts
35
35
  var WebElementInfo = class {
@@ -448,8 +448,8 @@ var ScriptPlayer = class {
448
448
  var import_js_yaml = __toESM(require("js-yaml"));
449
449
 
450
450
  // src/yaml/utils.ts
451
- var import_utils4 = require("misoai-shared/utils");
452
451
  var import_js_yaml2 = __toESM(require("js-yaml"));
452
+ var import_utils4 = require("misoai-shared/utils");
453
453
  function interpolateEnvVars(content) {
454
454
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
455
455
  const value = process.env[envVar.trim()];
@@ -625,8 +625,12 @@ var WorkflowMemory = class {
625
625
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
626
626
  workflow.memory = [...memory];
627
627
  workflow.metadata.totalSteps = workflow.steps.length;
628
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
629
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
628
+ workflow.metadata.completedSteps = workflow.steps.filter(
629
+ (s) => s.status === "completed"
630
+ ).length;
631
+ workflow.metadata.failedSteps = workflow.steps.filter(
632
+ (s) => s.status === "failed"
633
+ ).length;
630
634
  this.workflows.set(workflowId, workflow);
631
635
  this.enforceRetentionPolicy();
632
636
  }
@@ -637,7 +641,9 @@ var WorkflowMemory = class {
637
641
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
638
642
  workflow.context = { ...workflow.context, ...context };
639
643
  if (context.currentStep) {
640
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
644
+ const existingStep = workflow.steps.find(
645
+ (s) => s.stepName === context.currentStep
646
+ );
641
647
  if (!existingStep) {
642
648
  workflow.steps.push({
643
649
  stepId: `step_${workflow.steps.length + 1}`,
@@ -682,7 +688,9 @@ var WorkflowMemory = class {
682
688
  enforceRetentionPolicy() {
683
689
  const maxWorkflows = 10;
684
690
  if (this.workflows.size > maxWorkflows) {
685
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
691
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
692
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
693
+ );
686
694
  const toDelete = sortedWorkflows.slice(maxWorkflows);
687
695
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
688
696
  }
@@ -1421,7 +1429,9 @@ var PageTaskExecutor = class {
1421
1429
  */
1422
1430
  getPersistentExecutor() {
1423
1431
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1424
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1432
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1433
+ this.sessionContext.workflowId
1434
+ );
1425
1435
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1426
1436
  onTaskStart: this.onTaskStartCallback,
1427
1437
  initialMemory: previousMemory
@@ -1450,7 +1460,9 @@ var PageTaskExecutor = class {
1450
1460
  if (this.persistentExecutor) {
1451
1461
  this.persistentExecutor.clearMemory();
1452
1462
  }
1453
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1463
+ this.workflowMemory.clearWorkflow(
1464
+ this.sessionContext.workflowId || "default"
1465
+ );
1454
1466
  }
1455
1467
  /**
1456
1468
  * Mevcut hafızayı döndürür
@@ -1462,7 +1474,9 @@ var PageTaskExecutor = class {
1462
1474
  * İş akışı hafızasını döndürür
1463
1475
  */
1464
1476
  getWorkflowMemory() {
1465
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1477
+ return this.workflowMemory.getWorkflowData(
1478
+ this.sessionContext.workflowId || "default"
1479
+ );
1466
1480
  }
1467
1481
  /**
1468
1482
  * Hafıza istatistiklerini döndürür
@@ -1470,7 +1484,13 @@ var PageTaskExecutor = class {
1470
1484
  getMemoryStats() {
1471
1485
  return this.persistentExecutor?.getMemoryStats() || {
1472
1486
  totalItems: 0,
1473
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1487
+ analytics: {
1488
+ totalTasks: 0,
1489
+ memoryHits: 0,
1490
+ memoryMisses: 0,
1491
+ averageMemorySize: 0,
1492
+ memoryEffectiveness: 0
1493
+ },
1474
1494
  config: this.memoryConfig
1475
1495
  };
1476
1496
  }
@@ -1506,11 +1526,14 @@ var PageTaskExecutor = class {
1506
1526
  let taskExecutor;
1507
1527
  if (useMemory) {
1508
1528
  taskExecutor = this.getPersistentExecutor();
1509
- this.workflowMemory.updateWorkflowContext({
1510
- currentStep: title,
1511
- pageInfo: this.sessionContext.pageInfo,
1512
- timestamp: Date.now()
1513
- }, this.sessionContext.workflowId || "default");
1529
+ this.workflowMemory.updateWorkflowContext(
1530
+ {
1531
+ currentStep: title,
1532
+ pageInfo: this.sessionContext.pageInfo,
1533
+ timestamp: Date.now()
1534
+ },
1535
+ this.sessionContext.workflowId || "default"
1536
+ );
1514
1537
  } else {
1515
1538
  taskExecutor = new import_misoai_core.Executor(title, {
1516
1539
  onTaskStart: this.onTaskStartCallback
@@ -1876,14 +1899,19 @@ var PageTaskExecutor = class {
1876
1899
  */
1877
1900
  addToMemory(memoryItem) {
1878
1901
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1879
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1902
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1903
+ this.sessionContext.workflowId
1904
+ );
1880
1905
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1881
1906
  onTaskStart: this.onTaskStartCallback,
1882
1907
  initialMemory: previousMemory
1883
1908
  });
1884
1909
  }
1885
1910
  this.persistentExecutor.memoryStore?.add(memoryItem);
1886
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1911
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1912
+ "add",
1913
+ memoryItem
1914
+ );
1887
1915
  }
1888
1916
  };
1889
1917
 
@@ -1972,14 +2000,14 @@ function buildPlans(type, locateParam, param) {
1972
2000
  var import_node_assert = __toESM(require("assert"));
1973
2001
  var import_node_fs2 = require("fs");
1974
2002
  var import_node_path2 = require("path");
2003
+ var import_js_yaml3 = __toESM(require("js-yaml"));
1975
2004
  var import_common2 = require("misoai-shared/common");
1976
2005
  var import_logger3 = require("misoai-shared/logger");
1977
2006
  var import_utils9 = require("misoai-shared/utils");
1978
- var import_js_yaml3 = __toESM(require("js-yaml"));
1979
2007
  var import_semver = __toESM(require("semver"));
1980
2008
 
1981
2009
  // package.json
1982
- var version = "1.6.0";
2010
+ var version = "1.6.1";
1983
2011
 
1984
2012
  // src/common/task-cache.ts
1985
2013
  var debug3 = (0, import_logger3.getDebug)("cache");
@@ -2274,22 +2302,28 @@ var PageAgent = class {
2274
2302
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2275
2303
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2276
2304
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2277
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2278
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2305
+ const planningTasks = executor.tasks.filter(
2306
+ (task) => task.type === "Planning"
2307
+ );
2308
+ const insightTasks = executor.tasks.filter(
2309
+ (task) => task.type === "Insight"
2310
+ );
2279
2311
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2280
2312
  const planning = planningTasks.length > 0 ? {
2281
2313
  type: "Planning",
2282
- description: `Planning for task execution`,
2314
+ description: "Planning for task execution",
2283
2315
  steps: planningTasks.map((task) => task.thought || "Planning step")
2284
2316
  } : void 0;
2285
2317
  const insight = insightTasks.length > 0 ? {
2286
2318
  type: "Insight",
2287
- description: `Insight for task execution`,
2288
- elements: insightTasks.map((task) => task.thought || "Insight element")
2319
+ description: "Insight for task execution",
2320
+ elements: insightTasks.map(
2321
+ (task) => task.thought || "Insight element"
2322
+ )
2289
2323
  } : void 0;
2290
2324
  const action = actionTasks.length > 0 ? {
2291
2325
  type: "Action",
2292
- description: `Action for task execution`,
2326
+ description: "Action for task execution",
2293
2327
  result: lastTask?.output
2294
2328
  } : void 0;
2295
2329
  const actionDetails = executor.tasks.map((task) => ({
@@ -2623,7 +2657,10 @@ ${memoryContext}` : void 0;
2623
2657
  }
2624
2658
  const memoryContext = this.getMemoryAsContext();
2625
2659
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2626
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2660
+ const { output, executor } = await this.taskExecutor.assert(
2661
+ assertionWithContext,
2662
+ memoryContext
2663
+ );
2627
2664
  const metadata = this.afterTaskRunning(executor, true);
2628
2665
  if (output && opt?.keepRawResponse) {
2629
2666
  return {
@@ -2662,7 +2699,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2662
2699
  Return only "complex" or "simple" based on your analysis.
2663
2700
  `;
2664
2701
  const complexityMsgs = [
2665
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2702
+ {
2703
+ role: "system",
2704
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2705
+ },
2666
2706
  {
2667
2707
  role: "user",
2668
2708
  content: [
@@ -2686,7 +2726,12 @@ Return only "complex" or "simple" based on your analysis.
2686
2726
  );
2687
2727
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2688
2728
  shouldUseDeepThink = responseText.includes("complex");
2689
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2729
+ debug4(
2730
+ "CAPTCHA complexity analysis:",
2731
+ responseText,
2732
+ "Using deep think:",
2733
+ shouldUseDeepThink
2734
+ );
2690
2735
  } catch (error) {
2691
2736
  debug4("Failed to analyze CAPTCHA complexity:", error);
2692
2737
  }
@@ -2703,7 +2748,9 @@ Return only "complex" or "simple" based on your analysis.
2703
2748
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2704
2749
  } else if (action.type === "input" && action.value) {
2705
2750
  if (action.target) {
2706
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2751
+ await this.aiInput(action.value, action.target, {
2752
+ deepThink: shouldUseDeepThink
2753
+ });
2707
2754
  }
2708
2755
  } else if (action.type === "verify" && action.target) {
2709
2756
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2715,7 +2762,9 @@ Return only "complex" or "simple" based on your analysis.
2715
2762
  if (action.coordinates) {
2716
2763
  const x = action.coordinates[0];
2717
2764
  const y = action.coordinates[1];
2718
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2765
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2766
+ deepThink: shouldUseDeepThink
2767
+ });
2719
2768
  } else if (action.target) {
2720
2769
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2721
2770
  }
@@ -2867,25 +2916,27 @@ ${errors}`);
2867
2916
  const executionDump = {
2868
2917
  name: screenshotTitle,
2869
2918
  description: content,
2870
- tasks: [{
2871
- type: "Screenshot",
2872
- subType: "log",
2873
- status: "finished",
2874
- executor: null,
2875
- param: {
2876
- title: screenshotTitle,
2877
- content
2878
- },
2879
- output: {
2880
- screenshot
2881
- },
2882
- thought: `Logged screenshot: ${screenshotTitle}`,
2883
- timing: {
2884
- start: Date.now(),
2885
- end: Date.now(),
2886
- cost: 0
2919
+ tasks: [
2920
+ {
2921
+ type: "Screenshot",
2922
+ subType: "log",
2923
+ status: "finished",
2924
+ executor: null,
2925
+ param: {
2926
+ title: screenshotTitle,
2927
+ content
2928
+ },
2929
+ output: {
2930
+ screenshot
2931
+ },
2932
+ thought: `Logged screenshot: ${screenshotTitle}`,
2933
+ timing: {
2934
+ start: Date.now(),
2935
+ end: Date.now(),
2936
+ cost: 0
2937
+ }
2887
2938
  }
2888
- }],
2939
+ ],
2889
2940
  sdkVersion: "1.0.0",
2890
2941
  logTime: Date.now(),
2891
2942
  model_name: "screenshot"
@@ -2937,7 +2988,9 @@ ${errors}`);
2937
2988
  totalTasks: stats.analytics.totalTasks,
2938
2989
  memoryHits: stats.analytics.memoryHits,
2939
2990
  memoryMisses: stats.analytics.memoryMisses,
2940
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
2991
+ memoryEffectiveness: Math.round(
2992
+ stats.analytics.memoryEffectiveness * 100
2993
+ ),
2941
2994
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2942
2995
  },
2943
2996
  config: stats.config,
@@ -3001,7 +3054,9 @@ ${errors}`);
3001
3054
  calculateSuccessRate(memory) {
3002
3055
  if (memory.length === 0)
3003
3056
  return 0;
3004
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3057
+ const successCount = memory.filter(
3058
+ (item) => item.metadata?.success !== false
3059
+ ).length;
3005
3060
  return Math.round(successCount / memory.length * 100);
3006
3061
  }
3007
3062
  calculateAverageExecutionTime(memory) {
@@ -3138,13 +3193,13 @@ var StaticPage = class {
3138
3193
  var import_node_crypto = require("crypto");
3139
3194
  var import_node_fs3 = require("fs");
3140
3195
  var import_node_path3 = require("path");
3196
+ var import_cors = __toESM(require("cors"));
3197
+ var import_dotenv = __toESM(require("dotenv"));
3198
+ var import_express = __toESM(require("express"));
3141
3199
  var import_utils18 = require("misoai-core/utils");
3142
3200
  var import_constants3 = require("misoai-shared/constants");
3143
3201
  var import_env3 = require("misoai-shared/env");
3144
3202
  var import_utils19 = require("misoai-shared/utils");
3145
- var import_cors = __toESM(require("cors"));
3146
- var import_dotenv = __toESM(require("dotenv"));
3147
- var import_express = __toESM(require("express"));
3148
3203
  var defaultPort = import_constants3.PLAYGROUND_SERVER_PORT;
3149
3204
  var errorHandler = (err, req, res, next) => {
3150
3205
  console.error(err);