misoai-web 1.0.5 → 1.5.6
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/LICENSE +21 -21
- package/README.md +9 -353
- package/bin/midscene-playground +2 -2
- package/dist/es/agent.js +9 -191
- 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 +11 -193
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +10 -192
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +13 -195
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +9 -191
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +9 -191
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright-report.js.map +1 -1
- package/dist/es/playwright.js +10 -192
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +13 -195
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +13 -195
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/ui-utils.js.map +1 -1
- package/dist/es/utils.js.map +1 -1
- package/dist/es/yaml.js +5 -3
- package/dist/es/yaml.js.map +1 -1
- package/dist/lib/agent.js +9 -191
- 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 +11 -193
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +10 -192
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +13 -195
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +9 -191
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +9 -191
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright-report.js.map +1 -1
- package/dist/lib/playwright.js +10 -192
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +13 -195
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +13 -195
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/ui-utils.js.map +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/yaml.js +5 -3
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent.d.ts +1 -27
- package/dist/types/bridge-mode-browser.d.ts +2 -2
- package/dist/types/bridge-mode.d.ts +2 -2
- package/dist/types/{browser-a1877d18.d.ts → browser-aec1055d.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/midscene-server.d.ts +1 -1
- package/dist/types/{page-663ece08.d.ts → page-86ab0fe1.d.ts} +34 -34
- package/dist/types/playground.d.ts +2 -2
- package/dist/types/playwright.d.ts +1 -1
- package/dist/types/puppeteer-agent-launcher.d.ts +1 -1
- package/dist/types/puppeteer.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/yaml.d.ts +1 -1
- package/iife-script/htmlElement.js +2 -2
- package/iife-script/htmlElementDebug.js +2 -2
- package/package.json +3 -3
@@ -193,10 +193,11 @@ var ScriptPlayer = class {
|
|
193
193
|
this.unnamedResultIndex = 0;
|
194
194
|
this.pageAgent = null;
|
195
195
|
this.result = {};
|
196
|
+
const target = script.target || script.web || script.android;
|
196
197
|
if (import_utils3.ifInBrowser) {
|
197
198
|
this.output = void 0;
|
198
|
-
} else if (
|
199
|
-
this.output = (0, import_node_path.resolve)(process.cwd(),
|
199
|
+
} else if (target?.output) {
|
200
|
+
this.output = (0, import_node_path.resolve)(process.cwd(), target.output);
|
200
201
|
} else {
|
201
202
|
this.output = (0, import_node_path.join)((0, import_common.getMidsceneRunSubDir)("output"), `${process.pid}.json`);
|
202
203
|
}
|
@@ -270,12 +271,13 @@ var ScriptPlayer = class {
|
|
270
271
|
} else if ("aiAssert" in flowItem) {
|
271
272
|
const assertTask = flowItem;
|
272
273
|
const prompt = assertTask.aiAssert;
|
274
|
+
const msg = assertTask.errorMessage;
|
273
275
|
(0, import_utils3.assert)(prompt, "missing prompt for aiAssert");
|
274
276
|
(0, import_utils3.assert)(
|
275
277
|
typeof prompt === "string",
|
276
278
|
"prompt for aiAssert must be a string"
|
277
279
|
);
|
278
|
-
await agent.aiAssert(prompt);
|
280
|
+
await agent.aiAssert(prompt, msg);
|
279
281
|
} else if ("aiQuery" in flowItem) {
|
280
282
|
const queryTask = flowItem;
|
281
283
|
const prompt = queryTask.aiQuery;
|
@@ -1725,7 +1727,7 @@ var import_js_yaml3 = __toESM(require("js-yaml"));
|
|
1725
1727
|
var import_semver = __toESM(require("semver"));
|
1726
1728
|
|
1727
1729
|
// package.json
|
1728
|
-
var version = "1.
|
1730
|
+
var version = "1.5.6";
|
1729
1731
|
|
1730
1732
|
// src/common/task-cache.ts
|
1731
1733
|
var debug3 = (0, import_logger3.getDebug)("cache");
|
@@ -1907,13 +1909,10 @@ var PageAgent = class {
|
|
1907
1909
|
generateReport: true,
|
1908
1910
|
autoPrintReportMsg: true,
|
1909
1911
|
groupName: "Midscene Report",
|
1910
|
-
groupDescription: ""
|
1911
|
-
enableCumulativeContext: true,
|
1912
|
-
autoClearContext: false
|
1912
|
+
groupDescription: ""
|
1913
1913
|
},
|
1914
1914
|
opts || {}
|
1915
1915
|
);
|
1916
|
-
this.initializeContextStore();
|
1917
1916
|
if (this.page.pageType === "puppeteer" || this.page.pageType === "playwright") {
|
1918
1917
|
this.page.waitForNavigationTimeout = this.opts.waitForNavigationTimeout || import_constants2.DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
1919
1918
|
this.page.waitForNetworkIdleTimeout = this.opts.waitForNetworkIdleTimeout || import_constants2.DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT;
|
@@ -1940,69 +1939,6 @@ var PageAgent = class {
|
|
1940
1939
|
opts?.testId || this.page.pageType || "web"
|
1941
1940
|
);
|
1942
1941
|
}
|
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
|
-
}
|
2006
1942
|
async getUIContext(action) {
|
2007
1943
|
if (action && (action === "extract" || action === "assert" || action === "captcha")) {
|
2008
1944
|
return await parseContextFromWebPage(this.page, {
|
@@ -2238,31 +2174,6 @@ var PageAgent = class {
|
|
2238
2174
|
};
|
2239
2175
|
}
|
2240
2176
|
async aiAction(taskPrompt, opt) {
|
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
|
-
}
|
2265
|
-
}
|
2266
2177
|
const cacheable = opt?.cacheable;
|
2267
2178
|
const isVlmUiTars = (0, import_env2.vlLocateMode)() === "vlm-ui-tars";
|
2268
2179
|
const matchedCache = isVlmUiTars || cacheable === false ? void 0 : this.taskCache?.matchPlanCache(taskPrompt);
|
@@ -2309,75 +2220,7 @@ var PageAgent = class {
|
|
2309
2220
|
};
|
2310
2221
|
}
|
2311
2222
|
async aiQuery(demand) {
|
2312
|
-
|
2313
|
-
let storageKey;
|
2314
|
-
try {
|
2315
|
-
const aiModel = await import("misoai-core/ai-model");
|
2316
|
-
const contextStore = aiModel.getContextStore();
|
2317
|
-
if (typeof demand === "string") {
|
2318
|
-
const storageInstruction = contextStore.parseStorageInstruction(demand);
|
2319
|
-
if (storageInstruction) {
|
2320
|
-
storageKey = storageInstruction.key;
|
2321
|
-
processedDemand = storageInstruction.cleanText;
|
2322
|
-
contextStore._pendingAliases = storageInstruction.aliases;
|
2323
|
-
} else {
|
2324
|
-
const storageMatch = demand.match(/store\s+(?:as\s+)?(\w+)/i);
|
2325
|
-
if (storageMatch) {
|
2326
|
-
storageKey = storageMatch[1];
|
2327
|
-
processedDemand = demand.replace(/,?\s*store\s+(?:as\s+)?\w+/i, "").trim();
|
2328
|
-
}
|
2329
|
-
}
|
2330
|
-
}
|
2331
|
-
} catch (error) {
|
2332
|
-
debug4("Context store not available:", error);
|
2333
|
-
}
|
2334
|
-
const { output, executor } = await this.taskExecutor.query(processedDemand);
|
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);
|
2378
|
-
}
|
2379
|
-
}
|
2380
|
-
}
|
2223
|
+
const { output, executor } = await this.taskExecutor.query(demand);
|
2381
2224
|
const metadata = this.afterTaskRunning(executor);
|
2382
2225
|
return {
|
2383
2226
|
result: output,
|
@@ -2487,31 +2330,6 @@ var PageAgent = class {
|
|
2487
2330
|
};
|
2488
2331
|
}
|
2489
2332
|
async aiAssert(assertion, msg, opt) {
|
2490
|
-
let processedAssertion = assertion;
|
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
|
-
}
|
2514
|
-
}
|
2515
2333
|
let currentUrl = "";
|
2516
2334
|
if (this.page.url) {
|
2517
2335
|
try {
|
@@ -2519,7 +2337,7 @@ var PageAgent = class {
|
|
2519
2337
|
} catch (e) {
|
2520
2338
|
}
|
2521
2339
|
}
|
2522
|
-
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${
|
2340
|
+
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2523
2341
|
const { output, executor } = await this.taskExecutor.assert(assertionWithContext);
|
2524
2342
|
const metadata = this.afterTaskRunning(executor, true);
|
2525
2343
|
if (output && opt?.keepRawResponse) {
|
@@ -2950,7 +2768,7 @@ function sleep2(ms) {
|
|
2950
2768
|
var ChromeExtensionProxyPage = class {
|
2951
2769
|
constructor(forceSameTabNavigation) {
|
2952
2770
|
this.pageType = "chrome-extension-proxy";
|
2953
|
-
this.version = "1.
|
2771
|
+
this.version = "1.5.6";
|
2954
2772
|
this.activeTabId = null;
|
2955
2773
|
this.tabIdOfDebuggerAttached = null;
|
2956
2774
|
this.attachingDebugger = null;
|