@burdenoff/ui-engine 2026.1127.5 → 2026.1129.2
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 +53 -4
- package/dist/analyze/messages.d.ts +7 -0
- package/dist/analyze/rules/heal-consequential.d.ts +2 -0
- package/dist/analyze/rules/popup-handler-loop.d.ts +2 -0
- package/dist/analyze/types.d.ts +24 -1
- package/dist/analyze.js +1 -1
- package/dist/dom-runtime.iife.js +1 -1
- package/dist/dom-runtime.js +2 -2
- package/dist/drivers.js +9 -7
- package/dist/heal/answer.d.ts +26 -0
- package/dist/heal/consequence.d.ts +74 -0
- package/dist/heal/index.d.ts +19 -0
- package/dist/heal/modes.d.ts +25 -0
- package/dist/heal/popup-limits.d.ts +11 -0
- package/dist/heal/popup.d.ts +48 -0
- package/dist/heal/question.d.ts +41 -0
- package/dist/heal/target-from-node.d.ts +9 -0
- package/dist/heal/types.d.ts +134 -0
- package/dist/heal/verify-rules.d.ts +19 -0
- package/dist/heal/verify.d.ts +52 -0
- package/dist/heal.d.ts +2 -0
- package/dist/heal.js +106 -0
- package/dist/index-20bbwwc9.js +37 -0
- package/dist/{index-xner4tgb.js → index-5cffktzd.js} +481 -3
- package/dist/index-6h7ah1dw.js +328 -0
- package/dist/{index-8w0f6rsz.js → index-6kva2gvd.js} +3 -3
- package/dist/{index-ct2xctrq.js → index-70vm0qz8.js} +2 -2
- package/dist/{index-21hvbvx1.js → index-8w31tpfq.js} +21 -8
- package/dist/{index-r2a9rftv.js → index-eff47v1g.js} +424 -17
- package/dist/{index-9s5nphx0.js → index-hw5npwsv.js} +1 -37
- package/dist/{index-ycs2bz1a.js → index-mhv6a02p.js} +11 -166
- package/dist/index-p5823rpv.js +0 -0
- package/dist/{index-5k26keah.js → index-qg9yfr7r.js} +16 -67
- package/dist/{index-c88tvyj1.js → index-qmv3ar39.js} +1 -1
- package/dist/index-t55wvhvh.js +229 -0
- package/dist/{index-77pcz6n3.js → index-vnv9tp11.js} +4 -2
- package/dist/index-w9jc25y9.js +306 -0
- package/dist/{index-s7qdecev.js → index-xdtanv9b.js} +358 -4
- package/dist/{index-vg8r40y7.js → index-yc0jgph6.js} +7 -0
- package/dist/index-zhbwhdya.js +407 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +142 -24
- package/dist/interpret/driver.d.ts +14 -0
- package/dist/interpret/errors.d.ts +11 -2
- package/dist/interpret/events.d.ts +4 -0
- package/dist/interpret/run.d.ts +33 -0
- package/dist/interpret.js +5 -4
- package/dist/script/adapters/from-computer-use.d.ts +124 -0
- package/dist/script/index.d.ts +1 -0
- package/dist/script.js +28 -9
- package/dist/target/index.d.ts +2 -0
- package/dist/target/roles.d.ts +11 -0
- package/dist/target/snapshot-mask.d.ts +49 -0
- package/dist/target/snapshot-tree.d.ts +65 -0
- package/dist/target/snapshot-url.d.ts +6 -0
- package/dist/target/snapshot.d.ts +1 -6
- package/dist/target.js +55 -13
- package/dist/testing.js +2 -2
- package/package.json +7 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Healing modes: reading a mode from stored data, the production cap, and the
|
|
3
|
+
* decision a verified candidate leads to (contract README section 22.2,
|
|
4
|
+
* decision D-P4-11).
|
|
5
|
+
*/
|
|
6
|
+
import { type UiConsequence, type UiHealDecision, type UiHealMode } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* A mode from stored or transported data: the node-data names, or the
|
|
9
|
+
* GraphQL enum names in capitals. Anything else is undefined.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseHealMode(value: unknown): UiHealMode | undefined;
|
|
12
|
+
/** The lower of a mode and a cap, by rank: a production run never heals above `healingMaxModeProd`. */
|
|
13
|
+
export declare function capHealMode(mode: UiHealMode, max: UiHealMode): UiHealMode;
|
|
14
|
+
/**
|
|
15
|
+
* What a verified candidate leads to:
|
|
16
|
+
* - `off`: no decision (the step fails as it does without healing);
|
|
17
|
+
* - `suggest`: stop and report the candidate;
|
|
18
|
+
* - `heal_with_approval`: stop and ask a person (the run parks, D-P4-11);
|
|
19
|
+
* - `heal_and_continue`: continue with the candidate, unless the element is
|
|
20
|
+
* consequential or the step or a keyword always asks, which asks instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function decideHeal(mode: UiHealMode, verdict: {
|
|
23
|
+
consequence?: UiConsequence | null;
|
|
24
|
+
alwaysAsk?: boolean;
|
|
25
|
+
}): UiHealDecision | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Limits of pop-up handlers (plan P4-06a, threats R7 and C4 of document 24). */
|
|
2
|
+
/** Most handlers tried for one step. */
|
|
3
|
+
export declare const MAX_POPUP_HANDLERS_PER_STEP = 2;
|
|
4
|
+
/** Most handlers an application may hold (the service's limit; the interpreter takes no more). */
|
|
5
|
+
export declare const MAX_POPUP_HANDLERS_PER_APPLICATION = 50;
|
|
6
|
+
/** Most steps of one handler. */
|
|
7
|
+
export declare const MAX_POPUP_HANDLER_STEPS = 10;
|
|
8
|
+
/** Longest URL pattern. */
|
|
9
|
+
export declare const MAX_POPUP_URL_PATTERN = 500;
|
|
10
|
+
/** The wait of a handler step that sets none: a pop-up handler never waits long. */
|
|
11
|
+
export declare const POPUP_HANDLER_STEP_WAIT_MS = 5000;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { UiScriptProblem } from '../analyze/types.js';
|
|
2
|
+
import type { UiScript, UiStep, UiTarget } from '../script/types.js';
|
|
3
|
+
export { MAX_POPUP_HANDLERS_PER_APPLICATION, MAX_POPUP_HANDLERS_PER_STEP, MAX_POPUP_HANDLER_STEPS, MAX_POPUP_URL_PATTERN, POPUP_HANDLER_STEP_WAIT_MS, } from './popup-limits.js';
|
|
4
|
+
/** The actions a handler step may take: it clicks, checks, presses keys, scrolls, hovers or waits. */
|
|
5
|
+
export declare const POPUP_HANDLER_ACTIONS: readonly ["click", "doubleClick", "hover", "check", "pressKey", "scroll", "waitFor"];
|
|
6
|
+
export interface UiPopupHandlerMatch {
|
|
7
|
+
urlPattern?: string;
|
|
8
|
+
target: UiTarget;
|
|
9
|
+
}
|
|
10
|
+
export interface UiPopupHandler {
|
|
11
|
+
id: string;
|
|
12
|
+
match: UiPopupHandlerMatch;
|
|
13
|
+
steps: UiStep[];
|
|
14
|
+
}
|
|
15
|
+
/** A handler's steps as a script, so the parser's checks and the analyzer apply to them. */
|
|
16
|
+
export declare function popupHandlerScript(handler: Pick<UiPopupHandler, 'steps'>): UiScript;
|
|
17
|
+
/**
|
|
18
|
+
* Parse a stored handler. Throws `UiScriptError` when the shape is wrong, a
|
|
19
|
+
* step does not parse (the script parser's checks apply: unique ids,
|
|
20
|
+
* fingerprints, no credentials), or a step uses a library element (handlers
|
|
21
|
+
* carry inline targets only).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseUiPopupHandler(value: unknown): UiPopupHandler;
|
|
24
|
+
/** The `popupHandlerLoop` problems of a parsed handler; empty means the interpreter may run it. */
|
|
25
|
+
export declare function analyzeUiPopupHandler(handler: UiPopupHandler): UiScriptProblem[];
|
|
26
|
+
/** Why a handler given to a run was not used. */
|
|
27
|
+
export interface UiPopupHandlerRejection {
|
|
28
|
+
index: number;
|
|
29
|
+
id?: string;
|
|
30
|
+
reason: 'INVALID' | 'LOOP_RULE' | 'DUPLICATE_ID' | 'LIMIT';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The handlers a run may use, in the order given: each parsed and checked by
|
|
34
|
+
* the `popupHandlerLoop` rule, ids unique, at most 50. The rest are reported.
|
|
35
|
+
*/
|
|
36
|
+
export declare function usablePopupHandlers(values: readonly unknown[]): {
|
|
37
|
+
handlers: UiPopupHandler[];
|
|
38
|
+
rejected: UiPopupHandlerRejection[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* True when an address matches a `*` wildcard pattern, compared without case
|
|
42
|
+
* against the address without query or fragment. A pattern with `scheme://`
|
|
43
|
+
* is matched in parts: the scheme exactly, the host label by label (see
|
|
44
|
+
* `hostMatches`), and the path with `*` matching anything. A pattern without
|
|
45
|
+
* it is matched against the whole address. No regular expression is built,
|
|
46
|
+
* and the work is linear in the address length per pattern part.
|
|
47
|
+
*/
|
|
48
|
+
export declare function matchesUrlPattern(url: string, pattern: string): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UiStepAction, UiTarget } from '../script/types.js';
|
|
2
|
+
import type { UiTreeSnapshot } from '../target/snapshot.js';
|
|
3
|
+
/** Most elements a heal question lists (document 24 C4). */
|
|
4
|
+
export declare const MAX_HEAL_QUESTION_NODES = 400;
|
|
5
|
+
/** Longest element name a heal question shows. */
|
|
6
|
+
export declare const MAX_HEAL_NODE_NAME = 100;
|
|
7
|
+
/** One element as the question lists it. */
|
|
8
|
+
export interface UiHealQuestionNode {
|
|
9
|
+
path: string;
|
|
10
|
+
role: string;
|
|
11
|
+
name: string;
|
|
12
|
+
/** `hidden` for a form field (its value is never sent), `masked` for a masked element. */
|
|
13
|
+
value?: 'hidden' | 'masked';
|
|
14
|
+
masked?: true;
|
|
15
|
+
/** `[x, y, width, height]` in CSS pixels, when the snapshot recorded bounds. */
|
|
16
|
+
bbox?: [number, number, number, number];
|
|
17
|
+
}
|
|
18
|
+
/** The question: a system message, a user message, and the listed elements. */
|
|
19
|
+
export interface UiHealQuestion {
|
|
20
|
+
system: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
nodes: UiHealQuestionNode[];
|
|
23
|
+
/** Elements that could have been listed. */
|
|
24
|
+
candidateCount: number;
|
|
25
|
+
/** True when more elements qualified than the question lists. */
|
|
26
|
+
truncated: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** What the question needs from a heal request. */
|
|
29
|
+
export interface UiHealQuestionInput {
|
|
30
|
+
action: UiStepAction;
|
|
31
|
+
stepSentence?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
target: UiTarget;
|
|
34
|
+
snapshot: Pick<UiTreeSnapshot, 'root' | 'url' | 'title'>;
|
|
35
|
+
}
|
|
36
|
+
/** The system message: what the model is, what it may answer, and that page text is data. */
|
|
37
|
+
export declare const HEAL_SYSTEM_PROMPT: string;
|
|
38
|
+
/** Build the heal question. `maxNodes` can only lower the cap of 400. */
|
|
39
|
+
export declare function buildHealQuestion(input: UiHealQuestionInput, options?: {
|
|
40
|
+
maxNodes?: number;
|
|
41
|
+
}): UiHealQuestion;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UiTarget } from '../script/types.js';
|
|
2
|
+
import type { UiTreeSnapshot } from '../target/snapshot.js';
|
|
3
|
+
import { type SnapshotIndex } from '../target/snapshot-tree.js';
|
|
4
|
+
/**
|
|
5
|
+
* A target for the element at `path`, or null when the path names no
|
|
6
|
+
* element, or no method or frame selector can name it alone. Pass an index
|
|
7
|
+
* from `indexSnapshot` when building several targets from one snapshot.
|
|
8
|
+
*/
|
|
9
|
+
export declare function targetFromSnapshotNode(path: string, snapshot: Pick<UiTreeSnapshot, 'root'>, index?: SnapshotIndex): UiTarget | null;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of UI step healing (spec 10 section 3, plan P4-06a, contract README
|
|
3
|
+
* sections 22.2, 24 and 26.2).
|
|
4
|
+
*
|
|
5
|
+
* When a step's target is no longer found, the interpreter can ask its host
|
|
6
|
+
* for a repaired target (`RunUiScriptOptions.onTargetNotFound`). The host sends
|
|
7
|
+
* the masked request to the workflow service (P4-13), which asks a model one
|
|
8
|
+
* narrow question (`buildHealQuestion`) and reads the answer strictly
|
|
9
|
+
* (`parseHealAnswer`). The engine then checks the candidate on the live page
|
|
10
|
+
* (`verifyHealCandidate`), classifies what acting on it could cause
|
|
11
|
+
* (`classifyConsequence`) and decides, from the effective mode, whether to
|
|
12
|
+
* continue, stop with a suggestion, or stop and ask a person
|
|
13
|
+
* (`HEAL_APPROVAL_REQUIRED`). Nothing here changes a stored target: a
|
|
14
|
+
* proposal changes an element only when a person accepts it (threat P2).
|
|
15
|
+
*/
|
|
16
|
+
import type { UiStepAction, UiTarget } from '../script/types.js';
|
|
17
|
+
import type { UiTreeSnapshot } from '../target/snapshot.js';
|
|
18
|
+
import type { WebRect } from '../target/types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Healing modes of a Use Browser node (`args.state.healing.mode`), lowest first.
|
|
21
|
+
* The GraphQL enum `UiHealingMode` uses the same names in capitals.
|
|
22
|
+
*/
|
|
23
|
+
export declare const UI_HEAL_MODES: readonly ["off", "suggest", "heal_with_approval", "heal_and_continue"];
|
|
24
|
+
export type UiHealMode = (typeof UI_HEAL_MODES)[number];
|
|
25
|
+
/**
|
|
26
|
+
* The rank of each mode, for the production cap (`healingMaxModeProd`). The
|
|
27
|
+
* cap compares ranks from this table, never positions in an enum list.
|
|
28
|
+
*/
|
|
29
|
+
export declare const UI_HEAL_MODE_RANK: Readonly<Record<UiHealMode, number>>;
|
|
30
|
+
/** What the interpreter does with a verified candidate. */
|
|
31
|
+
export type UiHealDecision = 'continue' | 'stop_suggest' | 'ask';
|
|
32
|
+
/** What acting on an element could cause, from the classifier's keyword lists. */
|
|
33
|
+
export declare const UI_CONSEQUENCES: readonly ["payment", "delete", "send_external", "security"];
|
|
34
|
+
export type UiConsequence = (typeof UI_CONSEQUENCES)[number];
|
|
35
|
+
/** A proposed replacement for a step's target. */
|
|
36
|
+
export interface UiHealCandidate {
|
|
37
|
+
/** The snapshot node the answer named (see `snapshot-tree.ts` for the path grammar). */
|
|
38
|
+
nodePath: string;
|
|
39
|
+
/** A multi-method target built from that node (`targetFromSnapshotNode`). */
|
|
40
|
+
proposedTarget: UiTarget;
|
|
41
|
+
/** The model's confidence, 0 to 1, when it gave one. */
|
|
42
|
+
confidence?: number;
|
|
43
|
+
}
|
|
44
|
+
/** The answer to a heal request. */
|
|
45
|
+
export type UiHealAnswer = {
|
|
46
|
+
kind: 'candidate';
|
|
47
|
+
candidate: UiHealCandidate;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'not_present';
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'unavailable';
|
|
52
|
+
reason: string;
|
|
53
|
+
};
|
|
54
|
+
/** The library element a failed step pinned. */
|
|
55
|
+
export interface UiHealElementRef {
|
|
56
|
+
/** The key in the script's `elements`. */
|
|
57
|
+
element: string;
|
|
58
|
+
elementId?: string;
|
|
59
|
+
version?: number;
|
|
60
|
+
}
|
|
61
|
+
/** The target failure codes healing repairs. */
|
|
62
|
+
export declare const UI_HEAL_FAILURE_CODES: readonly ["ELEMENT_NOT_FOUND", "ELEMENT_AMBIGUOUS"];
|
|
63
|
+
export type UiHealFailureCode = (typeof UI_HEAL_FAILURE_CODES)[number];
|
|
64
|
+
/**
|
|
65
|
+
* What the interpreter hands the host when a step's target fails. The
|
|
66
|
+
* snapshot is already masked (`maskSnapshot`); `screenshotMask` holds the
|
|
67
|
+
* rectangles a desk paints over its screenshot before upload (threat R1).
|
|
68
|
+
*/
|
|
69
|
+
export interface UiHealRequest {
|
|
70
|
+
stepPath: string;
|
|
71
|
+
stepId: string;
|
|
72
|
+
/** The step in words (`describeStep`), English. */
|
|
73
|
+
stepSentence: string;
|
|
74
|
+
action: UiStepAction;
|
|
75
|
+
elementRef?: UiHealElementRef;
|
|
76
|
+
/** The target that failed. */
|
|
77
|
+
target: UiTarget;
|
|
78
|
+
/** How the target reads in a sentence (`describeTarget`). */
|
|
79
|
+
description: string;
|
|
80
|
+
failureCode: UiHealFailureCode;
|
|
81
|
+
/** The page address, as the desk reports it. */
|
|
82
|
+
url: string;
|
|
83
|
+
snapshot: UiTreeSnapshot;
|
|
84
|
+
/** The outermost masked elements of the snapshot. */
|
|
85
|
+
maskedPaths: string[];
|
|
86
|
+
screenshotMask: WebRect[];
|
|
87
|
+
}
|
|
88
|
+
/** What the host's `onTargetNotFound` returns. */
|
|
89
|
+
export interface UiHealHookResult {
|
|
90
|
+
answer: UiHealAnswer;
|
|
91
|
+
/** The effective mode after the node setting, the workspace default, the production cap and the flags. */
|
|
92
|
+
mode: UiHealMode;
|
|
93
|
+
/** True when the service says a person must always approve (an always-ask step or keyword). */
|
|
94
|
+
alwaysAsk?: boolean;
|
|
95
|
+
/** The service's own classification of the candidate, when it made one. */
|
|
96
|
+
consequence?: UiConsequence | null;
|
|
97
|
+
/** The fix proposal the service stored, carried into events and the run result. */
|
|
98
|
+
proposalId?: string;
|
|
99
|
+
}
|
|
100
|
+
/** The host's heal hook. It receives the run's abort signal; when the run is cancelled the hook's answer is ignored. */
|
|
101
|
+
export type UiHealHook = (request: UiHealRequest, context: {
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
}) => Promise<UiHealHookResult>;
|
|
104
|
+
/** Why a candidate failed the deterministic check. */
|
|
105
|
+
export declare const UI_HEAL_CHECK_REASONS: readonly ["UNKNOWN_NODE", "HIDDEN_NODE", "ACTION_NOT_HEALABLE", "NOT_FOUND", "NOT_UNIQUE", "NOT_INTERACTABLE", "OTHER_ELEMENT", "WRONG_CONTROL", "OTHER_FRAME", "SENSITIVE_FIELD", "DRIVER_ERROR", "STEP_FAILED"];
|
|
106
|
+
export type UiHealCheckReason = (typeof UI_HEAL_CHECK_REASONS)[number];
|
|
107
|
+
/** How a heal ended, as events and the run result report it. */
|
|
108
|
+
export type UiHealOutcome = 'healed' | 'suggested' | 'approval_required' | 'not_present' | 'unavailable' | 'check_failed';
|
|
109
|
+
/** A heal's report on a step: in `STEP_FAILED.detail.heal` and `UiRunFailure.heal`. */
|
|
110
|
+
export interface UiHealReport {
|
|
111
|
+
outcome: UiHealOutcome;
|
|
112
|
+
/** The effective mode, once the host answered. */
|
|
113
|
+
mode?: UiHealMode;
|
|
114
|
+
decision?: UiHealDecision;
|
|
115
|
+
candidate?: UiHealCandidate;
|
|
116
|
+
proposalId?: string;
|
|
117
|
+
consequence?: UiConsequence;
|
|
118
|
+
alwaysAsk?: boolean;
|
|
119
|
+
/** A short code: the check reason, or why no answer came. */
|
|
120
|
+
reason?: string;
|
|
121
|
+
/** The step ran on the healed target and failed with this code (its action may have taken effect). */
|
|
122
|
+
stepFailureCode?: string;
|
|
123
|
+
/** True when the step was tried on the healed target. */
|
|
124
|
+
attempted?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** Healing settings a host passes with the run (from the node data and the workspace's RPA settings). */
|
|
127
|
+
export interface UiHealSettings {
|
|
128
|
+
/** Step ids that always ask a person when healed (`args.state.healing.alwaysAskStepIds`). */
|
|
129
|
+
alwaysAskStepIds?: readonly string[];
|
|
130
|
+
/** The workspace's always-ask keyword phrases (D-P4-12): case-folded phrases, never regular expressions. */
|
|
131
|
+
keywords?: readonly string[];
|
|
132
|
+
/** Extra snapshot paths to mask before the request leaves the desk. */
|
|
133
|
+
maskedPaths?: readonly string[];
|
|
134
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which steps healing may repair, and which control types fit each action
|
|
3
|
+
* (plan P4-06a, threat R2 of document 24). Pure tables shared by the question
|
|
4
|
+
* builder (to rank elements), the verifier (to refuse a candidate whose
|
|
5
|
+
* control does not fit) and the interpreter (to decide whether to ask).
|
|
6
|
+
*/
|
|
7
|
+
import type { UiStepAction } from '../script/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* The actions a heal may repair. `typeSecret` and `login` are never healed:
|
|
10
|
+
* a secret is never typed into an element a model chose. Navigation, flow,
|
|
11
|
+
* page reads and screenshots have no target to repair.
|
|
12
|
+
*/
|
|
13
|
+
export declare const HEALABLE_ACTIONS: ReadonlySet<UiStepAction>;
|
|
14
|
+
/** Roles an element of the snapshot or the page may have for the action, or undefined when any role fits (reads, waits). */
|
|
15
|
+
export declare function compatibleRoles(action: UiStepAction): ReadonlySet<string> | undefined;
|
|
16
|
+
/** The actions that type or change a field's value: they never act on a password or masked field. */
|
|
17
|
+
export declare const VALUE_ACTIONS: ReadonlySet<UiStepAction>;
|
|
18
|
+
/** Roles worth listing in a heal question even without a name: the controls steps act on. */
|
|
19
|
+
export declare const ACTIONABLE_ROLES: ReadonlySet<string>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `verifyHealCandidate` (plan P4-06a, threat R2 of document 24): the
|
|
3
|
+
* deterministic check every heal candidate passes before it is used or
|
|
4
|
+
* suggested. A model's answer is a hint; this check decides.
|
|
5
|
+
*
|
|
6
|
+
* A candidate passes only when:
|
|
7
|
+
* 1. the step's action is one healing repairs (never `typeSecret` or `login`);
|
|
8
|
+
* 2. its node is a visible element of the (masked) snapshot;
|
|
9
|
+
* 3. its proposed target resolves on the live page, in one attempt, to
|
|
10
|
+
* exactly one element that is visible, and enabled for a step that acts;
|
|
11
|
+
* 4. that element's control type fits the action (a click needs a button,
|
|
12
|
+
* link, checkbox, menu item, tab or option; a type step a text box), on
|
|
13
|
+
* the page and in the snapshot alike;
|
|
14
|
+
* 5. it is in the same frame as the failed step: the desk compares the two
|
|
15
|
+
* frames' origins when it can (`UiDriver.frameOrigin`), otherwise the two
|
|
16
|
+
* frame chains must be the same;
|
|
17
|
+
* 6. for a step that types or changes a value, it is not a password, secret
|
|
18
|
+
* or masked field;
|
|
19
|
+
* 7. in the top document, its position on the page matches the snapshot node
|
|
20
|
+
* (so a target that happens to resolve elsewhere is refused).
|
|
21
|
+
*/
|
|
22
|
+
import type { UiDriver, UiStepContext } from '../interpret/driver.js';
|
|
23
|
+
import type { UiStep, UiTarget } from '../script/types.js';
|
|
24
|
+
import type { UiTreeSnapshot } from '../target/snapshot.js';
|
|
25
|
+
import { type SnapshotIndex } from '../target/snapshot-tree.js';
|
|
26
|
+
import type { UiHealElementInfo } from './consequence.js';
|
|
27
|
+
import type { UiHealCandidate, UiHealCheckReason } from './types.js';
|
|
28
|
+
/** How far, in CSS pixels, the element's centre may be from the snapshot node's centre. */
|
|
29
|
+
export declare const HEAL_POSITION_TOLERANCE_PX = 24;
|
|
30
|
+
export interface VerifyHealContext {
|
|
31
|
+
/** The snapshot the candidate's node path belongs to (the masked copy the question was built from). */
|
|
32
|
+
snapshot: Pick<UiTreeSnapshot, 'root'>;
|
|
33
|
+
/** The target that failed. */
|
|
34
|
+
failedTarget: UiTarget;
|
|
35
|
+
/** The step's driver context. */
|
|
36
|
+
stepContext: UiStepContext;
|
|
37
|
+
/** A prepared index of the snapshot. */
|
|
38
|
+
index?: SnapshotIndex;
|
|
39
|
+
}
|
|
40
|
+
export type UiHealCheck = {
|
|
41
|
+
ok: true;
|
|
42
|
+
role: string;
|
|
43
|
+
name: string;
|
|
44
|
+
element: UiHealElementInfo;
|
|
45
|
+
/** The element is sensitive or masked, so its words could not be read. */
|
|
46
|
+
sensitive: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
reason: UiHealCheckReason;
|
|
50
|
+
};
|
|
51
|
+
/** Check a heal candidate on the live page. Never throws: a desk failure is `DRIVER_ERROR`. */
|
|
52
|
+
export declare function verifyHealCandidate(driver: UiDriver, candidate: UiHealCandidate, step: Pick<UiStep, 'action' | 'id'>, context: VerifyHealContext): Promise<UiHealCheck>;
|
package/dist/heal.d.ts
ADDED
package/dist/heal.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import"./index-cs6acyjn.js";
|
|
2
|
+
import"./index-qmv3ar39.js";
|
|
3
|
+
import {
|
|
4
|
+
UI_HEAL_MODES2,
|
|
5
|
+
UI_HEAL_MODE_RANK2,
|
|
6
|
+
UI_CONSEQUENCES2,
|
|
7
|
+
UI_HEAL_FAILURE_CODES2,
|
|
8
|
+
UI_HEAL_CHECK_REASONS2,
|
|
9
|
+
parseHealMode2,
|
|
10
|
+
capHealMode2,
|
|
11
|
+
decideHeal2,
|
|
12
|
+
POPUP_HANDLER_ACTIONS2,
|
|
13
|
+
popupHandlerScript2,
|
|
14
|
+
parseUiPopupHandler2,
|
|
15
|
+
analyzeUiPopupHandler2,
|
|
16
|
+
usablePopupHandlers2,
|
|
17
|
+
matchesUrlPattern2,
|
|
18
|
+
HEAL_POSITION_TOLERANCE_PX2,
|
|
19
|
+
verifyHealCandidate2
|
|
20
|
+
} from "./index-w9jc25y9.js";
|
|
21
|
+
import {
|
|
22
|
+
MAX_HEAL_QUESTION_NODES2,
|
|
23
|
+
MAX_HEAL_NODE_NAME2,
|
|
24
|
+
HEAL_SYSTEM_PROMPT2,
|
|
25
|
+
buildHealQuestion2,
|
|
26
|
+
targetFromSnapshotNode2,
|
|
27
|
+
MAX_HEAL_ANSWER_LENGTH2,
|
|
28
|
+
parseHealAnswer2
|
|
29
|
+
} from "./index-6h7ah1dw.js";
|
|
30
|
+
import {
|
|
31
|
+
MAX_HEAL_KEYWORDS2,
|
|
32
|
+
MAX_HEAL_KEYWORD_LENGTH2,
|
|
33
|
+
CONSEQUENCE_KEYWORDS2,
|
|
34
|
+
keywordWords2,
|
|
35
|
+
usableKeywords2,
|
|
36
|
+
classifyConsequence2,
|
|
37
|
+
elementInfoFromTarget2,
|
|
38
|
+
HEALABLE_ACTIONS2,
|
|
39
|
+
compatibleRoles2,
|
|
40
|
+
VALUE_ACTIONS2,
|
|
41
|
+
MAX_POPUP_HANDLERS_PER_STEP2,
|
|
42
|
+
MAX_POPUP_HANDLERS_PER_APPLICATION2,
|
|
43
|
+
MAX_POPUP_HANDLER_STEPS2,
|
|
44
|
+
MAX_POPUP_URL_PATTERN2,
|
|
45
|
+
POPUP_HANDLER_STEP_WAIT_MS2
|
|
46
|
+
} from "./index-xdtanv9b.js";
|
|
47
|
+
import {
|
|
48
|
+
SNAPSHOT_ROOT_PATH2,
|
|
49
|
+
MAX_SNAPSHOT_PATH_LENGTH2,
|
|
50
|
+
isSnapshotPath2,
|
|
51
|
+
walkSnapshot2,
|
|
52
|
+
snapshotNodeAt2,
|
|
53
|
+
indexSnapshot2,
|
|
54
|
+
MASKED_MARKER2,
|
|
55
|
+
MAX_MASKED_PATHS2,
|
|
56
|
+
maskSnapshot2
|
|
57
|
+
} from "./index-zhbwhdya.js";
|
|
58
|
+
export {
|
|
59
|
+
CONSEQUENCE_KEYWORDS2 as CONSEQUENCE_KEYWORDS,
|
|
60
|
+
HEALABLE_ACTIONS2 as HEALABLE_ACTIONS,
|
|
61
|
+
HEAL_POSITION_TOLERANCE_PX2 as HEAL_POSITION_TOLERANCE_PX,
|
|
62
|
+
HEAL_SYSTEM_PROMPT2 as HEAL_SYSTEM_PROMPT,
|
|
63
|
+
MASKED_MARKER2 as MASKED_MARKER,
|
|
64
|
+
MAX_HEAL_ANSWER_LENGTH2 as MAX_HEAL_ANSWER_LENGTH,
|
|
65
|
+
MAX_HEAL_KEYWORDS2 as MAX_HEAL_KEYWORDS,
|
|
66
|
+
MAX_HEAL_KEYWORD_LENGTH2 as MAX_HEAL_KEYWORD_LENGTH,
|
|
67
|
+
MAX_HEAL_NODE_NAME2 as MAX_HEAL_NODE_NAME,
|
|
68
|
+
MAX_HEAL_QUESTION_NODES2 as MAX_HEAL_QUESTION_NODES,
|
|
69
|
+
MAX_MASKED_PATHS2 as MAX_MASKED_PATHS,
|
|
70
|
+
MAX_POPUP_HANDLERS_PER_APPLICATION2 as MAX_POPUP_HANDLERS_PER_APPLICATION,
|
|
71
|
+
MAX_POPUP_HANDLERS_PER_STEP2 as MAX_POPUP_HANDLERS_PER_STEP,
|
|
72
|
+
MAX_POPUP_HANDLER_STEPS2 as MAX_POPUP_HANDLER_STEPS,
|
|
73
|
+
MAX_POPUP_URL_PATTERN2 as MAX_POPUP_URL_PATTERN,
|
|
74
|
+
MAX_SNAPSHOT_PATH_LENGTH2 as MAX_SNAPSHOT_PATH_LENGTH,
|
|
75
|
+
POPUP_HANDLER_ACTIONS2 as POPUP_HANDLER_ACTIONS,
|
|
76
|
+
POPUP_HANDLER_STEP_WAIT_MS2 as POPUP_HANDLER_STEP_WAIT_MS,
|
|
77
|
+
SNAPSHOT_ROOT_PATH2 as SNAPSHOT_ROOT_PATH,
|
|
78
|
+
UI_CONSEQUENCES2 as UI_CONSEQUENCES,
|
|
79
|
+
UI_HEAL_CHECK_REASONS2 as UI_HEAL_CHECK_REASONS,
|
|
80
|
+
UI_HEAL_FAILURE_CODES2 as UI_HEAL_FAILURE_CODES,
|
|
81
|
+
UI_HEAL_MODES2 as UI_HEAL_MODES,
|
|
82
|
+
UI_HEAL_MODE_RANK2 as UI_HEAL_MODE_RANK,
|
|
83
|
+
VALUE_ACTIONS2 as VALUE_ACTIONS,
|
|
84
|
+
analyzeUiPopupHandler2 as analyzeUiPopupHandler,
|
|
85
|
+
buildHealQuestion2 as buildHealQuestion,
|
|
86
|
+
capHealMode2 as capHealMode,
|
|
87
|
+
classifyConsequence2 as classifyConsequence,
|
|
88
|
+
compatibleRoles2 as compatibleRoles,
|
|
89
|
+
decideHeal2 as decideHeal,
|
|
90
|
+
elementInfoFromTarget2 as elementInfoFromTarget,
|
|
91
|
+
indexSnapshot2 as indexSnapshot,
|
|
92
|
+
isSnapshotPath2 as isSnapshotPath,
|
|
93
|
+
keywordWords2 as keywordWords,
|
|
94
|
+
maskSnapshot2 as maskSnapshot,
|
|
95
|
+
matchesUrlPattern2 as matchesUrlPattern,
|
|
96
|
+
parseHealAnswer2 as parseHealAnswer,
|
|
97
|
+
parseHealMode2 as parseHealMode,
|
|
98
|
+
parseUiPopupHandler2 as parseUiPopupHandler,
|
|
99
|
+
popupHandlerScript2 as popupHandlerScript,
|
|
100
|
+
snapshotNodeAt2 as snapshotNodeAt,
|
|
101
|
+
targetFromSnapshotNode2 as targetFromSnapshotNode,
|
|
102
|
+
usableKeywords2 as usableKeywords,
|
|
103
|
+
usablePopupHandlers2 as usablePopupHandlers,
|
|
104
|
+
verifyHealCandidate2 as verifyHealCandidate,
|
|
105
|
+
walkSnapshot2 as walkSnapshot
|
|
106
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/script/limits.ts
|
|
2
|
+
var UI_SCRIPT_VERSION2 = 1;
|
|
3
|
+
var MAX_SCRIPT_STEPS2 = 500;
|
|
4
|
+
var MAX_SCRIPT_BYTES2 = 1024 * 1024;
|
|
5
|
+
var MAX_FLOW_DEPTH2 = 8;
|
|
6
|
+
var MAX_EXPRESSION_DEPTH2 = 16;
|
|
7
|
+
var MAX_EXPRESSION_ITEMS2 = 1000;
|
|
8
|
+
var MAX_OPERATOR_ARGS2 = 16;
|
|
9
|
+
var MAX_SCRIPT_INPUTS2 = 100;
|
|
10
|
+
var MAX_SCRIPT_OUTPUTS2 = 100;
|
|
11
|
+
var MAX_SCRIPT_VARIABLES2 = 100;
|
|
12
|
+
var MAX_SCRIPT_ELEMENTS2 = 500;
|
|
13
|
+
var MAX_TARGET_METHODS2 = 8;
|
|
14
|
+
var MAX_FRAME_DEPTH2 = 8;
|
|
15
|
+
var MAX_EXTRACT_FIELDS2 = 50;
|
|
16
|
+
var MAX_LIST_ITEMS2 = 5000;
|
|
17
|
+
var MAX_LIST_PAGES2 = 50;
|
|
18
|
+
var MAX_LOOP_ITERATIONS2 = 1e4;
|
|
19
|
+
var MAX_RETRY_ATTEMPTS2 = 10;
|
|
20
|
+
var MAX_STEP_TIMEOUT_MS2 = 600000;
|
|
21
|
+
var MAX_DELAY_MS2 = 60000;
|
|
22
|
+
var MAX_KEYS2 = 8;
|
|
23
|
+
var MAX_SELECT_VALUES2 = 50;
|
|
24
|
+
var MAX_SELECTOR_LENGTH2 = 500;
|
|
25
|
+
var MAX_URL_LENGTH2 = 4096;
|
|
26
|
+
var MAX_LABEL_LENGTH2 = 512;
|
|
27
|
+
var MAX_TEXT_LENGTH2 = 1e4;
|
|
28
|
+
var MAX_INTENT_LENGTH2 = 500;
|
|
29
|
+
var MAX_NAME_LENGTH2 = 64;
|
|
30
|
+
var LEGACY_MAX_BROWSER_STEPS2 = 100;
|
|
31
|
+
var LEGACY_MAX_STEPS_BYTES2 = 256 * 1024;
|
|
32
|
+
var LEGACY_MAX_STEP_TIMEOUT_MS2 = 60000;
|
|
33
|
+
function jsonByteLength2(value) {
|
|
34
|
+
return new TextEncoder().encode(JSON.stringify(value) ?? "").length;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { UI_SCRIPT_VERSION2, MAX_SCRIPT_STEPS2, MAX_SCRIPT_BYTES2, MAX_FLOW_DEPTH2, MAX_EXPRESSION_DEPTH2, MAX_EXPRESSION_ITEMS2, MAX_OPERATOR_ARGS2, MAX_SCRIPT_INPUTS2, MAX_SCRIPT_OUTPUTS2, MAX_SCRIPT_VARIABLES2, MAX_SCRIPT_ELEMENTS2, MAX_TARGET_METHODS2, MAX_FRAME_DEPTH2, MAX_EXTRACT_FIELDS2, MAX_LIST_ITEMS2, MAX_LIST_PAGES2, MAX_LOOP_ITERATIONS2, MAX_RETRY_ATTEMPTS2, MAX_STEP_TIMEOUT_MS2, MAX_DELAY_MS2, MAX_KEYS2, MAX_SELECT_VALUES2, MAX_SELECTOR_LENGTH2, MAX_URL_LENGTH2, MAX_LABEL_LENGTH2, MAX_TEXT_LENGTH2, MAX_INTENT_LENGTH2, MAX_NAME_LENGTH2, LEGACY_MAX_BROWSER_STEPS2, LEGACY_MAX_STEPS_BYTES2, LEGACY_MAX_STEP_TIMEOUT_MS2, jsonByteLength2 };
|