sentienceapi 0.92.2 → 0.93.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/README.md +152 -54
- package/dist/actions.d.ts +33 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +81 -3
- package/dist/actions.js.map +1 -1
- package/dist/agent-runtime.d.ts +190 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +257 -0
- package/dist/agent-runtime.js.map +1 -0
- package/dist/canonicalization.d.ts +126 -0
- package/dist/canonicalization.d.ts.map +1 -0
- package/dist/canonicalization.js +161 -0
- package/dist/canonicalization.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/ordinal.d.ts +90 -0
- package/dist/ordinal.d.ts.map +1 -0
- package/dist/ordinal.js +249 -0
- package/dist/ordinal.js.map +1 -0
- package/dist/snapshot-diff.d.ts +8 -15
- package/dist/snapshot-diff.d.ts.map +1 -1
- package/dist/snapshot-diff.js +38 -43
- package/dist/snapshot-diff.js.map +1 -1
- package/dist/snapshot.js +2 -0
- package/dist/snapshot.js.map +1 -1
- package/dist/tracing/indexer.d.ts.map +1 -1
- package/dist/tracing/indexer.js +3 -46
- package/dist/tracing/indexer.js.map +1 -1
- package/dist/tracing/types.d.ts +19 -0
- package/dist/tracing/types.d.ts.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/verification.d.ts +177 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +315 -0
- package/dist/verification.js.map +1 -0
- package/package.json +1 -1
- package/src/extension/injected_api.js +9 -2
- package/src/extension/manifest.json +1 -1
- package/src/extension/pkg/sentience_core_bg.wasm +0 -0
- package/src/extension/release.json +47 -46
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared canonicalization utilities for snapshot comparison and indexing.
|
|
3
|
+
*
|
|
4
|
+
* This module provides consistent normalization functions used by both:
|
|
5
|
+
* - tracing/indexer.ts (for computing stable digests)
|
|
6
|
+
* - snapshot-diff.ts (for computing diff_status labels)
|
|
7
|
+
*
|
|
8
|
+
* By sharing these helpers, we ensure consistent behavior:
|
|
9
|
+
* - Same text normalization (whitespace, case, length)
|
|
10
|
+
* - Same bbox rounding (2px precision)
|
|
11
|
+
* - Same change detection thresholds
|
|
12
|
+
*/
|
|
13
|
+
export interface BBox {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
export interface VisualCues {
|
|
20
|
+
is_primary?: boolean;
|
|
21
|
+
is_clickable?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ElementData {
|
|
24
|
+
id?: number;
|
|
25
|
+
role?: string;
|
|
26
|
+
text?: string | null;
|
|
27
|
+
bbox?: BBox;
|
|
28
|
+
visual_cues?: VisualCues;
|
|
29
|
+
is_primary?: boolean;
|
|
30
|
+
is_clickable?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface CanonicalElement {
|
|
33
|
+
id: number | undefined;
|
|
34
|
+
role: string;
|
|
35
|
+
text_norm: string;
|
|
36
|
+
bbox: BBox;
|
|
37
|
+
is_primary: boolean;
|
|
38
|
+
is_clickable: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Normalize text for canonical comparison.
|
|
42
|
+
*
|
|
43
|
+
* Transforms:
|
|
44
|
+
* - Trims leading/trailing whitespace
|
|
45
|
+
* - Collapses internal whitespace to single spaces
|
|
46
|
+
* - Lowercases
|
|
47
|
+
* - Caps length
|
|
48
|
+
*
|
|
49
|
+
* @param text - Input text (may be undefined/null)
|
|
50
|
+
* @param maxLen - Maximum length to retain (default: 80)
|
|
51
|
+
* @returns Normalized text string (empty string if input is falsy)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* normalizeText(" Hello World ") // "hello world"
|
|
55
|
+
* normalizeText(undefined) // ""
|
|
56
|
+
*/
|
|
57
|
+
export declare function normalizeText(text: string | undefined | null, maxLen?: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Round bbox coordinates to reduce noise.
|
|
60
|
+
*
|
|
61
|
+
* Snaps coordinates to grid of `precision` pixels to ignore
|
|
62
|
+
* sub-pixel rendering differences.
|
|
63
|
+
*
|
|
64
|
+
* @param bbox - Bounding box with x, y, width, height
|
|
65
|
+
* @param precision - Grid size in pixels (default: 2)
|
|
66
|
+
* @returns Rounded bbox with integer coordinates
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* roundBBox({x: 101, y: 203, width: 50, height: 25})
|
|
70
|
+
* // {x: 100, y: 202, width: 50, height: 24}
|
|
71
|
+
*/
|
|
72
|
+
export declare function roundBBox(bbox: Partial<BBox>, precision?: number): BBox;
|
|
73
|
+
/**
|
|
74
|
+
* Check if two bboxes are equal within a threshold.
|
|
75
|
+
*
|
|
76
|
+
* @param bbox1 - First bounding box
|
|
77
|
+
* @param bbox2 - Second bounding box
|
|
78
|
+
* @param threshold - Maximum allowed difference in pixels (default: 5.0)
|
|
79
|
+
* @returns True if all bbox properties differ by less than threshold
|
|
80
|
+
*/
|
|
81
|
+
export declare function bboxEqual(bbox1: Partial<BBox>, bbox2: Partial<BBox>, threshold?: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Check if two bboxes differ beyond the threshold.
|
|
84
|
+
*
|
|
85
|
+
* This is the inverse of bboxEqual, provided for semantic clarity
|
|
86
|
+
* in diff detection code.
|
|
87
|
+
*
|
|
88
|
+
* @param bbox1 - First bounding box
|
|
89
|
+
* @param bbox2 - Second bounding box
|
|
90
|
+
* @param threshold - Maximum allowed difference in pixels (default: 5.0)
|
|
91
|
+
* @returns True if any bbox property differs by more than threshold
|
|
92
|
+
*/
|
|
93
|
+
export declare function bboxChanged(bbox1: Partial<BBox>, bbox2: Partial<BBox>, threshold?: number): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Create canonical representation of an element for comparison/hashing.
|
|
96
|
+
*
|
|
97
|
+
* Extracts and normalizes the fields that matter for identity:
|
|
98
|
+
* - id, role, normalized text, rounded bbox
|
|
99
|
+
* - is_primary, is_clickable from visual_cues
|
|
100
|
+
*
|
|
101
|
+
* @param elem - Raw element object
|
|
102
|
+
* @returns Canonical element object with normalized fields
|
|
103
|
+
*/
|
|
104
|
+
export declare function canonicalizeElement(elem: ElementData): CanonicalElement;
|
|
105
|
+
/**
|
|
106
|
+
* Check if two elements have equal content (ignoring position).
|
|
107
|
+
*
|
|
108
|
+
* Compares normalized text, role, and visual cues.
|
|
109
|
+
*
|
|
110
|
+
* @param elem1 - First element (raw or canonical)
|
|
111
|
+
* @param elem2 - Second element (raw or canonical)
|
|
112
|
+
* @returns True if content is equal after normalization
|
|
113
|
+
*/
|
|
114
|
+
export declare function contentEqual(elem1: ElementData, elem2: ElementData): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Check if two elements have different content (ignoring position).
|
|
117
|
+
*
|
|
118
|
+
* This is the inverse of contentEqual, provided for semantic clarity
|
|
119
|
+
* in diff detection code.
|
|
120
|
+
*
|
|
121
|
+
* @param elem1 - First element
|
|
122
|
+
* @param elem2 - Second element
|
|
123
|
+
* @returns True if content differs after normalization
|
|
124
|
+
*/
|
|
125
|
+
export declare function contentChanged(elem1: ElementData, elem2: ElementData): boolean;
|
|
126
|
+
//# sourceMappingURL=canonicalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalization.d.ts","sourceRoot":"","sources":["../src/canonicalization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAA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AAmB,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,CAoBvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAW5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE9E"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared canonicalization utilities for snapshot comparison and indexing.
|
|
4
|
+
*
|
|
5
|
+
* This module provides consistent normalization functions used by both:
|
|
6
|
+
* - tracing/indexer.ts (for computing stable digests)
|
|
7
|
+
* - snapshot-diff.ts (for computing diff_status labels)
|
|
8
|
+
*
|
|
9
|
+
* By sharing these helpers, we ensure consistent behavior:
|
|
10
|
+
* - Same text normalization (whitespace, case, length)
|
|
11
|
+
* - Same bbox rounding (2px precision)
|
|
12
|
+
* - Same change detection thresholds
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.normalizeText = normalizeText;
|
|
16
|
+
exports.roundBBox = roundBBox;
|
|
17
|
+
exports.bboxEqual = bboxEqual;
|
|
18
|
+
exports.bboxChanged = bboxChanged;
|
|
19
|
+
exports.canonicalizeElement = canonicalizeElement;
|
|
20
|
+
exports.contentEqual = contentEqual;
|
|
21
|
+
exports.contentChanged = contentChanged;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize text for canonical comparison.
|
|
24
|
+
*
|
|
25
|
+
* Transforms:
|
|
26
|
+
* - Trims leading/trailing whitespace
|
|
27
|
+
* - Collapses internal whitespace to single spaces
|
|
28
|
+
* - Lowercases
|
|
29
|
+
* - Caps length
|
|
30
|
+
*
|
|
31
|
+
* @param text - Input text (may be undefined/null)
|
|
32
|
+
* @param maxLen - Maximum length to retain (default: 80)
|
|
33
|
+
* @returns Normalized text string (empty string if input is falsy)
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* normalizeText(" Hello World ") // "hello world"
|
|
37
|
+
* normalizeText(undefined) // ""
|
|
38
|
+
*/
|
|
39
|
+
function normalizeText(text, maxLen = 80) {
|
|
40
|
+
if (!text)
|
|
41
|
+
return '';
|
|
42
|
+
// Trim and collapse whitespace
|
|
43
|
+
let normalized = text.split(/\s+/).join(' ').trim();
|
|
44
|
+
// Lowercase
|
|
45
|
+
normalized = normalized.toLowerCase();
|
|
46
|
+
// Cap length
|
|
47
|
+
if (normalized.length > maxLen) {
|
|
48
|
+
normalized = normalized.substring(0, maxLen);
|
|
49
|
+
}
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Round bbox coordinates to reduce noise.
|
|
54
|
+
*
|
|
55
|
+
* Snaps coordinates to grid of `precision` pixels to ignore
|
|
56
|
+
* sub-pixel rendering differences.
|
|
57
|
+
*
|
|
58
|
+
* @param bbox - Bounding box with x, y, width, height
|
|
59
|
+
* @param precision - Grid size in pixels (default: 2)
|
|
60
|
+
* @returns Rounded bbox with integer coordinates
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* roundBBox({x: 101, y: 203, width: 50, height: 25})
|
|
64
|
+
* // {x: 100, y: 202, width: 50, height: 24}
|
|
65
|
+
*/
|
|
66
|
+
function roundBBox(bbox, precision = 2) {
|
|
67
|
+
return {
|
|
68
|
+
x: Math.round((bbox.x || 0) / precision) * precision,
|
|
69
|
+
y: Math.round((bbox.y || 0) / precision) * precision,
|
|
70
|
+
width: Math.round((bbox.width || 0) / precision) * precision,
|
|
71
|
+
height: Math.round((bbox.height || 0) / precision) * precision,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if two bboxes are equal within a threshold.
|
|
76
|
+
*
|
|
77
|
+
* @param bbox1 - First bounding box
|
|
78
|
+
* @param bbox2 - Second bounding box
|
|
79
|
+
* @param threshold - Maximum allowed difference in pixels (default: 5.0)
|
|
80
|
+
* @returns True if all bbox properties differ by less than threshold
|
|
81
|
+
*/
|
|
82
|
+
function bboxEqual(bbox1, bbox2, threshold = 5.0) {
|
|
83
|
+
return (Math.abs((bbox1.x || 0) - (bbox2.x || 0)) <= threshold &&
|
|
84
|
+
Math.abs((bbox1.y || 0) - (bbox2.y || 0)) <= threshold &&
|
|
85
|
+
Math.abs((bbox1.width || 0) - (bbox2.width || 0)) <= threshold &&
|
|
86
|
+
Math.abs((bbox1.height || 0) - (bbox2.height || 0)) <= threshold);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if two bboxes differ beyond the threshold.
|
|
90
|
+
*
|
|
91
|
+
* This is the inverse of bboxEqual, provided for semantic clarity
|
|
92
|
+
* in diff detection code.
|
|
93
|
+
*
|
|
94
|
+
* @param bbox1 - First bounding box
|
|
95
|
+
* @param bbox2 - Second bounding box
|
|
96
|
+
* @param threshold - Maximum allowed difference in pixels (default: 5.0)
|
|
97
|
+
* @returns True if any bbox property differs by more than threshold
|
|
98
|
+
*/
|
|
99
|
+
function bboxChanged(bbox1, bbox2, threshold = 5.0) {
|
|
100
|
+
return !bboxEqual(bbox1, bbox2, threshold);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create canonical representation of an element for comparison/hashing.
|
|
104
|
+
*
|
|
105
|
+
* Extracts and normalizes the fields that matter for identity:
|
|
106
|
+
* - id, role, normalized text, rounded bbox
|
|
107
|
+
* - is_primary, is_clickable from visual_cues
|
|
108
|
+
*
|
|
109
|
+
* @param elem - Raw element object
|
|
110
|
+
* @returns Canonical element object with normalized fields
|
|
111
|
+
*/
|
|
112
|
+
function canonicalizeElement(elem) {
|
|
113
|
+
// Extract is_primary and is_clickable from visual_cues if present
|
|
114
|
+
const visualCues = elem.visual_cues || {};
|
|
115
|
+
const isPrimary = typeof visualCues === 'object' && visualCues !== null
|
|
116
|
+
? visualCues.is_primary || false
|
|
117
|
+
: elem.is_primary || false;
|
|
118
|
+
const isClickable = typeof visualCues === 'object' && visualCues !== null
|
|
119
|
+
? visualCues.is_clickable || false
|
|
120
|
+
: elem.is_clickable || false;
|
|
121
|
+
return {
|
|
122
|
+
id: elem.id,
|
|
123
|
+
role: elem.role || '',
|
|
124
|
+
text_norm: normalizeText(elem.text),
|
|
125
|
+
bbox: roundBBox(elem.bbox || { x: 0, y: 0, width: 0, height: 0 }),
|
|
126
|
+
is_primary: isPrimary,
|
|
127
|
+
is_clickable: isClickable,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if two elements have equal content (ignoring position).
|
|
132
|
+
*
|
|
133
|
+
* Compares normalized text, role, and visual cues.
|
|
134
|
+
*
|
|
135
|
+
* @param elem1 - First element (raw or canonical)
|
|
136
|
+
* @param elem2 - Second element (raw or canonical)
|
|
137
|
+
* @returns True if content is equal after normalization
|
|
138
|
+
*/
|
|
139
|
+
function contentEqual(elem1, elem2) {
|
|
140
|
+
// Normalize both elements
|
|
141
|
+
const c1 = canonicalizeElement(elem1);
|
|
142
|
+
const c2 = canonicalizeElement(elem2);
|
|
143
|
+
return (c1.role === c2.role &&
|
|
144
|
+
c1.text_norm === c2.text_norm &&
|
|
145
|
+
c1.is_primary === c2.is_primary &&
|
|
146
|
+
c1.is_clickable === c2.is_clickable);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check if two elements have different content (ignoring position).
|
|
150
|
+
*
|
|
151
|
+
* This is the inverse of contentEqual, provided for semantic clarity
|
|
152
|
+
* in diff detection code.
|
|
153
|
+
*
|
|
154
|
+
* @param elem1 - First element
|
|
155
|
+
* @param elem2 - Second element
|
|
156
|
+
* @returns True if content differs after normalization
|
|
157
|
+
*/
|
|
158
|
+
function contentChanged(elem1, elem2) {
|
|
159
|
+
return !contentEqual(elem1, elem2);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=canonicalization.js.map
|
|
@@ -0,0 +1 @@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AU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI;QACnD,CAAC,CAAC,UAAU,CAAC,YAAY,IAAI,KAAK;QAClC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC;IAEjC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACjE,UAAU,EAAE,SAAS;QACrB,YAAY,EAAE,WAAW;KAC1B,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,KAAkB,EAAE,KAAkB;IACjE,0BAA0B;IAC1B,MAAM,EAAE,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAEtC,OAAO,CACL,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI;QACnB,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS;QAC7B,EAAE,CAAC,UAAU,KAAK,EAAE,CAAC,UAAU;QAC/B,EAAE,CAAC,YAAY,KAAK,EAAE,CAAC,YAAY,CACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,cAAc,CAAC,KAAkB,EAAE,KAAkB;IACnE,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export { SentienceBrowser } from './browser';
|
|
5
5
|
export { snapshot, SnapshotOptions } from './snapshot';
|
|
6
6
|
export { query, find, parseSelector } from './query';
|
|
7
|
-
export { click, typeText, press, clickRect, ClickRect } from './actions';
|
|
7
|
+
export { click, typeText, press, scrollTo, clickRect, ClickRect } from './actions';
|
|
8
8
|
export { waitFor } from './wait';
|
|
9
9
|
export { expect, Expectation } from './expect';
|
|
10
10
|
export { Inspector, inspect } from './inspector';
|
|
@@ -21,4 +21,7 @@ export { SentienceAgent, AgentActResult, HistoryEntry, TokenStats } from './agen
|
|
|
21
21
|
export { SentienceVisualAgent } from './visual-agent';
|
|
22
22
|
export { ConversationalAgent, ExecutionPlan, PlanStep, StepResult, ConversationEntry, ActionType, ActionParameters, } from './conversational-agent';
|
|
23
23
|
export { Tracer, TraceSink, JsonlTraceSink, TraceEvent, TraceEventData } from './tracing';
|
|
24
|
+
export { AssertOutcome, AssertContext, Predicate, urlMatches, urlContains, exists, notExists, elementCount, allOf, anyOf, custom, } from './verification';
|
|
25
|
+
export { AgentRuntime, AssertionRecord } from './agent-runtime';
|
|
26
|
+
export { OrdinalIntent, OrdinalKind, detectOrdinalIntent, selectByOrdinal, boostOrdinalElements, } from './ordinal';
|
|
24
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,g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AAU,EACV,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG1F,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,WAAW,EACX,MAAM,EACN,SAAS,EACT,YAAY,EACZ,KAAK,EACL,KAAK,EACL,MAAM,GACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,EACL,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,oBAAoB,GACrB,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.JsonlTraceSink = exports.TraceSink = exports.Tracer = exports.ConversationalAgent = exports.SentienceVisualAgent = exports.SentienceAgent = exports.GLMProvider = exports.AnthropicProvider = exports.OpenAIProvider = exports.LLMProvider = exports.saveStorageState = exports.findTextRect = exports.clearOverlay = exports.showOverlay = exports.screenshot = exports.read = exports.generate = exports.ScriptGenerator = exports.record = exports.Recorder = exports.inspect = exports.Inspector = exports.Expectation = exports.expect = exports.waitFor = exports.clickRect = exports.press = exports.typeText = exports.click = exports.parseSelector = exports.find = exports.query = exports.snapshot = exports.SentienceBrowser = void 0;
|
|
20
|
+
exports.boostOrdinalElements = exports.selectByOrdinal = exports.detectOrdinalIntent = exports.AgentRuntime = exports.custom = exports.anyOf = exports.allOf = exports.elementCount = exports.notExists = exports.exists = exports.urlContains = exports.urlMatches = exports.JsonlTraceSink = exports.TraceSink = exports.Tracer = exports.ConversationalAgent = exports.SentienceVisualAgent = exports.SentienceAgent = exports.GLMProvider = exports.AnthropicProvider = exports.OpenAIProvider = exports.LLMProvider = exports.saveStorageState = exports.findTextRect = exports.clearOverlay = exports.showOverlay = exports.screenshot = exports.read = exports.generate = exports.ScriptGenerator = exports.record = exports.Recorder = exports.inspect = exports.Inspector = exports.Expectation = exports.expect = exports.waitFor = exports.clickRect = exports.press = exports.typeText = exports.click = exports.parseSelector = exports.find = exports.query = exports.snapshot = exports.SentienceBrowser = void 0;
|
|
21
21
|
var browser_1 = require("./browser");
|
|
22
22
|
Object.defineProperty(exports, "SentienceBrowser", { enumerable: true, get: function () { return browser_1.SentienceBrowser; } });
|
|
23
23
|
var snapshot_1 = require("./snapshot");
|
|
@@ -30,6 +30,7 @@ var actions_1 = require("./actions");
|
|
|
30
30
|
Object.defineProperty(exports, "click", { enumerable: true, get: function () { return actions_1.click; } });
|
|
31
31
|
Object.defineProperty(exports, "typeText", { enumerable: true, get: function () { return actions_1.typeText; } });
|
|
32
32
|
Object.defineProperty(exports, "press", { enumerable: true, get: function () { return actions_1.press; } });
|
|
33
|
+
Object.defineProperty(exports, "scrollTo", { enumerable: true, get: function () { return actions_1.scrollTo; } });
|
|
33
34
|
Object.defineProperty(exports, "clickRect", { enumerable: true, get: function () { return actions_1.clickRect; } });
|
|
34
35
|
var wait_1 = require("./wait");
|
|
35
36
|
Object.defineProperty(exports, "waitFor", { enumerable: true, get: function () { return wait_1.waitFor; } });
|
|
@@ -75,4 +76,21 @@ var tracing_1 = require("./tracing");
|
|
|
75
76
|
Object.defineProperty(exports, "Tracer", { enumerable: true, get: function () { return tracing_1.Tracer; } });
|
|
76
77
|
Object.defineProperty(exports, "TraceSink", { enumerable: true, get: function () { return tracing_1.TraceSink; } });
|
|
77
78
|
Object.defineProperty(exports, "JsonlTraceSink", { enumerable: true, get: function () { return tracing_1.JsonlTraceSink; } });
|
|
79
|
+
// Verification Layer (agent assertion loop)
|
|
80
|
+
var verification_1 = require("./verification");
|
|
81
|
+
Object.defineProperty(exports, "urlMatches", { enumerable: true, get: function () { return verification_1.urlMatches; } });
|
|
82
|
+
Object.defineProperty(exports, "urlContains", { enumerable: true, get: function () { return verification_1.urlContains; } });
|
|
83
|
+
Object.defineProperty(exports, "exists", { enumerable: true, get: function () { return verification_1.exists; } });
|
|
84
|
+
Object.defineProperty(exports, "notExists", { enumerable: true, get: function () { return verification_1.notExists; } });
|
|
85
|
+
Object.defineProperty(exports, "elementCount", { enumerable: true, get: function () { return verification_1.elementCount; } });
|
|
86
|
+
Object.defineProperty(exports, "allOf", { enumerable: true, get: function () { return verification_1.allOf; } });
|
|
87
|
+
Object.defineProperty(exports, "anyOf", { enumerable: true, get: function () { return verification_1.anyOf; } });
|
|
88
|
+
Object.defineProperty(exports, "custom", { enumerable: true, get: function () { return verification_1.custom; } });
|
|
89
|
+
var agent_runtime_1 = require("./agent-runtime");
|
|
90
|
+
Object.defineProperty(exports, "AgentRuntime", { enumerable: true, get: function () { return agent_runtime_1.AgentRuntime; } });
|
|
91
|
+
// Ordinal Support (Phase 3)
|
|
92
|
+
var ordinal_1 = require("./ordinal");
|
|
93
|
+
Object.defineProperty(exports, "detectOrdinalIntent", { enumerable: true, get: function () { return ordinal_1.detectOrdinalIntent; } });
|
|
94
|
+
Object.defineProperty(exports, "selectByOrdinal", { enumerable: true, get: function () { return ordinal_1.selectByOrdinal; } });
|
|
95
|
+
Object.defineProperty(exports, "boostOrdinalElements", { enumerable: true, get: function () { return ordinal_1.boostOrdinalElements; } });
|
|
78
96
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,qCAA6C;AAApC,2GAAA,gBAAgB,OAAA;AACzB,uCAAuD;AAA9C,oGAAA,QAAQ,OAAA;AACjB,iCAAqD;AAA5C,8FAAA,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sD;AAA7C,oHAAA,oBAAoB,OAAA;AAE7B,uCAAuC;AACvC,+DAQgC;AAP9B,2HAAA,mBAAmB,OAAA;AASrB,0BAA0B;AAC1B,qCAA0F;AAAjF,iGAAA,MAAM,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,yGAAA,cAAc,OAAA;AAE1C,4CAA4C;AAC5C,+CAYwB;AARtB,0GAAA,UAAU,OAAA;AACV,2GAAA,WAAW,OAAA;AACX,sGAAA,MAAM,OAAA;AACN,yGAAA,SAAS,OAAA;AACT,4GAAA,YAAY,OAAA;AACZ,qGAAA,KAAK,OAAA;AACL,qGAAA,KAAK,OAAA;AACL,sGAAA,MAAM,OAAA;AAER,iDAAgE;AAAvD,6GAAA,YAAY,OAAA;AAErB,4BAA4B;AAC5B,qCAMmB;AAHjB,8GAAA,mBAAmB,OAAA;AACnB,0GAAA,eAAe,OAAA;AACf,+GAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 3: Ordinal Intent Detection for Semantic Search
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to detect ordinal intent in natural language goals
|
|
5
|
+
* and select elements based on their position within groups.
|
|
6
|
+
*
|
|
7
|
+
* Ordinal operators supported:
|
|
8
|
+
* - Position-based: "first", "second", "third", "1st", "2nd", "3rd", etc.
|
|
9
|
+
* - Relative: "top", "bottom", "last", "next", "previous"
|
|
10
|
+
* - Numeric: "#1", "#2", "number 1", "item 3"
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { detectOrdinalIntent, selectByOrdinal } from 'sentience';
|
|
15
|
+
*
|
|
16
|
+
* const intent = detectOrdinalIntent("click the first search result");
|
|
17
|
+
* // { detected: true, kind: 'nth', n: 1 }
|
|
18
|
+
*
|
|
19
|
+
* const element = selectByOrdinal(elements, "x5-w2-h1", intent);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { Element } from './types';
|
|
23
|
+
export type OrdinalKind = 'first' | 'last' | 'nth' | 'top_k' | 'next' | 'previous';
|
|
24
|
+
export interface OrdinalIntent {
|
|
25
|
+
/** Whether ordinal intent was detected */
|
|
26
|
+
detected: boolean;
|
|
27
|
+
/** Type of ordinal intent */
|
|
28
|
+
kind?: OrdinalKind;
|
|
29
|
+
/** For "nth" kind: 1-indexed position (1=first, 2=second) */
|
|
30
|
+
n?: number;
|
|
31
|
+
/** For "top_k" kind: number of items */
|
|
32
|
+
k?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detect ordinal intent from a goal string.
|
|
36
|
+
*
|
|
37
|
+
* @param goal - Natural language goal (e.g., "click the first search result")
|
|
38
|
+
* @returns OrdinalIntent with detected=true if ordinal intent found
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* detectOrdinalIntent("click the first item")
|
|
43
|
+
* // { detected: true, kind: 'nth', n: 1 }
|
|
44
|
+
*
|
|
45
|
+
* detectOrdinalIntent("select the 3rd option")
|
|
46
|
+
* // { detected: true, kind: 'nth', n: 3 }
|
|
47
|
+
*
|
|
48
|
+
* detectOrdinalIntent("show top 5 results")
|
|
49
|
+
* // { detected: true, kind: 'top_k', k: 5 }
|
|
50
|
+
*
|
|
51
|
+
* detectOrdinalIntent("find the submit button")
|
|
52
|
+
* // { detected: false }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function detectOrdinalIntent(goal: string): OrdinalIntent;
|
|
56
|
+
/**
|
|
57
|
+
* Select element(s) from a list based on ordinal intent.
|
|
58
|
+
*
|
|
59
|
+
* Uses the dominantGroupKey to filter to the "main content" group,
|
|
60
|
+
* then selects by group_index based on the ordinal intent.
|
|
61
|
+
*
|
|
62
|
+
* @param elements - List of elements with group_key and group_index populated
|
|
63
|
+
* @param dominantGroupKey - The most common group key (main content group)
|
|
64
|
+
* @param intent - Detected ordinal intent
|
|
65
|
+
* @param currentElementId - Current element ID (for next/previous navigation)
|
|
66
|
+
* @returns Single Element for nth/first/last, array of Elements for top_k, or null
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const intent = { detected: true, kind: 'nth', n: 1 };
|
|
71
|
+
* const element = selectByOrdinal(elements, "x5-w2-h1", intent);
|
|
72
|
+
* // Returns element with group_key="x5-w2-h1" and group_index=0
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function selectByOrdinal(elements: Element[], dominantGroupKey: string | null | undefined, intent: OrdinalIntent, currentElementId?: number): Element | Element[] | null;
|
|
76
|
+
/**
|
|
77
|
+
* Boost the importance of elements matching ordinal intent.
|
|
78
|
+
*
|
|
79
|
+
* This is useful for integrating ordinal selection with existing
|
|
80
|
+
* importance-based ranking. Elements matching the ordinal intent
|
|
81
|
+
* get a significant importance boost.
|
|
82
|
+
*
|
|
83
|
+
* @param elements - List of elements (not modified)
|
|
84
|
+
* @param dominantGroupKey - The most common group key
|
|
85
|
+
* @param intent - Detected ordinal intent
|
|
86
|
+
* @param boostFactor - Amount to add to importance (default: 10000)
|
|
87
|
+
* @returns A new array with copies of elements, with boosted importance for matches
|
|
88
|
+
*/
|
|
89
|
+
export declare function boostOrdinalElements(elements: Element[], dominantGroupKey: string | null | undefined, intent: OrdinalIntent, boostFactor?: number): Element[];
|
|
90
|
+
//# sourceMappingURL=ordinal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordinal.d.ts","sourceRoot":"","sources":["../src/ordinal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAEnF,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,6DAA6D;IAC7D,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAwDD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAqD/D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,MAAM,EAAE,aAAa,EACrB,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,CAmE5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,OAAO,EAAE,EACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC3C,MAAM,EAAE,aAAa,EACrB,WAAW,GAAE,MAAc,GAC1B,OAAO,EAAE,CAsBX"}
|