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