@vortex-browser/shared 1.0.0
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 -0
- package/README.md +43 -0
- package/dist/actions.d.ts +118 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +117 -0
- package/dist/actions.js.map +1 -0
- package/dist/commit-kinds.d.ts +3 -0
- package/dist/commit-kinds.d.ts.map +1 -0
- package/dist/commit-kinds.js +20 -0
- package/dist/commit-kinds.js.map +1 -0
- package/dist/errors.d.ts +106 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.hints.d.ts +28 -0
- package/dist/errors.hints.d.ts.map +1 -0
- package/dist/errors.hints.js +217 -0
- package/dist/errors.hints.js.map +1 -0
- package/dist/errors.js +117 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +29 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +37 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +74 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +2 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nicofroggo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @vortex-browser/shared
|
|
2
|
+
|
|
3
|
+
Vortex 单子项目共享的类型与协议常量。**纯类型 / 常量包,无运行时副作用**。所有上游(extension / server / cli / mcp)都从这里导入,避免协议分裂。
|
|
4
|
+
|
|
5
|
+
## 内容
|
|
6
|
+
|
|
7
|
+
| 文件 | 内容 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| `actions.ts` | 全部 action 名常量(`PageActions.NAVIGATE = "page.navigate"` 等),按模块分组的枚举 |
|
|
10
|
+
| `protocol.ts` | `VtxRequest` / `VtxResponse` / `VtxEvent` / `NmRequest` / `NmResponse` 等线缆消息类型 |
|
|
11
|
+
| `errors.ts` | `VtxErrorCode` 枚举(`TIMEOUT`、`NOT_FOUND`、`PERMISSION_DENIED` 等) |
|
|
12
|
+
| `index.ts` | 统一 re-export |
|
|
13
|
+
|
|
14
|
+
## 使用
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {
|
|
18
|
+
PageActions, DomActions,
|
|
19
|
+
type VtxRequest, type VtxResponse,
|
|
20
|
+
VtxErrorCode,
|
|
21
|
+
} from "@vortex-browser/shared";
|
|
22
|
+
|
|
23
|
+
const req: VtxRequest = {
|
|
24
|
+
id: "x",
|
|
25
|
+
action: PageActions.NAVIGATE,
|
|
26
|
+
params: { url: "https://example.com" },
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 添加/修改 action
|
|
31
|
+
|
|
32
|
+
1. 在 `actions.ts` 对应模块枚举里新增条目
|
|
33
|
+
2. extension 端在 `packages/extension/src/handlers/<mod>.ts` 注册处理函数
|
|
34
|
+
3. 如需新错误码:在 `errors.ts` 加 `VtxErrorCode` 成员
|
|
35
|
+
|
|
36
|
+
## 构建
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm build # tsc 一次
|
|
40
|
+
pnpm dev # tsc --watch
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
下游包通过 workspace 协议引用:`"@vortex-browser/shared": "workspace:*"`,改动后无需 publish 即生效。
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export declare const TabActions: {
|
|
2
|
+
readonly LIST: "tab.list";
|
|
3
|
+
readonly CREATE: "tab.create";
|
|
4
|
+
readonly CLOSE: "tab.close";
|
|
5
|
+
readonly ACTIVATE: "tab.activate";
|
|
6
|
+
readonly GET_INFO: "tab.getInfo";
|
|
7
|
+
};
|
|
8
|
+
export declare const PageActions: {
|
|
9
|
+
readonly NAVIGATE: "page.navigate";
|
|
10
|
+
readonly RELOAD: "page.reload";
|
|
11
|
+
readonly BACK: "page.back";
|
|
12
|
+
readonly FORWARD: "page.forward";
|
|
13
|
+
readonly WAIT: "page.wait";
|
|
14
|
+
readonly INFO: "page.info";
|
|
15
|
+
readonly WAIT_FOR_NETWORK_IDLE: "page.waitForNetworkIdle";
|
|
16
|
+
/** XHR/Fetch 专用 idle 等待。语义上是 WAIT_FOR_NETWORK_IDLE + requestTypes=["XHR","Fetch"]。@since 0.4.0 */
|
|
17
|
+
readonly WAIT_FOR_XHR_IDLE: "page.waitForXhrIdle";
|
|
18
|
+
/** 等待 caller 传入的 JS 表达式返回 truthy。给 idle/element 无法表达的就绪信号
|
|
19
|
+
* (如 Alpine `document.body._x_dataStack`、Vue `app.config.globalProperties.$ready`、
|
|
20
|
+
* 自定义 window flag)。@since 0.8.x */
|
|
21
|
+
readonly WAIT_FOR_EXPRESSION: "page.waitForExpression";
|
|
22
|
+
};
|
|
23
|
+
export declare const JsActions: {
|
|
24
|
+
readonly EVALUATE: "js.evaluate";
|
|
25
|
+
readonly EVALUATE_ASYNC: "js.evaluateAsync";
|
|
26
|
+
readonly CALL_FUNCTION: "js.callFunction";
|
|
27
|
+
};
|
|
28
|
+
export declare const DomActions: {
|
|
29
|
+
readonly QUERY: "dom.query";
|
|
30
|
+
readonly QUERY_ALL: "dom.queryAll";
|
|
31
|
+
readonly CLICK: "dom.click";
|
|
32
|
+
readonly TYPE: "dom.type";
|
|
33
|
+
readonly FILL: "dom.fill";
|
|
34
|
+
readonly SELECT: "dom.select";
|
|
35
|
+
readonly SCROLL: "dom.scroll";
|
|
36
|
+
readonly HOVER: "dom.hover";
|
|
37
|
+
readonly GET_ATTRIBUTE: "dom.getAttribute";
|
|
38
|
+
readonly GET_SCROLL_INFO: "dom.getScrollInfo";
|
|
39
|
+
readonly WAIT_FOR_MUTATION: "dom.waitForMutation";
|
|
40
|
+
/** 等待 DOM 子树在 quietMs ms 内无任何 mutation 后返回。与 WAIT_FOR_MUTATION 语义互补。@since 0.4.0 */
|
|
41
|
+
readonly WAIT_SETTLED: "dom.waitSettled";
|
|
42
|
+
/** 对 framework 受控组件(picker/cascader/select 等)提交值:打开→导航→点→确认的完整流程。@since 0.4.0 */
|
|
43
|
+
readonly COMMIT: "dom.commit";
|
|
44
|
+
readonly WATCH_MUTATIONS: "dom.watchMutations";
|
|
45
|
+
readonly UNWATCH_MUTATIONS: "dom.unwatchMutations";
|
|
46
|
+
};
|
|
47
|
+
export declare const ContentActions: {
|
|
48
|
+
readonly GET_TEXT: "content.getText";
|
|
49
|
+
readonly GET_HTML: "content.getHTML";
|
|
50
|
+
readonly GET_ACCESSIBILITY_TREE: "content.getAccessibilityTree";
|
|
51
|
+
readonly GET_ELEMENT_TEXT: "content.getElementText";
|
|
52
|
+
readonly GET_COMPUTED_STYLE: "content.getComputedStyle";
|
|
53
|
+
};
|
|
54
|
+
export declare const ConsoleActions: {
|
|
55
|
+
readonly GET_LOGS: "console.getLogs";
|
|
56
|
+
readonly GET_ERRORS: "console.getErrors";
|
|
57
|
+
readonly SUBSCRIBE: "console.subscribe";
|
|
58
|
+
readonly CLEAR: "console.clear";
|
|
59
|
+
};
|
|
60
|
+
export declare const NetworkActions: {
|
|
61
|
+
readonly GET_LOGS: "network.getLogs";
|
|
62
|
+
readonly GET_ERRORS: "network.getErrors";
|
|
63
|
+
readonly SUBSCRIBE: "network.subscribe";
|
|
64
|
+
readonly FILTER: "network.filter";
|
|
65
|
+
readonly CLEAR: "network.clear";
|
|
66
|
+
readonly GET_RESPONSE_BODY: "network.getResponseBody";
|
|
67
|
+
};
|
|
68
|
+
export declare const CaptureActions: {
|
|
69
|
+
readonly SCREENSHOT: "capture.screenshot";
|
|
70
|
+
readonly ELEMENT: "capture.element";
|
|
71
|
+
readonly GIF_START: "capture.gifStart";
|
|
72
|
+
readonly GIF_STOP: "capture.gifStop";
|
|
73
|
+
readonly GIF_FRAME: "capture.gifFrame";
|
|
74
|
+
};
|
|
75
|
+
export declare const StorageActions: {
|
|
76
|
+
readonly GET_COOKIES: "storage.getCookies";
|
|
77
|
+
readonly SET_COOKIE: "storage.setCookie";
|
|
78
|
+
readonly DELETE_COOKIE: "storage.deleteCookie";
|
|
79
|
+
readonly GET_LOCAL_STORAGE: "storage.getLocalStorage";
|
|
80
|
+
readonly SET_LOCAL_STORAGE: "storage.setLocalStorage";
|
|
81
|
+
readonly GET_SESSION_STORAGE: "storage.getSessionStorage";
|
|
82
|
+
readonly SET_SESSION_STORAGE: "storage.setSessionStorage";
|
|
83
|
+
readonly EXPORT_SESSION: "storage.exportSession";
|
|
84
|
+
readonly IMPORT_SESSION: "storage.importSession";
|
|
85
|
+
};
|
|
86
|
+
export declare const KeyboardActions: {
|
|
87
|
+
readonly PRESS: "keyboard.press";
|
|
88
|
+
readonly SHORTCUT: "keyboard.shortcut";
|
|
89
|
+
};
|
|
90
|
+
export declare const MouseActions: {
|
|
91
|
+
readonly CLICK: "mouse.click";
|
|
92
|
+
readonly DOUBLE_CLICK: "mouse.doubleClick";
|
|
93
|
+
readonly MOVE: "mouse.move";
|
|
94
|
+
readonly DRAG: "mouse.drag";
|
|
95
|
+
};
|
|
96
|
+
export declare const FramesActions: {
|
|
97
|
+
readonly LIST: "frames.list";
|
|
98
|
+
readonly FIND: "frames.find";
|
|
99
|
+
};
|
|
100
|
+
export declare const FileActions: {
|
|
101
|
+
readonly UPLOAD: "file.upload";
|
|
102
|
+
readonly DOWNLOAD: "file.download";
|
|
103
|
+
readonly GET_DOWNLOADS: "file.getDownloads";
|
|
104
|
+
readonly ON_DOWNLOAD_COMPLETE: "file.onDownloadComplete";
|
|
105
|
+
};
|
|
106
|
+
export declare const ObserveActions: {
|
|
107
|
+
readonly SNAPSHOT: "observe.snapshot";
|
|
108
|
+
};
|
|
109
|
+
export declare const EventsActions: {
|
|
110
|
+
/** 强制立即 flush dispatcher 的 notice+info buffer,绕过节流窗口 */
|
|
111
|
+
readonly DRAIN: "events.drain";
|
|
112
|
+
};
|
|
113
|
+
export declare const DiagnosticsActions: {
|
|
114
|
+
/** 返回扩展版本 + 支持的 action 列表指纹,供 MCP ping 做版本协商。@since 0.4.0 */
|
|
115
|
+
readonly VERSION: "diagnostics.version";
|
|
116
|
+
};
|
|
117
|
+
export type ActionString = (typeof TabActions)[keyof typeof TabActions] | (typeof PageActions)[keyof typeof PageActions] | (typeof JsActions)[keyof typeof JsActions] | (typeof DomActions)[keyof typeof DomActions] | (typeof ContentActions)[keyof typeof ContentActions] | (typeof ConsoleActions)[keyof typeof ConsoleActions] | (typeof NetworkActions)[keyof typeof NetworkActions] | (typeof CaptureActions)[keyof typeof CaptureActions] | (typeof StorageActions)[keyof typeof StorageActions] | (typeof KeyboardActions)[keyof typeof KeyboardActions] | (typeof MouseActions)[keyof typeof MouseActions] | (typeof FramesActions)[keyof typeof FramesActions] | (typeof FileActions)[keyof typeof FileActions] | (typeof ObserveActions)[keyof typeof ObserveActions] | (typeof EventsActions)[keyof typeof EventsActions] | (typeof DiagnosticsActions)[keyof typeof DiagnosticsActions];
|
|
118
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;;;IAQtB,kGAAkG;;IAElG;;wCAEoC;;CAE5B,CAAC;AAEX,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;IAYrB,oFAAoF;;IAEpF,iFAAiF;;;;CAIzE,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;CAUjB,CAAC;AAEX,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAEX,eAAO,MAAM,aAAa;IACxB,wDAAwD;;CAEhD,CAAC;AAEX,eAAO,MAAM,kBAAkB;IAC7B,6DAA6D;;CAErD,CAAC;AAEX,MAAM,MAAM,YAAY,GACpB,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,GAC5C,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,GAC9C,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,GAC1C,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,GAC5C,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,GACtD,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAChD,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,GAClD,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,GAC9C,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,GACpD,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,GAClD,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export const TabActions = {
|
|
2
|
+
LIST: "tab.list",
|
|
3
|
+
CREATE: "tab.create",
|
|
4
|
+
CLOSE: "tab.close",
|
|
5
|
+
ACTIVATE: "tab.activate",
|
|
6
|
+
GET_INFO: "tab.getInfo",
|
|
7
|
+
};
|
|
8
|
+
export const PageActions = {
|
|
9
|
+
NAVIGATE: "page.navigate",
|
|
10
|
+
RELOAD: "page.reload",
|
|
11
|
+
BACK: "page.back",
|
|
12
|
+
FORWARD: "page.forward",
|
|
13
|
+
WAIT: "page.wait",
|
|
14
|
+
INFO: "page.info",
|
|
15
|
+
WAIT_FOR_NETWORK_IDLE: "page.waitForNetworkIdle",
|
|
16
|
+
/** XHR/Fetch 专用 idle 等待。语义上是 WAIT_FOR_NETWORK_IDLE + requestTypes=["XHR","Fetch"]。@since 0.4.0 */
|
|
17
|
+
WAIT_FOR_XHR_IDLE: "page.waitForXhrIdle",
|
|
18
|
+
/** 等待 caller 传入的 JS 表达式返回 truthy。给 idle/element 无法表达的就绪信号
|
|
19
|
+
* (如 Alpine `document.body._x_dataStack`、Vue `app.config.globalProperties.$ready`、
|
|
20
|
+
* 自定义 window flag)。@since 0.8.x */
|
|
21
|
+
WAIT_FOR_EXPRESSION: "page.waitForExpression",
|
|
22
|
+
};
|
|
23
|
+
export const JsActions = {
|
|
24
|
+
EVALUATE: "js.evaluate",
|
|
25
|
+
EVALUATE_ASYNC: "js.evaluateAsync",
|
|
26
|
+
CALL_FUNCTION: "js.callFunction",
|
|
27
|
+
};
|
|
28
|
+
export const DomActions = {
|
|
29
|
+
QUERY: "dom.query",
|
|
30
|
+
QUERY_ALL: "dom.queryAll",
|
|
31
|
+
CLICK: "dom.click",
|
|
32
|
+
TYPE: "dom.type",
|
|
33
|
+
FILL: "dom.fill",
|
|
34
|
+
SELECT: "dom.select",
|
|
35
|
+
SCROLL: "dom.scroll",
|
|
36
|
+
HOVER: "dom.hover",
|
|
37
|
+
GET_ATTRIBUTE: "dom.getAttribute",
|
|
38
|
+
GET_SCROLL_INFO: "dom.getScrollInfo",
|
|
39
|
+
WAIT_FOR_MUTATION: "dom.waitForMutation",
|
|
40
|
+
/** 等待 DOM 子树在 quietMs ms 内无任何 mutation 后返回。与 WAIT_FOR_MUTATION 语义互补。@since 0.4.0 */
|
|
41
|
+
WAIT_SETTLED: "dom.waitSettled",
|
|
42
|
+
/** 对 framework 受控组件(picker/cascader/select 等)提交值:打开→导航→点→确认的完整流程。@since 0.4.0 */
|
|
43
|
+
COMMIT: "dom.commit",
|
|
44
|
+
WATCH_MUTATIONS: "dom.watchMutations",
|
|
45
|
+
UNWATCH_MUTATIONS: "dom.unwatchMutations",
|
|
46
|
+
};
|
|
47
|
+
export const ContentActions = {
|
|
48
|
+
GET_TEXT: "content.getText",
|
|
49
|
+
GET_HTML: "content.getHTML",
|
|
50
|
+
GET_ACCESSIBILITY_TREE: "content.getAccessibilityTree",
|
|
51
|
+
GET_ELEMENT_TEXT: "content.getElementText",
|
|
52
|
+
GET_COMPUTED_STYLE: "content.getComputedStyle",
|
|
53
|
+
};
|
|
54
|
+
export const ConsoleActions = {
|
|
55
|
+
GET_LOGS: "console.getLogs",
|
|
56
|
+
GET_ERRORS: "console.getErrors",
|
|
57
|
+
SUBSCRIBE: "console.subscribe",
|
|
58
|
+
CLEAR: "console.clear",
|
|
59
|
+
};
|
|
60
|
+
export const NetworkActions = {
|
|
61
|
+
GET_LOGS: "network.getLogs",
|
|
62
|
+
GET_ERRORS: "network.getErrors",
|
|
63
|
+
SUBSCRIBE: "network.subscribe",
|
|
64
|
+
FILTER: "network.filter",
|
|
65
|
+
CLEAR: "network.clear",
|
|
66
|
+
GET_RESPONSE_BODY: "network.getResponseBody",
|
|
67
|
+
};
|
|
68
|
+
export const CaptureActions = {
|
|
69
|
+
SCREENSHOT: "capture.screenshot",
|
|
70
|
+
ELEMENT: "capture.element",
|
|
71
|
+
GIF_START: "capture.gifStart",
|
|
72
|
+
GIF_STOP: "capture.gifStop",
|
|
73
|
+
GIF_FRAME: "capture.gifFrame",
|
|
74
|
+
};
|
|
75
|
+
export const StorageActions = {
|
|
76
|
+
GET_COOKIES: "storage.getCookies",
|
|
77
|
+
SET_COOKIE: "storage.setCookie",
|
|
78
|
+
DELETE_COOKIE: "storage.deleteCookie",
|
|
79
|
+
GET_LOCAL_STORAGE: "storage.getLocalStorage",
|
|
80
|
+
SET_LOCAL_STORAGE: "storage.setLocalStorage",
|
|
81
|
+
GET_SESSION_STORAGE: "storage.getSessionStorage",
|
|
82
|
+
SET_SESSION_STORAGE: "storage.setSessionStorage",
|
|
83
|
+
EXPORT_SESSION: "storage.exportSession",
|
|
84
|
+
IMPORT_SESSION: "storage.importSession",
|
|
85
|
+
};
|
|
86
|
+
export const KeyboardActions = {
|
|
87
|
+
PRESS: "keyboard.press",
|
|
88
|
+
SHORTCUT: "keyboard.shortcut",
|
|
89
|
+
};
|
|
90
|
+
export const MouseActions = {
|
|
91
|
+
CLICK: "mouse.click",
|
|
92
|
+
DOUBLE_CLICK: "mouse.doubleClick",
|
|
93
|
+
MOVE: "mouse.move",
|
|
94
|
+
DRAG: "mouse.drag",
|
|
95
|
+
};
|
|
96
|
+
export const FramesActions = {
|
|
97
|
+
LIST: "frames.list",
|
|
98
|
+
FIND: "frames.find",
|
|
99
|
+
};
|
|
100
|
+
export const FileActions = {
|
|
101
|
+
UPLOAD: "file.upload",
|
|
102
|
+
DOWNLOAD: "file.download",
|
|
103
|
+
GET_DOWNLOADS: "file.getDownloads",
|
|
104
|
+
ON_DOWNLOAD_COMPLETE: "file.onDownloadComplete",
|
|
105
|
+
};
|
|
106
|
+
export const ObserveActions = {
|
|
107
|
+
SNAPSHOT: "observe.snapshot",
|
|
108
|
+
};
|
|
109
|
+
export const EventsActions = {
|
|
110
|
+
/** 强制立即 flush dispatcher 的 notice+info buffer,绕过节流窗口 */
|
|
111
|
+
DRAIN: "events.drain",
|
|
112
|
+
};
|
|
113
|
+
export const DiagnosticsActions = {
|
|
114
|
+
/** 返回扩展版本 + 支持的 action 列表指纹,供 MCP ping 做版本协商。@since 0.4.0 */
|
|
115
|
+
VERSION: "diagnostics.version",
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UA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AW,GAAG;IACzB,MAAM,EAAE,aAAa;IACrB,QAAQ,EAAE,eAAe;IACzB,aAAa,EAAE,mBAAmB;IAClC,oBAAoB,EAAE,yBAAyB;CACvC,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,kBAAkB;CACpB,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,wDAAwD;IACxD,KAAK,EAAE,cAAc;CACb,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,6DAA6D;IAC7D,OAAO,EAAE,qBAAqB;CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-kinds.d.ts","sourceRoot":"","sources":["../src/commit-kinds.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,wGAQf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Single source of truth for vortex_fill commit driver kinds.
|
|
2
|
+
//
|
|
3
|
+
// Consumed by:
|
|
4
|
+
// - packages/extension/src/patterns/commit-drivers.ts (CommitKind type + runtime registry)
|
|
5
|
+
// - packages/mcp/src/tools/schemas-public.ts (vortex_fill.kind enum)
|
|
6
|
+
// - packages/mcp/src/tools/schemas.ts (internal vortex_fill enum)
|
|
7
|
+
//
|
|
8
|
+
// Adding or removing a kind requires implementing / removing the corresponding
|
|
9
|
+
// driver in commit-drivers.ts AND updating dom.ts commit handler switch.
|
|
10
|
+
// I15 invariant test locks public schema enum === COMMIT_KINDS to prevent drift.
|
|
11
|
+
export const COMMIT_KINDS = [
|
|
12
|
+
"daterange",
|
|
13
|
+
"datetimerange",
|
|
14
|
+
"cascader",
|
|
15
|
+
"select",
|
|
16
|
+
"time",
|
|
17
|
+
"checkbox-group",
|
|
18
|
+
"aria-select",
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=commit-kinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-kinds.js","sourceRoot":"","sources":["../src/commit-kinds.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,eAAe;AACf,2FAA2F;AAC3F,qEAAqE;AACrE,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,yEAAyE;AACzE,iFAAiF;AAEjF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW;IACX,eAAe;IACf,UAAU;IACV,QAAQ;IACR,MAAM;IACN,gBAAgB;IAChB,aAAa;CACL,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare const VtxErrorCode: {
|
|
2
|
+
readonly ELEMENT_NOT_FOUND: "ELEMENT_NOT_FOUND";
|
|
3
|
+
readonly ELEMENT_OCCLUDED: "ELEMENT_OCCLUDED";
|
|
4
|
+
readonly ELEMENT_OFFSCREEN: "ELEMENT_OFFSCREEN";
|
|
5
|
+
readonly ELEMENT_DISABLED: "ELEMENT_DISABLED";
|
|
6
|
+
readonly ELEMENT_DETACHED: "ELEMENT_DETACHED";
|
|
7
|
+
readonly SELECTOR_AMBIGUOUS: "SELECTOR_AMBIGUOUS";
|
|
8
|
+
readonly NAVIGATION_IN_PROGRESS: "NAVIGATION_IN_PROGRESS";
|
|
9
|
+
readonly PAGE_NOT_READY: "PAGE_NOT_READY";
|
|
10
|
+
readonly DIALOG_BLOCKING: "DIALOG_BLOCKING";
|
|
11
|
+
readonly IFRAME_NOT_READY: "IFRAME_NOT_READY";
|
|
12
|
+
readonly STALE_SNAPSHOT: "STALE_SNAPSHOT";
|
|
13
|
+
readonly INVALID_INDEX: "INVALID_INDEX";
|
|
14
|
+
readonly NAVIGATION_FAILED: "NAVIGATION_FAILED";
|
|
15
|
+
readonly TAB_NOT_FOUND: "TAB_NOT_FOUND";
|
|
16
|
+
readonly TAB_CLOSED: "TAB_CLOSED";
|
|
17
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
18
|
+
readonly JS_EXECUTION_ERROR: "JS_EXECUTION_ERROR";
|
|
19
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
20
|
+
readonly CSP_BLOCKED: "CSP_BLOCKED";
|
|
21
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
22
|
+
readonly NATIVE_MESSAGING_ERROR: "NATIVE_MESSAGING_ERROR";
|
|
23
|
+
readonly EXTENSION_NOT_CONNECTED: "EXTENSION_NOT_CONNECTED";
|
|
24
|
+
readonly INVALID_PARAMS: "INVALID_PARAMS";
|
|
25
|
+
readonly UNKNOWN_ACTION: "UNKNOWN_ACTION";
|
|
26
|
+
/** 目标元素属于框架托管的受控组件(如 Element Plus datetime-range picker),
|
|
27
|
+
* 不能用普通 DOM 原语(fill/type)安全提交值;需换用 vortex_dom_commit。 */
|
|
28
|
+
readonly UNSUPPORTED_TARGET: "UNSUPPORTED_TARGET";
|
|
29
|
+
/** vortex_dom_commit 的 driver 在流程中途失败(picker 打不开、日期格找不到、校验不一致等)。
|
|
30
|
+
* context.extras 会带 stage 字段标识失败阶段。*/
|
|
31
|
+
readonly COMMIT_FAILED: "COMMIT_FAILED";
|
|
32
|
+
/** Actionability: element detached from DOM */
|
|
33
|
+
readonly NOT_ATTACHED: "NOT_ATTACHED";
|
|
34
|
+
/** Actionability: display:none / visibility:hidden / opacity:0 / 0x0 */
|
|
35
|
+
readonly NOT_VISIBLE: "NOT_VISIBLE";
|
|
36
|
+
/** Actionability: double-RAF sample shows unstable position (animating) */
|
|
37
|
+
readonly NOT_STABLE: "NOT_STABLE";
|
|
38
|
+
/** Actionability: hit-test hit a different element (covered) */
|
|
39
|
+
readonly OBSCURED: "OBSCURED";
|
|
40
|
+
/** Actionability: disabled / aria-disabled / fieldset[disabled] */
|
|
41
|
+
readonly DISABLED: "DISABLED";
|
|
42
|
+
/** Actionability: fill/type target is readonly or non-input */
|
|
43
|
+
readonly NOT_EDITABLE: "NOT_EDITABLE";
|
|
44
|
+
/** Fallback chain exhausted all paths */
|
|
45
|
+
readonly ACTION_FAILED_ALL_PATHS: "ACTION_FAILED_ALL_PATHS";
|
|
46
|
+
/** Drag operation but CDP unavailable */
|
|
47
|
+
readonly DRAG_REQUIRES_CDP: "DRAG_REQUIRES_CDP";
|
|
48
|
+
/** select action: 传入的 value 在 <select> 的 option 里既不匹配 value 属性、
|
|
49
|
+
* 也不匹配可见文本(label)。避免静默选不中却返回 success。
|
|
50
|
+
* context.extras.available 带可选项清单供 agent 重新选取。*/
|
|
51
|
+
readonly NO_MATCHING_OPTION: "NO_MATCHING_OPTION";
|
|
52
|
+
/** 赋值/驱动类 act 原语(select 多选 / scroll / press 等)dispatch 后回读校验,
|
|
53
|
+
* 发现副作用未真正发生(选项未选中 / 未滚动 / 状态未变)。避免 dispatch 即返回
|
|
54
|
+
* success 的 silent false-success(2026-06-03 act 原语白盒审计族 A)。*/
|
|
55
|
+
readonly NO_EFFECT: "NO_EFFECT";
|
|
56
|
+
/** a11y tree 不可用(CSP / sandboxed page),无法 getFullAXTree。*/
|
|
57
|
+
readonly A11Y_UNAVAILABLE: "A11Y_UNAVAILABLE";
|
|
58
|
+
/** chrome.debugger.attach 失败(缺权限、tab 已关闭等)。*/
|
|
59
|
+
readonly CDP_NOT_ATTACHED: "CDP_NOT_ATTACHED";
|
|
60
|
+
/** ref 关联节点 stale,descriptor 三级消解仍然失败。*/
|
|
61
|
+
readonly STALE_REF: "STALE_REF";
|
|
62
|
+
/** descriptor strict 模式下多匹配。*/
|
|
63
|
+
readonly AMBIGUOUS_DESCRIPTOR: "AMBIGUOUS_DESCRIPTOR";
|
|
64
|
+
/** RefStore 中找不到此 ref。*/
|
|
65
|
+
readonly REF_NOT_FOUND: "REF_NOT_FOUND";
|
|
66
|
+
/** snapshot 已过期(> 5 min)。*/
|
|
67
|
+
readonly SNAPSHOT_EXPIRED: "SNAPSHOT_EXPIRED";
|
|
68
|
+
/** 跨源 iframe,Accessibility.getFullAXTree 拒绝(CDP 已 attach,但 AX tree 不能跨源查询)。*/
|
|
69
|
+
readonly CROSS_ORIGIN_IFRAME: "CROSS_ORIGIN_IFRAME";
|
|
70
|
+
/** closed shadow host,无法穿透。*/
|
|
71
|
+
readonly CLOSED_SHADOW_DOM: "CLOSED_SHADOW_DOM";
|
|
72
|
+
/** 元素在 open shadow root 内:observe 经 querySelectorAllDeep 穿 shadow 发出了 ref,
|
|
73
|
+
* 但 act/fill 的 CSS selector 解析不穿 shadow → 永久不可解析。快速失败给诊断,
|
|
74
|
+
* 而非 NOT_ATTACHED 重试满 timeout(issue #27)。*/
|
|
75
|
+
readonly OPEN_SHADOW_DOM: "OPEN_SHADOW_DOM";
|
|
76
|
+
/** target 既不是合法 ref 也不是 valid descriptor 对象。*/
|
|
77
|
+
readonly INVALID_TARGET: "INVALID_TARGET";
|
|
78
|
+
/** action 不在 act 7 enum 内(click/fill/type/select/scroll/hover/drag)。*/
|
|
79
|
+
readonly UNSUPPORTED_ACTION: "UNSUPPORTED_ACTION";
|
|
80
|
+
};
|
|
81
|
+
export type VtxErrorCode = (typeof VtxErrorCode)[keyof typeof VtxErrorCode];
|
|
82
|
+
export interface VtxErrorContext {
|
|
83
|
+
selector?: string;
|
|
84
|
+
index?: number;
|
|
85
|
+
snapshotId?: string;
|
|
86
|
+
tabId?: number;
|
|
87
|
+
frameId?: number;
|
|
88
|
+
/** 兜底字段:存放 handler 场景特有的结构化信息(如遮挡元素 tag、目标 URL、action 名等) */
|
|
89
|
+
extras?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
export interface VtxErrorPayload {
|
|
92
|
+
code: VtxErrorCode;
|
|
93
|
+
message: string;
|
|
94
|
+
hint?: string;
|
|
95
|
+
recoverable?: boolean;
|
|
96
|
+
context?: VtxErrorContext;
|
|
97
|
+
}
|
|
98
|
+
export type VtxErrorExtra = Omit<VtxErrorPayload, "code" | "message">;
|
|
99
|
+
export declare class VtxError extends Error {
|
|
100
|
+
readonly code: VtxErrorCode;
|
|
101
|
+
readonly extra?: VtxErrorExtra | undefined;
|
|
102
|
+
constructor(code: VtxErrorCode, message: string, extra?: VtxErrorExtra | undefined);
|
|
103
|
+
toJSON(): VtxErrorPayload;
|
|
104
|
+
toString(): string;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;IAsCvB;8DAC0D;;IAE1D;2CACuC;;IAIvC,+CAA+C;;IAE/C,wEAAwE;;IAExE,2EAA2E;;IAE3E,gEAAgE;;IAEhE,mEAAmE;;IAEnE,+DAA+D;;IAE/D,yCAAyC;;IAEzC,yCAAyC;;IAEzC;;sDAEkD;;IAElD;;mEAE+D;;IAI/D,2DAA2D;;IAE3D,8CAA8C;;IAE9C,yCAAyC;;IAEzC,+BAA+B;;IAE/B,yBAAyB;;IAEzB,4BAA4B;;IAE5B,8EAA8E;;IAE9E,8BAA8B;;IAE9B;;iDAE6C;;IAI7C,+CAA+C;;IAE/C,uEAAuE;;CAE/D,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEtE,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,YAAY;aAElB,KAAK,CAAC,EAAE,aAAa;gBAFrB,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,aAAa,YAAA;IAMvC,MAAM,IAAI,eAAe;IAWzB,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VtxError, VtxErrorCode } from "./errors.js";
|
|
2
|
+
import type { VtxErrorContext } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* 错误元信息:给上游 LLM Agent 的恢复提示。
|
|
5
|
+
*
|
|
6
|
+
* `recoverable` 语义:
|
|
7
|
+
* - `true`:同一动作带参数调整后重试可能成功(如 ELEMENT_OCCLUDED 清理遮挡后重试)
|
|
8
|
+
* - `false`:同一动作重试无意义,但 hint 可能指引换一个动作达成目标
|
|
9
|
+
* (如 TAB_CLOSED 需要换 tab,不是动作本身的重试)
|
|
10
|
+
*
|
|
11
|
+
* Hint quality contract(I19 + I20,see L5-spec §1.2/§1.4):
|
|
12
|
+
* - 含 next-action 动词(call/use/verify/check/retry/wait/set/inspect/...)
|
|
13
|
+
* - 含工具名 OR 参数关键词(vortex_*, selector, mode, action, ...)
|
|
14
|
+
* - 长度 50-300 字符
|
|
15
|
+
* - 引用工具名必须在 v0.6 公开 11 之内(否则 LLM tools/list 看不到)
|
|
16
|
+
*/
|
|
17
|
+
export interface VtxErrorMeta {
|
|
18
|
+
hint: string;
|
|
19
|
+
recoverable: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_ERROR_META: Record<VtxErrorCode, VtxErrorMeta>;
|
|
22
|
+
/**
|
|
23
|
+
* 便捷构造 VtxError:自动注入 DEFAULT_ERROR_META 的 hint 与 recoverable。
|
|
24
|
+
* 调用方只需传 code / message / context。
|
|
25
|
+
* 如需覆盖默认 hint 或 recoverable,传 `override` 参数。
|
|
26
|
+
*/
|
|
27
|
+
export declare function vtxError(code: VtxErrorCode, message: string, context?: VtxErrorContext, override?: Partial<VtxErrorMeta>): VtxError;
|
|
28
|
+
//# sourceMappingURL=errors.hints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.hints.d.ts","sourceRoot":"","sources":["../src/errors.hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,aAAa,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,YAAY,EAAE,YAAY,CAkNjE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC/B,QAAQ,CAQV"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { VtxError } from "./errors.js";
|
|
2
|
+
export const DEFAULT_ERROR_META = {
|
|
3
|
+
// -- 元素定位 --
|
|
4
|
+
ELEMENT_NOT_FOUND: {
|
|
5
|
+
hint: "Element not found. Verify the selector or call vortex_observe to list interactive elements with their refs. If the element may live inside an iframe, call vortex_observe with scope='full' to descend into iframes — the returned element.frameId routes follow-up vortex_act correctly.",
|
|
6
|
+
recoverable: true,
|
|
7
|
+
},
|
|
8
|
+
ELEMENT_OCCLUDED: {
|
|
9
|
+
hint: "Element is covered by another (modal / overlay / cookie banner). Inspect via vortex_screenshot to identify the blocker, dismiss it via vortex_act with action='click' on its close selector, then retry.",
|
|
10
|
+
recoverable: true,
|
|
11
|
+
},
|
|
12
|
+
ELEMENT_OFFSCREEN: {
|
|
13
|
+
hint: "Element is outside the viewport. Call vortex_act with action='scroll' on the target to bring it into view, then retry the original action.",
|
|
14
|
+
recoverable: true,
|
|
15
|
+
},
|
|
16
|
+
ELEMENT_DISABLED: {
|
|
17
|
+
hint: "Element has the disabled attribute. Fill required prior fields via vortex_act or satisfy prerequisites to enable it, then retry.",
|
|
18
|
+
recoverable: true,
|
|
19
|
+
},
|
|
20
|
+
ELEMENT_DETACHED: {
|
|
21
|
+
hint: "Element was removed from the DOM. Call vortex_observe to capture the current state and retry with the new ref.",
|
|
22
|
+
recoverable: true,
|
|
23
|
+
},
|
|
24
|
+
SELECTOR_AMBIGUOUS: {
|
|
25
|
+
hint: "Selector matched multiple elements. Use a more specific selector, or call vortex_observe to get unique ref indexes (@eN form).",
|
|
26
|
+
recoverable: true,
|
|
27
|
+
},
|
|
28
|
+
// -- 页面状态 --
|
|
29
|
+
NAVIGATION_IN_PROGRESS: {
|
|
30
|
+
hint: "A page navigation is in progress. Call vortex_wait_for with mode='idle' and value='network' before retrying the action.",
|
|
31
|
+
recoverable: true,
|
|
32
|
+
},
|
|
33
|
+
PAGE_NOT_READY: {
|
|
34
|
+
hint: "Page DOM is not ready. Call vortex_wait_for with mode='element' on a load-marker selector, or mode='idle' value='network', before retrying.",
|
|
35
|
+
recoverable: true,
|
|
36
|
+
},
|
|
37
|
+
DIALOG_BLOCKING: {
|
|
38
|
+
hint: "A native browser dialog (alert / confirm / prompt) is blocking. Handle or dismiss it via vortex_act with action='click' on the OK / Cancel selector, then retry.",
|
|
39
|
+
recoverable: true,
|
|
40
|
+
},
|
|
41
|
+
IFRAME_NOT_READY: {
|
|
42
|
+
hint: "Target iframe is not ready or not yet loaded. Retry vortex_observe with scope='full' to descend into iframes — the returned elements carry frameId so follow-up vortex_act routes correctly.",
|
|
43
|
+
recoverable: true,
|
|
44
|
+
},
|
|
45
|
+
// -- Snapshot --
|
|
46
|
+
STALE_SNAPSHOT: {
|
|
47
|
+
hint: "Page has changed since the snapshot. Call vortex_observe to capture a fresh snapshot, then retry with the new ref.",
|
|
48
|
+
recoverable: true,
|
|
49
|
+
},
|
|
50
|
+
INVALID_INDEX: {
|
|
51
|
+
hint: "Index does not exist in this snapshot. Call vortex_observe to list valid ref indexes (@eN form).",
|
|
52
|
+
recoverable: true,
|
|
53
|
+
},
|
|
54
|
+
// -- 网络与标签 --
|
|
55
|
+
NAVIGATION_FAILED: {
|
|
56
|
+
hint: "Navigation failed (network error, blocked URL, or invalid URL). Verify the url argument passed to vortex_navigate and retry; the context may carry the underlying browser error.",
|
|
57
|
+
recoverable: true,
|
|
58
|
+
},
|
|
59
|
+
TAB_NOT_FOUND: {
|
|
60
|
+
hint: "tabId argument does not exist. Call vortex_tab_create to open a new tab, or omit tabId to operate on the active tab.",
|
|
61
|
+
recoverable: false,
|
|
62
|
+
},
|
|
63
|
+
TAB_CLOSED: {
|
|
64
|
+
hint: "The target tab was closed during execution. Call vortex_tab_create to open a new tab and re-run the flow, or pick another tabId.",
|
|
65
|
+
recoverable: false,
|
|
66
|
+
},
|
|
67
|
+
// -- 执行与权限 --
|
|
68
|
+
TIMEOUT: {
|
|
69
|
+
hint: "Action timed out. Increase the timeout argument, or call vortex_wait_for with mode='idle' to let the page settle before retrying.",
|
|
70
|
+
recoverable: true,
|
|
71
|
+
},
|
|
72
|
+
JS_EXECUTION_ERROR: {
|
|
73
|
+
hint: "Injected JavaScript threw an error. Inspect the error message in context.extras and adjust the selector or action arguments before retrying.",
|
|
74
|
+
recoverable: false,
|
|
75
|
+
},
|
|
76
|
+
PERMISSION_DENIED: {
|
|
77
|
+
hint: "Operation blocked by browser permission (cross-origin, file access, or extension permission). Verify the manifest permissions attribute and the target tab is not chrome://.",
|
|
78
|
+
recoverable: false,
|
|
79
|
+
},
|
|
80
|
+
CSP_BLOCKED: {
|
|
81
|
+
hint: "Action blocked by Content-Security-Policy. Use vortex_act with action='click' (which routes via CDP real mouse and bypasses page-side CSP), or pick a selector outside the CSP-restricted frame.",
|
|
82
|
+
recoverable: true,
|
|
83
|
+
},
|
|
84
|
+
INTERNAL_ERROR: {
|
|
85
|
+
hint: "Unexpected error in the vortex runtime (server / mcp). Inspect context.extras for the underlying message and retry — transient errors often recover.",
|
|
86
|
+
recoverable: true,
|
|
87
|
+
},
|
|
88
|
+
// -- 传输层 --
|
|
89
|
+
NATIVE_MESSAGING_ERROR: {
|
|
90
|
+
hint: "Native messaging channel error. Verify the vortex host is installed and the extension is reloaded; inspect the chrome://extensions page for the connection state.",
|
|
91
|
+
recoverable: false,
|
|
92
|
+
},
|
|
93
|
+
EXTENSION_NOT_CONNECTED: {
|
|
94
|
+
hint: "Vortex extension is not connected. Ensure Chrome is open with the extension enabled at chrome://extensions, then call vortex_observe to re-check connectivity.",
|
|
95
|
+
recoverable: false,
|
|
96
|
+
},
|
|
97
|
+
INVALID_PARAMS: {
|
|
98
|
+
hint: "Invalid parameters. Check the tool schema for required fields and value constraints, then retry with corrected arguments.",
|
|
99
|
+
recoverable: false,
|
|
100
|
+
},
|
|
101
|
+
UNKNOWN_ACTION: {
|
|
102
|
+
hint: "Unknown action. Verify the action argument spelling matches the tool's enum (e.g. vortex_act expects click / fill / type / select / scroll / hover).",
|
|
103
|
+
recoverable: false,
|
|
104
|
+
},
|
|
105
|
+
// -- 组件 / 框架 --
|
|
106
|
+
UNSUPPORTED_TARGET: {
|
|
107
|
+
hint: "Target is a framework-controlled component (e.g. Element Plus datetime-range picker). The runtime auto-routes to a commit driver via vortex_act; if the framework version is not yet covered, inspect context.extras.kind and pick a CSS selector outside the controlled region.",
|
|
108
|
+
recoverable: false,
|
|
109
|
+
},
|
|
110
|
+
COMMIT_FAILED: {
|
|
111
|
+
hint: "Commit driver failed mid-flow. Inspect context.extras.stage (open-picker / navigate-month / click-day / confirm / verify) to see which step broke; the page state may have changed or the framework version may not be matched by any driver.",
|
|
112
|
+
recoverable: true,
|
|
113
|
+
},
|
|
114
|
+
// -- L2 Action layer --
|
|
115
|
+
NOT_ATTACHED: {
|
|
116
|
+
hint: "Element detached from DOM. Call vortex_observe to re-locate the element and retry vortex_act with the fresh ref.",
|
|
117
|
+
recoverable: true,
|
|
118
|
+
},
|
|
119
|
+
NOT_VISIBLE: {
|
|
120
|
+
hint: "Element not visible (display:none / visibility:hidden / 0x0 box). Call vortex_wait_for with mode='element' on a parent visibility marker, or check whether the parent container is hidden.",
|
|
121
|
+
recoverable: true,
|
|
122
|
+
},
|
|
123
|
+
NOT_STABLE: {
|
|
124
|
+
hint: "Element position is unstable (animating). Call vortex_wait_for with mode='idle' to let the animation settle, then retry vortex_act.",
|
|
125
|
+
recoverable: true,
|
|
126
|
+
},
|
|
127
|
+
OBSCURED: {
|
|
128
|
+
hint: "Element hit-test failed; covered by another element (e.g. modal / loading overlay). Inspect via vortex_screenshot, dismiss the overlay (context.extras.blocker may identify it), then retry.",
|
|
129
|
+
recoverable: true,
|
|
130
|
+
},
|
|
131
|
+
DISABLED: {
|
|
132
|
+
hint: "Element is disabled (disabled attribute / aria-disabled / fieldset[disabled]). Complete prerequisite vortex_act interactions to unlock it before retrying.",
|
|
133
|
+
recoverable: true,
|
|
134
|
+
},
|
|
135
|
+
NOT_EDITABLE: {
|
|
136
|
+
hint: "Target is not editable (readonly or non-input element). Use vortex_extract to read its text instead, or pick a different selector that points to an actual input.",
|
|
137
|
+
recoverable: false,
|
|
138
|
+
},
|
|
139
|
+
ACTION_FAILED_ALL_PATHS: {
|
|
140
|
+
hint: "All fallback paths exhausted (dispatchEvent → CDP → ...). context.extras.attemptedPaths lists what was tried. Inspect via vortex_screenshot, retry with a different selector, or check whether the element lives in a closed shadow root.",
|
|
141
|
+
recoverable: false,
|
|
142
|
+
},
|
|
143
|
+
DRAG_REQUIRES_CDP: {
|
|
144
|
+
hint: "Drag operation requires CDP, but CDP is unavailable (DevTools may be open, or chrome.debugger attach was denied). Close DevTools and retry; drag is exposed via vortex_act with action='drag' once CDP attaches.",
|
|
145
|
+
recoverable: false,
|
|
146
|
+
},
|
|
147
|
+
// -- L3 Reasoning(@since 0.6.0 PR #3)--
|
|
148
|
+
A11Y_UNAVAILABLE: {
|
|
149
|
+
hint: "Accessibility tree unavailable on this page (CSP-restricted or sandboxed). Switch to a regular page or fall back to CSS selectors via vortex_act and vortex_extract.",
|
|
150
|
+
recoverable: false,
|
|
151
|
+
},
|
|
152
|
+
CDP_NOT_ATTACHED: {
|
|
153
|
+
hint: "chrome.debugger could not attach to the tab. Verify the manifest debugger attribute is granted, and the tab is not chrome:// or chrome-extension:// (CDP cannot attach to those).",
|
|
154
|
+
recoverable: false,
|
|
155
|
+
},
|
|
156
|
+
STALE_REF: {
|
|
157
|
+
hint: "Element ref is stale and could not be re-resolved by descriptor. Call vortex_observe to mint fresh refs and retry.",
|
|
158
|
+
recoverable: true,
|
|
159
|
+
},
|
|
160
|
+
AMBIGUOUS_DESCRIPTOR: {
|
|
161
|
+
hint: "Descriptor matched multiple elements in strict mode. Add a 'near' relation to disambiguate, narrow the name attribute, or set strict:false to take the first match.",
|
|
162
|
+
recoverable: true,
|
|
163
|
+
},
|
|
164
|
+
REF_NOT_FOUND: {
|
|
165
|
+
hint: "ref does not exist in the current RefStore. Call vortex_observe to mint fresh refs and retry the action.",
|
|
166
|
+
recoverable: true,
|
|
167
|
+
},
|
|
168
|
+
SNAPSHOT_EXPIRED: {
|
|
169
|
+
hint: "Snapshot expired (> 5 min). Call vortex_observe to capture a new snapshot and retry with the fresh ref.",
|
|
170
|
+
recoverable: true,
|
|
171
|
+
},
|
|
172
|
+
CROSS_ORIGIN_IFRAME: {
|
|
173
|
+
hint: "Accessibility.getFullAXTree was rejected for a cross-origin frameId; the AX tree cannot be queried across origin boundaries. Switch to a same-origin entry point or operate within the iframe via its own tab context.",
|
|
174
|
+
recoverable: false,
|
|
175
|
+
},
|
|
176
|
+
CLOSED_SHADOW_DOM: {
|
|
177
|
+
hint: "Element lives inside a closed shadow root and cannot be pierced. Ask the component author to switch the mode attribute to 'open', or expose an ARIA-rich light-DOM proxy selector.",
|
|
178
|
+
recoverable: false,
|
|
179
|
+
},
|
|
180
|
+
OPEN_SHADOW_DOM: {
|
|
181
|
+
hint: "Element lives inside an open shadow root that vortex_observe surfaced but act cannot reach via a CSS selector. Expose a light-DOM proxy selector for the control, or have the component render the actionable element in light DOM.",
|
|
182
|
+
recoverable: false,
|
|
183
|
+
},
|
|
184
|
+
NO_MATCHING_OPTION: {
|
|
185
|
+
hint: "The select value matched no <option> by value attribute or visible text. Read the available options (listed in context.extras.available) and retry vortex_act select with an exact option value or label.",
|
|
186
|
+
recoverable: true,
|
|
187
|
+
},
|
|
188
|
+
NO_EFFECT: {
|
|
189
|
+
hint: "The action dispatched but a post-action read-back showed no real change (option not selected, page not scrolled, state unchanged). The target may be a disabled option or a no-op scroll. Re-observe and verify the element is operable before retrying.",
|
|
190
|
+
recoverable: true,
|
|
191
|
+
},
|
|
192
|
+
// -- L4 Task layer(@since 0.6.0 PR #4)--
|
|
193
|
+
INVALID_TARGET: {
|
|
194
|
+
hint: "Use a target ref string like @e3 (returned from vortex_observe) or a CSS selector. The Descriptor object form arrives in v0.6.x once the resolver lands.",
|
|
195
|
+
recoverable: false,
|
|
196
|
+
},
|
|
197
|
+
UNSUPPORTED_ACTION: {
|
|
198
|
+
hint: "Verify the action argument matches one of vortex_act's enum values: click, fill, type, select, scroll, hover. The drag action is not yet exposed via vortex_act in v0.6.",
|
|
199
|
+
recoverable: false,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* 便捷构造 VtxError:自动注入 DEFAULT_ERROR_META 的 hint 与 recoverable。
|
|
204
|
+
* 调用方只需传 code / message / context。
|
|
205
|
+
* 如需覆盖默认 hint 或 recoverable,传 `override` 参数。
|
|
206
|
+
*/
|
|
207
|
+
export function vtxError(code, message, context, override) {
|
|
208
|
+
const meta = DEFAULT_ERROR_META[code];
|
|
209
|
+
const extra = {
|
|
210
|
+
hint: override?.hint ?? meta.hint,
|
|
211
|
+
recoverable: override?.recoverable ?? meta.recoverable,
|
|
212
|
+
};
|
|
213
|
+
if (context !== undefined)
|
|
214
|
+
extra.context = context;
|
|
215
|
+
return new VtxError(code, message, extra);
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=errors.hints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.hints.js","sourceRoot":"","sources":["../src/errors.hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AAsBrD,MAAM,CAAC,MAAM,kBAAkB,GAAuC;IACpE,aAAa;IACb,iBAAiB,EAAE;QACjB,IAAI,EAAE,2RAA2R;QACjS,WAAW,EAAE,IAAI;KAClB;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,0MAA0M;QAChN,WAAW,EAAE,IAAI;KAClB;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,4IAA4I;QAClJ,WAAW,EAAE,IAAI;KAClB;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,kIAAkI;QACxI,WAAW,EAAE,IAAI;KAClB;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,gHAAgH;QACtH,WAAW,EAAE,IAAI;KAClB;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,gIAAgI;QACtI,WAAW,EAAE,IAAI;KAClB;IAED,aAAa;IACb,sBAAsB,EAAE;QACtB,IAAI,EAAE,yHAAyH;QAC/H,WAAW,EAAE,IAAI;KAClB;IACD,cAAc,EAAE;QACd,IAAI,EAAE,6IAA6I;QACnJ,WAAW,EAAE,IAAI;KAClB;IACD,eAAe,EAAE;QACf,IAAI,EAAE,kK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_OFFSCREEN",
|
|
6
|
+
ELEMENT_DISABLED: "ELEMENT_DISABLED",
|
|
7
|
+
ELEMENT_DETACHED: "ELEMENT_DETACHED",
|
|
8
|
+
SELECTOR_AMBIGUOUS: "SELECTOR_AMBIGUOUS",
|
|
9
|
+
// -- 页面状态(4 类)--
|
|
10
|
+
NAVIGATION_IN_PROGRESS: "NAVIGATION_IN_PROGRESS",
|
|
11
|
+
PAGE_NOT_READY: "PAGE_NOT_READY",
|
|
12
|
+
DIALOG_BLOCKING: "DIALOG_BLOCKING",
|
|
13
|
+
IFRAME_NOT_READY: "IFRAME_NOT_READY",
|
|
14
|
+
// -- Snapshot(2 类,配合 vortex_observe)--
|
|
15
|
+
STALE_SNAPSHOT: "STALE_SNAPSHOT",
|
|
16
|
+
INVALID_INDEX: "INVALID_INDEX",
|
|
17
|
+
// -- 网络与标签(3 类)--
|
|
18
|
+
NAVIGATION_FAILED: "NAVIGATION_FAILED",
|
|
19
|
+
TAB_NOT_FOUND: "TAB_NOT_FOUND",
|
|
20
|
+
TAB_CLOSED: "TAB_CLOSED",
|
|
21
|
+
// -- 执行与权限(5 类)--
|
|
22
|
+
TIMEOUT: "TIMEOUT",
|
|
23
|
+
JS_EXECUTION_ERROR: "JS_EXECUTION_ERROR",
|
|
24
|
+
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
25
|
+
CSP_BLOCKED: "CSP_BLOCKED",
|
|
26
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
27
|
+
// -- 传输层(4 类)--
|
|
28
|
+
NATIVE_MESSAGING_ERROR: "NATIVE_MESSAGING_ERROR",
|
|
29
|
+
EXTENSION_NOT_CONNECTED: "EXTENSION_NOT_CONNECTED",
|
|
30
|
+
INVALID_PARAMS: "INVALID_PARAMS",
|
|
31
|
+
UNKNOWN_ACTION: "UNKNOWN_ACTION",
|
|
32
|
+
// -- 组件 / 框架(2 类,@since 0.4.0)--
|
|
33
|
+
/** 目标元素属于框架托管的受控组件(如 Element Plus datetime-range picker),
|
|
34
|
+
* 不能用普通 DOM 原语(fill/type)安全提交值;需换用 vortex_dom_commit。 */
|
|
35
|
+
UNSUPPORTED_TARGET: "UNSUPPORTED_TARGET",
|
|
36
|
+
/** vortex_dom_commit 的 driver 在流程中途失败(picker 打不开、日期格找不到、校验不一致等)。
|
|
37
|
+
* context.extras 会带 stage 字段标识失败阶段。*/
|
|
38
|
+
COMMIT_FAILED: "COMMIT_FAILED",
|
|
39
|
+
// -- L2 Action layer (added in PR #2) --
|
|
40
|
+
/** Actionability: element detached from DOM */
|
|
41
|
+
NOT_ATTACHED: "NOT_ATTACHED",
|
|
42
|
+
/** Actionability: display:none / visibility:hidden / opacity:0 / 0x0 */
|
|
43
|
+
NOT_VISIBLE: "NOT_VISIBLE",
|
|
44
|
+
/** Actionability: double-RAF sample shows unstable position (animating) */
|
|
45
|
+
NOT_STABLE: "NOT_STABLE",
|
|
46
|
+
/** Actionability: hit-test hit a different element (covered) */
|
|
47
|
+
OBSCURED: "OBSCURED",
|
|
48
|
+
/** Actionability: disabled / aria-disabled / fieldset[disabled] */
|
|
49
|
+
DISABLED: "DISABLED",
|
|
50
|
+
/** Actionability: fill/type target is readonly or non-input */
|
|
51
|
+
NOT_EDITABLE: "NOT_EDITABLE",
|
|
52
|
+
/** Fallback chain exhausted all paths */
|
|
53
|
+
ACTION_FAILED_ALL_PATHS: "ACTION_FAILED_ALL_PATHS",
|
|
54
|
+
/** Drag operation but CDP unavailable */
|
|
55
|
+
DRAG_REQUIRES_CDP: "DRAG_REQUIRES_CDP",
|
|
56
|
+
/** select action: 传入的 value 在 <select> 的 option 里既不匹配 value 属性、
|
|
57
|
+
* 也不匹配可见文本(label)。避免静默选不中却返回 success。
|
|
58
|
+
* context.extras.available 带可选项清单供 agent 重新选取。*/
|
|
59
|
+
NO_MATCHING_OPTION: "NO_MATCHING_OPTION",
|
|
60
|
+
/** 赋值/驱动类 act 原语(select 多选 / scroll / press 等)dispatch 后回读校验,
|
|
61
|
+
* 发现副作用未真正发生(选项未选中 / 未滚动 / 状态未变)。避免 dispatch 即返回
|
|
62
|
+
* success 的 silent false-success(2026-06-03 act 原语白盒审计族 A)。*/
|
|
63
|
+
NO_EFFECT: "NO_EFFECT",
|
|
64
|
+
// -- L3 Reasoning(9 类:8 @since 0.6.0 PR #3 + OPEN_SHADOW_DOM @issue #27)--
|
|
65
|
+
/** a11y tree 不可用(CSP / sandboxed page),无法 getFullAXTree。*/
|
|
66
|
+
A11Y_UNAVAILABLE: "A11Y_UNAVAILABLE",
|
|
67
|
+
/** chrome.debugger.attach 失败(缺权限、tab 已关闭等)。*/
|
|
68
|
+
CDP_NOT_ATTACHED: "CDP_NOT_ATTACHED",
|
|
69
|
+
/** ref 关联节点 stale,descriptor 三级消解仍然失败。*/
|
|
70
|
+
STALE_REF: "STALE_REF",
|
|
71
|
+
/** descriptor strict 模式下多匹配。*/
|
|
72
|
+
AMBIGUOUS_DESCRIPTOR: "AMBIGUOUS_DESCRIPTOR",
|
|
73
|
+
/** RefStore 中找不到此 ref。*/
|
|
74
|
+
REF_NOT_FOUND: "REF_NOT_FOUND",
|
|
75
|
+
/** snapshot 已过期(> 5 min)。*/
|
|
76
|
+
SNAPSHOT_EXPIRED: "SNAPSHOT_EXPIRED",
|
|
77
|
+
/** 跨源 iframe,Accessibility.getFullAXTree 拒绝(CDP 已 attach,但 AX tree 不能跨源查询)。*/
|
|
78
|
+
CROSS_ORIGIN_IFRAME: "CROSS_ORIGIN_IFRAME",
|
|
79
|
+
/** closed shadow host,无法穿透。*/
|
|
80
|
+
CLOSED_SHADOW_DOM: "CLOSED_SHADOW_DOM",
|
|
81
|
+
/** 元素在 open shadow root 内:observe 经 querySelectorAllDeep 穿 shadow 发出了 ref,
|
|
82
|
+
* 但 act/fill 的 CSS selector 解析不穿 shadow → 永久不可解析。快速失败给诊断,
|
|
83
|
+
* 而非 NOT_ATTACHED 重试满 timeout(issue #27)。*/
|
|
84
|
+
OPEN_SHADOW_DOM: "OPEN_SHADOW_DOM",
|
|
85
|
+
// -- L4 Task layer(2 类,@since 0.6.0 PR #4)--
|
|
86
|
+
/** target 既不是合法 ref 也不是 valid descriptor 对象。*/
|
|
87
|
+
INVALID_TARGET: "INVALID_TARGET",
|
|
88
|
+
/** action 不在 act 7 enum 内(click/fill/type/select/scroll/hover/drag)。*/
|
|
89
|
+
UNSUPPORTED_ACTION: "UNSUPPORTED_ACTION",
|
|
90
|
+
};
|
|
91
|
+
export class VtxError extends Error {
|
|
92
|
+
code;
|
|
93
|
+
extra;
|
|
94
|
+
constructor(code, message, extra) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.code = code;
|
|
97
|
+
this.extra = extra;
|
|
98
|
+
this.name = "VtxError";
|
|
99
|
+
}
|
|
100
|
+
toJSON() {
|
|
101
|
+
const payload = {
|
|
102
|
+
code: this.code,
|
|
103
|
+
message: this.message,
|
|
104
|
+
};
|
|
105
|
+
if (this.extra?.hint !== undefined)
|
|
106
|
+
payload.hint = this.extra.hint;
|
|
107
|
+
if (this.extra?.recoverable !== undefined)
|
|
108
|
+
payload.recoverable = this.extra.recoverable;
|
|
109
|
+
if (this.extra?.context !== undefined)
|
|
110
|
+
payload.context = this.extra.context;
|
|
111
|
+
return payload;
|
|
112
|
+
}
|
|
113
|
+
toString() {
|
|
114
|
+
return `VtxError[${this.code}]: ${this.message}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,iBAAiB;IACjB,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,kBAAkB,EAAE,oBAAoB;IAExC,iBAAiB;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/dist/events.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件系统:vortex 从"被动响应请求"升格为"主动推送事件"。
|
|
3
|
+
*
|
|
4
|
+
* - urgent:默认推送(用户介入 / 阻塞性事件)
|
|
5
|
+
* - notice:订阅后推送
|
|
6
|
+
* - info:debug/观察用,需显式订阅
|
|
7
|
+
*/
|
|
8
|
+
export type VtxEventLevel = "info" | "notice" | "urgent";
|
|
9
|
+
export declare const VtxEventType: {
|
|
10
|
+
readonly USER_SWITCHED_TAB: "user.switched_tab";
|
|
11
|
+
readonly USER_CLOSED_TAB: "user.closed_tab";
|
|
12
|
+
readonly DIALOG_OPENED: "dialog.opened";
|
|
13
|
+
readonly DOWNLOAD_COMPLETED: "download.completed";
|
|
14
|
+
readonly EXTENSION_DISCONNECTED: "extension.disconnected";
|
|
15
|
+
readonly PAGE_NAVIGATED: "page.navigated";
|
|
16
|
+
readonly NETWORK_ERROR_DETECTED: "network.error_detected";
|
|
17
|
+
readonly CONSOLE_ERROR: "console.error";
|
|
18
|
+
readonly FORM_SUBMITTED: "form.submitted";
|
|
19
|
+
readonly DOM_MUTATED: "dom.mutated";
|
|
20
|
+
readonly NETWORK_REQUEST: "network.request";
|
|
21
|
+
};
|
|
22
|
+
export type VtxEventType = (typeof VtxEventType)[keyof typeof VtxEventType];
|
|
23
|
+
/**
|
|
24
|
+
* 每个事件类型的默认 level。未在表中的事件(例如 legacy 的
|
|
25
|
+
* "console.message" / "network.requestStart")默认视为 "info"。
|
|
26
|
+
*/
|
|
27
|
+
export declare const EVENT_LEVEL: Record<string, VtxEventLevel>;
|
|
28
|
+
export declare function eventLevelOf(eventName: string): VtxEventLevel;
|
|
29
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzD,eAAO,MAAM,YAAY;;;;;;;;;;;;CAiBf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAYrD,CAAC;AAEF,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAE7D"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const VtxEventType = {
|
|
2
|
+
// urgent
|
|
3
|
+
USER_SWITCHED_TAB: "user.switched_tab",
|
|
4
|
+
USER_CLOSED_TAB: "user.closed_tab",
|
|
5
|
+
DIALOG_OPENED: "dialog.opened",
|
|
6
|
+
DOWNLOAD_COMPLETED: "download.completed",
|
|
7
|
+
EXTENSION_DISCONNECTED: "extension.disconnected",
|
|
8
|
+
// notice
|
|
9
|
+
PAGE_NAVIGATED: "page.navigated",
|
|
10
|
+
NETWORK_ERROR_DETECTED: "network.error_detected",
|
|
11
|
+
CONSOLE_ERROR: "console.error",
|
|
12
|
+
FORM_SUBMITTED: "form.submitted",
|
|
13
|
+
// info
|
|
14
|
+
DOM_MUTATED: "dom.mutated",
|
|
15
|
+
NETWORK_REQUEST: "network.request",
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 每个事件类型的默认 level。未在表中的事件(例如 legacy 的
|
|
19
|
+
* "console.message" / "network.requestStart")默认视为 "info"。
|
|
20
|
+
*/
|
|
21
|
+
export const EVENT_LEVEL = {
|
|
22
|
+
"user.switched_tab": "urgent",
|
|
23
|
+
"user.closed_tab": "urgent",
|
|
24
|
+
"dialog.opened": "urgent",
|
|
25
|
+
"download.completed": "urgent",
|
|
26
|
+
"extension.disconnected": "urgent",
|
|
27
|
+
"page.navigated": "notice",
|
|
28
|
+
"network.error_detected": "notice",
|
|
29
|
+
"console.error": "notice",
|
|
30
|
+
"form.submitted": "notice",
|
|
31
|
+
"dom.mutated": "info",
|
|
32
|
+
"network.request": "info",
|
|
33
|
+
};
|
|
34
|
+
export function eventLevelOf(eventName) {
|
|
35
|
+
return EVENT_LEVEL[eventName] ?? "info";
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS;IACT,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAClC,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,sBAAsB,EAAE,wBAAwB;IAEhD,SAAS;IACT,cAAc,EAAE,gBAAgB;IAChC,sBAAsB,EAAE,wBAAwB;IAChD,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAEhC,OAAO;IACP,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAIX;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkC;IACxD,mBAAmB,EAAE,QAAQ;IAC7B,iBAAiB,EAAE,QAAQ;IAC3B,eAAe,EAAE,QAAQ;IACzB,oBAAoB,EAAE,QAAQ;IAC9B,wBAAwB,EAAE,QAAQ;IAClC,gBAAgB,EAAE,QAAQ;IAC1B,wBAAwB,EAAE,QAAQ;IAClC,eAAe,EAAE,QAAQ;IACzB,gBAAgB,EAAE,QAAQ;IAC1B,aAAa,EAAE,MAAM;IACrB,iBAAiB,EAAE,MAAM;CAC1B,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,WAAW,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { VtxErrorPayload } from "./errors.js";
|
|
2
|
+
import type { VtxEventLevel } from "./events.js";
|
|
3
|
+
export interface VtxRequest {
|
|
4
|
+
action: string;
|
|
5
|
+
params?: Record<string, unknown>;
|
|
6
|
+
id: string;
|
|
7
|
+
tabId?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface VtxResponse {
|
|
10
|
+
action: string;
|
|
11
|
+
id: string;
|
|
12
|
+
result?: unknown;
|
|
13
|
+
error?: VtxErrorPayload;
|
|
14
|
+
}
|
|
15
|
+
export interface VtxEvent {
|
|
16
|
+
event: string;
|
|
17
|
+
data: unknown;
|
|
18
|
+
tabId?: number;
|
|
19
|
+
frameId?: number;
|
|
20
|
+
level?: VtxEventLevel;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
export interface NmRequest {
|
|
24
|
+
type: "tool_request";
|
|
25
|
+
tool: string;
|
|
26
|
+
args: Record<string, unknown>;
|
|
27
|
+
requestId: string;
|
|
28
|
+
tabId?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface NmResponse {
|
|
31
|
+
type: "tool_response";
|
|
32
|
+
requestId: string;
|
|
33
|
+
result?: unknown;
|
|
34
|
+
error?: VtxErrorPayload;
|
|
35
|
+
}
|
|
36
|
+
export interface NmEvent {
|
|
37
|
+
type: "event";
|
|
38
|
+
event: string;
|
|
39
|
+
data: unknown;
|
|
40
|
+
tabId?: number;
|
|
41
|
+
frameId?: number;
|
|
42
|
+
level?: VtxEventLevel;
|
|
43
|
+
}
|
|
44
|
+
export interface NmResponseChunk {
|
|
45
|
+
type: "tool_response_chunk";
|
|
46
|
+
requestId: string;
|
|
47
|
+
chunkIndex: number;
|
|
48
|
+
totalChunks: number;
|
|
49
|
+
data: string;
|
|
50
|
+
}
|
|
51
|
+
export interface NmPing {
|
|
52
|
+
type: "ping";
|
|
53
|
+
}
|
|
54
|
+
export interface NmPong {
|
|
55
|
+
type: "pong";
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Server→Extension 控制消息。@since 0.4.0
|
|
59
|
+
*
|
|
60
|
+
* 目前仅支持 `reload-extension`:server 端 watcher 检测到扩展 dist 变化后
|
|
61
|
+
* 向扩展推送此消息,扩展侧调 `chrome.runtime.reload()` 自重载并读取新 dist,
|
|
62
|
+
* 避免每次 `pnpm -C packages/extension build` 后人工去 `chrome://extensions`
|
|
63
|
+
* 点刷新。与 MCP 的 O-3 `fs.watch` 自 exit 对称。
|
|
64
|
+
*/
|
|
65
|
+
export interface NmControl {
|
|
66
|
+
type: "control";
|
|
67
|
+
action: "reload-extension";
|
|
68
|
+
/** 可选:方便扩展侧日志打点/调试,不影响行为 */
|
|
69
|
+
reason?: string;
|
|
70
|
+
}
|
|
71
|
+
export type NmMessageFromServer = NmRequest | NmPing | NmControl;
|
|
72
|
+
export type NmMessageFromExtension = NmResponse | NmEvent | NmResponseChunk | NmPong;
|
|
73
|
+
export type NmMessage = NmMessageFromServer | NmMessageFromExtension;
|
|
74
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d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AC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,MAAM,CAAC;AACrF,MAAM,MAAM,SAAS,GAAG,mBAAmB,GAAG,sBAAsB,CAAC"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vortex-browser/shared",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"typescript": "^5.7.0",
|
|
12
|
+
"vitest": "^2.1.0"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"description": "Shared types, action names, and error codes for Vortex browser automation.",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"browser-automation",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"mcp",
|
|
20
|
+
"chrome-extension",
|
|
21
|
+
"llm",
|
|
22
|
+
"puppeteer-alternative",
|
|
23
|
+
"playwright-alternative"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://github.com/benbergg/vortex-browser",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/benbergg/vortex-browser.git"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"dev": "tsc --watch",
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
39
|
+
}
|