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
@@ -1804,9 +1804,15 @@ var PageTaskExecutor = class {
|
|
1804
1804
|
}
|
1805
1805
|
async waitFor(assertion, opt) {
|
1806
1806
|
const description = `waitFor: ${assertion}`;
|
1807
|
-
const
|
1808
|
-
|
1809
|
-
|
1807
|
+
const useMemory = true;
|
1808
|
+
let taskExecutor;
|
1809
|
+
if (useMemory) {
|
1810
|
+
taskExecutor = this.getPersistentExecutor();
|
1811
|
+
} else {
|
1812
|
+
taskExecutor = new Executor(taskTitleStr("WaitFor", description), {
|
1813
|
+
onTaskStart: this.onTaskStartCallback
|
1814
|
+
});
|
1815
|
+
}
|
1810
1816
|
const { timeoutMs, checkIntervalMs } = opt;
|
1811
1817
|
assert4(assertion, "No assertion for waitFor");
|
1812
1818
|
assert4(timeoutMs, "No timeoutMs for waitFor");
|
@@ -1861,6 +1867,20 @@ var PageTaskExecutor = class {
|
|
1861
1867
|
`waitFor timeout: ${errorThought}`
|
1862
1868
|
);
|
1863
1869
|
}
|
1870
|
+
/**
|
1871
|
+
* Hafızaya yeni bir öğe ekler
|
1872
|
+
*/
|
1873
|
+
addToMemory(memoryItem) {
|
1874
|
+
if (!this.persistentExecutor || this.persistentExecutor.status === "error") {
|
1875
|
+
const previousMemory = this.workflowMemory.getWorkflowMemory(this.sessionContext.workflowId);
|
1876
|
+
this.persistentExecutor = new Executor("Persistent Task Executor", {
|
1877
|
+
onTaskStart: this.onTaskStartCallback,
|
1878
|
+
initialMemory: previousMemory
|
1879
|
+
});
|
1880
|
+
}
|
1881
|
+
this.persistentExecutor.memoryStore?.add(memoryItem);
|
1882
|
+
this.persistentExecutor.memoryAnalytics?.recordMemoryOperation("add", memoryItem);
|
1883
|
+
}
|
1864
1884
|
};
|
1865
1885
|
|
1866
1886
|
// src/common/plan-builder.ts
|
@@ -1955,7 +1975,7 @@ import yaml3 from "js-yaml";
|
|
1955
1975
|
import semver from "semver";
|
1956
1976
|
|
1957
1977
|
// package.json
|
1958
|
-
var version = "1.
|
1978
|
+
var version = "1.6.0";
|
1959
1979
|
|
1960
1980
|
// src/common/task-cache.ts
|
1961
1981
|
var debug3 = getDebug3("cache");
|
@@ -2166,7 +2186,10 @@ var PageAgent = class {
|
|
2166
2186
|
}
|
2167
2187
|
this.taskExecutor = new PageTaskExecutor(this.page, this.insight, {
|
2168
2188
|
taskCache: this.taskCache,
|
2169
|
-
onTaskStart: this.callbackOnTaskStartTip.bind(this)
|
2189
|
+
onTaskStart: this.callbackOnTaskStartTip.bind(this),
|
2190
|
+
memoryConfig: opts?.memoryConfig,
|
2191
|
+
sessionId: opts?.sessionId,
|
2192
|
+
workflowId: opts?.workflowId
|
2170
2193
|
});
|
2171
2194
|
this.dump = this.resetDump();
|
2172
2195
|
this.reportFileName = reportFileName(
|
@@ -2617,6 +2640,7 @@ ${reasonMsg}`);
|
|
2617
2640
|
}
|
2618
2641
|
async aiCaptcha(options) {
|
2619
2642
|
const { deepThink = false, autoDetectComplexity = true } = options || {};
|
2643
|
+
const memoryContext = this.getMemoryAsContext();
|
2620
2644
|
let shouldUseDeepThink = deepThink;
|
2621
2645
|
if (autoDetectComplexity && !deepThink) {
|
2622
2646
|
const context = await this.getUIContext();
|
@@ -2697,6 +2721,26 @@ Return only "complex" or "simple" based on your analysis.
|
|
2697
2721
|
}
|
2698
2722
|
}
|
2699
2723
|
await new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
2724
|
+
const captchaMemoryItem = {
|
2725
|
+
id: `captcha_${Date.now()}`,
|
2726
|
+
timestamp: Date.now(),
|
2727
|
+
taskType: "Action",
|
2728
|
+
summary: `Solved ${captchaResult.captchaType} CAPTCHA: ${captchaResult.thought}`,
|
2729
|
+
context: {
|
2730
|
+
url: await this.page.url?.() || "",
|
2731
|
+
captchaType: captchaResult.captchaType,
|
2732
|
+
actions: captchaResult.actions,
|
2733
|
+
deepThink: actualDeepThink
|
2734
|
+
},
|
2735
|
+
metadata: {
|
2736
|
+
executionTime: Date.now() - Date.now(),
|
2737
|
+
// Will be updated
|
2738
|
+
success: true,
|
2739
|
+
confidence: 0.9
|
2740
|
+
},
|
2741
|
+
tags: ["captcha", "action", captchaResult.captchaType]
|
2742
|
+
};
|
2743
|
+
this.taskExecutor.addToMemory(captchaMemoryItem);
|
2700
2744
|
const metadata = {
|
2701
2745
|
status: "finished",
|
2702
2746
|
usage,
|
@@ -2713,10 +2757,15 @@ Return only "complex" or "simple" based on your analysis.
|
|
2713
2757
|
}
|
2714
2758
|
async aiWaitFor(assertion, opt) {
|
2715
2759
|
const startTime = Date.now();
|
2716
|
-
const
|
2760
|
+
const memoryContext = this.getMemoryAsContext();
|
2761
|
+
const assertionWithContext = memoryContext ? `${assertion}
|
2762
|
+
|
2763
|
+
Previous workflow steps:
|
2764
|
+
${memoryContext}` : assertion;
|
2765
|
+
const { executor } = await this.taskExecutor.waitFor(assertionWithContext, {
|
2717
2766
|
timeoutMs: opt?.timeoutMs || 15 * 1e3,
|
2718
2767
|
checkIntervalMs: opt?.checkIntervalMs || 3 * 1e3,
|
2719
|
-
assertion
|
2768
|
+
assertion: assertionWithContext
|
2720
2769
|
});
|
2721
2770
|
const metadata = {
|
2722
2771
|
status: executor.isInErrorState() ? "failed" : "finished",
|
@@ -2872,6 +2921,109 @@ ${errors}`);
|
|
2872
2921
|
clearMemory() {
|
2873
2922
|
this.taskExecutor.clearMemory();
|
2874
2923
|
}
|
2924
|
+
/**
|
2925
|
+
* Test sonunda kullanım için detaylı hafıza raporu döndürür (JSON formatında)
|
2926
|
+
*/
|
2927
|
+
getMemoryReport() {
|
2928
|
+
const memory = this.getMemory();
|
2929
|
+
const stats = this.getMemoryStats();
|
2930
|
+
return {
|
2931
|
+
summary: {
|
2932
|
+
totalItems: memory.length,
|
2933
|
+
totalTasks: stats.analytics.totalTasks,
|
2934
|
+
memoryHits: stats.analytics.memoryHits,
|
2935
|
+
memoryMisses: stats.analytics.memoryMisses,
|
2936
|
+
memoryEffectiveness: Math.round(stats.analytics.memoryEffectiveness * 100),
|
2937
|
+
averageMemorySize: Math.round(stats.analytics.averageMemorySize * 100) / 100
|
2938
|
+
},
|
2939
|
+
config: stats.config,
|
2940
|
+
items: memory.map((item) => ({
|
2941
|
+
id: item.id,
|
2942
|
+
timestamp: item.timestamp,
|
2943
|
+
taskType: item.taskType,
|
2944
|
+
summary: item.summary,
|
2945
|
+
context: item.context,
|
2946
|
+
metadata: item.metadata,
|
2947
|
+
tags: item.tags,
|
2948
|
+
relativeTime: this.formatRelativeTime(item.timestamp)
|
2949
|
+
})),
|
2950
|
+
analytics: {
|
2951
|
+
taskTypeDistribution: this.getTaskTypeDistribution(memory),
|
2952
|
+
successRate: this.calculateSuccessRate(memory),
|
2953
|
+
averageExecutionTime: this.calculateAverageExecutionTime(memory),
|
2954
|
+
dataExtractionCount: this.countDataExtractions(memory),
|
2955
|
+
workflowSteps: this.extractWorkflowSteps(memory)
|
2956
|
+
}
|
2957
|
+
};
|
2958
|
+
}
|
2959
|
+
/**
|
2960
|
+
* Test sonunda kullanım için basit hafıza özeti döndürür (JSON formatında)
|
2961
|
+
*/
|
2962
|
+
getMemorySummary() {
|
2963
|
+
const memory = this.getMemory();
|
2964
|
+
const stats = this.getMemoryStats();
|
2965
|
+
return {
|
2966
|
+
totalItems: memory.length,
|
2967
|
+
memoryEffectiveness: `${Math.round(stats.analytics.memoryEffectiveness * 100)}%`,
|
2968
|
+
taskTypes: this.getTaskTypeDistribution(memory),
|
2969
|
+
recentSteps: memory.slice(-5).map((item) => ({
|
2970
|
+
step: item.summary,
|
2971
|
+
type: item.taskType,
|
2972
|
+
success: item.metadata?.success || false,
|
2973
|
+
time: this.formatRelativeTime(item.timestamp)
|
2974
|
+
})),
|
2975
|
+
dataExtracted: this.getExtractedDataSummary(memory)
|
2976
|
+
};
|
2977
|
+
}
|
2978
|
+
formatRelativeTime(timestamp) {
|
2979
|
+
const now = Date.now();
|
2980
|
+
const diff = now - timestamp;
|
2981
|
+
const seconds = Math.floor(diff / 1e3);
|
2982
|
+
const minutes = Math.floor(seconds / 60);
|
2983
|
+
const hours = Math.floor(minutes / 60);
|
2984
|
+
if (hours > 0)
|
2985
|
+
return `${hours}h ${minutes % 60}m ago`;
|
2986
|
+
if (minutes > 0)
|
2987
|
+
return `${minutes}m ${seconds % 60}s ago`;
|
2988
|
+
return `${seconds}s ago`;
|
2989
|
+
}
|
2990
|
+
getTaskTypeDistribution(memory) {
|
2991
|
+
const distribution = {};
|
2992
|
+
memory.forEach((item) => {
|
2993
|
+
distribution[item.taskType] = (distribution[item.taskType] || 0) + 1;
|
2994
|
+
});
|
2995
|
+
return distribution;
|
2996
|
+
}
|
2997
|
+
calculateSuccessRate(memory) {
|
2998
|
+
if (memory.length === 0)
|
2999
|
+
return 0;
|
3000
|
+
const successCount = memory.filter((item) => item.metadata?.success !== false).length;
|
3001
|
+
return Math.round(successCount / memory.length * 100);
|
3002
|
+
}
|
3003
|
+
calculateAverageExecutionTime(memory) {
|
3004
|
+
const executionTimes = memory.map((item) => item.metadata?.executionTime).filter((time) => typeof time === "number");
|
3005
|
+
if (executionTimes.length === 0)
|
3006
|
+
return 0;
|
3007
|
+
const average = executionTimes.reduce((sum, time) => sum + time, 0) / executionTimes.length;
|
3008
|
+
return Math.round(average);
|
3009
|
+
}
|
3010
|
+
countDataExtractions(memory) {
|
3011
|
+
return memory.filter(
|
3012
|
+
(item) => item.context?.dataExtracted || item.taskType === "Insight" && item.summary.includes("Extracted")
|
3013
|
+
).length;
|
3014
|
+
}
|
3015
|
+
extractWorkflowSteps(memory) {
|
3016
|
+
return memory.map((item) => item.summary);
|
3017
|
+
}
|
3018
|
+
getExtractedDataSummary(memory) {
|
3019
|
+
const extractedData = {};
|
3020
|
+
memory.forEach((item, index) => {
|
3021
|
+
if (item.context?.dataExtracted) {
|
3022
|
+
extractedData[`step_${index + 1}`] = item.context.dataExtracted;
|
3023
|
+
}
|
3024
|
+
});
|
3025
|
+
return extractedData;
|
3026
|
+
}
|
2875
3027
|
};
|
2876
3028
|
|
2877
3029
|
// src/playground/agent.ts
|