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
@@ -137,10 +137,11 @@ var ScriptPlayer = class {
|
|
137
137
|
this.unnamedResultIndex = 0;
|
138
138
|
this.pageAgent = null;
|
139
139
|
this.result = {};
|
140
|
+
const target = script.target || script.web || script.android;
|
140
141
|
if (ifInBrowser) {
|
141
142
|
this.output = void 0;
|
142
|
-
} else if (
|
143
|
-
this.output = resolve(process.cwd(),
|
143
|
+
} else if (target?.output) {
|
144
|
+
this.output = resolve(process.cwd(), target.output);
|
144
145
|
} else {
|
145
146
|
this.output = join(getMidsceneRunSubDir("output"), `${process.pid}.json`);
|
146
147
|
}
|
@@ -214,12 +215,13 @@ var ScriptPlayer = class {
|
|
214
215
|
} else if ("aiAssert" in flowItem) {
|
215
216
|
const assertTask = flowItem;
|
216
217
|
const prompt = assertTask.aiAssert;
|
218
|
+
const msg = assertTask.errorMessage;
|
217
219
|
assert2(prompt, "missing prompt for aiAssert");
|
218
220
|
assert2(
|
219
221
|
typeof prompt === "string",
|
220
222
|
"prompt for aiAssert must be a string"
|
221
223
|
);
|
222
|
-
await agent.aiAssert(prompt);
|
224
|
+
await agent.aiAssert(prompt, msg);
|
223
225
|
} else if ("aiQuery" in flowItem) {
|
224
226
|
const queryTask = flowItem;
|
225
227
|
const prompt = queryTask.aiQuery;
|
@@ -1661,7 +1663,7 @@ import yaml3 from "js-yaml";
|
|
1661
1663
|
import semver from "semver";
|
1662
1664
|
|
1663
1665
|
// package.json
|
1664
|
-
var version = "1.
|
1666
|
+
var version = "1.5.6";
|
1665
1667
|
|
1666
1668
|
// src/common/task-cache.ts
|
1667
1669
|
var debug3 = getDebug3("cache");
|
@@ -1843,13 +1845,10 @@ var PageAgent = class {
|
|
1843
1845
|
generateReport: true,
|
1844
1846
|
autoPrintReportMsg: true,
|
1845
1847
|
groupName: "Midscene Report",
|
1846
|
-
groupDescription: ""
|
1847
|
-
enableCumulativeContext: true,
|
1848
|
-
autoClearContext: false
|
1848
|
+
groupDescription: ""
|
1849
1849
|
},
|
1850
1850
|
opts || {}
|
1851
1851
|
);
|
1852
|
-
this.initializeContextStore();
|
1853
1852
|
if (this.page.pageType === "puppeteer" || this.page.pageType === "playwright") {
|
1854
1853
|
this.page.waitForNavigationTimeout = this.opts.waitForNavigationTimeout || DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
1855
1854
|
this.page.waitForNetworkIdleTimeout = this.opts.waitForNetworkIdleTimeout || DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT;
|
@@ -1876,69 +1875,6 @@ var PageAgent = class {
|
|
1876
1875
|
opts?.testId || this.page.pageType || "web"
|
1877
1876
|
);
|
1878
1877
|
}
|
1879
|
-
/**
|
1880
|
-
* Initialize context store for cumulative context functionality
|
1881
|
-
*/
|
1882
|
-
async initializeContextStore() {
|
1883
|
-
if (!this.opts.enableCumulativeContext) {
|
1884
|
-
debug4("Cumulative context disabled via options");
|
1885
|
-
return;
|
1886
|
-
}
|
1887
|
-
try {
|
1888
|
-
const aiModel = await import("misoai-core/ai-model");
|
1889
|
-
this.contextStore = aiModel.getContextStore();
|
1890
|
-
debug4("Context store initialized successfully", {
|
1891
|
-
autoClearContext: this.opts.autoClearContext,
|
1892
|
-
testId: this.opts.testId
|
1893
|
-
});
|
1894
|
-
if (this.opts.autoClearContext) {
|
1895
|
-
this.contextStore.clear();
|
1896
|
-
debug4("Context store cleared due to autoClearContext option");
|
1897
|
-
} else {
|
1898
|
-
const existingData = this.contextStore.getAllData();
|
1899
|
-
const existingSteps = this.contextStore.getRecentSteps(100).length;
|
1900
|
-
debug4("Context store preserving existing data", {
|
1901
|
-
existingDataKeys: Object.keys(existingData),
|
1902
|
-
existingStepsCount: existingSteps
|
1903
|
-
});
|
1904
|
-
}
|
1905
|
-
} catch (error) {
|
1906
|
-
debug4("Failed to initialize context store:", error);
|
1907
|
-
console.warn("⚠️ Could not initialize context store:", error);
|
1908
|
-
}
|
1909
|
-
}
|
1910
|
-
/**
|
1911
|
-
* Get the context store instance
|
1912
|
-
*/
|
1913
|
-
getContextStore() {
|
1914
|
-
return this.contextStore;
|
1915
|
-
}
|
1916
|
-
/**
|
1917
|
-
* Clear the context store
|
1918
|
-
*/
|
1919
|
-
clearContext() {
|
1920
|
-
if (this.contextStore) {
|
1921
|
-
this.contextStore.clear();
|
1922
|
-
}
|
1923
|
-
}
|
1924
|
-
/**
|
1925
|
-
* Get all stored data from context store
|
1926
|
-
*/
|
1927
|
-
getStoredData() {
|
1928
|
-
if (this.contextStore) {
|
1929
|
-
return this.contextStore.getAllData();
|
1930
|
-
}
|
1931
|
-
return {};
|
1932
|
-
}
|
1933
|
-
/**
|
1934
|
-
* Get step summary from context store
|
1935
|
-
*/
|
1936
|
-
getStepSummary() {
|
1937
|
-
if (this.contextStore) {
|
1938
|
-
return this.contextStore.getStepSummary();
|
1939
|
-
}
|
1940
|
-
return "";
|
1941
|
-
}
|
1942
1878
|
async getUIContext(action) {
|
1943
1879
|
if (action && (action === "extract" || action === "assert" || action === "captcha")) {
|
1944
1880
|
return await parseContextFromWebPage(this.page, {
|
@@ -2174,31 +2110,6 @@ var PageAgent = class {
|
|
2174
2110
|
};
|
2175
2111
|
}
|
2176
2112
|
async aiAction(taskPrompt, opt) {
|
2177
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2178
|
-
try {
|
2179
|
-
const originalPrompt = taskPrompt;
|
2180
|
-
const processedPrompt = this.contextStore.replaceAllReferences(taskPrompt, "action");
|
2181
|
-
if (originalPrompt !== processedPrompt) {
|
2182
|
-
debug4("Context replacement in aiAction:", {
|
2183
|
-
original: originalPrompt,
|
2184
|
-
processed: processedPrompt,
|
2185
|
-
storedData: this.contextStore.getAllData()
|
2186
|
-
});
|
2187
|
-
}
|
2188
|
-
this.contextStore.addStep({
|
2189
|
-
type: "action",
|
2190
|
-
summary: `Action: ${processedPrompt}`,
|
2191
|
-
prompt: processedPrompt
|
2192
|
-
});
|
2193
|
-
debug4("Added action step to context store:", {
|
2194
|
-
stepNumber: this.contextStore.getRecentSteps(1)[0]?.stepNumber,
|
2195
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2196
|
-
});
|
2197
|
-
taskPrompt = processedPrompt;
|
2198
|
-
} catch (error) {
|
2199
|
-
debug4("Context store operation failed:", error);
|
2200
|
-
}
|
2201
|
-
}
|
2202
2113
|
const cacheable = opt?.cacheable;
|
2203
2114
|
const isVlmUiTars = vlLocateMode() === "vlm-ui-tars";
|
2204
2115
|
const matchedCache = isVlmUiTars || cacheable === false ? void 0 : this.taskCache?.matchPlanCache(taskPrompt);
|
@@ -2245,75 +2156,7 @@ var PageAgent = class {
|
|
2245
2156
|
};
|
2246
2157
|
}
|
2247
2158
|
async aiQuery(demand) {
|
2248
|
-
|
2249
|
-
let storageKey;
|
2250
|
-
try {
|
2251
|
-
const aiModel = await import("misoai-core/ai-model");
|
2252
|
-
const contextStore = aiModel.getContextStore();
|
2253
|
-
if (typeof demand === "string") {
|
2254
|
-
const storageInstruction = contextStore.parseStorageInstruction(demand);
|
2255
|
-
if (storageInstruction) {
|
2256
|
-
storageKey = storageInstruction.key;
|
2257
|
-
processedDemand = storageInstruction.cleanText;
|
2258
|
-
contextStore._pendingAliases = storageInstruction.aliases;
|
2259
|
-
} else {
|
2260
|
-
const storageMatch = demand.match(/store\s+(?:as\s+)?(\w+)/i);
|
2261
|
-
if (storageMatch) {
|
2262
|
-
storageKey = storageMatch[1];
|
2263
|
-
processedDemand = demand.replace(/,?\s*store\s+(?:as\s+)?\w+/i, "").trim();
|
2264
|
-
}
|
2265
|
-
}
|
2266
|
-
}
|
2267
|
-
} catch (error) {
|
2268
|
-
debug4("Context store not available:", error);
|
2269
|
-
}
|
2270
|
-
const { output, executor } = await this.taskExecutor.query(processedDemand);
|
2271
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2272
|
-
if (storageKey && output) {
|
2273
|
-
try {
|
2274
|
-
const pendingAliases = this.contextStore._pendingAliases;
|
2275
|
-
if (pendingAliases) {
|
2276
|
-
this.contextStore.storeDataWithAliases(storageKey, output, pendingAliases, typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand));
|
2277
|
-
delete this.contextStore._pendingAliases;
|
2278
|
-
debug4("Stored query result with aliases:", {
|
2279
|
-
key: storageKey,
|
2280
|
-
value: output,
|
2281
|
-
aliases: pendingAliases
|
2282
|
-
});
|
2283
|
-
} else {
|
2284
|
-
this.contextStore.storeData(storageKey, output);
|
2285
|
-
debug4("Stored query result:", {
|
2286
|
-
key: storageKey,
|
2287
|
-
value: output
|
2288
|
-
});
|
2289
|
-
}
|
2290
|
-
this.contextStore.addStep({
|
2291
|
-
type: "query",
|
2292
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2293
|
-
data: output,
|
2294
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2295
|
-
});
|
2296
|
-
debug4("Added query step to context store:", {
|
2297
|
-
storageKey,
|
2298
|
-
totalStoredItems: Object.keys(this.contextStore.getAllData()).length,
|
2299
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2300
|
-
});
|
2301
|
-
} catch (error) {
|
2302
|
-
debug4("Failed to store query result:", error);
|
2303
|
-
}
|
2304
|
-
} else {
|
2305
|
-
try {
|
2306
|
-
this.contextStore.addStep({
|
2307
|
-
type: "query",
|
2308
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2309
|
-
data: output,
|
2310
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2311
|
-
});
|
2312
|
-
} catch (error) {
|
2313
|
-
debug4("Failed to add query step:", error);
|
2314
|
-
}
|
2315
|
-
}
|
2316
|
-
}
|
2159
|
+
const { output, executor } = await this.taskExecutor.query(demand);
|
2317
2160
|
const metadata = this.afterTaskRunning(executor);
|
2318
2161
|
return {
|
2319
2162
|
result: output,
|
@@ -2423,31 +2266,6 @@ var PageAgent = class {
|
|
2423
2266
|
};
|
2424
2267
|
}
|
2425
2268
|
async aiAssert(assertion, msg, opt) {
|
2426
|
-
let processedAssertion = assertion;
|
2427
|
-
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2428
|
-
try {
|
2429
|
-
const originalAssertion = assertion;
|
2430
|
-
processedAssertion = this.contextStore.replaceAllReferences(assertion, "assertion");
|
2431
|
-
if (originalAssertion !== processedAssertion) {
|
2432
|
-
debug4("Context replacement in aiAssert:", {
|
2433
|
-
original: originalAssertion,
|
2434
|
-
processed: processedAssertion,
|
2435
|
-
context: "assertion",
|
2436
|
-
storedData: this.contextStore.getAllData()
|
2437
|
-
});
|
2438
|
-
}
|
2439
|
-
this.contextStore.addStep({
|
2440
|
-
type: "assertion",
|
2441
|
-
summary: `Assertion: ${processedAssertion}`,
|
2442
|
-
prompt: processedAssertion
|
2443
|
-
});
|
2444
|
-
debug4("Added assertion step to context store:", {
|
2445
|
-
totalSteps: this.contextStore.getRecentSteps(100).length
|
2446
|
-
});
|
2447
|
-
} catch (error) {
|
2448
|
-
debug4("Context store operation failed:", error);
|
2449
|
-
}
|
2450
|
-
}
|
2451
2269
|
let currentUrl = "";
|
2452
2270
|
if (this.page.url) {
|
2453
2271
|
try {
|
@@ -2455,7 +2273,7 @@ var PageAgent = class {
|
|
2455
2273
|
} catch (e) {
|
2456
2274
|
}
|
2457
2275
|
}
|
2458
|
-
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${
|
2276
|
+
const assertionWithContext = currentUrl ? `For the page at URL "${currentUrl}", ${assertion}` : assertion;
|
2459
2277
|
const { output, executor } = await this.taskExecutor.assert(assertionWithContext);
|
2460
2278
|
const metadata = this.afterTaskRunning(executor, true);
|
2461
2279
|
if (output && opt?.keepRawResponse) {
|