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/lib/index.js
CHANGED
@@ -349,8 +349,8 @@ var ScriptPlayer = class {
|
|
349
349
|
var import_js_yaml = __toESM(require("js-yaml"));
|
350
350
|
|
351
351
|
// src/yaml/utils.ts
|
352
|
-
var import_utils2 = require("misoai-shared/utils");
|
353
352
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
353
|
+
var import_utils2 = require("misoai-shared/utils");
|
354
354
|
function interpolateEnvVars(content) {
|
355
355
|
return content.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
|
356
356
|
const value = process.env[envVar.trim()];
|
@@ -496,13 +496,13 @@ function paramStr(task) {
|
|
496
496
|
}
|
497
497
|
|
498
498
|
// src/common/utils.ts
|
499
|
+
var import_dayjs = __toESM(require("dayjs"));
|
499
500
|
var import_ai_model = require("misoai-core/ai-model");
|
500
501
|
var import_utils3 = require("misoai-core/utils");
|
501
502
|
var import_env = require("misoai-shared/env");
|
502
503
|
var import_extractor = require("misoai-shared/extractor");
|
503
504
|
var import_img = require("misoai-shared/img");
|
504
505
|
var import_utils4 = require("misoai-shared/utils");
|
505
|
-
var import_dayjs = __toESM(require("dayjs"));
|
506
506
|
|
507
507
|
// src/web-element.ts
|
508
508
|
var WebElementInfo = class {
|
@@ -671,8 +671,12 @@ var WorkflowMemory = class {
|
|
671
671
|
const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
|
672
672
|
workflow.memory = [...memory];
|
673
673
|
workflow.metadata.totalSteps = workflow.steps.length;
|
674
|
-
workflow.metadata.completedSteps = workflow.steps.filter(
|
675
|
-
|
674
|
+
workflow.metadata.completedSteps = workflow.steps.filter(
|
675
|
+
(s) => s.status === "completed"
|
676
|
+
).length;
|
677
|
+
workflow.metadata.failedSteps = workflow.steps.filter(
|
678
|
+
(s) => s.status === "failed"
|
679
|
+
).length;
|
676
680
|
this.workflows.set(workflowId, workflow);
|
677
681
|
this.enforceRetentionPolicy();
|
678
682
|
}
|
@@ -683,7 +687,9 @@ var WorkflowMemory = class {
|
|
683
687
|
const workflow = this.workflows.get(workflowId) || this.createEmptyWorkflowData(workflowId);
|
684
688
|
workflow.context = { ...workflow.context, ...context };
|
685
689
|
if (context.currentStep) {
|
686
|
-
const existingStep = workflow.steps.find(
|
690
|
+
const existingStep = workflow.steps.find(
|
691
|
+
(s) => s.stepName === context.currentStep
|
692
|
+
);
|
687
693
|
if (!existingStep) {
|
688
694
|
workflow.steps.push({
|
689
695
|
stepId: `step_${workflow.steps.length + 1}`,
|
@@ -728,7 +734,9 @@ var WorkflowMemory = class {
|
|
728
734
|
enforceRetentionPolicy() {
|
729
735
|
const maxWorkflows = 10;
|
730
736
|
if (this.workflows.size > maxWorkflows) {
|
731
|
-
const sortedWorkflows = Array.from(this.workflows.entries()).sort(
|
737
|
+
const sortedWorkflows = Array.from(this.workflows.entries()).sort(
|
738
|
+
([, a], [, b]) => (b.metadata.endTime || b.metadata.startTime) - (a.metadata.endTime || a.metadata.startTime)
|
739
|
+
);
|
732
740
|
const toDelete = sortedWorkflows.slice(maxWorkflows);
|
733
741
|
toDelete.forEach(([workflowId]) => this.workflows.delete(workflowId));
|
734
742
|
}
|
@@ -1467,7 +1475,9 @@ var PageTaskExecutor = class {
|
|
1467
1475
|
*/
|
1468
1476
|
getPersistentExecutor() {
|
1469
1477
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1470
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1478
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1479
|
+
this.sessionContext.workflowId
|
1480
|
+
);
|
1471
1481
|
this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
|
1472
1482
|
onTaskStart: this.onTaskStartCallback,
|
1473
1483
|
initialMemory: previousMemory
|
@@ -1496,7 +1506,9 @@ var PageTaskExecutor = class {
|
|
1496
1506
|
if (this.persistentExecutor) {
|
1497
1507
|
this.persistentExecutor.clearMemory();
|
1498
1508
|
}
|
1499
|
-
this.workflowMemory.clearWorkflow(
|
1509
|
+
this.workflowMemory.clearWorkflow(
|
1510
|
+
this.sessionContext.workflowId || "default"
|
1511
|
+
);
|
1500
1512
|
}
|
1501
1513
|
/**
|
1502
1514
|
* Mevcut hafızayı döndürür
|
@@ -1508,7 +1520,9 @@ var PageTaskExecutor = class {
|
|
1508
1520
|
* İş akışı hafızasını döndürür
|
1509
1521
|
*/
|
1510
1522
|
getWorkflowMemory() {
|
1511
|
-
return this.workflowMemory.getWorkflowData(
|
1523
|
+
return this.workflowMemory.getWorkflowData(
|
1524
|
+
this.sessionContext.workflowId || "default"
|
1525
|
+
);
|
1512
1526
|
}
|
1513
1527
|
/**
|
1514
1528
|
* Hafıza istatistiklerini döndürür
|
@@ -1516,7 +1530,13 @@ var PageTaskExecutor = class {
|
|
1516
1530
|
getMemoryStats() {
|
1517
1531
|
return this.persistentExecutor?.getMemoryStats() || {
|
1518
1532
|
totalItems: 0,
|
1519
|
-
analytics: {
|
1533
|
+
analytics: {
|
1534
|
+
totalTasks: 0,
|
1535
|
+
memoryHits: 0,
|
1536
|
+
memoryMisses: 0,
|
1537
|
+
averageMemorySize: 0,
|
1538
|
+
memoryEffectiveness: 0
|
1539
|
+
},
|
1520
1540
|
config: this.memoryConfig
|
1521
1541
|
};
|
1522
1542
|
}
|
@@ -1552,11 +1572,14 @@ var PageTaskExecutor = class {
|
|
1552
1572
|
let taskExecutor;
|
1553
1573
|
if (useMemory) {
|
1554
1574
|
taskExecutor = this.getPersistentExecutor();
|
1555
|
-
this.workflowMemory.updateWorkflowContext(
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1575
|
+
this.workflowMemory.updateWorkflowContext(
|
1576
|
+
{
|
1577
|
+
currentStep: title,
|
1578
|
+
pageInfo: this.sessionContext.pageInfo,
|
1579
|
+
timestamp: Date.now()
|
1580
|
+
},
|
1581
|
+
this.sessionContext.workflowId || "default"
|
1582
|
+
);
|
1560
1583
|
} else {
|
1561
1584
|
taskExecutor = new import_misoai_core.Executor(title, {
|
1562
1585
|
onTaskStart: this.onTaskStartCallback
|
@@ -1922,14 +1945,19 @@ var PageTaskExecutor = class {
|
|
1922
1945
|
*/
|
1923
1946
|
addToMemory(memoryItem) {
|
1924
1947
|
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1925
|
-
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1948
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(
|
1949
|
+
this.sessionContext.workflowId
|
1950
|
+
);
|
1926
1951
|
this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
|
1927
1952
|
onTaskStart: this.onTaskStartCallback,
|
1928
1953
|
initialMemory: previousMemory
|
1929
1954
|
});
|
1930
1955
|
}
|
1931
1956
|
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1932
|
-
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1957
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation(
|
1958
|
+
"add",
|
1959
|
+
memoryItem
|
1960
|
+
);
|
1933
1961
|
}
|
1934
1962
|
};
|
1935
1963
|
|
@@ -2018,14 +2046,14 @@ function buildPlans(type, locateParam, param) {
|
|
2018
2046
|
var import_node_assert = __toESM(require("assert"));
|
2019
2047
|
var import_node_fs2 = require("fs");
|
2020
2048
|
var import_node_path2 = require("path");
|
2049
|
+
var import_js_yaml3 = __toESM(require("js-yaml"));
|
2021
2050
|
var import_common2 = require("misoai-shared/common");
|
2022
2051
|
var import_logger3 = require("misoai-shared/logger");
|
2023
2052
|
var import_utils9 = require("misoai-shared/utils");
|
2024
|
-
var import_js_yaml3 = __toESM(require("js-yaml"));
|
2025
2053
|
var import_semver = __toESM(require("semver"));
|
2026
2054
|
|
2027
2055
|
// package.json
|
2028
|
-
var version = "1.6.
|
2056
|
+
var version = "1.6.1";
|
2029
2057
|
|
2030
2058
|
// src/common/task-cache.ts
|
2031
2059
|
var debug3 = (0, import_logger3.getDebug)("cache");
|
@@ -2320,22 +2348,28 @@ var PageAgent = class {
|
|
2320
2348
|
const allThoughts = executor.tasks.filter((task) => task.thought).map((task) => task.thought);
|
2321
2349
|
const allLocates = executor.tasks.filter((task) => task.locate).map((task) => task.locate);
|
2322
2350
|
const allPlans = executor.tasks.filter((task) => task.param?.plans).map((task) => task.param?.plans);
|
2323
|
-
const planningTasks = executor.tasks.filter(
|
2324
|
-
|
2351
|
+
const planningTasks = executor.tasks.filter(
|
2352
|
+
(task) => task.type === "Planning"
|
2353
|
+
);
|
2354
|
+
const insightTasks = executor.tasks.filter(
|
2355
|
+
(task) => task.type === "Insight"
|
2356
|
+
);
|
2325
2357
|
const actionTasks = executor.tasks.filter((task) => task.type === "Action");
|
2326
2358
|
const planning = planningTasks.length > 0 ? {
|
2327
2359
|
type: "Planning",
|
2328
|
-
description:
|
2360
|
+
description: "Planning for task execution",
|
2329
2361
|
steps: planningTasks.map((task) => task.thought || "Planning step")
|
2330
2362
|
} : void 0;
|
2331
2363
|
const insight = insightTasks.length > 0 ? {
|
2332
2364
|
type: "Insight",
|
2333
|
-
description:
|
2334
|
-
elements: insightTasks.map(
|
2365
|
+
description: "Insight for task execution",
|
2366
|
+
elements: insightTasks.map(
|
2367
|
+
(task) => task.thought || "Insight element"
|
2368
|
+
)
|
2335
2369
|
} : void 0;
|
2336
2370
|
const action = actionTasks.length > 0 ? {
|
2337
2371
|
type: "Action",
|
2338
|
-
description:
|
2372
|
+
description: "Action for task execution",
|
2339
2373
|
result: lastTask?.output
|
2340
2374
|
} : void 0;
|
2341
2375
|
const actionDetails = executor.tasks.map((task) => ({
|
@@ -2669,7 +2703,10 @@ ${memoryContext}` : void 0;
|
|
2669
2703
|
}
|
2670
2704
|
const memoryContext = this.getMemoryAsContext();
|
2671
2705
|
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2672
|
-
const { output, executor } = await this.taskExecutor.assert(
|
2706
|
+
const { output, executor } = await this.taskExecutor.assert(
|
2707
|
+
assertionWithContext,
|
2708
|
+
memoryContext
|
2709
|
+
);
|
2673
2710
|
const metadata = this.afterTaskRunning(executor, true);
|
2674
2711
|
if (output && opt?.keepRawResponse) {
|
2675
2712
|
return {
|
@@ -2708,7 +2745,10 @@ A complex CAPTCHA typically has one or more of these characteristics:
|
|
2708
2745
|
Return only "complex" or "simple" based on your analysis.
|
2709
2746
|
`;
|
2710
2747
|
const complexityMsgs = [
|
2711
|
-
{
|
2748
|
+
{
|
2749
|
+
role: "system",
|
2750
|
+
content: "You are an AI assistant that analyzes screenshots to determine CAPTCHA complexity."
|
2751
|
+
},
|
2712
2752
|
{
|
2713
2753
|
role: "user",
|
2714
2754
|
content: [
|
@@ -2732,7 +2772,12 @@ Return only "complex" or "simple" based on your analysis.
|
|
2732
2772
|
);
|
2733
2773
|
const responseText = typeof complexityResult.content === "string" ? complexityResult.content.toLowerCase() : JSON.stringify(complexityResult.content).toLowerCase();
|
2734
2774
|
shouldUseDeepThink = responseText.includes("complex");
|
2735
|
-
debug4(
|
2775
|
+
debug4(
|
2776
|
+
"CAPTCHA complexity analysis:",
|
2777
|
+
responseText,
|
2778
|
+
"Using deep think:",
|
2779
|
+
shouldUseDeepThink
|
2780
|
+
);
|
2736
2781
|
} catch (error) {
|
2737
2782
|
debug4("Failed to analyze CAPTCHA complexity:", error);
|
2738
2783
|
}
|
@@ -2749,7 +2794,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2749
2794
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2750
2795
|
} else if (action.type === "input" && action.value) {
|
2751
2796
|
if (action.target) {
|
2752
|
-
await this.aiInput(action.value, action.target, {
|
2797
|
+
await this.aiInput(action.value, action.target, {
|
2798
|
+
deepThink: shouldUseDeepThink
|
2799
|
+
});
|
2753
2800
|
}
|
2754
2801
|
} else if (action.type === "verify" && action.target) {
|
2755
2802
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
@@ -2761,7 +2808,9 @@ Return only "complex" or "simple" based on your analysis.
|
|
2761
2808
|
if (action.coordinates) {
|
2762
2809
|
const x = action.coordinates[0];
|
2763
2810
|
const y = action.coordinates[1];
|
2764
|
-
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2811
|
+
await this.aiTap(`element at coordinates (${x}, ${y})`, {
|
2812
|
+
deepThink: shouldUseDeepThink
|
2813
|
+
});
|
2765
2814
|
} else if (action.target) {
|
2766
2815
|
await this.aiTap(action.target, { deepThink: shouldUseDeepThink });
|
2767
2816
|
}
|
@@ -2913,25 +2962,27 @@ ${errors}`);
|
|
2913
2962
|
const executionDump = {
|
2914
2963
|
name: screenshotTitle,
|
2915
2964
|
description: content,
|
2916
|
-
tasks: [
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2965
|
+
tasks: [
|
2966
|
+
{
|
2967
|
+
type: "Screenshot",
|
2968
|
+
subType: "log",
|
2969
|
+
status: "finished",
|
2970
|
+
executor: null,
|
2971
|
+
param: {
|
2972
|
+
title: screenshotTitle,
|
2973
|
+
content
|
2974
|
+
},
|
2975
|
+
output: {
|
2976
|
+
screenshot
|
2977
|
+
},
|
2978
|
+
thought: `Logged screenshot: ${screenshotTitle}`,
|
2979
|
+
timing: {
|
2980
|
+
start: Date.now(),
|
2981
|
+
end: Date.now(),
|
2982
|
+
cost: 0
|
2983
|
+
}
|
2933
2984
|
}
|
2934
|
-
|
2985
|
+
],
|
2935
2986
|
sdkVersion: "1.0.0",
|
2936
2987
|
logTime: Date.now(),
|
2937
2988
|
model_name: "screenshot"
|
@@ -2983,7 +3034,9 @@ ${errors}`);
|
|
2983
3034
|
totalTasks: stats.analytics.totalTasks,
|
2984
3035
|
memoryHits: stats.analytics.memoryHits,
|
2985
3036
|
memoryMisses: stats.analytics.memoryMisses,
|
2986
|
-
memoryEffectiveness: Math.round(
|
3037
|
+
memoryEffectiveness: Math.round(
|
3038
|
+
stats.analytics.memoryEffectiveness * 100
|
3039
|
+
),
|
2987
3040
|
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2988
3041
|
},
|
2989
3042
|
config: stats.config,
|
@@ -3047,7 +3100,9 @@ ${errors}`);
|
|
3047
3100
|
calculateSuccessRate(memory) {
|
3048
3101
|
if (memory.length === 0)
|
3049
3102
|
return 0;
|
3050
|
-
const successCount = memory.filter(
|
3103
|
+
const successCount = memory.filter(
|
3104
|
+
(item) => item.metadata?.success !== false
|
3105
|
+
).length;
|
3051
3106
|
return Math.round(successCount / memory.length * 100);
|
3052
3107
|
}
|
3053
3108
|
calculateAverageExecutionTime(memory) {
|
@@ -3365,8 +3420,8 @@ var WebPage = class extends Page {
|
|
3365
3420
|
|
3366
3421
|
// src/playwright/ai-fixture.ts
|
3367
3422
|
var import_node_crypto = require("crypto");
|
3368
|
-
var import_logger6 = require("misoai-shared/logger");
|
3369
3423
|
var import_test = require("@playwright/test");
|
3424
|
+
var import_logger6 = require("misoai-shared/logger");
|
3370
3425
|
var debugPage2 = (0, import_logger6.getDebug)("web:playwright:ai-fixture");
|
3371
3426
|
var groupAndCaseForTest = (testInfo) => {
|
3372
3427
|
let taskFile;
|