@kkeve/suite 0.0.13 → 0.0.17
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/bin/keve.js +2 -1
- package/dist/commands/clean.js +2 -2
- package/dist/commands/config.js +7 -7
- package/dist/commands/init.js +2 -2
- package/dist/commands/report.js +7 -7
- package/dist/commands/run.js +16 -12
- package/dist/commands/test.js +7 -7
- package/dist/config.js +7 -7
- package/dist/core/action-log-writer.js +4 -1
- package/dist/core/decorator/keve-decorators.d.ts +128 -0
- package/dist/core/decorator/keve-decorators.js +254 -0
- package/dist/core/decorator/keve-host.d.ts +40 -0
- package/dist/core/decorator/keve-host.js +33 -0
- package/dist/core/{keve-registry.d.ts → decorator/keve-registry.d.ts} +19 -0
- package/dist/core/{keve-registry.js → decorator/keve-registry.js} +13 -1
- package/dist/core/generateReport/report.d.ts +1 -1
- package/dist/core/generateReport/report.js +2 -2
- package/dist/core/generateReport/reportData.d.ts +3 -0
- package/dist/core/generateReport/reportData.js +55 -18
- package/dist/core/judge/confidence.d.ts +119 -0
- package/dist/core/judge/confidence.js +295 -0
- package/dist/core/judge/goal-heuristics.d.ts +32 -0
- package/dist/core/judge/goal-heuristics.js +128 -0
- package/dist/core/judge/pngCodec.d.ts +23 -0
- package/dist/core/judge/pngCodec.js +215 -0
- package/dist/core/judge/screenshotDiff.d.ts +112 -0
- package/dist/core/judge/screenshotDiff.js +420 -0
- package/dist/core/page-object/definePage.d.ts +95 -0
- package/dist/core/page-object/definePage.js +62 -0
- package/dist/core/page-object/elementResolver.d.ts +32 -0
- package/dist/core/page-object/elementResolver.js +236 -0
- package/dist/core/page-object/engine-types.d.ts +140 -0
- package/dist/core/page-object/engine-types.js +34 -0
- package/dist/core/sso-cookie.d.ts +18 -0
- package/dist/core/sso-cookie.js +10 -0
- package/dist/dsl/index.d.ts +15 -0
- package/dist/dsl/index.js +29 -0
- package/dist/dsl/locatorSource.d.ts +25 -0
- package/dist/dsl/locatorSource.js +323 -0
- package/dist/dsl/ops.d.ts +46 -0
- package/dist/dsl/ops.js +95 -0
- package/dist/dsl/toDecorator.d.ts +98 -0
- package/dist/dsl/toDecorator.js +747 -0
- package/dist/engine-cypress/adapter.d.ts +108 -0
- package/dist/engine-cypress/adapter.js +514 -0
- package/dist/engine-cypress/agent-page.d.ts +159 -0
- package/dist/engine-cypress/agent-page.js +566 -0
- package/dist/engine-cypress/agentDom.d.ts +22 -0
- package/dist/engine-cypress/agentDom.js +590 -0
- package/dist/engine-cypress/bridge.d.ts +39 -0
- package/dist/engine-cypress/bridge.js +598 -0
- package/dist/engine-cypress/cdp.d.ts +78 -0
- package/dist/engine-cypress/cdp.js +339 -0
- package/dist/engine-cypress/host.d.ts +22 -0
- package/dist/engine-cypress/host.js +480 -0
- package/dist/engine-cypress/index.d.ts +26 -0
- package/dist/engine-cypress/index.js +58 -0
- package/dist/engine-cypress/keveGoal.d.ts +43 -0
- package/dist/engine-cypress/keveGoal.js +265 -0
- package/dist/engine-cypress/pageOps.d.ts +41 -0
- package/dist/engine-cypress/pageOps.js +439 -0
- package/dist/engine-cypress/reporter.d.ts +20 -0
- package/dist/engine-cypress/reporter.js +128 -0
- package/dist/engine-cypress/setup.d.ts +21 -0
- package/dist/engine-cypress/setup.js +27 -0
- package/dist/engine-cypress/shotBuffer.d.ts +40 -0
- package/dist/engine-cypress/shotBuffer.js +41 -0
- package/dist/engine-cypress/state.d.ts +56 -0
- package/dist/engine-cypress/state.js +81 -0
- package/dist/engine-playwright/engineAdapter.d.ts +78 -0
- package/dist/engine-playwright/engineAdapter.js +371 -0
- package/dist/engine-playwright/global-setup.d.ts +28 -0
- package/dist/engine-playwright/global-setup.js +142 -0
- package/dist/{core → engine-playwright}/keve-report.d.ts +0 -1
- package/dist/engine-playwright/keve-report.js +137 -0
- package/dist/{core → engine-playwright}/keve-test.d.ts +10 -8
- package/dist/{core → engine-playwright}/keve-test.js +257 -207
- package/dist/{core → engine-playwright}/pw-config.js +8 -7
- package/dist/index.d.ts +13 -8
- package/dist/index.js +43 -28
- package/dist/page-agent/agent.d.ts +98 -7
- package/dist/page-agent/agent.js +338 -84
- package/dist/page-agent/diagnostics.d.ts +184 -0
- package/dist/page-agent/diagnostics.js +377 -0
- package/dist/page-agent/hooks.d.ts +3 -2
- package/dist/page-agent/hooks.js +4 -3
- package/dist/page-agent/page-like.d.ts +116 -0
- package/dist/page-agent/page-like.js +14 -0
- package/dist/page-agent/playwright-page.d.ts +20 -0
- package/dist/page-agent/playwright-page.js +98 -0
- package/dist/page-agent/system-prompt.d.ts +7 -0
- package/dist/page-agent/system-prompt.js +10 -0
- package/dist/page-agent/system_prompt.md +1 -1
- package/dist/page-agent/tools.d.ts +1 -1
- package/dist/page-agent/tools.js +441 -9
- package/doc/skills/keve-e2e-gen/references/script-generation-guide.md +11 -0
- package/package.json +24 -11
- package/scripts/gen-system-prompt.mjs +36 -0
- package/scripts/run-dsl-task.mjs +619 -0
- package/scripts/runtime/cypress-preprocessor.mjs +44 -0
- package/scripts/runtime/cypress.config.mjs +35 -0
- package/scripts/runtime/playwright.config.mjs +41 -0
- package/scripts/verify-shot-diff.mjs +243 -0
- package/dist/commands/auth-update.d.ts +0 -16
- package/dist/commands/auth-update.js +0 -88
- package/dist/core/auth.d.ts +0 -17
- package/dist/core/auth.js +0 -224
- package/dist/core/cdp-resolver.d.ts +0 -5
- package/dist/core/cdp-resolver.js +0 -93
- package/dist/core/global-setup.d.ts +0 -6
- package/dist/core/global-setup.js +0 -113
- package/dist/core/keve-decorators.d.ts +0 -51
- package/dist/core/keve-decorators.js +0 -95
- package/dist/core/keve-report.js +0 -376
- /package/dist/core/{keve-aspect.d.ts → decorator/keve-aspect.d.ts} +0 -0
- /package/dist/core/{keve-aspect.js → decorator/keve-aspect.js} +0 -0
- /package/dist/{core → engine-playwright}/pw-config.d.ts +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-page — Cypress 侧的 AgentPage 实现(CDP + 页内 agentDom)
|
|
3
|
+
*
|
|
4
|
+
* 与 Playwright 侧的 `page-agent/playwright-page.ts` 一一对应:同一个 Re-Act
|
|
5
|
+
* 循环吃同一份 `AgentPage` 契约,差异只在这层:
|
|
6
|
+
* - DOM 读写全部经 CDP 在 AUT isolated world 内求值(绝不碰 runner 顶层页)
|
|
7
|
+
* - 键盘/鼠标走 CDP Input 域,坐标需叠加 AUT iframe 在 runner 里的偏移
|
|
8
|
+
* - 截图统一裁剪到 AUT iframe,元素截图在此基础上再按 boundingBox 裁一次
|
|
9
|
+
*
|
|
10
|
+
* 本模块零 Node 依赖,也不得 import '@playwright/test'(连类型都不需要)。
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentBoundingBox, AgentKeyboard, AgentLocator, AgentMouse, AgentPage, AgentScreenshot } from '../page-agent/page-like.js';
|
|
13
|
+
import { type Cdp } from './cdp.js';
|
|
14
|
+
import { type PagePerformanceMetrics, type RawConsoleRecord, type RawNetworkRecord } from '../page-agent/diagnostics.js';
|
|
15
|
+
/** 主世界诊断采集写入 DOM 的快照形态 */
|
|
16
|
+
interface CypressDiagnosticsSnapshot {
|
|
17
|
+
browser?: RawConsoleRecord[];
|
|
18
|
+
network?: RawNetworkRecord[];
|
|
19
|
+
page?: PagePerformanceMetrics;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 合并多个 frame 的主世界诊断快照。
|
|
23
|
+
*
|
|
24
|
+
* 业务页面(如 kwaibi)可能把主要内容放在同源/跨域 iframe 内;单个 frame
|
|
25
|
+
* 的 dataset 只包含自己上下文里发生的 console/网络/性能事件,不能只看 AUT
|
|
26
|
+
* 顶层 frame。计数类网络/console 记录直接拼接,页面性能只有 longtask 是
|
|
27
|
+
* 可累加阻塞量,其余指标取各 frame 的最大值。
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeFrameDiagnostics(snaps: Array<CypressDiagnosticsSnapshot | undefined>): CypressDiagnosticsSnapshot | undefined;
|
|
30
|
+
/** locator 链的一跳:与 agentDom.resolve() 的 op 结构一一对应 */
|
|
31
|
+
type LocOp = {
|
|
32
|
+
t: 'css';
|
|
33
|
+
selector: string;
|
|
34
|
+
} | {
|
|
35
|
+
t: 'ariaRef';
|
|
36
|
+
ref: string;
|
|
37
|
+
} | {
|
|
38
|
+
t: 'text';
|
|
39
|
+
text: string;
|
|
40
|
+
exact: boolean;
|
|
41
|
+
} | {
|
|
42
|
+
t: 'role';
|
|
43
|
+
role: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
exact: boolean;
|
|
46
|
+
} | {
|
|
47
|
+
t: 'filterHasText';
|
|
48
|
+
text: string;
|
|
49
|
+
} | {
|
|
50
|
+
t: 'filterVisible';
|
|
51
|
+
};
|
|
52
|
+
export declare class CyAgentLocator implements AgentLocator {
|
|
53
|
+
private readonly page;
|
|
54
|
+
private readonly ops;
|
|
55
|
+
/** null = 集合本身(count/allInnerTexts 用全部);数字 = 选中项,-1 = last */
|
|
56
|
+
private readonly index;
|
|
57
|
+
constructor(page: CyAgentPage, ops: LocOp[],
|
|
58
|
+
/** null = 集合本身(count/allInnerTexts 用全部);数字 = 选中项,-1 = last */
|
|
59
|
+
index?: number | null);
|
|
60
|
+
private extend;
|
|
61
|
+
private withIndex;
|
|
62
|
+
/** 集合语义的索引:null(未约束)在执行动作时按 Playwright 的「首个匹配」处理 */
|
|
63
|
+
private pickIndex;
|
|
64
|
+
private resolveExpr;
|
|
65
|
+
click(options?: any): Promise<void>;
|
|
66
|
+
dblclick(options?: any): Promise<void>;
|
|
67
|
+
fill(value: string, options?: any): Promise<void>;
|
|
68
|
+
hover(options?: any): Promise<void>;
|
|
69
|
+
pressSequentially(text: string, _options?: any): Promise<void>;
|
|
70
|
+
focus(): Promise<void>;
|
|
71
|
+
evaluate(fn: any, arg?: any): Promise<any>;
|
|
72
|
+
textContent(_options?: any): Promise<string | null>;
|
|
73
|
+
innerText(_options?: any): Promise<string>;
|
|
74
|
+
inputValue(_options?: any): Promise<string>;
|
|
75
|
+
isChecked(_options?: any): Promise<boolean>;
|
|
76
|
+
setChecked(checked: boolean, _options?: any): Promise<void>;
|
|
77
|
+
selectOption(values: any, _options?: any): Promise<any>;
|
|
78
|
+
waitFor(options?: any): Promise<void>;
|
|
79
|
+
boundingBox(_options?: any): Promise<AgentBoundingBox | null>;
|
|
80
|
+
getAttribute(name: string, _options?: any): Promise<string | null>;
|
|
81
|
+
count(): Promise<number>;
|
|
82
|
+
allInnerTexts(): Promise<string[]>;
|
|
83
|
+
isVisible(_options?: any): Promise<boolean>;
|
|
84
|
+
screenshot(_options?: any): Promise<AgentScreenshot>;
|
|
85
|
+
first(): AgentLocator;
|
|
86
|
+
last(): AgentLocator;
|
|
87
|
+
nth(index: number): AgentLocator;
|
|
88
|
+
filter(options?: any): AgentLocator;
|
|
89
|
+
locator(selector: string): AgentLocator;
|
|
90
|
+
/** 仅调试用:暴露定位链 */
|
|
91
|
+
toOps(): LocOp[];
|
|
92
|
+
/** 供 page.evaluate 之外的诊断使用 */
|
|
93
|
+
resolveHandleExpr(): string;
|
|
94
|
+
}
|
|
95
|
+
export declare class CyAgentPage implements AgentPage {
|
|
96
|
+
readonly cdp: Cdp;
|
|
97
|
+
private dialogHandler;
|
|
98
|
+
private dialogPreference;
|
|
99
|
+
private readonly listeners;
|
|
100
|
+
constructor(cdp: Cdp);
|
|
101
|
+
private ensureAgent;
|
|
102
|
+
/**
|
|
103
|
+
* 调用页内 `window.__keveAgent` 的某个方法。
|
|
104
|
+
*
|
|
105
|
+
* 刻意不走 `Runtime.callFunctionOn`:isolated world 里每次求值都是独立表达式,
|
|
106
|
+
* 用 JSON 组装调用最简单,且 agentDom 的入参全是可序列化的 ops/字面量。
|
|
107
|
+
*/
|
|
108
|
+
callAgent<T = any>(method: string, args: any[], _options?: any): Promise<T>;
|
|
109
|
+
locator(selector: string): AgentLocator;
|
|
110
|
+
getByText(text: string, options?: any): AgentLocator;
|
|
111
|
+
getByRole(role: string, options?: any): AgentLocator;
|
|
112
|
+
ariaSnapshot(_options?: {
|
|
113
|
+
mode?: string;
|
|
114
|
+
}): Promise<string>;
|
|
115
|
+
url(): Promise<string>;
|
|
116
|
+
title(): Promise<string>;
|
|
117
|
+
goto(url: string, _options?: any): Promise<void>;
|
|
118
|
+
reload(_options?: any): Promise<void>;
|
|
119
|
+
evaluate(fn: any): Promise<any>;
|
|
120
|
+
/**
|
|
121
|
+
* 读取主世界诊断快照。
|
|
122
|
+
*
|
|
123
|
+
* Cypress 的 CDP 通道没有 domain event 订阅,主世界里的 console/网络采集
|
|
124
|
+
* 结果通过 `documentElement.dataset` 暴露给 isolated world —— 两个世界共享
|
|
125
|
+
* DOM,但不共享 JS 全局,这是唯一的稳定只读通道。
|
|
126
|
+
*/
|
|
127
|
+
readDiagnosticsSnapshot(): Promise<CypressDiagnosticsSnapshot | undefined>;
|
|
128
|
+
screenshot(_options?: any): Promise<AgentScreenshot>;
|
|
129
|
+
viewportSize(): Promise<{
|
|
130
|
+
width: number;
|
|
131
|
+
height: number;
|
|
132
|
+
} | null>;
|
|
133
|
+
/** 调整 AUT iframe 尺寸(只改 runner 里的 iframe 盒子,不触碰被测页 DOM) */
|
|
134
|
+
setViewportSize(size: {
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
}): Promise<void>;
|
|
138
|
+
waitForTimeout(ms: number): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Cypress 下拿不到 Playwright 的页面事件流(Cypress.automation 只暴露命令,
|
|
141
|
+
* 不暴露 CDP 事件订阅)。这里保留注册表,让 agent 的 setupPageListeners 不炸;
|
|
142
|
+
* dialog 由 `setDialogPreference` + 原生 dialog 自动处理兜底。
|
|
143
|
+
*/
|
|
144
|
+
on(event: string, handler: (...args: any[]) => any): void;
|
|
145
|
+
/** 供未来事件桥接使用;当前仅保证接口存在 */
|
|
146
|
+
emit(event: string, ...args: any[]): void;
|
|
147
|
+
setDialogPreference(accept: boolean, promptText?: string): void;
|
|
148
|
+
private dispatchKey;
|
|
149
|
+
private parseKeyCombo;
|
|
150
|
+
private topLevelPoint;
|
|
151
|
+
readonly keyboard: AgentKeyboard;
|
|
152
|
+
/** 最近一次鼠标坐标(AUT 视口坐标),供 down/up 复用 */
|
|
153
|
+
private lastMouse;
|
|
154
|
+
readonly mouse: AgentMouse;
|
|
155
|
+
private createMouse;
|
|
156
|
+
dispose(): void;
|
|
157
|
+
}
|
|
158
|
+
export declare function createCyAgentPage(cdp: Cdp): CyAgentPage;
|
|
159
|
+
export {};
|