@opentiny/next-sdk 0.4.2 → 0.4.3
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/dist/{SimulatorMask-BHVXyogh-CARX3Rff.js → SimulatorMask-BHVXyogh-CKmEDsYG.js} +1 -1
- package/dist/{index-R_HIbfUX.js → index-CHMa2zG4.js} +1065 -1042
- package/dist/index.js +1 -1
- package/dist/page-tools/a11y/config.d.ts +6 -3
- package/dist/page-tools/a11y/constants.d.ts +20 -0
- package/dist/page-tools/a11y/utils.d.ts +14 -0
- package/dist/page-tools/constants.d.ts +4 -2
- package/dist/page-tools/context.d.ts +2 -0
- package/dist/page-tools/handlers/hover.d.ts +9 -0
- package/dist/page-tools/schema.d.ts +3 -3
- package/dist/page-tools/utils/dom.d.ts +8 -2
- package/dist/runtime.js +19 -172
- package/package.json +6 -1
- package/WebMcpClient.ts +0 -505
- package/WebMcpServer.ts +0 -447
- package/agent/AgentModelProvider.ts +0 -932
- package/agent/type.ts +0 -91
- package/agent/utils/generateReActPrompt.ts +0 -71
- package/agent/utils/getAISDKTools.ts +0 -34
- package/agent/utils/getBuiltinMcpTools.ts +0 -86
- package/agent/utils/parseReActAction.ts +0 -34
- package/core.ts +0 -26
- package/index.ts +0 -91
- package/page-tools/a11y/build.ts +0 -74
- package/page-tools/a11y/config.ts +0 -465
- package/page-tools/a11y/constants.ts +0 -131
- package/page-tools/a11y/search.ts +0 -127
- package/page-tools/a11y/types.ts +0 -105
- package/page-tools/a11y/utils.ts +0 -239
- package/page-tools/a11y/vnode.ts +0 -439
- package/page-tools/a11y-tree.ts +0 -14
- package/page-tools/bridge.ts +0 -722
- package/page-tools/configs/console-cloud.ts +0 -172
- package/page-tools/constants.ts +0 -12
- package/page-tools/context.ts +0 -50
- package/page-tools/effects.ts +0 -345
- package/page-tools/handlers/browserState.ts +0 -12
- package/page-tools/handlers/click.ts +0 -30
- package/page-tools/handlers/executeJavascript.ts +0 -22
- package/page-tools/handlers/fill.ts +0 -65
- package/page-tools/handlers/scroll.ts +0 -66
- package/page-tools/handlers/searchTree.ts +0 -27
- package/page-tools/handlers/select.ts +0 -39
- package/page-tools/initialize-builtin-WebMCP.ts +0 -20
- package/page-tools/page-agent-highlight/index.ts +0 -245
- package/page-tools/page-agent-mask/SimulatorMask.module.css +0 -14
- package/page-tools/page-agent-mask/SimulatorMask.ts +0 -299
- package/page-tools/page-agent-mask/checkDarkMode.ts +0 -181
- package/page-tools/page-agent-mask/cursor-border.svg +0 -3
- package/page-tools/page-agent-mask/cursor-fill.svg +0 -5
- package/page-tools/page-agent-mask/cursor.module.css +0 -70
- package/page-tools/page-agent-mask/hauwei.svg +0 -25
- package/page-tools/page-agent-prompt.md +0 -139
- package/page-tools/page-agent-tool-event.ts +0 -113
- package/page-tools/page-agent-tool.ts +0 -207
- package/page-tools/page-state-cache.ts +0 -78
- package/page-tools/schema.ts +0 -52
- package/page-tools/tool-config.ts +0 -100
- package/page-tools/utils/dom.ts +0 -158
- package/page-tools/utils/scroll.ts +0 -58
- package/remoter/QrCode.ts +0 -54
- package/remoter/createRemoter.ts +0 -957
- package/remoter/svgs/chat.svg +0 -43
- package/remoter/svgs/icon-copy.svg +0 -25
- package/remoter/svgs/link.svg +0 -28
- package/remoter/svgs/logo.svg +0 -45
- package/remoter/svgs/qrcode.svg +0 -35
- package/remoter/svgs/scan.svg +0 -21
- package/remoter/tooltips.ts +0 -260
- package/runtime.html +0 -39
- package/runtime.ts +0 -44
- package/script/utils.ts +0 -26
- package/skills/index.ts +0 -287
- package/test/page-tools/a11y/build.test.ts +0 -638
- package/test/page-tools/a11y/config.test.ts +0 -370
- package/test/page-tools/configs/console-cloud.test.ts +0 -168
- package/test/page-tools/page-agent-highlight.test.ts +0 -110
- package/test/page-tools/page-agent-tool-dispatch.test.ts +0 -208
- package/test/page-tools/page-agent-tool.test.ts +0 -102
- package/test/page-tools/tool-config.test.ts +0 -112
- package/test/page-tools/utils/dom.test.ts +0 -122
- package/tsconfig.json +0 -16
- package/utils/builtinProxy.ts +0 -144
- package/utils/env.ts +0 -13
- package/utils/uuid.ts +0 -10
- package/vite.config.runtime.ts +0 -22
- package/vite.config.ts +0 -63
- package/vitest.config.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { completable as C } from "@modelcontextprotocol/sdk/server/completable.j
|
|
|
7
7
|
import { getDisplayName as S } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
|
|
8
8
|
import { InMemoryTransport as f } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
9
9
|
import { A as P, p as E, M as c, o as v, e as _, W as y, u as d, j as O, a as x, c as h, f as b, h as G, g as R, i as u, v as N, v as L, n as k, d as D, m as W, b as I, x as F, k as z, l as U, r as j, q as w, s as B, t as H, y as q, w as Q } from "./initialize-builtin-WebMCP-JaoKwVlm.js";
|
|
10
|
-
import { k as Y, D as K, P as J, e as X, Q as Z, x as $, i as ee, z as ae, d as se, l as re, u as te, w as oe, f as le, c as ie, b as ne, h as Te, a as ge, g as pe, j as Ce, v as Ae, q as Se, t as me, p as fe, r as Me, m as Pe, n as Ee, o as ce, y as ve, s as _e } from "./index-
|
|
10
|
+
import { k as Y, D as K, P as J, e as X, Q as Z, x as $, i as ee, z as ae, d as se, l as re, u as te, w as oe, f as le, c as ie, b as ne, h as Te, a as ge, g as pe, j as Ce, v as Ae, q as Se, t as me, p as fe, r as Me, m as Pe, n as Ee, o as ce, y as ve, s as _e } from "./index-CHMa2zG4.js";
|
|
11
11
|
export {
|
|
12
12
|
P as AgentModelProvider,
|
|
13
13
|
s as Ajv,
|
|
@@ -38,8 +38,6 @@ export interface A11yConfig {
|
|
|
38
38
|
blacklist?: Array<Element | string>;
|
|
39
39
|
/** 额外暴露的自定义 DOM 属性(作为 token 输出,如 [data-testid="xxx"]) */
|
|
40
40
|
exposedAttributes?: string[];
|
|
41
|
-
/** 模态弹窗 CSS 选择器(用于 detectPageDialog 检测阻塞交互的弹窗) */
|
|
42
|
-
dialogSelectors?: string[];
|
|
43
41
|
}
|
|
44
42
|
/** 单个元素解析出的完整无障碍信息 */
|
|
45
43
|
export interface A11yInfo {
|
|
@@ -59,13 +57,18 @@ export interface ResolvedA11yConfig {
|
|
|
59
57
|
whitelist: Array<Element | string>;
|
|
60
58
|
blacklist: Array<Element | string>;
|
|
61
59
|
exposedAttributes: string[];
|
|
62
|
-
dialogSelectors: string[];
|
|
63
60
|
readonly [RESOLVED_A11Y_BRAND]?: true;
|
|
64
61
|
}
|
|
65
62
|
/** 是否为 {@link mergeA11yConfig}/{@link mergeA11yConfigs} 产出的已规整配置 */
|
|
66
63
|
export declare function isResolvedA11yConfig(config?: A11yConfig | ResolvedA11yConfig | null): config is ResolvedA11yConfig;
|
|
67
64
|
/** 默认生效的无障碍配置:零配置即可覆盖 ARIA 标准 + 主流 UI 框架的常见错误/警告/选中态检测 */
|
|
68
65
|
export declare const DEFAULT_A11Y_CONFIG: ResolvedA11yConfig;
|
|
66
|
+
/**
|
|
67
|
+
* 从 roles 规则中提取指定角色的所有 CSS 选择器(展平为一维 string[])。
|
|
68
|
+
* 供 DOM 检测函数(detectPageDialog / getVisibleTooltipElements)复用:
|
|
69
|
+
* 这些函数需要选择器字符串做 deepQuerySelectorAll,而非 matches 判断。
|
|
70
|
+
*/
|
|
71
|
+
export declare function getSelectorsForRole(roles: A11yRoleRule[], targetRole: string): string[];
|
|
69
72
|
/** 从状态规则中提取纯 CSS 选择器列表(忽略只有 match 函数、没有 selector 的规则;数组 selector 会被展开),供页面级选择器扫描场景复用 */
|
|
70
73
|
export declare function extractSelectors(rules?: A11yMatcher | A11yMatcher[]): string[];
|
|
71
74
|
/** 合并两份 A11yConfig:数组类字段拼接(additive,不丢失 base 中已有的规则),states 按 key 独立合并 */
|
|
@@ -7,5 +7,25 @@ export declare const DEFAULT_ERROR_SELECTORS: string[];
|
|
|
7
7
|
export declare const DEFAULT_WARNING_SELECTORS: string[];
|
|
8
8
|
/** 模态弹窗默认选择器:ARIA 标准 + 主流 UI 框架(唯一来源,顶层 constants.ts 从此处重新导出) */
|
|
9
9
|
export declare const DEFAULT_DIALOG_SELECTORS: string[];
|
|
10
|
+
/** 可见 tooltip / 浮层提示默认选择器:ARIA 标准 + 主流 UI 框架(唯一来源,顶层 constants.ts 从此处重新导出) */
|
|
11
|
+
export declare const DEFAULT_TOOLTIP_SELECTORS: string[];
|
|
10
12
|
export declare const TAG_ROLE_MAP: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* 框架级 role 覆盖规则
|
|
15
|
+
*
|
|
16
|
+
* 当元素没有显式 role 属性时,按 CSS 选择器匹配框架特有 class 模式,
|
|
17
|
+
* 推断出符合 ARIA 语义的 role,使无障碍树能正确识别非标准 UI 组件。
|
|
18
|
+
*
|
|
19
|
+
* 优先级:显式 role 属性 > 框架 role 覆盖 > 标签隐式映射 > generic
|
|
20
|
+
*
|
|
21
|
+
* 注意:框架特有规则(如 Tiny3 Tabs、tp-helptip)应放在各框架预设配置中
|
|
22
|
+
*(如 configs/console-cloud.ts),此处仅保留通用规则。
|
|
23
|
+
*/
|
|
24
|
+
export interface RoleOverride {
|
|
25
|
+
/** CSS 选择器,匹配则应用该 role */
|
|
26
|
+
selector: string;
|
|
27
|
+
/** 覆盖后的 ARIA 角色 */
|
|
28
|
+
role: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const DEFAULT_ROLE_OVERRIDES: RoleOverride[];
|
|
11
31
|
export declare const INPUT_TYPE_ROLE: Record<string, string>;
|
|
@@ -53,3 +53,17 @@ export declare function collectDescendantText(el: Element, config?: ResolvedA11y
|
|
|
53
53
|
* 无 shadowRoot 时直接遍历 light DOM children。
|
|
54
54
|
*/
|
|
55
55
|
export declare function getComposedChildren(el: Element): Element[];
|
|
56
|
+
/**
|
|
57
|
+
* 提取元素的 tooltip / 帮助提示文本
|
|
58
|
+
*
|
|
59
|
+
* 按以下优先级查找(返回首个非空结果):
|
|
60
|
+
* 1. title 属性
|
|
61
|
+
* 2. aria-describedby 引用的元素文本
|
|
62
|
+
* 3. data-tooltip / data-tips 自定义属性
|
|
63
|
+
* 4. 框架级 tooltip 内容(如 Tiny3 tp-helptip 内的 .tp-helptip-label 文本)
|
|
64
|
+
* 4b. 框架级 overflow 指令(Tiny3 tioverflow / Angular Material matTooltip)
|
|
65
|
+
*
|
|
66
|
+
* 即使 tooltip 容器被隐藏(display:none / opacity:0),也提取其文本内容,
|
|
67
|
+
* 让 AI 无需 hover 即可获取帮助信息。
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractTooltipText(el: Element): string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export { DEFAULT_ERROR_SELECTORS, DEFAULT_DIALOG_SELECTORS } from './a11y/constants';
|
|
1
|
+
/** 校验错误/弹窗/tooltip 默认选择器:ARIA 标准 + 主流 UI 框架(唯一来源为 a11y/constants.ts,此处重新导出保持旧路径可用) */
|
|
2
|
+
export { DEFAULT_ERROR_SELECTORS, DEFAULT_DIALOG_SELECTORS, DEFAULT_TOOLTIP_SELECTORS } from './a11y/constants';
|
|
3
|
+
/** 框架级 role 覆盖规则:为非标准 UI 组件推断 ARIA 角色(已纳入 DEFAULT_A11Y_CONFIG.roles,此处重新导出保持旧路径可用) */
|
|
4
|
+
export { DEFAULT_ROLE_OVERRIDES, type RoleOverride } from './a11y/constants';
|
|
3
5
|
/** registerPageAgentTool(options) 的入参类型,定义见 tool-config.ts(与运行期 setPageAgentToolConfig 的补丁类型一致) */
|
|
4
6
|
export type { PageAgentToolOptions } from './tool-config';
|
|
5
7
|
declare global {
|
|
@@ -12,6 +12,8 @@ export type PageAgentToolErrorResult = PageAgentToolContentResult & {
|
|
|
12
12
|
isError: true;
|
|
13
13
|
error: string;
|
|
14
14
|
};
|
|
15
|
+
/** 将额外字段合并进 browserState JSON,保持整段可反序列化 */
|
|
16
|
+
export declare function withStateFields(stateText: string, extra: Record<string, unknown>): string;
|
|
15
17
|
export declare function createActionErrorResult(message: string, buildBrowserStateResponse: ActionContext['buildBrowserStateResponse']): Promise<PageAgentToolErrorResult>;
|
|
16
18
|
export interface ActionContext {
|
|
17
19
|
pageController: PageController;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
export declare const inputSchema: z.ZodObject<{
|
|
4
|
-
action: z.ZodEnum<["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]>;
|
|
4
|
+
action: z.ZodEnum<["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree", "hover"]>;
|
|
5
5
|
index: z.ZodOptional<z.ZodNumber>;
|
|
6
6
|
text: z.ZodOptional<z.ZodString>;
|
|
7
7
|
down: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -14,7 +14,7 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
14
14
|
maxMatches: z.ZodDefault<z.ZodNumber>;
|
|
15
15
|
responseMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["full", "diff", "both"]>>>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
action: "fill" | "click" | "select" | "scroll" | "browserState" | "executeJavascript" | "searchTree";
|
|
17
|
+
action: "fill" | "hover" | "click" | "select" | "scroll" | "browserState" | "executeJavascript" | "searchTree";
|
|
18
18
|
contextLines: number;
|
|
19
19
|
maxMatches: number;
|
|
20
20
|
responseMode: "full" | "diff" | "both";
|
|
@@ -27,7 +27,7 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
27
27
|
pixels?: number | undefined;
|
|
28
28
|
query?: string | undefined;
|
|
29
29
|
}, {
|
|
30
|
-
action: "fill" | "click" | "select" | "scroll" | "browserState" | "executeJavascript" | "searchTree";
|
|
30
|
+
action: "fill" | "hover" | "click" | "select" | "scroll" | "browserState" | "executeJavascript" | "searchTree";
|
|
31
31
|
text?: string | undefined;
|
|
32
32
|
right?: boolean | undefined;
|
|
33
33
|
script?: string | undefined;
|
|
@@ -2,5 +2,11 @@ export declare function isInShadowDom(el: Element): boolean;
|
|
|
2
2
|
export declare function dispatchComposedEvents(el: Element, ...types: string[]): void;
|
|
3
3
|
export declare function deepQuerySelectorAll(selector: string, root?: Document | Element | ShadowRoot): Element[];
|
|
4
4
|
export declare function waitForDomSettled(timeout?: number, settleTime?: number): Promise<void>;
|
|
5
|
-
|
|
6
|
-
export
|
|
5
|
+
/** 页面级模态弹窗检测结果 */
|
|
6
|
+
export interface DetectedDialog {
|
|
7
|
+
text: string;
|
|
8
|
+
buttons: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function detectPageDialog(): DetectedDialog[];
|
|
11
|
+
export declare function detectValidationErrors(): string[];
|
|
12
|
+
export declare function detectVisibleTooltips(): string[];
|