misoai-web 1.0.4 → 1.0.5
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/README.md +349 -5
- package/dist/es/agent.js +158 -56
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +3 -3
- package/dist/es/bridge-mode.js +160 -58
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +159 -57
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +158 -56
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +158 -56
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/playground.js +158 -56
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright.js +158 -56
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +158 -56
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +158 -56
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/lib/agent.js +158 -56
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +3 -3
- package/dist/lib/bridge-mode.js +160 -58
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +159 -57
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +158 -56
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +158 -56
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/playground.js +158 -56
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright.js +158 -56
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +158 -56
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +158 -56
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/types/agent.d.ts +26 -0
- package/package.json +1 -1
@@ -1725,7 +1725,7 @@ var import_js_yaml3 = __toESM(require("js-yaml"));
|
|
1725
1725
|
var import_semver = __toESM(require("semver"));
|
1726
1726
|
|
1727
1727
|
// package.json
|
1728
|
-
var version = "1.0.
|
1728
|
+
var version = "1.0.5";
|
1729
1729
|
|
1730
1730
|
// src/common/task-cache.ts
|
1731
1731
|
var debug3 = (0, import_logger3.getDebug)("cache");
|
@@ -1907,10 +1907,13 @@ var PageAgent = class {
|
|
1907
1907
|
generateReport: true,
|
1908
1908
|
autoPrintReportMsg: true,
|
1909
1909
|
groupName: "Midscene Report",
|
1910
|
-
groupDescription: ""
|
1910
|
+
groupDescription: "",
|
1911
|
+
enableCumulativeContext: true,
|
1912
|
+
autoClearContext: false
|
1911
1913
|
},
|
1912
1914
|
opts || {}
|
1913
1915
|
);
|
1916
|
+
this.initializeContextStore();
|
1914
1917
|
if (this.page.pageType === "puppeteer" || this.page.pageType === "playwright") {
|
1915
1918
|
this.page.waitForNavigationTimeout = this.opts.waitForNavigationTimeout || import_constants2.DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
1916
1919
|
this.page.waitForNetworkIdleTimeout = this.opts.waitForNetworkIdleTimeout || import_constants2.DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT;
|
@@ -1937,6 +1940,69 @@ var PageAgent = class {
|
|
1937
1940
|
opts?.testId || this.page.pageType || "web"
|
1938
1941
|
);
|
1939
1942
|
}
|
1943
|
+
/**
|
1944
|
+
* Initialize context store for cumulative context functionality
|
1945
|
+
*/
|
1946
|
+
async initializeContextStore() {
|
1947
|
+
if (!this.opts.enableCumulativeContext) {
|
1948
|
+
debug4("Cumulative context disabled via options");
|
1949
|
+
return;
|
1950
|
+
}
|
1951
|
+
try {
|
1952
|
+
const aiModel = await import("misoai-core/ai-model");
|
1953
|
+
this.contextStore = aiModel.getContextStore();
|
1954
|
+
debug4("Context store initialized successfully", {
|
1955
|
+
autoClearContext: this.opts.autoClearContext,
|
1956
|
+
testId: this.opts.testId
|
1957
|
+
});
|
1958
|
+
if (this.opts.autoClearContext) {
|
1959
|
+
this.contextStore.clear();
|
1960
|
+
debug4("Context store cleared due to autoClearContext option");
|
1961
|
+
} else {
|
1962
|
+
const existingData = this.contextStore.getAllData();
|
1963
|
+
const existingSteps = this.contextStore.getRecentSteps(100).length;
|
1964
|
+
debug4("Context store preserving existing data", {
|
1965
|
+
existingDataKeys: Object.keys(existingData),
|
1966
|
+
existingStepsCount: existingSteps
|
1967
|
+
});
|
1968
|
+
}
|
1969
|
+
} catch (error) {
|
1970
|
+
debug4("Failed to initialize context store:", error);
|
1971
|
+
console.warn("⚠️ Could not initialize context store:", error);
|
1972
|
+
}
|
1973
|
+
}
|
1974
|
+
/**
|
1975
|
+
* Get the context store instance
|
1976
|
+
*/
|
1977
|
+
getContextStore() {
|
1978
|
+
return this.contextStore;
|
1979
|
+
}
|
1980
|
+
/**
|
1981
|
+
* Clear the context store
|
1982
|
+
*/
|
1983
|
+
clearContext() {
|
1984
|
+
if (this.contextStore) {
|
1985
|
+
this.contextStore.clear();
|
1986
|
+
}
|
1987
|
+
}
|
1988
|
+
/**
|
1989
|
+
* Get all stored data from context store
|
1990
|
+
*/
|
1991
|
+
getStoredData() {
|
1992
|
+
if (this.contextStore) {
|
1993
|
+
return this.contextStore.getAllData();
|
1994
|
+
}
|
1995
|
+
return {};
|
1996
|
+
}
|
1997
|
+
/**
|
1998
|
+
* Get step summary from context store
|
1999
|
+
*/
|
2000
|
+
getStepSummary() {
|
2001
|
+
if (this.contextStore) {
|
2002
|
+
return this.contextStore.getStepSummary();
|
2003
|
+
}
|
2004
|
+
return "";
|
2005
|
+
}
|
1940
2006
|
async getUIContext(action) {
|
1941
2007
|
if (action && (action === "extract" || action === "assert" || action === "captcha")) {
|
1942
2008
|
return await parseContextFromWebPage(this.page, {
|
@@ -2172,18 +2238,30 @@ var PageAgent = class {
|
|
2172
2238
|
};
|
2173
2239
|
}
|
2174
2240
|
async aiAction(taskPrompt, opt) {
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2241
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2242
|
+
try {
|
2243
|
+
const originalPrompt = taskPrompt;
|
2244
|
+
const processedPrompt = this.contextStore.replaceAllReferences(taskPrompt, "action");
|
2245
|
+
if (originalPrompt !== processedPrompt) {
|
2246
|
+
debug4("Context replacement in aiAction:", {
|
2247
|
+
original: originalPrompt,
|
2248
|
+
processed: processedPrompt,
|
2249
|
+
storedData: this.contextStore.getAllData()
|
2250
|
+
});
|
2251
|
+
}
|
2252
|
+
this.contextStore.addStep({
|
2253
|
+
type: "action",
|
2254
|
+
summary: `Action: ${processedPrompt}`,
|
2255
|
+
prompt: processedPrompt
|
2256
|
+
});
|
2257
|
+
debug4("Added action step to context store:", {
|
2258
|
+
stepNumber: this.contextStore.getRecentSteps(1)[0]?.stepNumber,
|
2259
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2260
|
+
});
|
2261
|
+
taskPrompt = processedPrompt;
|
2262
|
+
} catch (error) {
|
2263
|
+
debug4("Context store operation failed:", error);
|
2264
|
+
}
|
2187
2265
|
}
|
2188
2266
|
const cacheable = opt?.cacheable;
|
2189
2267
|
const isVlmUiTars = (0, import_env2.vlLocateMode)() === "vlm-ui-tars";
|
@@ -2254,38 +2332,50 @@ var PageAgent = class {
|
|
2254
2332
|
debug4("Context store not available:", error);
|
2255
2333
|
}
|
2256
2334
|
const { output, executor } = await this.taskExecutor.query(processedDemand);
|
2257
|
-
if (
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2335
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2336
|
+
if (storageKey && output) {
|
2337
|
+
try {
|
2338
|
+
const pendingAliases = this.contextStore._pendingAliases;
|
2339
|
+
if (pendingAliases) {
|
2340
|
+
this.contextStore.storeDataWithAliases(storageKey, output, pendingAliases, typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand));
|
2341
|
+
delete this.contextStore._pendingAliases;
|
2342
|
+
debug4("Stored query result with aliases:", {
|
2343
|
+
key: storageKey,
|
2344
|
+
value: output,
|
2345
|
+
aliases: pendingAliases
|
2346
|
+
});
|
2347
|
+
} else {
|
2348
|
+
this.contextStore.storeData(storageKey, output);
|
2349
|
+
debug4("Stored query result:", {
|
2350
|
+
key: storageKey,
|
2351
|
+
value: output
|
2352
|
+
});
|
2353
|
+
}
|
2354
|
+
this.contextStore.addStep({
|
2355
|
+
type: "query",
|
2356
|
+
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2357
|
+
data: output,
|
2358
|
+
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2359
|
+
});
|
2360
|
+
debug4("Added query step to context store:", {
|
2361
|
+
storageKey,
|
2362
|
+
totalStoredItems: Object.keys(this.contextStore.getAllData()).length,
|
2363
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2364
|
+
});
|
2365
|
+
} catch (error) {
|
2366
|
+
debug4("Failed to store query result:", error);
|
2367
|
+
}
|
2368
|
+
} else {
|
2369
|
+
try {
|
2370
|
+
this.contextStore.addStep({
|
2371
|
+
type: "query",
|
2372
|
+
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2373
|
+
data: output,
|
2374
|
+
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2375
|
+
});
|
2376
|
+
} catch (error) {
|
2377
|
+
debug4("Failed to add query step:", error);
|
2267
2378
|
}
|
2268
|
-
contextStore.addStep({
|
2269
|
-
type: "query",
|
2270
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2271
|
-
data: output,
|
2272
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2273
|
-
});
|
2274
|
-
} catch (error) {
|
2275
|
-
debug4("Failed to store query result:", error);
|
2276
|
-
}
|
2277
|
-
} else {
|
2278
|
-
try {
|
2279
|
-
const aiModel = await import("misoai-core/ai-model");
|
2280
|
-
const contextStore = aiModel.getContextStore();
|
2281
|
-
contextStore.addStep({
|
2282
|
-
type: "query",
|
2283
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2284
|
-
data: output,
|
2285
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2286
|
-
});
|
2287
|
-
} catch (error) {
|
2288
|
-
debug4("Failed to add query step:", error);
|
2289
2379
|
}
|
2290
2380
|
}
|
2291
2381
|
const metadata = this.afterTaskRunning(executor);
|
@@ -2398,17 +2488,29 @@ var PageAgent = class {
|
|
2398
2488
|
}
|
2399
2489
|
async aiAssert(assertion, msg, opt) {
|
2400
2490
|
let processedAssertion = assertion;
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
2411
|
-
|
2491
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2492
|
+
try {
|
2493
|
+
const originalAssertion = assertion;
|
2494
|
+
processedAssertion = this.contextStore.replaceAllReferences(assertion, "assertion");
|
2495
|
+
if (originalAssertion !== processedAssertion) {
|
2496
|
+
debug4("Context replacement in aiAssert:", {
|
2497
|
+
original: originalAssertion,
|
2498
|
+
processed: processedAssertion,
|
2499
|
+
context: "assertion",
|
2500
|
+
storedData: this.contextStore.getAllData()
|
2501
|
+
});
|
2502
|
+
}
|
2503
|
+
this.contextStore.addStep({
|
2504
|
+
type: "assertion",
|
2505
|
+
summary: `Assertion: ${processedAssertion}`,
|
2506
|
+
prompt: processedAssertion
|
2507
|
+
});
|
2508
|
+
debug4("Added assertion step to context store:", {
|
2509
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2510
|
+
});
|
2511
|
+
} catch (error) {
|
2512
|
+
debug4("Context store operation failed:", error);
|
2513
|
+
}
|
2412
2514
|
}
|
2413
2515
|
let currentUrl = "";
|
2414
2516
|
if (this.page.url) {
|
@@ -2848,7 +2950,7 @@ function sleep2(ms) {
|
|
2848
2950
|
var ChromeExtensionProxyPage = class {
|
2849
2951
|
constructor(forceSameTabNavigation) {
|
2850
2952
|
this.pageType = "chrome-extension-proxy";
|
2851
|
-
this.version = "1.0.
|
2953
|
+
this.version = "1.0.5";
|
2852
2954
|
this.activeTabId = null;
|
2853
2955
|
this.tabIdOfDebuggerAttached = null;
|
2854
2956
|
this.attachingDebugger = null;
|