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
package/dist/lib/index.js
CHANGED
@@ -1854,9 +1854,15 @@ var PageTaskExecutor = class {
|
|
1854
1854
|
}
|
1855
1855
|
async waitFor(assertion, opt) {
|
1856
1856
|
const description = `waitFor: ${assertion}`;
|
1857
|
-
const
|
1858
|
-
|
1859
|
-
|
1857
|
+
const useMemory = true;
|
1858
|
+
let taskExecutor;
|
1859
|
+
if (useMemory) {
|
1860
|
+
taskExecutor = this.getPersistentExecutor();
|
1861
|
+
} else {
|
1862
|
+
taskExecutor = new import_misoai_core.Executor(taskTitleStr("WaitFor", description), {
|
1863
|
+
onTaskStart: this.onTaskStartCallback
|
1864
|
+
});
|
1865
|
+
}
|
1860
1866
|
const { timeoutMs, checkIntervalMs } = opt;
|
1861
1867
|
(0, import_utils6.assert)(assertion, "No assertion for waitFor");
|
1862
1868
|
(0, import_utils6.assert)(timeoutMs, "No timeoutMs for waitFor");
|
@@ -1911,6 +1917,20 @@ var PageTaskExecutor = class {
|
|
1911
1917
|
`waitFor timeout: ${errorThought}`
|
1912
1918
|
);
|
1913
1919
|
}
|
1920
|
+
/**
|
1921
|
+
* Hafızaya yeni bir öğe ekler
|
1922
|
+
*/
|
1923
|
+
addToMemory(memoryItem) {
|
1924
|
+
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1925
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
|
1926
|
+
this.persistentExecutor = new import_misoai_core.Executor("Persistent Task Executor", {
|
1927
|
+
onTaskStart: this.onTaskStartCallback,
|
1928
|
+
initialMemory: previousMemory
|
1929
|
+
});
|
1930
|
+
}
|
1931
|
+
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1932
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
|
1933
|
+
}
|
1914
1934
|
};
|
1915
1935
|
|
1916
1936
|
// src/common/plan-builder.ts
|
@@ -2005,7 +2025,7 @@ var import_js_yaml3 = __toESM(require("js-yaml"));
|
|
2005
2025
|
var import_semver = __toESM(require("semver"));
|
2006
2026
|
|
2007
2027
|
// package.json
|
2008
|
-
var version = "1.
|
2028
|
+
var version = "1.6.0";
|
2009
2029
|
|
2010
2030
|
// src/common/task-cache.ts
|
2011
2031
|
var debug3 = (0, import_logger3.getDebug)("cache");
|
@@ -2216,7 +2236,10 @@ var PageAgent = class {
|
|
2216
2236
|
}
|
2217
2237
|
this.taskExecutor = new PageTaskExecutor(this.page, this.insight, {
|
2218
2238
|
taskCache: this.taskCache,
|
2219
|
-
onTaskStart: this.callbackOnTaskStartTip.bind(this)
|
2239
|
+
onTaskStart: this.callbackOnTaskStartTip.bind(this),
|
2240
|
+
memoryConfig: opts?.memoryConfig,
|
2241
|
+
sessionId: opts?.sessionId,
|
2242
|
+
workflowId: opts?.workflowId
|
2220
2243
|
});
|
2221
2244
|
this.dump = this.resetDump();
|
2222
2245
|
this.reportFileName = reportFileName(
|
@@ -2667,6 +2690,7 @@ ${reasonMsg}`);
|
|
2667
2690
|
}
|
2668
2691
|
async aiCaptcha(options) {
|
2669
2692
|
const { deepThink = false, autoDetectComplexity = true } = options || {};
|
2693
|
+
const memoryContext = this.getMemoryAsContext();
|
2670
2694
|
let shouldUseDeepThink = deepThink;
|
2671
2695
|
if (autoDetectComplexity && !deepThink) {
|
2672
2696
|
const context = await this.getUIContext();
|
@@ -2747,6 +2771,26 @@ Return only "complex" or "simple" based on your analysis.
|
|
2747
2771
|
}
|
2748
2772
|
}
|
2749
2773
|
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
2774
|
+
const captchaMemoryItem = {
|
2775
|
+
id: `captcha_${Date.now()}`,
|
2776
|
+
timestamp: Date.now(),
|
2777
|
+
taskType: "Action",
|
2778
|
+
summary: `Solved ${captchaResult.captchaType} CAPTCHA: ${captchaResult.thought}`,
|
2779
|
+
context: {
|
2780
|
+
url: await this.page.url?.() || "",
|
2781
|
+
captchaType: captchaResult.captchaType,
|
2782
|
+
actions: captchaResult.actions,
|
2783
|
+
deepThink: actualDeepThink
|
2784
|
+
},
|
2785
|
+
metadata: {
|
2786
|
+
executionTime: Date.now() - Date.now(),
|
2787
|
+
// Will be updated
|
2788
|
+
success: true,
|
2789
|
+
confidence: 0.9
|
2790
|
+
},
|
2791
|
+
tags: ["captcha", "action", captchaResult.captchaType]
|
2792
|
+
};
|
2793
|
+
this.taskExecutor.addToMemory(captchaMemoryItem);
|
2750
2794
|
const metadata = {
|
2751
2795
|
status: "finished",
|
2752
2796
|
usage,
|
@@ -2763,10 +2807,15 @@ Return only "complex" or "simple" based on your analysis.
|
|
2763
2807
|
}
|
2764
2808
|
async aiWaitFor(assertion, opt) {
|
2765
2809
|
const startTime = Date.now();
|
2766
|
-
const
|
2810
|
+
const memoryContext = this.getMemoryAsContext();
|
2811
|
+
const assertionWithContext = memoryContext ? `${assertion}
|
2812
|
+
|
2813
|
+
Previous workflow steps:
|
2814
|
+
${memoryContext}` : assertion;
|
2815
|
+
const { executor } = await this.taskExecutor.waitFor(assertionWithContext, {
|
2767
2816
|
timeoutMs: opt?.timeoutMs || 15 * 1e3,
|
2768
2817
|
checkIntervalMs: opt?.checkIntervalMs || 3 * 1e3,
|
2769
|
-
assertion
|
2818
|
+
assertion: assertionWithContext
|
2770
2819
|
});
|
2771
2820
|
const metadata = {
|
2772
2821
|
status: executor.isInErrorState() ? "failed" : "finished",
|
@@ -2922,6 +2971,109 @@ ${errors}`);
|
|
2922
2971
|
clearMemory() {
|
2923
2972
|
this.taskExecutor.clearMemory();
|
2924
2973
|
}
|
2974
|
+
/**
|
2975
|
+
* Test sonunda kullanım için detaylı hafıza raporu döndürür (JSON formatında)
|
2976
|
+
*/
|
2977
|
+
getMemoryReport() {
|
2978
|
+
const memory = this.getMemory();
|
2979
|
+
const stats = this.getMemoryStats();
|
2980
|
+
return {
|
2981
|
+
summary: {
|
2982
|
+
totalItems: memory.length,
|
2983
|
+
totalTasks: stats.analytics.totalTasks,
|
2984
|
+
memoryHits: stats.analytics.memoryHits,
|
2985
|
+
memoryMisses: stats.analytics.memoryMisses,
|
2986
|
+
memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
|
2987
|
+
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2988
|
+
},
|
2989
|
+
config: stats.config,
|
2990
|
+
items: memory.map((item) => ({
|
2991
|
+
id: item.id,
|
2992
|
+
timestamp: item.timestamp,
|
2993
|
+
taskType: item.taskType,
|
2994
|
+
summary: item.summary,
|
2995
|
+
context: item.context,
|
2996
|
+
metadata: item.metadata,
|
2997
|
+
tags: item.tags,
|
2998
|
+
relativeTime: this.formatRelativeTime(item.timestamp)
|
2999
|
+
})),
|
3000
|
+
analytics: {
|
3001
|
+
taskTypeDistribution: this.getTaskTypeDistribution(memory),
|
3002
|
+
successRate: this.calculateSuccessRate(memory),
|
3003
|
+
averageExecutionTime: this.calculateAverageExecutionTime(memory),
|
3004
|
+
dataExtractionCount: this.countDataExtractions(memory),
|
3005
|
+
workflowSteps: this.extractWorkflowSteps(memory)
|
3006
|
+
}
|
3007
|
+
};
|
3008
|
+
}
|
3009
|
+
/**
|
3010
|
+
* Test sonunda kullanım için basit hafıza özeti döndürür (JSON formatında)
|
3011
|
+
*/
|
3012
|
+
getMemorySummary() {
|
3013
|
+
const memory = this.getMemory();
|
3014
|
+
const stats = this.getMemoryStats();
|
3015
|
+
return {
|
3016
|
+
totalItems: memory.length,
|
3017
|
+
memoryEffectiveness: `${Math.round(stats.analytics.memoryEffectiveness * 100)}%`,
|
3018
|
+
taskTypes: this.getTaskTypeDistribution(memory),
|
3019
|
+
recentSteps: memory.slice(-5).map((item) => ({
|
3020
|
+
step: item.summary,
|
3021
|
+
type: item.taskType,
|
3022
|
+
success: item.metadata?.success || false,
|
3023
|
+
time: this.formatRelativeTime(item.timestamp)
|
3024
|
+
})),
|
3025
|
+
dataExtracted: this.getExtractedDataSummary(memory)
|
3026
|
+
};
|
3027
|
+
}
|
3028
|
+
formatRelativeTime(timestamp) {
|
3029
|
+
const now = Date.now();
|
3030
|
+
const diff = now - timestamp;
|
3031
|
+
const seconds = Math.floor(diff / 1e3);
|
3032
|
+
const minutes = Math.floor(seconds / 60);
|
3033
|
+
const hours = Math.floor(minutes / 60);
|
3034
|
+
if (hours > 0)
|
3035
|
+
return `${hours}h ${minutes % 60}m ago`;
|
3036
|
+
if (minutes > 0)
|
3037
|
+
return `${minutes}m ${seconds % 60}s ago`;
|
3038
|
+
return `${seconds}s ago`;
|
3039
|
+
}
|
3040
|
+
getTaskTypeDistribution(memory) {
|
3041
|
+
const distribution = {};
|
3042
|
+
memory.forEach((item) => {
|
3043
|
+
distribution[item.taskType] = (distribution[item.taskType] || 0) + 1;
|
3044
|
+
});
|
3045
|
+
return distribution;
|
3046
|
+
}
|
3047
|
+
calculateSuccessRate(memory) {
|
3048
|
+
if (memory.length === 0)
|
3049
|
+
return 0;
|
3050
|
+
const successCount = memory.filter((item) => item.metadata?.success !== false).length;
|
3051
|
+
return Math.round(successCount / memory.length * 100);
|
3052
|
+
}
|
3053
|
+
calculateAverageExecutionTime(memory) {
|
3054
|
+
const executionTimes = memory.map((item) => item.metadata?.executionTime).filter((time) => typeof time === "number");
|
3055
|
+
if (executionTimes.length === 0)
|
3056
|
+
return 0;
|
3057
|
+
const average = executionTimes.reduce((sum, time) => sum + time, 0) / executionTimes.length;
|
3058
|
+
return Math.round(average);
|
3059
|
+
}
|
3060
|
+
countDataExtractions(memory) {
|
3061
|
+
return memory.filter(
|
3062
|
+
(item) => item.context?.dataExtracted || item.taskType === "Insight" && item.summary.includes("Extracted")
|
3063
|
+
).length;
|
3064
|
+
}
|
3065
|
+
extractWorkflowSteps(memory) {
|
3066
|
+
return memory.map((item) => item.summary);
|
3067
|
+
}
|
3068
|
+
getExtractedDataSummary(memory) {
|
3069
|
+
const extractedData = {};
|
3070
|
+
memory.forEach((item, index) => {
|
3071
|
+
if (item.context?.dataExtracted) {
|
3072
|
+
extractedData[`step_${index + 1}`] = item.context.dataExtracted;
|
3073
|
+
}
|
3074
|
+
});
|
3075
|
+
return extractedData;
|
3076
|
+
}
|
2925
3077
|
};
|
2926
3078
|
|
2927
3079
|
// src/puppeteer/base-page.ts
|