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
package/dist/es/agent.js CHANGED
@@ -306,8 +306,8 @@ var ScriptPlayer = class {
306
306
  import yaml from "js-yaml";
307
307
 
308
308
  // src/yaml/utils.ts
309
- import { assert as assert2 } from "misoai-shared/utils";
310
309
  import yaml2 from "js-yaml";
310
+ import { assert as assert2 } from "misoai-shared/utils";
311
311
  function interpolateEnvVars(content) {
312
312
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
313
313
  const value = process.env[envVar.trim()];
@@ -468,6 +468,7 @@ function paramStr(task) {
468
468
  }
469
469
 
470
470
  // src/common/utils.ts
471
+ import dayjs from "dayjs";
471
472
  import { elementByPositionWithElementInfo } from "misoai-core/ai-model";
472
473
  import { uploadTestInfoToServer } from "misoai-core/utils";
473
474
  import { MIDSCENE_REPORT_TAG_NAME, getAIConfig } from "misoai-shared/env";
@@ -479,7 +480,6 @@ import {
479
480
  } from "misoai-shared/extractor";
480
481
  import { resizeImgBase64 } from "misoai-shared/img";
481
482
  import { assert as assert3, logMsg, uuid } from "misoai-shared/utils";
482
- import dayjs from "dayjs";
483
483
 
484
484
  // src/web-element.ts
485
485
  var WebElementInfo = class {
@@ -620,8 +620,12 @@ var WorkflowMemory = class {
620
620
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
621
621
  workflow.memory = [...memory];
622
622
  workflow.metadata.totalSteps = workflow.steps.length;
623
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
624
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
623
+ workflow.metadata.completedSteps = workflow.steps.filter(
624
+ (s) => s.status === "completed"
625
+ ).length;
626
+ workflow.metadata.failedSteps = workflow.steps.filter(
627
+ (s) => s.status === "failed"
628
+ ).length;
625
629
  this.workflows.set(workflowId, workflow);
626
630
  this.enforceRetentionPolicy();
627
631
  }
@@ -632,7 +636,9 @@ var WorkflowMemory = class {
632
636
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
633
637
  workflow.context = { ...workflow.context, ...context };
634
638
  if (context.currentStep) {
635
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
639
+ const existingStep = workflow.steps.find(
640
+ (s) => s.stepName === context.currentStep
641
+ );
636
642
  if (!existingStep) {
637
643
  workflow.steps.push({
638
644
  stepId: `step_${workflow.steps.length + 1}`,
@@ -677,7 +683,9 @@ var WorkflowMemory = class {
677
683
  enforceRetentionPolicy() {
678
684
  const maxWorkflows = 10;
679
685
  if (this.workflows.size > maxWorkflows) {
680
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
686
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
687
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
688
+ );
681
689
  const toDelete = sortedWorkflows.slice(maxWorkflows);
682
690
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
683
691
  }
@@ -1244,6 +1252,7 @@ var PageTaskExecutor = class {
1244
1252
  actions: [],
1245
1253
  more_actions_needed_by_instruction: false,
1246
1254
  log: "",
1255
+ summary: "Loaded YAML workflow configuration",
1247
1256
  yamlString
1248
1257
  },
1249
1258
  cache: {
@@ -1345,6 +1354,7 @@ var PageTaskExecutor = class {
1345
1354
  actions: finalActions,
1346
1355
  more_actions_needed_by_instruction,
1347
1356
  log: log2,
1357
+ summary: planResult.summary || "Generated action plan from user instruction",
1348
1358
  yamlFlow: planResult.yamlFlow
1349
1359
  },
1350
1360
  cache: {
@@ -1400,6 +1410,7 @@ var PageTaskExecutor = class {
1400
1410
  actionType: actions[0].type,
1401
1411
  more_actions_needed_by_instruction: true,
1402
1412
  log: "",
1413
+ summary: action_summary || "Generated VLM action plan",
1403
1414
  yamlFlow: planResult.yamlFlow
1404
1415
  },
1405
1416
  cache: {
@@ -1416,7 +1427,9 @@ var PageTaskExecutor = class {
1416
1427
  */
1417
1428
  getPersistentExecutor() {
1418
1429
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1419
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1430
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1431
+ this.sessionContext.workflowId
1432
+ );
1420
1433
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1421
1434
  onTaskStart: this.onTaskStartCallback,
1422
1435
  initialMemory: previousMemory
@@ -1445,7 +1458,9 @@ var PageTaskExecutor = class {
1445
1458
  if (this.persistentExecutor) {
1446
1459
  this.persistentExecutor.clearMemory();
1447
1460
  }
1448
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1461
+ this.workflowMemory.clearWorkflow(
1462
+ this.sessionContext.workflowId || "default"
1463
+ );
1449
1464
  }
1450
1465
  /**
1451
1466
  * Mevcut hafızayı döndürür
@@ -1457,7 +1472,9 @@ var PageTaskExecutor = class {
1457
1472
  * İş akışı hafızasını döndürür
1458
1473
  */
1459
1474
  getWorkflowMemory() {
1460
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1475
+ return this.workflowMemory.getWorkflowData(
1476
+ this.sessionContext.workflowId || "default"
1477
+ );
1461
1478
  }
1462
1479
  /**
1463
1480
  * Hafıza istatistiklerini döndürür
@@ -1465,7 +1482,13 @@ var PageTaskExecutor = class {
1465
1482
  getMemoryStats() {
1466
1483
  return this.persistentExecutor?.getMemoryStats() || {
1467
1484
  totalItems: 0,
1468
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1485
+ analytics: {
1486
+ totalTasks: 0,
1487
+ memoryHits: 0,
1488
+ memoryMisses: 0,
1489
+ averageMemorySize: 0,
1490
+ memoryEffectiveness: 0
1491
+ },
1469
1492
  config: this.memoryConfig
1470
1493
  };
1471
1494
  }
@@ -1501,11 +1524,14 @@ var PageTaskExecutor = class {
1501
1524
  let taskExecutor;
1502
1525
  if (useMemory) {
1503
1526
  taskExecutor = this.getPersistentExecutor();
1504
- this.workflowMemory.updateWorkflowContext({
1505
- currentStep: title,
1506
- pageInfo: this.sessionContext.pageInfo,
1507
- timestamp: Date.now()
1508
- }, this.sessionContext.workflowId || "default");
1527
+ this.workflowMemory.updateWorkflowContext(
1528
+ {
1529
+ currentStep: title,
1530
+ pageInfo: this.sessionContext.pageInfo,
1531
+ timestamp: Date.now()
1532
+ },
1533
+ this.sessionContext.workflowId || "default"
1534
+ );
1509
1535
  } else {
1510
1536
  taskExecutor = new Executor(title, {
1511
1537
  onTaskStart: this.onTaskStartCallback
@@ -1871,14 +1897,19 @@ var PageTaskExecutor = class {
1871
1897
  */
1872
1898
  addToMemory(memoryItem) {
1873
1899
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1874
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1900
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1901
+ this.sessionContext.workflowId
1902
+ );
1875
1903
  this.persistentExecutor = new Executor("Persistent Task Executor", {
1876
1904
  onTaskStart: this.onTaskStartCallback,
1877
1905
  initialMemory: previousMemory
1878
1906
  });
1879
1907
  }
1880
1908
  this.persistentExecutor.memoryStore?.add(memoryItem);
1881
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1909
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1910
+ "add",
1911
+ memoryItem
1912
+ );
1882
1913
  }
1883
1914
  };
1884
1915
 
@@ -1967,14 +1998,14 @@ function buildPlans(type, locateParam, param) {
1967
1998
  import assert6 from "assert";
1968
1999
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
1969
2000
  import { dirname as dirname2, join as join2 } from "path";
2001
+ import yaml3 from "js-yaml";
1970
2002
  import { getMidsceneRunSubDir as getMidsceneRunSubDir2 } from "misoai-shared/common";
1971
2003
  import { getDebug as getDebug3 } from "misoai-shared/logger";
1972
2004
  import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
1973
- import yaml3 from "js-yaml";
1974
2005
  import semver from "semver";
1975
2006
 
1976
2007
  // package.json
1977
- var version = "1.6.0";
2008
+ var version = "1.6.2";
1978
2009
 
1979
2010
  // src/common/task-cache.ts
1980
2011
  var debug3 = getDebug3("cache");
@@ -2269,22 +2300,28 @@ var PageAgent = class {
2269
2300
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2270
2301
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2271
2302
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2272
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2273
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2303
+ const planningTasks = executor.tasks.filter(
2304
+ (task) => task.type === "Planning"
2305
+ );
2306
+ const insightTasks = executor.tasks.filter(
2307
+ (task) => task.type === "Insight"
2308
+ );
2274
2309
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2275
2310
  const planning = planningTasks.length > 0 ? {
2276
2311
  type: "Planning",
2277
- description: `Planning for task execution`,
2312
+ description: "Planning for task execution",
2278
2313
  steps: planningTasks.map((task) => task.thought || "Planning step")
2279
2314
  } : void 0;
2280
2315
  const insight = insightTasks.length > 0 ? {
2281
2316
  type: "Insight",
2282
- description: `Insight for task execution`,
2283
- elements: insightTasks.map((task) => task.thought || "Insight element")
2317
+ description: "Insight for task execution",
2318
+ elements: insightTasks.map(
2319
+ (task) => task.thought || "Insight element"
2320
+ )
2284
2321
  } : void 0;
2285
2322
  const action = actionTasks.length > 0 ? {
2286
2323
  type: "Action",
2287
- description: `Action for task execution`,
2324
+ description: "Action for task execution",
2288
2325
  result: lastTask?.output
2289
2326
  } : void 0;
2290
2327
  const actionDetails = executor.tasks.map((task) => ({
@@ -2618,7 +2655,10 @@ ${memoryContext}` : void 0;
2618
2655
  }
2619
2656
  const memoryContext = this.getMemoryAsContext();
2620
2657
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2621
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2658
+ const { output, executor } = await this.taskExecutor.assert(
2659
+ assertionWithContext,
2660
+ memoryContext
2661
+ );
2622
2662
  const metadata = this.afterTaskRunning(executor, true);
2623
2663
  if (output && opt?.keepRawResponse) {
2624
2664
  return {
@@ -2657,7 +2697,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2657
2697
  Return only "complex" or "simple" based on your analysis.
2658
2698
  `;
2659
2699
  const complexityMsgs = [
2660
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2700
+ {
2701
+ role: "system",
2702
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2703
+ },
2661
2704
  {
2662
2705
  role: "user",
2663
2706
  content: [
@@ -2681,7 +2724,12 @@ Return only "complex" or "simple" based on your analysis.
2681
2724
  );
2682
2725
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2683
2726
  shouldUseDeepThink = responseText.includes("complex");
2684
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2727
+ debug4(
2728
+ "CAPTCHA complexity analysis:",
2729
+ responseText,
2730
+ "Using deep think:",
2731
+ shouldUseDeepThink
2732
+ );
2685
2733
  } catch (error) {
2686
2734
  debug4("Failed to analyze CAPTCHA complexity:", error);
2687
2735
  }
@@ -2698,7 +2746,9 @@ Return only "complex" or "simple" based on your analysis.
2698
2746
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2699
2747
  } else if (action.type === "input" && action.value) {
2700
2748
  if (action.target) {
2701
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2749
+ await this.aiInput(action.value, action.target, {
2750
+ deepThink: shouldUseDeepThink
2751
+ });
2702
2752
  }
2703
2753
  } else if (action.type === "verify" && action.target) {
2704
2754
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2710,7 +2760,9 @@ Return only "complex" or "simple" based on your analysis.
2710
2760
  if (action.coordinates) {
2711
2761
  const x = action.coordinates[0];
2712
2762
  const y = action.coordinates[1];
2713
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2763
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2764
+ deepThink: shouldUseDeepThink
2765
+ });
2714
2766
  } else if (action.target) {
2715
2767
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2716
2768
  }
@@ -2862,25 +2914,27 @@ ${errors}`);
2862
2914
  const executionDump = {
2863
2915
  name: screenshotTitle,
2864
2916
  description: content,
2865
- tasks: [{
2866
- type: "Screenshot",
2867
- subType: "log",
2868
- status: "finished",
2869
- executor: null,
2870
- param: {
2871
- title: screenshotTitle,
2872
- content
2873
- },
2874
- output: {
2875
- screenshot
2876
- },
2877
- thought: `Logged screenshot: ${screenshotTitle}`,
2878
- timing: {
2879
- start: Date.now(),
2880
- end: Date.now(),
2881
- cost: 0
2917
+ tasks: [
2918
+ {
2919
+ type: "Screenshot",
2920
+ subType: "log",
2921
+ status: "finished",
2922
+ executor: null,
2923
+ param: {
2924
+ title: screenshotTitle,
2925
+ content
2926
+ },
2927
+ output: {
2928
+ screenshot
2929
+ },
2930
+ thought: `Logged screenshot: ${screenshotTitle}`,
2931
+ timing: {
2932
+ start: Date.now(),
2933
+ end: Date.now(),
2934
+ cost: 0
2935
+ }
2882
2936
  }
2883
- }],
2937
+ ],
2884
2938
  sdkVersion: "1.0.0",
2885
2939
  logTime: Date.now(),
2886
2940
  model_name: "screenshot"
@@ -2932,7 +2986,9 @@ ${errors}`);
2932
2986
  totalTasks: stats.analytics.totalTasks,
2933
2987
  memoryHits: stats.analytics.memoryHits,
2934
2988
  memoryMisses: stats.analytics.memoryMisses,
2935
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
2989
+ memoryEffectiveness: Math.round(
2990
+ stats.analytics.memoryEffectiveness * 100
2991
+ ),
2936
2992
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2937
2993
  },
2938
2994
  config: stats.config,
@@ -2996,7 +3052,9 @@ ${errors}`);
2996
3052
  calculateSuccessRate(memory) {
2997
3053
  if (memory.length === 0)
2998
3054
  return 0;
2999
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3055
+ const successCount = memory.filter(
3056
+ (item) => item.metadata?.success !== false
3057
+ ).length;
3000
3058
  return Math.round(successCount / memory.length * 100);
3001
3059
  }
3002
3060
  calculateAverageExecutionTime(memory) {