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
@@ -258,7 +258,7 @@ function sleep(ms) {
|
|
258
258
|
var ChromeExtensionProxyPage = class {
|
259
259
|
constructor(forceSameTabNavigation) {
|
260
260
|
this.pageType = "chrome-extension-proxy";
|
261
|
-
this.version = "1.0.
|
261
|
+
this.version = "1.0.5";
|
262
262
|
this.activeTabId = null;
|
263
263
|
this.tabIdOfDebuggerAttached = null;
|
264
264
|
this.attachingDebugger = null;
|
@@ -751,7 +751,7 @@ var BridgeClient = class {
|
|
751
751
|
this.socket = ClientIO(this.endpoint, {
|
752
752
|
reconnection: false,
|
753
753
|
query: {
|
754
|
-
version: "1.0.
|
754
|
+
version: "1.0.5"
|
755
755
|
}
|
756
756
|
});
|
757
757
|
const timeout = setTimeout(() => {
|
@@ -892,7 +892,7 @@ var ExtensionBridgePageBrowserSide = class extends ChromeExtensionProxyPage {
|
|
892
892
|
);
|
893
893
|
await this.bridgeClient.connect();
|
894
894
|
this.onLogMessage(
|
895
|
-
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"1.0.
|
895
|
+
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"1.0.5"}`,
|
896
896
|
"log"
|
897
897
|
);
|
898
898
|
}
|
package/dist/es/bridge-mode.js
CHANGED
@@ -1660,7 +1660,7 @@ import yaml3 from "js-yaml";
|
|
1660
1660
|
import semver from "semver";
|
1661
1661
|
|
1662
1662
|
// package.json
|
1663
|
-
var version = "1.0.
|
1663
|
+
var version = "1.0.5";
|
1664
1664
|
|
1665
1665
|
// src/common/task-cache.ts
|
1666
1666
|
var debug3 = getDebug3("cache");
|
@@ -1842,10 +1842,13 @@ var PageAgent = class {
|
|
1842
1842
|
generateReport: true,
|
1843
1843
|
autoPrintReportMsg: true,
|
1844
1844
|
groupName: "Midscene Report",
|
1845
|
-
groupDescription: ""
|
1845
|
+
groupDescription: "",
|
1846
|
+
enableCumulativeContext: true,
|
1847
|
+
autoClearContext: false
|
1846
1848
|
},
|
1847
1849
|
opts || {}
|
1848
1850
|
);
|
1851
|
+
this.initializeContextStore();
|
1849
1852
|
if (this.page.pageType === "puppeteer" || this.page.pageType === "playwright") {
|
1850
1853
|
this.page.waitForNavigationTimeout = this.opts.waitForNavigationTimeout || DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT;
|
1851
1854
|
this.page.waitForNetworkIdleTimeout = this.opts.waitForNetworkIdleTimeout || DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT;
|
@@ -1872,6 +1875,69 @@ var PageAgent = class {
|
|
1872
1875
|
opts?.testId || this.page.pageType || "web"
|
1873
1876
|
);
|
1874
1877
|
}
|
1878
|
+
/**
|
1879
|
+
* Initialize context store for cumulative context functionality
|
1880
|
+
*/
|
1881
|
+
async initializeContextStore() {
|
1882
|
+
if (!this.opts.enableCumulativeContext) {
|
1883
|
+
debug4("Cumulative context disabled via options");
|
1884
|
+
return;
|
1885
|
+
}
|
1886
|
+
try {
|
1887
|
+
const aiModel = await import("misoai-core/ai-model");
|
1888
|
+
this.contextStore = aiModel.getContextStore();
|
1889
|
+
debug4("Context store initialized successfully", {
|
1890
|
+
autoClearContext: this.opts.autoClearContext,
|
1891
|
+
testId: this.opts.testId
|
1892
|
+
});
|
1893
|
+
if (this.opts.autoClearContext) {
|
1894
|
+
this.contextStore.clear();
|
1895
|
+
debug4("Context store cleared due to autoClearContext option");
|
1896
|
+
} else {
|
1897
|
+
const existingData = this.contextStore.getAllData();
|
1898
|
+
const existingSteps = this.contextStore.getRecentSteps(100).length;
|
1899
|
+
debug4("Context store preserving existing data", {
|
1900
|
+
existingDataKeys: Object.keys(existingData),
|
1901
|
+
existingStepsCount: existingSteps
|
1902
|
+
});
|
1903
|
+
}
|
1904
|
+
} catch (error) {
|
1905
|
+
debug4("Failed to initialize context store:", error);
|
1906
|
+
console.warn("⚠️ Could not initialize context store:", error);
|
1907
|
+
}
|
1908
|
+
}
|
1909
|
+
/**
|
1910
|
+
* Get the context store instance
|
1911
|
+
*/
|
1912
|
+
getContextStore() {
|
1913
|
+
return this.contextStore;
|
1914
|
+
}
|
1915
|
+
/**
|
1916
|
+
* Clear the context store
|
1917
|
+
*/
|
1918
|
+
clearContext() {
|
1919
|
+
if (this.contextStore) {
|
1920
|
+
this.contextStore.clear();
|
1921
|
+
}
|
1922
|
+
}
|
1923
|
+
/**
|
1924
|
+
* Get all stored data from context store
|
1925
|
+
*/
|
1926
|
+
getStoredData() {
|
1927
|
+
if (this.contextStore) {
|
1928
|
+
return this.contextStore.getAllData();
|
1929
|
+
}
|
1930
|
+
return {};
|
1931
|
+
}
|
1932
|
+
/**
|
1933
|
+
* Get step summary from context store
|
1934
|
+
*/
|
1935
|
+
getStepSummary() {
|
1936
|
+
if (this.contextStore) {
|
1937
|
+
return this.contextStore.getStepSummary();
|
1938
|
+
}
|
1939
|
+
return "";
|
1940
|
+
}
|
1875
1941
|
async getUIContext(action) {
|
1876
1942
|
if (action && (action === "extract" || action === "assert" || action === "captcha")) {
|
1877
1943
|
return await parseContextFromWebPage(this.page, {
|
@@ -2107,18 +2173,30 @@ var PageAgent = class {
|
|
2107
2173
|
};
|
2108
2174
|
}
|
2109
2175
|
async aiAction(taskPrompt, opt) {
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2176
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2177
|
+
try {
|
2178
|
+
const originalPrompt = taskPrompt;
|
2179
|
+
const processedPrompt = this.contextStore.replaceAllReferences(taskPrompt, "action");
|
2180
|
+
if (originalPrompt !== processedPrompt) {
|
2181
|
+
debug4("Context replacement in aiAction:", {
|
2182
|
+
original: originalPrompt,
|
2183
|
+
processed: processedPrompt,
|
2184
|
+
storedData: this.contextStore.getAllData()
|
2185
|
+
});
|
2186
|
+
}
|
2187
|
+
this.contextStore.addStep({
|
2188
|
+
type: "action",
|
2189
|
+
summary: `Action: ${processedPrompt}`,
|
2190
|
+
prompt: processedPrompt
|
2191
|
+
});
|
2192
|
+
debug4("Added action step to context store:", {
|
2193
|
+
stepNumber: this.contextStore.getRecentSteps(1)[0]?.stepNumber,
|
2194
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2195
|
+
});
|
2196
|
+
taskPrompt = processedPrompt;
|
2197
|
+
} catch (error) {
|
2198
|
+
debug4("Context store operation failed:", error);
|
2199
|
+
}
|
2122
2200
|
}
|
2123
2201
|
const cacheable = opt?.cacheable;
|
2124
2202
|
const isVlmUiTars = vlLocateMode() === "vlm-ui-tars";
|
@@ -2189,38 +2267,50 @@ var PageAgent = class {
|
|
2189
2267
|
debug4("Context store not available:", error);
|
2190
2268
|
}
|
2191
2269
|
const { output, executor } = await this.taskExecutor.query(processedDemand);
|
2192
|
-
if (
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2270
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2271
|
+
if (storageKey && output) {
|
2272
|
+
try {
|
2273
|
+
const pendingAliases = this.contextStore._pendingAliases;
|
2274
|
+
if (pendingAliases) {
|
2275
|
+
this.contextStore.storeDataWithAliases(storageKey, output, pendingAliases, typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand));
|
2276
|
+
delete this.contextStore._pendingAliases;
|
2277
|
+
debug4("Stored query result with aliases:", {
|
2278
|
+
key: storageKey,
|
2279
|
+
value: output,
|
2280
|
+
aliases: pendingAliases
|
2281
|
+
});
|
2282
|
+
} else {
|
2283
|
+
this.contextStore.storeData(storageKey, output);
|
2284
|
+
debug4("Stored query result:", {
|
2285
|
+
key: storageKey,
|
2286
|
+
value: output
|
2287
|
+
});
|
2288
|
+
}
|
2289
|
+
this.contextStore.addStep({
|
2290
|
+
type: "query",
|
2291
|
+
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2292
|
+
data: output,
|
2293
|
+
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2294
|
+
});
|
2295
|
+
debug4("Added query step to context store:", {
|
2296
|
+
storageKey,
|
2297
|
+
totalStoredItems: Object.keys(this.contextStore.getAllData()).length,
|
2298
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2299
|
+
});
|
2300
|
+
} catch (error) {
|
2301
|
+
debug4("Failed to store query result:", error);
|
2302
|
+
}
|
2303
|
+
} else {
|
2304
|
+
try {
|
2305
|
+
this.contextStore.addStep({
|
2306
|
+
type: "query",
|
2307
|
+
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2308
|
+
data: output,
|
2309
|
+
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2310
|
+
});
|
2311
|
+
} catch (error) {
|
2312
|
+
debug4("Failed to add query step:", error);
|
2202
2313
|
}
|
2203
|
-
contextStore.addStep({
|
2204
|
-
type: "query",
|
2205
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)} (stored as ${storageKey})`,
|
2206
|
-
data: output,
|
2207
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2208
|
-
});
|
2209
|
-
} catch (error) {
|
2210
|
-
debug4("Failed to store query result:", error);
|
2211
|
-
}
|
2212
|
-
} else {
|
2213
|
-
try {
|
2214
|
-
const aiModel = await import("misoai-core/ai-model");
|
2215
|
-
const contextStore = aiModel.getContextStore();
|
2216
|
-
contextStore.addStep({
|
2217
|
-
type: "query",
|
2218
|
-
summary: `Query: ${typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)}`,
|
2219
|
-
data: output,
|
2220
|
-
prompt: typeof processedDemand === "string" ? processedDemand : JSON.stringify(processedDemand)
|
2221
|
-
});
|
2222
|
-
} catch (error) {
|
2223
|
-
debug4("Failed to add query step:", error);
|
2224
2314
|
}
|
2225
2315
|
}
|
2226
2316
|
const metadata = this.afterTaskRunning(executor);
|
@@ -2333,17 +2423,29 @@ var PageAgent = class {
|
|
2333
2423
|
}
|
2334
2424
|
async aiAssert(assertion, msg, opt) {
|
2335
2425
|
let processedAssertion = assertion;
|
2336
|
-
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2426
|
+
if (this.opts.enableCumulativeContext && this.contextStore) {
|
2427
|
+
try {
|
2428
|
+
const originalAssertion = assertion;
|
2429
|
+
processedAssertion = this.contextStore.replaceAllReferences(assertion, "assertion");
|
2430
|
+
if (originalAssertion !== processedAssertion) {
|
2431
|
+
debug4("Context replacement in aiAssert:", {
|
2432
|
+
original: originalAssertion,
|
2433
|
+
processed: processedAssertion,
|
2434
|
+
context: "assertion",
|
2435
|
+
storedData: this.contextStore.getAllData()
|
2436
|
+
});
|
2437
|
+
}
|
2438
|
+
this.contextStore.addStep({
|
2439
|
+
type: "assertion",
|
2440
|
+
summary: `Assertion: ${processedAssertion}`,
|
2441
|
+
prompt: processedAssertion
|
2442
|
+
});
|
2443
|
+
debug4("Added assertion step to context store:", {
|
2444
|
+
totalSteps: this.contextStore.getRecentSteps(100).length
|
2445
|
+
});
|
2446
|
+
} catch (error) {
|
2447
|
+
debug4("Context store operation failed:", error);
|
2448
|
+
}
|
2347
2449
|
}
|
2348
2450
|
let currentUrl = "";
|
2349
2451
|
if (this.page.url) {
|
@@ -2678,7 +2780,7 @@ var BridgeServer = class {
|
|
2678
2780
|
this.socket = socket;
|
2679
2781
|
const clientVersion = socket.handshake.query.version;
|
2680
2782
|
logMsg2(
|
2681
|
-
`Bridge connected, cli-side version v${"1.0.
|
2783
|
+
`Bridge connected, cli-side version v${"1.0.5"}, browser-side version v${clientVersion}`
|
2682
2784
|
);
|
2683
2785
|
socket.on("bridge-call-response" /* CallResponse */, (params) => {
|
2684
2786
|
const id = params.id;
|
@@ -2709,7 +2811,7 @@ var BridgeServer = class {
|
|
2709
2811
|
setTimeout(() => {
|
2710
2812
|
this.onConnect?.();
|
2711
2813
|
const payload = {
|
2712
|
-
version: "1.0.
|
2814
|
+
version: "1.0.5"
|
2713
2815
|
};
|
2714
2816
|
socket.emit("bridge-connected" /* Connected */, payload);
|
2715
2817
|
Promise.resolve().then(() => {
|