@mearl/browser-core 3.0.0-beta.1 → 3.0.0-beta.10
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 +7 -5
- package/README.zh-CN.md +13 -0
- package/dist/agentChat.d.ts +10 -1
- package/dist/agentChat.js +8 -0
- package/dist/agentServiceProtocol.d.ts +23 -0
- package/dist/agentServiceProtocol.js +3 -0
- package/dist/agentSkills.d.ts +1 -1
- package/dist/app-profile-runtime/types.d.ts +10 -12
- package/dist/appProfileDefinition.d.ts +32 -14
- package/dist/appProfileDefinition.js +63 -69
- package/dist/axSnapshot.js +1 -1
- package/dist/boundedRequestBuffer.d.ts +4 -4
- package/dist/browserActionProtocol.d.ts +55 -45
- package/dist/browserActionProtocol.js +12 -15
- package/dist/browserCapabilities.d.ts +47 -0
- package/dist/browserCapabilities.js +63 -0
- package/dist/browserDiscovery.d.ts +3 -0
- package/dist/browserDiscovery.js +20 -0
- package/dist/browserEnhancement.d.ts +161 -0
- package/dist/browserEnhancement.js +80 -0
- package/dist/cookie.d.ts +6 -0
- package/dist/cookie.js +20 -5
- package/dist/dataStructure.d.ts +8 -0
- package/dist/dataStructure.js +58 -0
- package/dist/deviceEmulation.d.ts +6 -0
- package/dist/deviceEmulation.js +13 -0
- package/dist/deviceEnvironmentObservation.d.ts +48 -0
- package/dist/deviceEnvironmentObservation.js +77 -0
- package/dist/domClicking.d.ts +14 -0
- package/dist/domClicking.js +98 -10
- package/dist/domInspection.js +13 -1
- package/dist/extensionServiceProtocol.d.ts +7 -0
- package/dist/extensionServiceProtocol.js +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/pageAct.d.ts +2 -0
- package/dist/pageAct.js +42 -10
- package/dist/pageDialog.d.ts +66 -0
- package/dist/pageDialog.js +175 -0
- package/dist/pageObserver.js +16 -5
- package/dist/pagePressing.d.ts +1 -1
- package/dist/pluginPageHost.js +2 -2
- package/dist/providerAppResources.d.ts +39 -0
- package/dist/providerAppResources.js +2 -0
- package/dist/proxyPermissions.js +3 -3
- package/dist/requestMetadata.d.ts +9 -0
- package/dist/requestMetadata.js +8 -0
- package/dist/requestSerializer.d.ts +2 -2
- package/dist/requestSerializer.js +1 -29
- package/dist/requestStreamCapture.d.ts +5 -3
- package/dist/requestStreamCapture.js +2 -0
- package/dist/runActions.js +1 -1
- package/dist/types.d.ts +4 -2
- package/package.json +2 -2
package/dist/proxyPermissions.js
CHANGED
|
@@ -6,7 +6,7 @@ export class DomainPermissionError extends Error {
|
|
|
6
6
|
domain;
|
|
7
7
|
code = 'DOMAIN_PERMISSION_REQUIRED';
|
|
8
8
|
requestDispatched = false;
|
|
9
|
-
constructor(action, domain, message = `${action}: Access to "${domain}" is not authorized. Call
|
|
9
|
+
constructor(action, domain, message = `${action}: Access to "${domain}" is not authorized. Call request_permission with domain="${domain}" to request user authorization, then retry.`) {
|
|
10
10
|
super(message);
|
|
11
11
|
this.action = action;
|
|
12
12
|
this.domain = domain;
|
|
@@ -83,10 +83,10 @@ export function isDomainAuthorized(domain, allowedOrigins) {
|
|
|
83
83
|
* wrappers whose individual steps are checked independently.
|
|
84
84
|
*/
|
|
85
85
|
export const ACTIONS_SKIP_DOMAIN_CHECK = new Set([
|
|
86
|
-
'
|
|
86
|
+
'request_permission',
|
|
87
87
|
'get_browser_info',
|
|
88
|
+
'get_capabilities',
|
|
88
89
|
'__export_cookies',
|
|
89
|
-
'send_mtop_request',
|
|
90
90
|
'run_actions',
|
|
91
91
|
'browser_release',
|
|
92
92
|
'__control_cleanup',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Optional protocol annotations; the collector retains the original HTTP record. */
|
|
2
|
+
export interface RequestMetadata {
|
|
3
|
+
apiName: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
isProxy: boolean;
|
|
6
|
+
proxyRequestUrl: string | null;
|
|
7
|
+
environment?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseRequestMetadata(value: unknown): RequestMetadata | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function parseRequestMetadata(value) {
|
|
2
|
+
if (value === null || value === undefined)
|
|
3
|
+
return null;
|
|
4
|
+
const metadata = value;
|
|
5
|
+
if (typeof value !== 'object' || Array.isArray(value) || metadata.namespace !== undefined && (typeof metadata.namespace !== 'string' || metadata.namespace.length > 256) || typeof metadata.apiName !== 'string' || metadata.apiName.length > 4096 || typeof metadata.isProxy !== 'boolean' || metadata.proxyRequestUrl !== null && typeof metadata.proxyRequestUrl !== 'string' || metadata.environment !== undefined && (typeof metadata.environment !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,63}$/.test(metadata.environment)))
|
|
6
|
+
throw new Error('Invalid request metadata');
|
|
7
|
+
return { ...(metadata.namespace ? { namespace: metadata.namespace } : {}), apiName: metadata.apiName, isProxy: metadata.isProxy, proxyRequestUrl: metadata.proxyRequestUrl, ...(metadata.environment ? { environment: metadata.environment } : {}) };
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Request serialization utilities — pure computation, no environment dependencies.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { CapturedRequest } from './types.js';
|
|
5
5
|
export interface SerializeOptions {
|
|
6
6
|
includeBody?: boolean;
|
|
7
7
|
includeHeaders?: boolean;
|
|
@@ -10,4 +10,4 @@ export interface SerializeOptions {
|
|
|
10
10
|
keysOnly?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare function setValueByPath(obj: any, path: string, value: any): void;
|
|
13
|
-
export declare function serializeRequest(request:
|
|
13
|
+
export declare function serializeRequest(request: CapturedRequest, options?: SerializeOptions): any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Request serialization utilities — pure computation, no environment dependencies.
|
|
3
3
|
*/
|
|
4
|
+
import { getStructure } from './dataStructure.js';
|
|
4
5
|
// ─── Path utilities ───────────────────────────────────────────────────────────
|
|
5
6
|
function parsePath(path) {
|
|
6
7
|
if (path.length > 1000)
|
|
@@ -67,35 +68,6 @@ export function setValueByPath(obj, path, value) {
|
|
|
67
68
|
current[keys[keys.length - 1]] = value;
|
|
68
69
|
}
|
|
69
70
|
// ─── Structure helpers ────────────────────────────────────────────────────────
|
|
70
|
-
function getStructure(data, maxDepth = 5, currentDepth = 0) {
|
|
71
|
-
if (currentDepth >= maxDepth)
|
|
72
|
-
return '<max depth reached>';
|
|
73
|
-
if (data === null)
|
|
74
|
-
return 'null';
|
|
75
|
-
if (data === undefined)
|
|
76
|
-
return 'undefined';
|
|
77
|
-
const type = typeof data;
|
|
78
|
-
if (type === 'string' || type === 'number' || type === 'boolean')
|
|
79
|
-
return type;
|
|
80
|
-
if (Array.isArray(data)) {
|
|
81
|
-
if (data.length === 0)
|
|
82
|
-
return 'array[0]';
|
|
83
|
-
return {
|
|
84
|
-
_type: `array[${data.length}]`,
|
|
85
|
-
_sample: getStructure(data[0], maxDepth, currentDepth + 1),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (type === 'object') {
|
|
89
|
-
const structure = {};
|
|
90
|
-
for (const key in data) {
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
92
|
-
structure[key] = getStructure(data[key], maxDepth, currentDepth + 1);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return structure;
|
|
96
|
-
}
|
|
97
|
-
return type;
|
|
98
|
-
}
|
|
99
71
|
function truncateData(data, maxSize) {
|
|
100
72
|
const str = JSON.stringify(data);
|
|
101
73
|
if (str.length <= maxSize)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CapturedRequest } from './types.js';
|
|
2
2
|
export interface RequestStreamCapture {
|
|
3
|
-
request:
|
|
3
|
+
request: CapturedRequest;
|
|
4
4
|
startTimeMs: number;
|
|
5
5
|
lastMessageTimeMs?: number;
|
|
6
6
|
}
|
|
@@ -8,7 +8,9 @@ export interface RequestStreamCaptureStart {
|
|
|
8
8
|
id: number;
|
|
9
9
|
api: string;
|
|
10
10
|
url: string;
|
|
11
|
-
source?:
|
|
11
|
+
source?: CapturedRequest['source'];
|
|
12
|
+
namespace?: string;
|
|
13
|
+
environment?: string;
|
|
12
14
|
method: string;
|
|
13
15
|
requestHeaders?: Array<{
|
|
14
16
|
name: string;
|
|
@@ -34,6 +34,8 @@ export function createRequestStreamCapture(data) {
|
|
|
34
34
|
method: data.method,
|
|
35
35
|
url,
|
|
36
36
|
apiName: data.api,
|
|
37
|
+
...(data.namespace !== undefined ? { namespace: data.namespace } : {}),
|
|
38
|
+
...(data.environment !== undefined ? { environment: data.environment } : {}),
|
|
37
39
|
status: 0,
|
|
38
40
|
statusText: 'SSE Streaming',
|
|
39
41
|
headers: redactSensitiveHeaders(data.requestHeaders ?? []),
|
package/dist/runActions.js
CHANGED
|
@@ -22,7 +22,7 @@ export async function runActionBatch(data, execute, options = {}) {
|
|
|
22
22
|
validationError = `unsupported action "${action}"`;
|
|
23
23
|
else if (action === 'run_actions')
|
|
24
24
|
validationError = `composite action "${action}" is not allowed in run_actions`;
|
|
25
|
-
else if (action === 'browser_release')
|
|
25
|
+
else if (action === 'browser_release' || action === 'get_capabilities')
|
|
26
26
|
validationError = `browser-level action "${action}" is not allowed in run_actions`;
|
|
27
27
|
if (validationError)
|
|
28
28
|
return {
|
package/dist/types.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export interface ResponseOverride {
|
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
isSSE?: boolean;
|
|
21
21
|
}
|
|
22
|
-
export interface
|
|
22
|
+
export interface CapturedRequest {
|
|
23
|
+
namespace?: string;
|
|
24
|
+
environment?: string;
|
|
23
25
|
id: number;
|
|
24
26
|
timestamp: string;
|
|
25
27
|
timestampMs: number;
|
|
@@ -59,7 +61,7 @@ export interface MtopRequest {
|
|
|
59
61
|
_createdByInjected?: boolean;
|
|
60
62
|
tabId?: number;
|
|
61
63
|
isAutoTranslated?: boolean;
|
|
62
|
-
source?: '
|
|
64
|
+
source?: 'protocol' | 'requests';
|
|
63
65
|
resourceType?: string;
|
|
64
66
|
/** Monotonic sequence assigned when the request started. */
|
|
65
67
|
captureSequence?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/browser-core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
4
|
"description": "Shared pure-logic utilities for Mearl — usable in both browser extension and Node.js environments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"repository": {
|
|
62
62
|
"type": "git",
|
|
63
|
-
"url": "git+https://github.com/
|
|
63
|
+
"url": "git+https://github.com/mearlhq/mearl.git",
|
|
64
64
|
"directory": "packages/browser-core"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|