misoai-web 1.5.8 → 1.6.0
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 +159 -7
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode.js +161 -9
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +160 -8
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +159 -7
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +159 -7
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/playground.js +159 -7
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright.js +159 -7
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +159 -7
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +159 -7
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/lib/agent.js +159 -7
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode.js +161 -9
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +160 -8
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +159 -7
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +159 -7
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/playground.js +159 -7
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright.js +159 -7
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +159 -7
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +159 -7
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/types/agent.d.ts +24 -2
- package/package.json +2 -2
@@ -1836,9 +1836,15 @@ var PageTaskExecutor = class {
|
|
1836
1836
|
}
|
1837
1837
|
async waitFor(assertion, opt) {
|
1838
1838
|
const description = `waitFor: ${assertion}`;
|
1839
|
-
const
|
1840
|
-
|
1841
|
-
|
1839
|
+
const useMemory = true;
|
1840
|
+
let taskExecutor;
|
1841
|
+
if (useMemory) {
|
1842
|
+
taskExecutor = this.getPersistentExecutor();
|
1843
|
+
} else {
|
1844
|
+
taskExecutor = new Executor(taskTitleStr("WaitFor", description), {
|
1845
|
+
onTaskStart: this.onTaskStartCallback
|
1846
|
+
});
|
1847
|
+
}
|
1842
1848
|
const { timeoutMs, checkIntervalMs } = opt;
|
1843
1849
|
assert4(assertion, "No assertion for waitFor");
|
1844
1850
|
assert4(timeoutMs, "No timeoutMs for waitFor");
|
@@ -1893,6 +1899,20 @@ var PageTaskExecutor = class {
|
|
1893
1899
|
`waitFor timeout: ${errorThought}`
|
1894
1900
|
);
|
1895
1901
|
}
|
1902
|
+
/**
|
1903
|
+
* Hafızaya yeni bir öğe ekler
|
1904
|
+
*/
|
1905
|
+
addToMemory(memoryItem) {
|
1906
|
+
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1907
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
|
1908
|
+
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1909
|
+
onTaskStart: this.onTaskStartCallback,
|
1910
|
+
initialMemory: previousMemory
|
1911
|
+
});
|
1912
|
+
}
|
1913
|
+
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1914
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
|
1915
|
+
}
|
1896
1916
|
};
|
1897
1917
|
|
1898
1918
|
// src/common/plan-builder.ts
|
@@ -1987,7 +2007,7 @@ import yaml3 from "js-yaml";
|
|
1987
2007
|
import semver from "semver";
|
1988
2008
|
|
1989
2009
|
// package.json
|
1990
|
-
var version = "1.
|
2010
|
+
var version = "1.6.0";
|
1991
2011
|
|
1992
2012
|
// src/common/task-cache.ts
|
1993
2013
|
var debug3 = getDebug3("cache");
|
@@ -2198,7 +2218,10 @@ var PageAgent = class {
|
|
2198
2218
|
}
|
2199
2219
|
this.taskExecutor = new PageTaskExecutor(this.page, this.insight, {
|
2200
2220
|
taskCache: this.taskCache,
|
2201
|
-
onTaskStart: this.callbackOnTaskStartTip.bind(this)
|
2221
|
+
onTaskStart: this.callbackOnTaskStartTip.bind(this),
|
2222
|
+
memoryConfig: opts?.memoryConfig,
|
2223
|
+
sessionId: opts?.sessionId,
|
2224
|
+
workflowId: opts?.workflowId
|
2202
2225
|
});
|
2203
2226
|
this.dump = this.resetDump();
|
2204
2227
|
this.reportFileName = reportFileName(
|
@@ -2649,6 +2672,7 @@ ${reasonMsg}`);
|
|
2649
2672
|
}
|
2650
2673
|
async aiCaptcha(options) {
|
2651
2674
|
const { deepThink = false, autoDetectComplexity = true } = options || {};
|
2675
|
+
const memoryContext = this.getMemoryAsContext();
|
2652
2676
|
let shouldUseDeepThink = deepThink;
|
2653
2677
|
if (autoDetectComplexity && !deepThink) {
|
2654
2678
|
const context = await this.getUIContext();
|
@@ -2729,6 +2753,26 @@ Return only "complex" or "simple" based on your analysis.
|
|
2729
2753
|
}
|
2730
2754
|
}
|
2731
2755
|
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
2756
|
+
const captchaMemoryItem = {
|
2757
|
+
id: `captcha_${Date.now()}`,
|
2758
|
+
timestamp: Date.now(),
|
2759
|
+
taskType: "Action",
|
2760
|
+
summary: `Solved ${captchaResult.captchaType} CAPTCHA: ${captchaResult.thought}`,
|
2761
|
+
context: {
|
2762
|
+
url: await this.page.url?.() || "",
|
2763
|
+
captchaType: captchaResult.captchaType,
|
2764
|
+
actions: captchaResult.actions,
|
2765
|
+
deepThink: actualDeepThink
|
2766
|
+
},
|
2767
|
+
metadata: {
|
2768
|
+
executionTime: Date.now() - Date.now(),
|
2769
|
+
// Will be updated
|
2770
|
+
success: true,
|
2771
|
+
confidence: 0.9
|
2772
|
+
},
|
2773
|
+
tags: ["captcha", "action", captchaResult.captchaType]
|
2774
|
+
};
|
2775
|
+
this.taskExecutor.addToMemory(captchaMemoryItem);
|
2732
2776
|
const metadata = {
|
2733
2777
|
status: "finished",
|
2734
2778
|
usage,
|
@@ -2745,10 +2789,15 @@ Return only "complex" or "simple" based on your analysis.
|
|
2745
2789
|
}
|
2746
2790
|
async aiWaitFor(assertion, opt) {
|
2747
2791
|
const startTime = Date.now();
|
2748
|
-
const
|
2792
|
+
const memoryContext = this.getMemoryAsContext();
|
2793
|
+
const assertionWithContext = memoryContext ? `${assertion}
|
2794
|
+
|
2795
|
+
Previous workflow steps:
|
2796
|
+
${memoryContext}` : assertion;
|
2797
|
+
const { executor } = await this.taskExecutor.waitFor(assertionWithContext, {
|
2749
2798
|
timeoutMs: opt?.timeoutMs || 15 * 1e3,
|
2750
2799
|
checkIntervalMs: opt?.checkIntervalMs || 3 * 1e3,
|
2751
|
-
assertion
|
2800
|
+
assertion: assertionWithContext
|
2752
2801
|
});
|
2753
2802
|
const metadata = {
|
2754
2803
|
status: executor.isInErrorState() ? "failed" : "finished",
|
@@ -2904,6 +2953,109 @@ ${errors}`);
|
|
2904
2953
|
clearMemory() {
|
2905
2954
|
this.taskExecutor.clearMemory();
|
2906
2955
|
}
|
2956
|
+
/**
|
2957
|
+
* Test sonunda kullanım için detaylı hafıza raporu döndürür (JSON formatında)
|
2958
|
+
*/
|
2959
|
+
getMemoryReport() {
|
2960
|
+
const memory = this.getMemory();
|
2961
|
+
const stats = this.getMemoryStats();
|
2962
|
+
return {
|
2963
|
+
summary: {
|
2964
|
+
totalItems: memory.length,
|
2965
|
+
totalTasks: stats.analytics.totalTasks,
|
2966
|
+
memoryHits: stats.analytics.memoryHits,
|
2967
|
+
memoryMisses: stats.analytics.memoryMisses,
|
2968
|
+
memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
|
2969
|
+
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2970
|
+
},
|
2971
|
+
config: stats.config,
|
2972
|
+
items: memory.map((item) => ({
|
2973
|
+
id: item.id,
|
2974
|
+
timestamp: item.timestamp,
|
2975
|
+
taskType: item.taskType,
|
2976
|
+
summary: item.summary,
|
2977
|
+
context: item.context,
|
2978
|
+
metadata: item.metadata,
|
2979
|
+
tags: item.tags,
|
2980
|
+
relativeTime: this.formatRelativeTime(item.timestamp)
|
2981
|
+
})),
|
2982
|
+
analytics: {
|
2983
|
+
taskTypeDistribution: this.getTaskTypeDistribution(memory),
|
2984
|
+
successRate: this.calculateSuccessRate(memory),
|
2985
|
+
averageExecutionTime: this.calculateAverageExecutionTime(memory),
|
2986
|
+
dataExtractionCount: this.countDataExtractions(memory),
|
2987
|
+
workflowSteps: this.extractWorkflowSteps(memory)
|
2988
|
+
}
|
2989
|
+
};
|
2990
|
+
}
|
2991
|
+
/**
|
2992
|
+
* Test sonunda kullanım için basit hafıza özeti döndürür (JSON formatında)
|
2993
|
+
*/
|
2994
|
+
getMemorySummary() {
|
2995
|
+
const memory = this.getMemory();
|
2996
|
+
const stats = this.getMemoryStats();
|
2997
|
+
return {
|
2998
|
+
totalItems: memory.length,
|
2999
|
+
memoryEffectiveness: `${Math.round(stats.analytics.memoryEffectiveness * 100)}%`,
|
3000
|
+
taskTypes: this.getTaskTypeDistribution(memory),
|
3001
|
+
recentSteps: memory.slice(-5).map((item) => ({
|
3002
|
+
step: item.summary,
|
3003
|
+
type: item.taskType,
|
3004
|
+
success: item.metadata?.success || false,
|
3005
|
+
time: this.formatRelativeTime(item.timestamp)
|
3006
|
+
})),
|
3007
|
+
dataExtracted: this.getExtractedDataSummary(memory)
|
3008
|
+
};
|
3009
|
+
}
|
3010
|
+
formatRelativeTime(timestamp) {
|
3011
|
+
const now = Date.now();
|
3012
|
+
const diff = now - timestamp;
|
3013
|
+
const seconds = Math.floor(diff / 1e3);
|
3014
|
+
const minutes = Math.floor(seconds / 60);
|
3015
|
+
const hours = Math.floor(minutes / 60);
|
3016
|
+
if (hours > 0)
|
3017
|
+
return `${hours}h ${minutes % 60}m ago`;
|
3018
|
+
if (minutes > 0)
|
3019
|
+
return `${minutes}m ${seconds % 60}s ago`;
|
3020
|
+
return `${seconds}s ago`;
|
3021
|
+
}
|
3022
|
+
getTaskTypeDistribution(memory) {
|
3023
|
+
const distribution = {};
|
3024
|
+
memory.forEach((item) => {
|
3025
|
+
distribution[item.taskType] = (distribution[item.taskType] || 0) + 1;
|
3026
|
+
});
|
3027
|
+
return distribution;
|
3028
|
+
}
|
3029
|
+
calculateSuccessRate(memory) {
|
3030
|
+
if (memory.length === 0)
|
3031
|
+
return 0;
|
3032
|
+
const successCount = memory.filter((item) => item.metadata?.success !== false).length;
|
3033
|
+
return Math.round(successCount / memory.length * 100);
|
3034
|
+
}
|
3035
|
+
calculateAverageExecutionTime(memory) {
|
3036
|
+
const executionTimes = memory.map((item) => item.metadata?.executionTime).filter((time) => typeof time === "number");
|
3037
|
+
if (executionTimes.length === 0)
|
3038
|
+
return 0;
|
3039
|
+
const average = executionTimes.reduce((sum, time) => sum + time, 0) / executionTimes.length;
|
3040
|
+
return Math.round(average);
|
3041
|
+
}
|
3042
|
+
countDataExtractions(memory) {
|
3043
|
+
return memory.filter(
|
3044
|
+
(item) => item.context?.dataExtracted || item.taskType === "Insight" && item.summary.includes("Extracted")
|
3045
|
+
).length;
|
3046
|
+
}
|
3047
|
+
extractWorkflowSteps(memory) {
|
3048
|
+
return memory.map((item) => item.summary);
|
3049
|
+
}
|
3050
|
+
getExtractedDataSummary(memory) {
|
3051
|
+
const extractedData = {};
|
3052
|
+
memory.forEach((item, index) => {
|
3053
|
+
if (item.context?.dataExtracted) {
|
3054
|
+
extractedData[`step_${index + 1}`] = item.context.dataExtracted;
|
3055
|
+
}
|
3056
|
+
});
|
3057
|
+
return extractedData;
|
3058
|
+
}
|
2907
3059
|
};
|
2908
3060
|
|
2909
3061
|
// src/puppeteer/index.ts
|