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
@@ -345,8 +345,8 @@ var ScriptPlayer = class {
345
345
  var import_js_yaml = __toESM(require("js-yaml"));
346
346
 
347
347
  // src/yaml/utils.ts
348
- var import_utils2 = require("misoai-shared/utils");
349
348
  var import_js_yaml2 = __toESM(require("js-yaml"));
349
+ var import_utils2 = require("misoai-shared/utils");
350
350
  function interpolateEnvVars(content) {
351
351
  return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
352
352
  const value = process.env[envVar.trim()];
@@ -492,13 +492,13 @@ function paramStr(task) {
492
492
  }
493
493
 
494
494
  // src/common/utils.ts
495
+ var import_dayjs = __toESM(require("dayjs"));
495
496
  var import_ai_model = require("misoai-core/ai-model");
496
497
  var import_utils3 = require("misoai-core/utils");
497
498
  var import_env = require("misoai-shared/env");
498
499
  var import_extractor = require("misoai-shared/extractor");
499
500
  var import_img = require("misoai-shared/img");
500
501
  var import_utils4 = require("misoai-shared/utils");
501
- var import_dayjs = __toESM(require("dayjs"));
502
502
 
503
503
  // src/web-element.ts
504
504
  var WebElementInfo = class {
@@ -639,8 +639,12 @@ var WorkflowMemory = class {
639
639
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
640
640
  workflow.memory = [...memory];
641
641
  workflow.metadata.totalSteps = workflow.steps.length;
642
- workflow.metadata.completedSteps = workflow.steps.filter((s) => s.status === "completed").length;
643
- workflow.metadata.failedSteps = workflow.steps.filter((s) => s.status === "failed").length;
642
+ workflow.metadata.completedSteps = workflow.steps.filter(
643
+ (s) => s.status === "completed"
644
+ ).length;
645
+ workflow.metadata.failedSteps = workflow.steps.filter(
646
+ (s) => s.status === "failed"
647
+ ).length;
644
648
  this.workflows.set(workflowId, workflow);
645
649
  this.enforceRetentionPolicy();
646
650
  }
@@ -651,7 +655,9 @@ var WorkflowMemory = class {
651
655
  const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
652
656
  workflow.context = { ...workflow.context, ...context };
653
657
  if (context.currentStep) {
654
- const existingStep = workflow.steps.find((s) => s.stepName === context.currentStep);
658
+ const existingStep = workflow.steps.find(
659
+ (s) => s.stepName === context.currentStep
660
+ );
655
661
  if (!existingStep) {
656
662
  workflow.steps.push({
657
663
  stepId: `step_${workflow.steps.length + 1}`,
@@ -696,7 +702,9 @@ var WorkflowMemory = class {
696
702
  enforceRetentionPolicy() {
697
703
  const maxWorkflows = 10;
698
704
  if (this.workflows.size > maxWorkflows) {
699
- const sortedWorkflows = Array.from(this.workflows.entries()).sort(([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime));
705
+ const sortedWorkflows = Array.from(this.workflows.entries()).sort(
706
+ ([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
707
+ );
700
708
  const toDelete = sortedWorkflows.slice(maxWorkflows);
701
709
  toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
702
710
  }
@@ -1435,7 +1443,9 @@ var PageTaskExecutor = class {
1435
1443
  */
1436
1444
  getPersistentExecutor() {
1437
1445
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1438
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1446
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1447
+ this.sessionContext.workflowId
1448
+ );
1439
1449
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1440
1450
  onTaskStart: this.onTaskStartCallback,
1441
1451
  initialMemory: previousMemory
@@ -1464,7 +1474,9 @@ var PageTaskExecutor = class {
1464
1474
  if (this.persistentExecutor) {
1465
1475
  this.persistentExecutor.clearMemory();
1466
1476
  }
1467
- this.workflowMemory.clearWorkflow(this.sessionContext.workflowId || "default");
1477
+ this.workflowMemory.clearWorkflow(
1478
+ this.sessionContext.workflowId || "default"
1479
+ );
1468
1480
  }
1469
1481
  /**
1470
1482
  * Mevcut hafızayı döndürür
@@ -1476,7 +1488,9 @@ var PageTaskExecutor = class {
1476
1488
  * İş akışı hafızasını döndürür
1477
1489
  */
1478
1490
  getWorkflowMemory() {
1479
- return this.workflowMemory.getWorkflowData(this.sessionContext.workflowId || "default");
1491
+ return this.workflowMemory.getWorkflowData(
1492
+ this.sessionContext.workflowId || "default"
1493
+ );
1480
1494
  }
1481
1495
  /**
1482
1496
  * Hafıza istatistiklerini döndürür
@@ -1484,7 +1498,13 @@ var PageTaskExecutor = class {
1484
1498
  getMemoryStats() {
1485
1499
  return this.persistentExecutor?.getMemoryStats() || {
1486
1500
  totalItems: 0,
1487
- analytics: { totalTasks: 0, memoryHits: 0, memoryMisses: 0, averageMemorySize: 0, memoryEffectiveness: 0 },
1501
+ analytics: {
1502
+ totalTasks: 0,
1503
+ memoryHits: 0,
1504
+ memoryMisses: 0,
1505
+ averageMemorySize: 0,
1506
+ memoryEffectiveness: 0
1507
+ },
1488
1508
  config: this.memoryConfig
1489
1509
  };
1490
1510
  }
@@ -1520,11 +1540,14 @@ var PageTaskExecutor = class {
1520
1540
  let taskExecutor;
1521
1541
  if (useMemory) {
1522
1542
  taskExecutor = this.getPersistentExecutor();
1523
- this.workflowMemory.updateWorkflowContext({
1524
- currentStep: title,
1525
- pageInfo: this.sessionContext.pageInfo,
1526
- timestamp: Date.now()
1527
- }, this.sessionContext.workflowId || "default");
1543
+ this.workflowMemory.updateWorkflowContext(
1544
+ {
1545
+ currentStep: title,
1546
+ pageInfo: this.sessionContext.pageInfo,
1547
+ timestamp: Date.now()
1548
+ },
1549
+ this.sessionContext.workflowId || "default"
1550
+ );
1528
1551
  } else {
1529
1552
  taskExecutor = new import_misoai_core.Executor(title, {
1530
1553
  onTaskStart: this.onTaskStartCallback
@@ -1890,14 +1913,19 @@ var PageTaskExecutor = class {
1890
1913
  */
1891
1914
  addToMemory(memoryItem) {
1892
1915
  if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
1893
- const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
1916
+ const previousMemory = this.workflowMemory.getWorkflowMemory(
1917
+ this.sessionContext.workflowId
1918
+ );
1894
1919
  this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
1895
1920
  onTaskStart: this.onTaskStartCallback,
1896
1921
  initialMemory: previousMemory
1897
1922
  });
1898
1923
  }
1899
1924
  this.persistentExecutor.memoryStore?.add(memoryItem);
1900
- this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
1925
+ this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
1926
+ "add",
1927
+ memoryItem
1928
+ );
1901
1929
  }
1902
1930
  };
1903
1931
 
@@ -1986,14 +2014,14 @@ function buildPlans(type, locateParam, param) {
1986
2014
  var import_node_assert = __toESM(require("assert"));
1987
2015
  var import_node_fs2 = require("fs");
1988
2016
  var import_node_path2 = require("path");
2017
+ var import_js_yaml3 = __toESM(require("js-yaml"));
1989
2018
  var import_common2 = require("misoai-shared/common");
1990
2019
  var import_logger3 = require("misoai-shared/logger");
1991
2020
  var import_utils9 = require("misoai-shared/utils");
1992
- var import_js_yaml3 = __toESM(require("js-yaml"));
1993
2021
  var import_semver = __toESM(require("semver"));
1994
2022
 
1995
2023
  // package.json
1996
- var version = "1.6.0";
2024
+ var version = "1.6.1";
1997
2025
 
1998
2026
  // src/common/task-cache.ts
1999
2027
  var debug3 = (0, import_logger3.getDebug)("cache");
@@ -2288,22 +2316,28 @@ var PageAgent = class {
2288
2316
  const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
2289
2317
  const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
2290
2318
  const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
2291
- const planningTasks = executor.tasks.filter((task) => task.type === "Planning");
2292
- const insightTasks = executor.tasks.filter((task) => task.type === "Insight");
2319
+ const planningTasks = executor.tasks.filter(
2320
+ (task) => task.type === "Planning"
2321
+ );
2322
+ const insightTasks = executor.tasks.filter(
2323
+ (task) => task.type === "Insight"
2324
+ );
2293
2325
  const actionTasks = executor.tasks.filter((task) => task.type === "Action");
2294
2326
  const planning = planningTasks.length > 0 ? {
2295
2327
  type: "Planning",
2296
- description: `Planning for task execution`,
2328
+ description: "Planning for task execution",
2297
2329
  steps: planningTasks.map((task) => task.thought || "Planning step")
2298
2330
  } : void 0;
2299
2331
  const insight = insightTasks.length > 0 ? {
2300
2332
  type: "Insight",
2301
- description: `Insight for task execution`,
2302
- elements: insightTasks.map((task) => task.thought || "Insight element")
2333
+ description: "Insight for task execution",
2334
+ elements: insightTasks.map(
2335
+ (task) => task.thought || "Insight element"
2336
+ )
2303
2337
  } : void 0;
2304
2338
  const action = actionTasks.length > 0 ? {
2305
2339
  type: "Action",
2306
- description: `Action for task execution`,
2340
+ description: "Action for task execution",
2307
2341
  result: lastTask?.output
2308
2342
  } : void 0;
2309
2343
  const actionDetails = executor.tasks.map((task) => ({
@@ -2637,7 +2671,10 @@ ${memoryContext}` : void 0;
2637
2671
  }
2638
2672
  const memoryContext = this.getMemoryAsContext();
2639
2673
  const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
2640
- const { output, executor } = await this.taskExecutor.assert(assertionWithContext, memoryContext);
2674
+ const { output, executor } = await this.taskExecutor.assert(
2675
+ assertionWithContext,
2676
+ memoryContext
2677
+ );
2641
2678
  const metadata = this.afterTaskRunning(executor, true);
2642
2679
  if (output && opt?.keepRawResponse) {
2643
2680
  return {
@@ -2676,7 +2713,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
2676
2713
  Return only "complex" or "simple" based on your analysis.
2677
2714
  `;
2678
2715
  const complexityMsgs = [
2679
- { role: "system", content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity." },
2716
+ {
2717
+ role: "system",
2718
+ content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
2719
+ },
2680
2720
  {
2681
2721
  role: "user",
2682
2722
  content: [
@@ -2700,7 +2740,12 @@ Return only "complex" or "simple" based on your analysis.
2700
2740
  );
2701
2741
  const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
2702
2742
  shouldUseDeepThink = responseText.includes("complex");
2703
- debug4("CAPTCHA complexity analysis:", responseText, "Using deep think:", shouldUseDeepThink);
2743
+ debug4(
2744
+ "CAPTCHA complexity analysis:",
2745
+ responseText,
2746
+ "Using deep think:",
2747
+ shouldUseDeepThink
2748
+ );
2704
2749
  } catch (error) {
2705
2750
  debug4("Failed to analyze CAPTCHA complexity:", error);
2706
2751
  }
@@ -2717,7 +2762,9 @@ Return only "complex" or "simple" based on your analysis.
2717
2762
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2718
2763
  } else if (action.type === "input" && action.value) {
2719
2764
  if (action.target) {
2720
- await this.aiInput(action.value, action.target, { deepThink: shouldUseDeepThink });
2765
+ await this.aiInput(action.value, action.target, {
2766
+ deepThink: shouldUseDeepThink
2767
+ });
2721
2768
  }
2722
2769
  } else if (action.type === "verify" && action.target) {
2723
2770
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
@@ -2729,7 +2776,9 @@ Return only "complex" or "simple" based on your analysis.
2729
2776
  if (action.coordinates) {
2730
2777
  const x = action.coordinates[0];
2731
2778
  const y = action.coordinates[1];
2732
- await this.aiTap(`element at coordinates (${x}, ${y})`, { deepThink: shouldUseDeepThink });
2779
+ await this.aiTap(`element at coordinates (${x}, ${y})`, {
2780
+ deepThink: shouldUseDeepThink
2781
+ });
2733
2782
  } else if (action.target) {
2734
2783
  await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
2735
2784
  }
@@ -2881,25 +2930,27 @@ ${errors}`);
2881
2930
  const executionDump = {
2882
2931
  name: screenshotTitle,
2883
2932
  description: content,
2884
- tasks: [{
2885
- type: "Screenshot",
2886
- subType: "log",
2887
- status: "finished",
2888
- executor: null,
2889
- param: {
2890
- title: screenshotTitle,
2891
- content
2892
- },
2893
- output: {
2894
- screenshot
2895
- },
2896
- thought: `Logged screenshot: ${screenshotTitle}`,
2897
- timing: {
2898
- start: Date.now(),
2899
- end: Date.now(),
2900
- cost: 0
2933
+ tasks: [
2934
+ {
2935
+ type: "Screenshot",
2936
+ subType: "log",
2937
+ status: "finished",
2938
+ executor: null,
2939
+ param: {
2940
+ title: screenshotTitle,
2941
+ content
2942
+ },
2943
+ output: {
2944
+ screenshot
2945
+ },
2946
+ thought: `Logged screenshot: ${screenshotTitle}`,
2947
+ timing: {
2948
+ start: Date.now(),
2949
+ end: Date.now(),
2950
+ cost: 0
2951
+ }
2901
2952
  }
2902
- }],
2953
+ ],
2903
2954
  sdkVersion: "1.0.0",
2904
2955
  logTime: Date.now(),
2905
2956
  model_name: "screenshot"
@@ -2951,7 +3002,9 @@ ${errors}`);
2951
3002
  totalTasks: stats.analytics.totalTasks,
2952
3003
  memoryHits: stats.analytics.memoryHits,
2953
3004
  memoryMisses: stats.analytics.memoryMisses,
2954
- memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
3005
+ memoryEffectiveness: Math.round(
3006
+ stats.analytics.memoryEffectiveness * 100
3007
+ ),
2955
3008
  averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
2956
3009
  },
2957
3010
  config: stats.config,
@@ -3015,7 +3068,9 @@ ${errors}`);
3015
3068
  calculateSuccessRate(memory) {
3016
3069
  if (memory.length === 0)
3017
3070
  return 0;
3018
- const successCount = memory.filter((item) => item.metadata?.success !== false).length;
3071
+ const successCount = memory.filter(
3072
+ (item) => item.metadata?.success !== false
3073
+ ).length;
3019
3074
  return Math.round(successCount / memory.length * 100);
3020
3075
  }
3021
3076
  calculateAverageExecutionTime(memory) {
@@ -3154,7 +3209,7 @@ var BridgeServer = class {
3154
3209
  this.socket = socket;
3155
3210
  const clientVersion = socket.handshake.query.version;
3156
3211
  (0, import_utils16.logMsg)(
3157
- `Bridge connected, cli-side version v${"1.6.0"}, browser-side version v${clientVersion}`
3212
+ `Bridge connected, cli-side version v${"1.6.1"}, browser-side version v${clientVersion}`
3158
3213
  );
3159
3214
  socket.on("bridge-call-response" /* CallResponse */, (params) => {
3160
3215
  const id = params.id;
@@ -3185,7 +3240,7 @@ var BridgeServer = class {
3185
3240
  setTimeout(() => {
3186
3241
  this.onConnect?.();
3187
3242
  const payload = {
3188
- version: "1.6.0"
3243
+ version: "1.6.1"
3189
3244
  };
3190
3245
  socket.emit("bridge-connected" /* Connected */, payload);
3191
3246
  Promise.resolve().then(() => {