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
@@ -160,10 +160,11 @@ var ScriptPlayer = class {
|
|
160
160
|
this.unnamedResultIndex = 0;
|
161
161
|
this.pageAgent = null;
|
162
162
|
this.result = {};
|
163
|
+
const target = script.target || script.web || script.android;
|
163
164
|
if (ifInBrowser) {
|
164
165
|
this.output = void 0;
|
165
|
-
} else if (
|
166
|
-
this.output = resolve(process.cwd(),
|
166
|
+
} else if (target?.output) {
|
167
|
+
this.output = resolve(process.cwd(), target.output);
|
167
168
|
} else {
|
168
169
|
this.output = join(getMidsceneRunSubDir("output"), `${process.pid}.json`);
|
169
170
|
}
|
@@ -237,12 +238,13 @@ var ScriptPlayer = class {
|
|
237
238
|
} else if ("aiAssert" in flowItem) {
|
238
239
|
const assertTask = flowItem;
|
239
240
|
const prompt = assertTask.aiAssert;
|
241
|
+
const msg = assertTask.errorMessage;
|
240
242
|
assert2(prompt, "missing prompt for aiAssert");
|
241
243
|
assert2(
|
242
244
|
typeof prompt === "string",
|
243
245
|
"prompt for aiAssert must be a string"
|
244
246
|
);
|
245
|
-
await agent.aiAssert(prompt);
|
247
|
+
await agent.aiAssert(prompt, msg);
|
246
248
|
} else if ("aiQuery" in flowItem) {
|
247
249
|
const queryTask = flowItem;
|
248
250
|
const prompt = queryTask.aiQuery;
|
@@ -1707,7 +1709,7 @@ import yaml3 from "js-yaml";
|
|
1707
1709
|
import semver from "semver";
|
1708
1710
|
|
1709
1711
|
// package.json
|
1710
|
-
var version = "1.
|
1712
|
+
var version = "1.5.6";
|
1711
1713
|
|
1712
1714
|
// src/common/task-cache.ts
|
1713
1715
|
var debug3 = getDebug3("cache");
|
@@ -1889,13 +1891,10 @@ var PageAgent = class {
|
|
1889
1891
|
generateReport: true,
|
1890
1892
|
autoPrintReportMsg: true,
|
1891
1893
|
groupName: "Midscene Report",
|
1892
|
-
groupDescription: ""
|
1893
|
-
enableCumulativeContext: true,
|
1894
|
-
autoClearContext: false
|
1894
|
+
groupDescription: ""
|
1895
1895
|
},
|
1896
1896
|
opts || {}
|
1897
1897
|
);
|
1898
|
-
this.initializeContextStore();
|
1899
1898
|
if (this.page.pageType === "puppeteer" || this.page.pageType === "playwright") {
|
1900
1899
|
this.page.waitForNavigationTimeout = this.opts.waitForNavigationTimeout || DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
1901
1900
|
this.page.waitForNetworkIdleTimeout = this.opts.waitForNetworkIdleTimeout || DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT;
|
@@ -1922,69 +1921,6 @@ var PageAgent = class {
|
|
1922
1921
|
opts?.testId || this.page.pageType || "web"
|
1923
1922
|
);
|
1924
1923
|
}
|
1925
|
-
/**
|
1926
|
-
* Initialize context store for cumulative context functionality
|
1927
|
-
*/
|
1928
|
-
async initializeContextStore() {
|
1929
|
-
if (!this.opts.enableCumulativeContext) {
|
1930
|
-
debug4("Cumulative context disabled via options");
|
1931
|
-
return;
|
1932
|
-
}
|
1933
|
-
try {
|
1934
|
-
const aiModel = await import("misoai-core/ai-model");
|
1935
|
-
this.contextStore = aiModel.getContextStore();
|
1936
|
-
debug4("Context store initialized successfully", {
|
1937
|
-
autoClearContext: this.opts.autoClearContext,
|
1938
|
-
testId: this.opts.testId
|
1939
|
-
});
|
1940
|
-
if (this.opts.autoClearContext) {
|
1941
|
-
this.contextStore.clear();
|
1942
|
-
debug4("Context store cleared due to autoClearContext option");
|
1943
|
-
} else {
|
1944
|
-
const existingData = this.contextStore.getAllData();
|
1945
|
-
const existingSteps = this.contextStore.getRecentSteps(100).length;
|
1946
|
-
debug4("Context store preserving existing data", {
|
1947
|
-
existingDataKeys: Object.keys(existingData),
|
1948
|
-
existingStepsCount: existingSteps
|
1949
|
-
});
|
1950
|
-
}
|
1951
|
-
} catch (error) {
|
1952
|
-
debug4("Failed to initialize context store:", error);
|
1953
|
-
console.warn("⚠️ Could not initialize context store:", error);
|
1954
|
-
}
|
1955
|
-
}
|
1956
|
-
/**
|
1957
|
-
* Get the context store instance
|
1958
|
-
*/
|
1959
|
-
getContextStore() {
|
1960
|
-
return this.contextStore;
|
1961
|
-
}
|
1962
|
-
/**
|
1963
|
-
* Clear the context store
|
1964
|
-
*/
|
1965
|
-
clearContext() {
|
1966
|
-
if (this.contextStore) {
|
1967
|
-
this.contextStore.clear();
|
1968
|
-
}
|
1969
|
-
}
|
1970
|
-
/**
|
1971
|
-
* Get all stored data from context store
|
1972
|
-
*/
|
1973
|
-
getStoredData() {
|
1974
|
-
if (this.contextStore) {
|
1975
|
-
return this.contextStore.getAllData();
|
1976
|
-
}
|
1977
|
-
return {};
|
1978
|
-
}
|
1979
|
-
/**
|
1980
|
-
* Get step summary from context store
|
1981
|
-
*/
|
1982
|
-
getStepSummary() {
|
1983
|
-
if (this.contextStore) {
|
1984
|
-
return this.contextStore.getStepSummary();
|
1985
|
-
}
|
1986
|
-
return "";
|
1987
|
-
}
|
1988
1924
|
async getUIContext(action) {
|
1989
1925
|
if (action && (action === "extract" || action === "assert" || action === "captcha")) {
|
1990
1926
|
return await parseContextFromWebPage(this.page, {
|
@@ -2220,31 +2156,6 @@ var PageAgent = class {
|
|
2220
2156
|
};
|
2221
2157
|
}
|
2222
2158
|
async aiAction(taskPrompt, opt) {
|
2223
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2224
|
-
try {
|
2225
|
-
const originalPrompt = taskPrompt;
|
2226
|
-
const processedPrompt = this.contextStore.replaceAllReferences(taskPrompt, "action");
|
2227
|
-
if (originalPrompt !== processedPrompt) {
|
2228
|
-
debug4("Context replacement in aiAction:", {
|
2229
|
-
original: originalPrompt,
|
2230
|
-
processed: processedPrompt,
|
2231
|
-
storedData: this.contextStore.getAllData()
|
2232
|
-
});
|
2233
|
-
}
|
2234
|
-
this.contextStore.addStep({
|
2235
|
-
type: "action",
|
2236
|
-
summary: `Action: ${processedPrompt}`,
|
2237
|
-
prompt: processedPrompt
|
2238
|
-
});
|
2239
|
-
debug4("Added action step to context store:", {
|
2240
|
-
stepNumber: this.contextStore.getRecentSteps(1)[0]?.stepNumber,
|
2241
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2242
|
-
});
|
2243
|
-
taskPrompt = processedPrompt;
|
2244
|
-
} catch (error) {
|
2245
|
-
debug4("Context store operation failed:", error);
|
2246
|
-
}
|
2247
|
-
}
|
2248
2159
|
const cacheable = opt?.cacheable;
|
2249
2160
|
const isVlmUiTars = vlLocateMode() === "vlm-ui-tars";
|
2250
2161
|
const matchedCache = isVlmUiTars || cacheable === false ? void 0 : this.taskCache?.matchPlanCache(taskPrompt);
|
@@ -2291,75 +2202,7 @@ var PageAgent = class {
|
|
2291
2202
|
};
|
2292
2203
|
}
|
2293
2204
|
async aiQuery(demand) {
|
2294
|
-
|
2295
|
-
let storageKey;
|
2296
|
-
try {
|
2297
|
-
const aiModel = await import("misoai-core/ai-model");
|
2298
|
-
const contextStore = aiModel.getContextStore();
|
2299
|
-
if (typeof demand === "string") {
|
2300
|
-
const storageInstruction = contextStore.parseStorageInstruction(demand);
|
2301
|
-
if (storageInstruction) {
|
2302
|
-
storageKey = storageInstruction.key;
|
2303
|
-
processedDemand = storageInstruction.cleanText;
|
2304
|
-
contextStore._pendingAliases = storageInstruction.aliases;
|
2305
|
-
} else {
|
2306
|
-
const storageMatch = demand.match(/store\s+(?:as\s+)?(\w+)/i);
|
2307
|
-
if (storageMatch) {
|
2308
|
-
storageKey = storageMatch[1];
|
2309
|
-
processedDemand = demand.replace(/,?\s*store\s+(?:as\s+)?\w+/i, "").trim();
|
2310
|
-
}
|
2311
|
-
}
|
2312
|
-
}
|
2313
|
-
} catch (error) {
|
2314
|
-
debug4("Context store not available:", error);
|
2315
|
-
}
|
2316
|
-
const { output, executor } = await this.taskExecutor.query(processedDemand);
|
2317
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2318
|
-
if (storageKey && output) {
|
2319
|
-
try {
|
2320
|
-
const pendingAliases = this.contextStore._pendingAliases;
|
2321
|
-
if (pendingAliases) {
|
2322
|
-
this.contextStore.storeDataWithAliases(storageKey, output, pendingAliases, typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand));
|
2323
|
-
delete this.contextStore._pendingAliases;
|
2324
|
-
debug4("Stored query result with aliases:", {
|
2325
|
-
key: storageKey,
|
2326
|
-
value: output,
|
2327
|
-
aliases: pendingAliases
|
2328
|
-
});
|
2329
|
-
} else {
|
2330
|
-
this.contextStore.storeData(storageKey, output);
|
2331
|
-
debug4("Stored query result:", {
|
2332
|
-
key: storageKey,
|
2333
|
-
value: output
|
2334
|
-
});
|
2335
|
-
}
|
2336
|
-
this.contextStore.addStep({
|
2337
|
-
type: "query",
|
2338
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2339
|
-
data: output,
|
2340
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2341
|
-
});
|
2342
|
-
debug4("Added query step to context store:", {
|
2343
|
-
storageKey,
|
2344
|
-
totalStoredItems: Object.keys(this.contextStore.getAllData()).length,
|
2345
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2346
|
-
});
|
2347
|
-
} catch (error) {
|
2348
|
-
debug4("Failed to store query result:", error);
|
2349
|
-
}
|
2350
|
-
} else {
|
2351
|
-
try {
|
2352
|
-
this.contextStore.addStep({
|
2353
|
-
type: "query",
|
2354
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2355
|
-
data: output,
|
2356
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2357
|
-
});
|
2358
|
-
} catch (error) {
|
2359
|
-
debug4("Failed to add query step:", error);
|
2360
|
-
}
|
2361
|
-
}
|
2362
|
-
}
|
2205
|
+
const { output, executor } = await this.taskExecutor.query(demand);
|
2363
2206
|
const metadata = this.afterTaskRunning(executor);
|
2364
2207
|
return {
|
2365
2208
|
result: output,
|
@@ -2469,31 +2312,6 @@ var PageAgent = class {
|
|
2469
2312
|
};
|
2470
2313
|
}
|
2471
2314
|
async aiAssert(assertion, msg, opt) {
|
2472
|
-
let processedAssertion = assertion;
|
2473
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2474
|
-
try {
|
2475
|
-
const originalAssertion = assertion;
|
2476
|
-
processedAssertion = this.contextStore.replaceAllReferences(assertion, "assertion");
|
2477
|
-
if (originalAssertion !== processedAssertion) {
|
2478
|
-
debug4("Context replacement in aiAssert:", {
|
2479
|
-
original: originalAssertion,
|
2480
|
-
processed: processedAssertion,
|
2481
|
-
context: "assertion",
|
2482
|
-
storedData: this.contextStore.getAllData()
|
2483
|
-
});
|
2484
|
-
}
|
2485
|
-
this.contextStore.addStep({
|
2486
|
-
type: "assertion",
|
2487
|
-
summary: `Assertion: ${processedAssertion}`,
|
2488
|
-
prompt: processedAssertion
|
2489
|
-
});
|
2490
|
-
debug4("Added assertion step to context store:", {
|
2491
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2492
|
-
});
|
2493
|
-
} catch (error) {
|
2494
|
-
debug4("Context store operation failed:", error);
|
2495
|
-
}
|
2496
|
-
}
|
2497
2315
|
let currentUrl = "";
|
2498
2316
|
if (this.page.url) {
|
2499
2317
|
try {
|
@@ -2501,7 +2319,7 @@ var PageAgent = class {
|
|
2501
2319
|
} catch (e) {
|
2502
2320
|
}
|
2503
2321
|
}
|
2504
|
-
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${
|
2322
|
+
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2505
2323
|
const { output, executor } = await this.taskExecutor.assert(assertionWithContext);
|
2506
2324
|
const metadata = this.afterTaskRunning(executor, true);
|
2507
2325
|
if (output && opt?.keepRawResponse) {
|
@@ -2934,7 +2752,7 @@ function sleep2(ms) {
|
|
2934
2752
|
var ChromeExtensionProxyPage = class {
|
2935
2753
|
constructor(forceSameTabNavigation) {
|
2936
2754
|
this.pageType = "chrome-extension-proxy";
|
2937
|
-
this.version = "1.
|
2755
|
+
this.version = "1.5.6";
|
2938
2756
|
this.activeTabId = null;
|
2939
2757
|
this.tabIdOfDebuggerAttached = null;
|
2940
2758
|
this.attachingDebugger = null;
|