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
@@ -22,6 +22,7 @@ var __privateMethod = (obj, member, method) => {
|
|
22
22
|
};
|
23
23
|
|
24
24
|
// src/common/utils.ts
|
25
|
+
import dayjs from "dayjs";
|
25
26
|
import { elementByPositionWithElementInfo } from "misoai-core/ai-model";
|
26
27
|
import { uploadTestInfoToServer } from "misoai-core/utils";
|
27
28
|
import { MIDSCENE_REPORT_TAG_NAME, getAIConfig } from "misoai-shared/env";
|
@@ -33,7 +34,6 @@ import {
|
|
33
34
|
} from "misoai-shared/extractor";
|
34
35
|
import { resizeImgBase64 } from "misoai-shared/img";
|
35
36
|
import { assert, logMsg, uuid } from "misoai-shared/utils";
|
36
|
-
import dayjs from "dayjs";
|
37
37
|
|
38
38
|
// src/web-element.ts
|
39
39
|
var WebElementInfo = class {
|
@@ -452,8 +452,8 @@ var ScriptPlayer = class {
|
|
452
452
|
import yaml from "js-yaml";
|
453
453
|
|
454
454
|
// src/yaml/utils.ts
|
455
|
-
import { assert as assert3 } from "misoai-shared/utils";
|
456
455
|
import yaml2 from "js-yaml";
|
456
|
+
import { assert as assert3 } from "misoai-shared/utils";
|
457
457
|
function interpolateEnvVars(content) {
|
458
458
|
return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
|
459
459
|
const value = process.env[envVar.trim()];
|
@@ -667,8 +667,12 @@ var WorkflowMemory = class {
|
|
667
667
|
const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
|
668
668
|
workflow.memory = [...memory];
|
669
669
|
workflow.metadata.totalSteps = workflow.steps.length;
|
670
|
-
workflow.metadata.completedSteps = workflow.steps.filter(
|
671
|
-
|
670
|
+
workflow.metadata.completedSteps = workflow.steps.filter(
|
671
|
+
(s) => s.status === "completed"
|
672
|
+
).length;
|
673
|
+
workflow.metadata.failedSteps = workflow.steps.filter(
|
674
|
+
(s) => s.status === "failed"
|
675
|
+
).length;
|
672
676
|
this.workflows.set(workflowId, workflow);
|
673
677
|
this.enforceRetentionPolicy();
|
674
678
|
}
|
@@ -679,7 +683,9 @@ var WorkflowMemory = class {
|
|
679
683
|
const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
|
680
684
|
workflow.context = { ...workflow.context, ...context };
|
681
685
|
if (context.currentStep) {
|
682
|
-
const existingStep = workflow.steps.find(
|
686
|
+
const existingStep = workflow.steps.find(
|
687
|
+
(s) => s.stepName === context.currentStep
|
688
|
+
);
|
683
689
|
if (!existingStep) {
|
684
690
|
workflow.steps.push({
|
685
691
|
stepId: `step_${workflow.steps.length + 1}`,
|
@@ -724,7 +730,9 @@ var WorkflowMemory = class {
|
|
724
730
|
enforceRetentionPolicy() {
|
725
731
|
const maxWorkflows = 10;
|
726
732
|
if (this.workflows.size > maxWorkflows) {
|
727
|
-
const sortedWorkflows = Array.from(this.workflows.entries()).sort(
|
733
|
+
const sortedWorkflows = Array.from(this.workflows.entries()).sort(
|
734
|
+
([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
|
735
|
+
);
|
728
736
|
const toDelete = sortedWorkflows.slice(maxWorkflows);
|
729
737
|
toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
|
730
738
|
}
|
@@ -1463,7 +1471,9 @@ var PageTaskExecutor = class {
|
|
1463
1471
|
*/
|
1464
1472
|
getPersistentExecutor() {
|
1465
1473
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1466
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1474
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1475
|
+
this.sessionContext.workflowId
|
1476
|
+
);
|
1467
1477
|
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1468
1478
|
onTaskStart: this.onTaskStartCallback,
|
1469
1479
|
initialMemory: previousMemory
|
@@ -1492,7 +1502,9 @@ var PageTaskExecutor = class {
|
|
1492
1502
|
if (this.persistentExecutor) {
|
1493
1503
|
this.persistentExecutor.clearMemory();
|
1494
1504
|
}
|
1495
|
-
this.workflowMemory.clearWorkflow(
|
1505
|
+
this.workflowMemory.clearWorkflow(
|
1506
|
+
this.sessionContext.workflowId || "default"
|
1507
|
+
);
|
1496
1508
|
}
|
1497
1509
|
/**
|
1498
1510
|
* Mevcut hafızayı döndürür
|
@@ -1504,7 +1516,9 @@ var PageTaskExecutor = class {
|
|
1504
1516
|
* İş akışı hafızasını döndürür
|
1505
1517
|
*/
|
1506
1518
|
getWorkflowMemory() {
|
1507
|
-
return this.workflowMemory.getWorkflowData(
|
1519
|
+
return this.workflowMemory.getWorkflowData(
|
1520
|
+
this.sessionContext.workflowId || "default"
|
1521
|
+
);
|
1508
1522
|
}
|
1509
1523
|
/**
|
1510
1524
|
* Hafıza istatistiklerini döndürür
|
@@ -1512,7 +1526,13 @@ var PageTaskExecutor = class {
|
|
1512
1526
|
getMemoryStats() {
|
1513
1527
|
return this.persistentExecutor?.getMemoryStats() || {
|
1514
1528
|
totalItems: 0,
|
1515
|
-
analytics: {
|
1529
|
+
analytics: {
|
1530
|
+
totalTasks: 0,
|
1531
|
+
memoryHits: 0,
|
1532
|
+
memoryMisses: 0,
|
1533
|
+
averageMemorySize: 0,
|
1534
|
+
memoryEffectiveness: 0
|
1535
|
+
},
|
1516
1536
|
config: this.memoryConfig
|
1517
1537
|
};
|
1518
1538
|
}
|
@@ -1548,11 +1568,14 @@ var PageTaskExecutor = class {
|
|
1548
1568
|
let taskExecutor;
|
1549
1569
|
if (useMemory) {
|
1550
1570
|
taskExecutor = this.getPersistentExecutor();
|
1551
|
-
this.workflowMemory.updateWorkflowContext(
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1571
|
+
this.workflowMemory.updateWorkflowContext(
|
1572
|
+
{
|
1573
|
+
currentStep: title,
|
1574
|
+
pageInfo: this.sessionContext.pageInfo,
|
1575
|
+
timestamp: Date.now()
|
1576
|
+
},
|
1577
|
+
this.sessionContext.workflowId || "default"
|
1578
|
+
);
|
1556
1579
|
} else {
|
1557
1580
|
taskExecutor = new Executor(title, {
|
1558
1581
|
onTaskStart: this.onTaskStartCallback
|
@@ -1918,14 +1941,19 @@ var PageTaskExecutor = class {
|
|
1918
1941
|
*/
|
1919
1942
|
addToMemory(memoryItem) {
|
1920
1943
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1921
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1944
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1945
|
+
this.sessionContext.workflowId
|
1946
|
+
);
|
1922
1947
|
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1923
1948
|
onTaskStart: this.onTaskStartCallback,
|
1924
1949
|
initialMemory: previousMemory
|
1925
1950
|
});
|
1926
1951
|
}
|
1927
1952
|
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1928
|
-
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1953
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1954
|
+
"add",
|
1955
|
+
memoryItem
|
1956
|
+
);
|
1929
1957
|
}
|
1930
1958
|
};
|
1931
1959
|
|
@@ -2014,14 +2042,14 @@ function buildPlans(type, locateParam, param) {
|
|
2014
2042
|
import assert6 from "assert";
|
2015
2043
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
|
2016
2044
|
import { dirname as dirname2, join as join2 } from "path";
|
2045
|
+
import yaml3 from "js-yaml";
|
2017
2046
|
import { getMidsceneRunSubDir as getMidsceneRunSubDir2 } from "misoai-shared/common";
|
2018
2047
|
import { getDebug as getDebug3 } from "misoai-shared/logger";
|
2019
2048
|
import { ifInBrowser as ifInBrowser2 } from "misoai-shared/utils";
|
2020
|
-
import yaml3 from "js-yaml";
|
2021
2049
|
import semver from "semver";
|
2022
2050
|
|
2023
2051
|
// package.json
|
2024
|
-
var version = "1.6.
|
2052
|
+
var version = "1.6.1";
|
2025
2053
|
|
2026
2054
|
// src/common/task-cache.ts
|
2027
2055
|
var debug3 = getDebug3("cache");
|
@@ -2316,22 +2344,28 @@ var PageAgent = class {
|
|
2316
2344
|
const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
|
2317
2345
|
const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
|
2318
2346
|
const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
|
2319
|
-
const planningTasks = executor.tasks.filter(
|
2320
|
-
|
2347
|
+
const planningTasks = executor.tasks.filter(
|
2348
|
+
(task) => task.type === "Planning"
|
2349
|
+
);
|
2350
|
+
const insightTasks = executor.tasks.filter(
|
2351
|
+
(task) => task.type === "Insight"
|
2352
|
+
);
|
2321
2353
|
const actionTasks = executor.tasks.filter((task) => task.type === "Action");
|
2322
2354
|
const planning = planningTasks.length > 0 ? {
|
2323
2355
|
type: "Planning",
|
2324
|
-
description:
|
2356
|
+
description: "Planning for task execution",
|
2325
2357
|
steps: planningTasks.map((task) => task.thought || "Planning step")
|
2326
2358
|
} : void 0;
|
2327
2359
|
const insight = insightTasks.length > 0 ? {
|
2328
2360
|
type: "Insight",
|
2329
|
-
description:
|
2330
|
-
elements: insightTasks.map(
|
2361
|
+
description: "Insight for task execution",
|
2362
|
+
elements: insightTasks.map(
|
2363
|
+
(task) => task.thought || "Insight element"
|
2364
|
+
)
|
2331
2365
|
} : void 0;
|
2332
2366
|
const action = actionTasks.length > 0 ? {
|
2333
2367
|
type: "Action",
|
2334
|
-
description:
|
2368
|
+
description: "Action for task execution",
|
2335
2369
|
result: lastTask?.output
|
2336
2370
|
} : void 0;
|
2337
2371
|
const actionDetails = executor.tasks.map((task) => ({
|
@@ -2665,7 +2699,10 @@ ${memoryContext}` : void 0;
|
|
2665
2699
|
}
|
2666
2700
|
const memoryContext = this.getMemoryAsContext();
|
2667
2701
|
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2668
|
-
const { output, executor } = await this.taskExecutor.assert(
|
2702
|
+
const { output, executor } = await this.taskExecutor.assert(
|
2703
|
+
assertionWithContext,
|
2704
|
+
memoryContext
|
2705
|
+
);
|
2669
2706
|
const metadata = this.afterTaskRunning(executor, true);
|
2670
2707
|
if (output && opt?.keepRawResponse) {
|
2671
2708
|
return {
|
@@ -2704,7 +2741,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
|
|
2704
2741
|
Return only "complex" or "simple" based on your analysis.
|
2705
2742
|
`;
|
2706
2743
|
const complexityMsgs = [
|
2707
|
-
{
|
2744
|
+
{
|
2745
|
+
role: "system",
|
2746
|
+
content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
|
2747
|
+
},
|
2708
2748
|
{
|
2709
2749
|
role: "user",
|
2710
2750
|
content: [
|
@@ -2728,7 +2768,12 @@ Return only "complex" or "simple" based on your analysis.
|
|
2728
2768
|
);
|
2729
2769
|
const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
|
2730
2770
|
shouldUseDeepThink = responseText.includes("complex");
|
2731
|
-
debug4(
|
2771
|
+
debug4(
|
2772
|
+
"CAPTCHA complexity analysis:",
|
2773
|
+
responseText,
|
2774
|
+
"Using deep think:",
|
2775
|
+
shouldUseDeepThink
|
2776
|
+
);
|
2732
2777
|
} catch (error) {
|
2733
2778
|
debug4("Failed to analyze CAPTCHA complexity:", error);
|
2734
2779
|
}
|
@@ -2745,7 +2790,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2745
2790
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2746
2791
|
} else if (action.type === "input" && action.value) {
|
2747
2792
|
if (action.target) {
|
2748
|
-
await this.aiInput(action.value, action.target, {
|
2793
|
+
await this.aiInput(action.value, action.target, {
|
2794
|
+
deepThink: shouldUseDeepThink
|
2795
|
+
});
|
2749
2796
|
}
|
2750
2797
|
} else if (action.type === "verify" && action.target) {
|
2751
2798
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
@@ -2757,7 +2804,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2757
2804
|
if (action.coordinates) {
|
2758
2805
|
const x = action.coordinates[0];
|
2759
2806
|
const y = action.coordinates[1];
|
2760
|
-
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2807
|
+
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2808
|
+
deepThink: shouldUseDeepThink
|
2809
|
+
});
|
2761
2810
|
} else if (action.target) {
|
2762
2811
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2763
2812
|
}
|
@@ -2909,25 +2958,27 @@ ${errors}`);
|
|
2909
2958
|
const executionDump = {
|
2910
2959
|
name: screenshotTitle,
|
2911
2960
|
description: content,
|
2912
|
-
tasks: [
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2961
|
+
tasks: [
|
2962
|
+
{
|
2963
|
+
type: "Screenshot",
|
2964
|
+
subType: "log",
|
2965
|
+
status: "finished",
|
2966
|
+
executor: null,
|
2967
|
+
param: {
|
2968
|
+
title: screenshotTitle,
|
2969
|
+
content
|
2970
|
+
},
|
2971
|
+
output: {
|
2972
|
+
screenshot
|
2973
|
+
},
|
2974
|
+
thought: `Logged screenshot: ${screenshotTitle}`,
|
2975
|
+
timing: {
|
2976
|
+
start: Date.now(),
|
2977
|
+
end: Date.now(),
|
2978
|
+
cost: 0
|
2979
|
+
}
|
2929
2980
|
}
|
2930
|
-
|
2981
|
+
],
|
2931
2982
|
sdkVersion: "1.0.0",
|
2932
2983
|
logTime: Date.now(),
|
2933
2984
|
model_name: "screenshot"
|
@@ -2979,7 +3030,9 @@ ${errors}`);
|
|
2979
3030
|
totalTasks: stats.analytics.totalTasks,
|
2980
3031
|
memoryHits: stats.analytics.memoryHits,
|
2981
3032
|
memoryMisses: stats.analytics.memoryMisses,
|
2982
|
-
memoryEffectiveness: Math.round(
|
3033
|
+
memoryEffectiveness: Math.round(
|
3034
|
+
stats.analytics.memoryEffectiveness * 100
|
3035
|
+
),
|
2983
3036
|
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2984
3037
|
},
|
2985
3038
|
config: stats.config,
|
@@ -3043,7 +3096,9 @@ ${errors}`);
|
|
3043
3096
|
calculateSuccessRate(memory) {
|
3044
3097
|
if (memory.length === 0)
|
3045
3098
|
return 0;
|
3046
|
-
const successCount = memory.filter(
|
3099
|
+
const successCount = memory.filter(
|
3100
|
+
(item) => item.metadata?.success !== false
|
3101
|
+
).length;
|
3047
3102
|
return Math.round(successCount / memory.length * 100);
|
3048
3103
|
}
|
3049
3104
|
calculateAverageExecutionTime(memory) {
|
@@ -3289,7 +3344,7 @@ function sleep2(ms) {
|
|
3289
3344
|
var ChromeExtensionProxyPage = class {
|
3290
3345
|
constructor(forceSameTabNavigation) {
|
3291
3346
|
this.pageType = "chrome-extension-proxy";
|
3292
|
-
this.version = "1.6.
|
3347
|
+
this.version = "1.6.1";
|
3293
3348
|
this.activeTabId = null;
|
3294
3349
|
this.tabIdOfDebuggerAttached = null;
|
3295
3350
|
this.attachingDebugger = null;
|