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.
- package/dist/es/agent.js +105 -50
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode-browser.js.map +1 -1
- package/dist/es/bridge-mode.js +107 -52
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +106 -51
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +106 -51
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +108 -53
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js +4 -4
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +105 -50
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright-report.js +1 -1
- package/dist/es/playwright-report.js.map +1 -1
- package/dist/es/playwright.js +106 -51
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +105 -50
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +105 -50
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/utils.js +1 -1
- package/dist/es/utils.js.map +1 -1
- package/dist/es/yaml.js +1 -1
- package/dist/es/yaml.js.map +1 -1
- package/dist/lib/agent.js +105 -50
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode-browser.js.map +1 -1
- package/dist/lib/bridge-mode.js +107 -52
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +106 -51
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +106 -51
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +108 -53
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js +4 -4
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +105 -50
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright-report.js +1 -1
- package/dist/lib/playwright-report.js.map +1 -1
- package/dist/lib/playwright.js +106 -51
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +105 -50
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +105 -50
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/yaml.js +1 -1
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/playwright.d.ts +1 -1
- 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(
|
624
|
-
|
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(
|
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(
|
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
|
}
|
@@ -1416,7 +1424,9 @@ var PageTaskExecutor = class {
|
|
1416
1424
|
*/
|
1417
1425
|
getPersistentExecutor() {
|
1418
1426
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1419
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1427
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1428
|
+
this.sessionContext.workflowId
|
1429
|
+
);
|
1420
1430
|
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1421
1431
|
onTaskStart: this.onTaskStartCallback,
|
1422
1432
|
initialMemory: previousMemory
|
@@ -1445,7 +1455,9 @@ var PageTaskExecutor = class {
|
|
1445
1455
|
if (this.persistentExecutor) {
|
1446
1456
|
this.persistentExecutor.clearMemory();
|
1447
1457
|
}
|
1448
|
-
this.workflowMemory.clearWorkflow(
|
1458
|
+
this.workflowMemory.clearWorkflow(
|
1459
|
+
this.sessionContext.workflowId || "default"
|
1460
|
+
);
|
1449
1461
|
}
|
1450
1462
|
/**
|
1451
1463
|
* Mevcut hafızayı döndürür
|
@@ -1457,7 +1469,9 @@ var PageTaskExecutor = class {
|
|
1457
1469
|
* İş akışı hafızasını döndürür
|
1458
1470
|
*/
|
1459
1471
|
getWorkflowMemory() {
|
1460
|
-
return this.workflowMemory.getWorkflowData(
|
1472
|
+
return this.workflowMemory.getWorkflowData(
|
1473
|
+
this.sessionContext.workflowId || "default"
|
1474
|
+
);
|
1461
1475
|
}
|
1462
1476
|
/**
|
1463
1477
|
* Hafıza istatistiklerini döndürür
|
@@ -1465,7 +1479,13 @@ var PageTaskExecutor = class {
|
|
1465
1479
|
getMemoryStats() {
|
1466
1480
|
return this.persistentExecutor?.getMemoryStats() || {
|
1467
1481
|
totalItems: 0,
|
1468
|
-
analytics: {
|
1482
|
+
analytics: {
|
1483
|
+
totalTasks: 0,
|
1484
|
+
memoryHits: 0,
|
1485
|
+
memoryMisses: 0,
|
1486
|
+
averageMemorySize: 0,
|
1487
|
+
memoryEffectiveness: 0
|
1488
|
+
},
|
1469
1489
|
config: this.memoryConfig
|
1470
1490
|
};
|
1471
1491
|
}
|
@@ -1501,11 +1521,14 @@ var PageTaskExecutor = class {
|
|
1501
1521
|
let taskExecutor;
|
1502
1522
|
if (useMemory) {
|
1503
1523
|
taskExecutor = this.getPersistentExecutor();
|
1504
|
-
this.workflowMemory.updateWorkflowContext(
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1524
|
+
this.workflowMemory.updateWorkflowContext(
|
1525
|
+
{
|
1526
|
+
currentStep: title,
|
1527
|
+
pageInfo: this.sessionContext.pageInfo,
|
1528
|
+
timestamp: Date.now()
|
1529
|
+
},
|
1530
|
+
this.sessionContext.workflowId || "default"
|
1531
|
+
);
|
1509
1532
|
} else {
|
1510
1533
|
taskExecutor = new Executor(title, {
|
1511
1534
|
onTaskStart: this.onTaskStartCallback
|
@@ -1871,14 +1894,19 @@ var PageTaskExecutor = class {
|
|
1871
1894
|
*/
|
1872
1895
|
addToMemory(memoryItem) {
|
1873
1896
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1874
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1897
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1898
|
+
this.sessionContext.workflowId
|
1899
|
+
);
|
1875
1900
|
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1876
1901
|
onTaskStart: this.onTaskStartCallback,
|
1877
1902
|
initialMemory: previousMemory
|
1878
1903
|
});
|
1879
1904
|
}
|
1880
1905
|
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1881
|
-
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1906
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1907
|
+
"add",
|
1908
|
+
memoryItem
|
1909
|
+
);
|
1882
1910
|
}
|
1883
1911
|
};
|
1884
1912
|
|
@@ -1967,14 +1995,14 @@ function buildPlans(type, locateParam, param) {
|
|
1967
1995
|
import assert6 from "assert";
|
1968
1996
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
|
1969
1997
|
import { dirname as dirname2, join as join2 } from "path";
|
1998
|
+
import yaml3 from "js-yaml";
|
1970
1999
|
import { getMidsceneRunSubDir as getMidsceneRunSubDir2 } from "misoai-shared/common";
|
1971
2000
|
import { getDebug as getDebug3 } from "misoai-shared/logger";
|
1972
2001
|
import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
|
1973
|
-
import yaml3 from "js-yaml";
|
1974
2002
|
import semver from "semver";
|
1975
2003
|
|
1976
2004
|
// package.json
|
1977
|
-
var version = "1.6.
|
2005
|
+
var version = "1.6.1";
|
1978
2006
|
|
1979
2007
|
// src/common/task-cache.ts
|
1980
2008
|
var debug3 = getDebug3("cache");
|
@@ -2269,22 +2297,28 @@ var PageAgent = class {
|
|
2269
2297
|
const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
|
2270
2298
|
const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
|
2271
2299
|
const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
|
2272
|
-
const planningTasks = executor.tasks.filter(
|
2273
|
-
|
2300
|
+
const planningTasks = executor.tasks.filter(
|
2301
|
+
(task) => task.type === "Planning"
|
2302
|
+
);
|
2303
|
+
const insightTasks = executor.tasks.filter(
|
2304
|
+
(task) => task.type === "Insight"
|
2305
|
+
);
|
2274
2306
|
const actionTasks = executor.tasks.filter((task) => task.type === "Action");
|
2275
2307
|
const planning = planningTasks.length > 0 ? {
|
2276
2308
|
type: "Planning",
|
2277
|
-
description:
|
2309
|
+
description: "Planning for task execution",
|
2278
2310
|
steps: planningTasks.map((task) => task.thought || "Planning step")
|
2279
2311
|
} : void 0;
|
2280
2312
|
const insight = insightTasks.length > 0 ? {
|
2281
2313
|
type: "Insight",
|
2282
|
-
description:
|
2283
|
-
elements: insightTasks.map(
|
2314
|
+
description: "Insight for task execution",
|
2315
|
+
elements: insightTasks.map(
|
2316
|
+
(task) => task.thought || "Insight element"
|
2317
|
+
)
|
2284
2318
|
} : void 0;
|
2285
2319
|
const action = actionTasks.length > 0 ? {
|
2286
2320
|
type: "Action",
|
2287
|
-
description:
|
2321
|
+
description: "Action for task execution",
|
2288
2322
|
result: lastTask?.output
|
2289
2323
|
} : void 0;
|
2290
2324
|
const actionDetails = executor.tasks.map((task) => ({
|
@@ -2618,7 +2652,10 @@ ${memoryContext}` : void 0;
|
|
2618
2652
|
}
|
2619
2653
|
const memoryContext = this.getMemoryAsContext();
|
2620
2654
|
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2621
|
-
const { output, executor } = await this.taskExecutor.assert(
|
2655
|
+
const { output, executor } = await this.taskExecutor.assert(
|
2656
|
+
assertionWithContext,
|
2657
|
+
memoryContext
|
2658
|
+
);
|
2622
2659
|
const metadata = this.afterTaskRunning(executor, true);
|
2623
2660
|
if (output && opt?.keepRawResponse) {
|
2624
2661
|
return {
|
@@ -2657,7 +2694,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
|
|
2657
2694
|
Return only "complex" or "simple" based on your analysis.
|
2658
2695
|
`;
|
2659
2696
|
const complexityMsgs = [
|
2660
|
-
{
|
2697
|
+
{
|
2698
|
+
role: "system",
|
2699
|
+
content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
|
2700
|
+
},
|
2661
2701
|
{
|
2662
2702
|
role: "user",
|
2663
2703
|
content: [
|
@@ -2681,7 +2721,12 @@ Return only "complex" or "simple" based on your analysis.
|
|
2681
2721
|
);
|
2682
2722
|
const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
|
2683
2723
|
shouldUseDeepThink = responseText.includes("complex");
|
2684
|
-
debug4(
|
2724
|
+
debug4(
|
2725
|
+
"CAPTCHA complexity analysis:",
|
2726
|
+
responseText,
|
2727
|
+
"Using deep think:",
|
2728
|
+
shouldUseDeepThink
|
2729
|
+
);
|
2685
2730
|
} catch (error) {
|
2686
2731
|
debug4("Failed to analyze CAPTCHA complexity:", error);
|
2687
2732
|
}
|
@@ -2698,7 +2743,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2698
2743
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2699
2744
|
} else if (action.type === "input" && action.value) {
|
2700
2745
|
if (action.target) {
|
2701
|
-
await this.aiInput(action.value, action.target, {
|
2746
|
+
await this.aiInput(action.value, action.target, {
|
2747
|
+
deepThink: shouldUseDeepThink
|
2748
|
+
});
|
2702
2749
|
}
|
2703
2750
|
} else if (action.type === "verify" && action.target) {
|
2704
2751
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
@@ -2710,7 +2757,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2710
2757
|
if (action.coordinates) {
|
2711
2758
|
const x = action.coordinates[0];
|
2712
2759
|
const y = action.coordinates[1];
|
2713
|
-
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2760
|
+
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2761
|
+
deepThink: shouldUseDeepThink
|
2762
|
+
});
|
2714
2763
|
} else if (action.target) {
|
2715
2764
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2716
2765
|
}
|
@@ -2862,25 +2911,27 @@ ${errors}`);
|
|
2862
2911
|
const executionDump = {
|
2863
2912
|
name: screenshotTitle,
|
2864
2913
|
description: content,
|
2865
|
-
tasks: [
|
2866
|
-
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2914
|
+
tasks: [
|
2915
|
+
{
|
2916
|
+
type: "Screenshot",
|
2917
|
+
subType: "log",
|
2918
|
+
status: "finished",
|
2919
|
+
executor: null,
|
2920
|
+
param: {
|
2921
|
+
title: screenshotTitle,
|
2922
|
+
content
|
2923
|
+
},
|
2924
|
+
output: {
|
2925
|
+
screenshot
|
2926
|
+
},
|
2927
|
+
thought: `Logged screenshot: ${screenshotTitle}`,
|
2928
|
+
timing: {
|
2929
|
+
start: Date.now(),
|
2930
|
+
end: Date.now(),
|
2931
|
+
cost: 0
|
2932
|
+
}
|
2882
2933
|
}
|
2883
|
-
|
2934
|
+
],
|
2884
2935
|
sdkVersion: "1.0.0",
|
2885
2936
|
logTime: Date.now(),
|
2886
2937
|
model_name: "screenshot"
|
@@ -2932,7 +2983,9 @@ ${errors}`);
|
|
2932
2983
|
totalTasks: stats.analytics.totalTasks,
|
2933
2984
|
memoryHits: stats.analytics.memoryHits,
|
2934
2985
|
memoryMisses: stats.analytics.memoryMisses,
|
2935
|
-
memoryEffectiveness: Math.round(
|
2986
|
+
memoryEffectiveness: Math.round(
|
2987
|
+
stats.analytics.memoryEffectiveness * 100
|
2988
|
+
),
|
2936
2989
|
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2937
2990
|
},
|
2938
2991
|
config: stats.config,
|
@@ -2996,7 +3049,9 @@ ${errors}`);
|
|
2996
3049
|
calculateSuccessRate(memory) {
|
2997
3050
|
if (memory.length === 0)
|
2998
3051
|
return 0;
|
2999
|
-
const successCount = memory.filter(
|
3052
|
+
const successCount = memory.filter(
|
3053
|
+
(item) => item.metadata?.success !== false
|
3054
|
+
).length;
|
3000
3055
|
return Math.round(successCount / memory.length * 100);
|
3001
3056
|
}
|
3002
3057
|
calculateAverageExecutionTime(memory) {
|