sentienceapi 0.90.6 → 0.90.10

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.
Files changed (43) hide show
  1. package/README.md +81 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/textSearch.d.ts +64 -0
  7. package/dist/textSearch.d.ts.map +1 -0
  8. package/dist/textSearch.js +87 -0
  9. package/dist/textSearch.js.map +1 -0
  10. package/dist/tracing/cloud-sink.d.ts +4 -0
  11. package/dist/tracing/cloud-sink.d.ts.map +1 -1
  12. package/dist/tracing/cloud-sink.js +15 -0
  13. package/dist/tracing/cloud-sink.js.map +1 -1
  14. package/dist/tracing/index-schema.d.ts +182 -0
  15. package/dist/tracing/index-schema.d.ts.map +1 -0
  16. package/dist/tracing/index-schema.js +150 -0
  17. package/dist/tracing/index-schema.js.map +1 -0
  18. package/dist/tracing/indexer.d.ts +17 -0
  19. package/dist/tracing/indexer.d.ts.map +1 -0
  20. package/dist/tracing/indexer.js +282 -0
  21. package/dist/tracing/indexer.js.map +1 -0
  22. package/dist/tracing/jsonl-sink.d.ts +4 -0
  23. package/dist/tracing/jsonl-sink.d.ts.map +1 -1
  24. package/dist/tracing/jsonl-sink.js +15 -0
  25. package/dist/tracing/jsonl-sink.js.map +1 -1
  26. package/dist/tracing/tracer-factory.d.ts +11 -5
  27. package/dist/tracing/tracer-factory.d.ts.map +1 -1
  28. package/dist/tracing/tracer-factory.js +16 -7
  29. package/dist/tracing/tracer-factory.js.map +1 -1
  30. package/dist/types.d.ts +98 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/package.json +1 -1
  33. package/src/extension/background.js +222 -52
  34. package/src/extension/content.js +285 -9
  35. package/src/extension/injected_api.js +1224 -189
  36. package/src/extension/manifest.json +10 -4
  37. package/src/extension/pkg/README.md +163 -2
  38. package/src/extension/pkg/sentience_core.d.ts +9 -0
  39. package/src/extension/pkg/sentience_core.js +16 -0
  40. package/src/extension/pkg/sentience_core_bg.wasm +0 -0
  41. package/src/extension/pkg/sentience_core_bg.wasm.d.ts +1 -0
  42. package/src/extension/release.json +115 -0
  43. package/src/extension/test-content.js +4 -0
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Sentience Semantic Visual Grounding Extractor",
4
- "version": "1.0.5",
4
+ "version": "2.0.7",
5
5
  "description": "Extract semantic visual grounding data from web pages",
6
6
  "permissions": ["activeTab", "scripting"],
7
7
  "host_permissions": ["<all_urls>"],
8
+ "background": {
9
+ "service_worker": "background.js",
10
+ "type": "module"
11
+ },
8
12
  "web_accessible_resources": [
9
13
  {
10
14
  "resources": ["pkg/*"],
@@ -15,16 +19,18 @@
15
19
  {
16
20
  "matches": ["<all_urls>"],
17
21
  "js": ["content.js"],
18
- "run_at": "document_start"
22
+ "run_at": "document_start",
23
+ "all_frames": true
19
24
  },
20
25
  {
21
26
  "matches": ["<all_urls>"],
22
27
  "js": ["injected_api.js"],
23
28
  "run_at": "document_idle",
24
- "world": "MAIN"
29
+ "world": "MAIN",
30
+ "all_frames": true
25
31
  }
26
32
  ],
27
33
  "content_security_policy": {
28
34
  "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
29
35
  }
30
- }
36
+ }
@@ -21,6 +21,7 @@ Perfect for AI agents, automation scripts, visual grounding, and accessibility t
21
21
  11. [API Reference](#api-reference)
22
22
  12. [Performance](#performance)
23
23
  13. [Troubleshooting](#troubleshooting)
24
+ 14. Transferred to SentienceAPI Org
24
25
 
25
26
  ---
26
27
 
@@ -151,13 +152,20 @@ Claude/
151
152
 
152
153
  ## User API
153
154
 
154
- ### The Only Function You Need
155
+ ### Core Functions
156
+
157
+ The extension provides two main functions:
158
+
159
+ 1. **`window.sentience.snapshot(options?)`** - Extract page geometry and elements
160
+ 2. **`window.sentience.findTextRect(options)`** - Find exact pixel coordinates of text
161
+
162
+ ### snapshot() - Geometry Extraction
155
163
 
156
164
  ```javascript
157
165
  window.sentience.snapshot(options?)
158
166
  ```
159
167
 
160
- **One function, many capabilities:**
168
+ **Capabilities:**
161
169
  - Get geometry map
162
170
  - Capture screenshot
163
171
  - Filter by role/size/z-index
@@ -213,6 +221,159 @@ await window.sentience.snapshot({
213
221
  }
214
222
  ```
215
223
 
224
+ ### findTextRect() - Text Location Finder
225
+
226
+ Find exact pixel coordinates of any text on the page using the DOM Range API. Perfect for highlighting specific words, clicking on text, or text-based navigation **without Vision Models**.
227
+
228
+ ```javascript
229
+ window.sentience.findTextRect(options)
230
+ ```
231
+
232
+ **Parameters:**
233
+ ```typescript
234
+ {
235
+ text: string, // Required: Text to find
236
+ containerElement?: Element, // Optional: Search within (default: document.body)
237
+ caseSensitive?: boolean, // Optional: Case-sensitive search (default: false)
238
+ wholeWord?: boolean, // Optional: Match whole words only (default: false)
239
+ maxResults?: number // Optional: Limit results (default: 10)
240
+ }
241
+ ```
242
+
243
+ **Returns:**
244
+ ```typescript
245
+ {
246
+ status: "success" | "error",
247
+ query: string, // The search text
248
+ case_sensitive: boolean,
249
+ whole_word: boolean,
250
+ matches: number, // Total matches found
251
+ results: [{
252
+ text: string, // Actual matched text
253
+ rect: { // Absolute coordinates (with scroll)
254
+ x: number,
255
+ y: number,
256
+ width: number,
257
+ height: number,
258
+ left: number,
259
+ top: number,
260
+ right: number,
261
+ bottom: number
262
+ },
263
+ viewport_rect: { // Viewport-relative coordinates
264
+ x: number,
265
+ y: number,
266
+ width: number,
267
+ height: number
268
+ },
269
+ context: { // Surrounding text
270
+ before: string, // 20 chars before
271
+ after: string // 20 chars after
272
+ },
273
+ in_viewport: boolean // Is it currently visible?
274
+ }],
275
+ viewport: {
276
+ width: number,
277
+ height: number,
278
+ scroll_x: number,
279
+ scroll_y: number
280
+ },
281
+ error?: string // Error message if status is "error"
282
+ }
283
+ ```
284
+
285
+ **Usage Examples:**
286
+
287
+ ```javascript
288
+ // Example 1: Find "Add to Cart" text
289
+ const result = await window.sentience.findTextRect({
290
+ text: "Add to Cart"
291
+ });
292
+
293
+ if (result.status === "success") {
294
+ console.log(`Found ${result.matches} occurrences`);
295
+ result.results.forEach((match, i) => {
296
+ console.log(`${i+1}. At (${match.rect.x}, ${match.rect.y})`);
297
+ console.log(` Context: "${match.context.before}${match.text}${match.context.after}"`);
298
+ });
299
+ }
300
+
301
+ // Example 2: Highlight all matches
302
+ const result = await window.sentience.findTextRect({
303
+ text: "price",
304
+ caseSensitive: false,
305
+ maxResults: 20
306
+ });
307
+
308
+ result.results.forEach(match => {
309
+ const highlight = document.createElement('div');
310
+ highlight.style.cssText = `
311
+ position: absolute;
312
+ left: ${match.rect.x}px;
313
+ top: ${match.rect.y}px;
314
+ width: ${match.rect.width}px;
315
+ height: ${match.rect.height}px;
316
+ background: yellow;
317
+ opacity: 0.5;
318
+ pointer-events: none;
319
+ z-index: 9999;
320
+ `;
321
+ document.body.appendChild(highlight);
322
+ });
323
+
324
+ // Example 3: Click on specific text (not button!)
325
+ const result = await window.sentience.findTextRect({
326
+ text: "Terms of Service",
327
+ wholeWord: true
328
+ });
329
+
330
+ if (result.matches > 0) {
331
+ const first = result.results[0];
332
+ // Click the center of the text
333
+ const centerX = first.viewport_rect.x + first.viewport_rect.width / 2;
334
+ const centerY = first.viewport_rect.y + first.viewport_rect.height / 2;
335
+
336
+ document.elementFromPoint(centerX, centerY)?.click();
337
+ }
338
+
339
+ // Example 4: Find text only in header
340
+ const header = document.querySelector('header');
341
+ const result = await window.sentience.findTextRect({
342
+ text: "Login",
343
+ containerElement: header
344
+ });
345
+
346
+ // Example 5: Scroll to first match
347
+ const result = await window.sentience.findTextRect({
348
+ text: "Contact Us"
349
+ });
350
+
351
+ if (result.matches > 0) {
352
+ const first = result.results[0];
353
+ window.scrollTo({
354
+ top: first.rect.y - 100, // Offset for header
355
+ behavior: 'smooth'
356
+ });
357
+ }
358
+ ```
359
+
360
+ **Use Cases:**
361
+ - 🎯 **Text-based clicking** - Click on text that's not in a button
362
+ - 🖍️ **Text highlighting** - Draw bounding boxes around specific words
363
+ - 📍 **Text navigation** - Scroll to specific content
364
+ - ♿ **Accessibility** - Find and highlight important text
365
+ - 🤖 **AI Agents** - Locate text without vision models
366
+ - 🔍 **Search results** - Find and highlight search terms
367
+
368
+ **Features:**
369
+ - ✅ Pixel-perfect coordinates using DOM Range API
370
+ - ✅ Filters invisible/hidden text automatically
371
+ - ✅ Returns both absolute and viewport-relative coordinates
372
+ - ✅ Provides context for ambiguous matches
373
+ - ✅ Handles multiple occurrences
374
+ - ✅ Performance-safe with result limits
375
+ - ✅ Works with case-insensitive and whole-word matching
376
+
216
377
  ---
217
378
 
218
379
  ## Usage Examples
@@ -7,6 +7,14 @@ export function analyze_page_with_options(val: any, options: any): any;
7
7
 
8
8
  export function decide_and_act(_raw_elements: any): void;
9
9
 
10
+ /**
11
+ * Prune raw elements before sending to API
12
+ * This is a "dumb" filter that reduces payload size without leaking proprietary IP
13
+ * Filters out: tiny elements, invisible elements, non-interactive wrapper divs
14
+ * Amazon: 5000-6000 elements -> ~200-400 elements (~95% reduction)
15
+ */
16
+ export function prune_for_api(val: any): any;
17
+
10
18
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
11
19
 
12
20
  export interface InitOutput {
@@ -14,6 +22,7 @@ export interface InitOutput {
14
22
  readonly analyze_page: (a: number) => number;
15
23
  readonly analyze_page_with_options: (a: number, b: number) => number;
16
24
  readonly decide_and_act: (a: number) => void;
25
+ readonly prune_for_api: (a: number) => number;
17
26
  readonly __wbindgen_export: (a: number, b: number) => number;
18
27
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
19
28
  readonly __wbindgen_export3: (a: number) => void;
@@ -223,6 +223,19 @@ export function decide_and_act(_raw_elements) {
223
223
  wasm.decide_and_act(addHeapObject(_raw_elements));
224
224
  }
225
225
 
226
+ /**
227
+ * Prune raw elements before sending to API
228
+ * This is a "dumb" filter that reduces payload size without leaking proprietary IP
229
+ * Filters out: tiny elements, invisible elements, non-interactive wrapper divs
230
+ * Amazon: 5000-6000 elements -> ~200-400 elements (~95% reduction)
231
+ * @param {any} val
232
+ * @returns {any}
233
+ */
234
+ export function prune_for_api(val) {
235
+ const ret = wasm.prune_for_api(addHeapObject(val));
236
+ return takeObject(ret);
237
+ }
238
+
226
239
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
227
240
 
228
241
  async function __wbg_load(module, imports) {
@@ -338,6 +351,9 @@ function __wbg_get_imports() {
338
351
  const ret = getObject(arg0).done;
339
352
  return ret;
340
353
  };
354
+ imports.wbg.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
355
+ console.error(getObject(arg0));
356
+ };
341
357
  imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
342
358
  const ret = getObject(arg0)[arg1 >>> 0];
343
359
  return addHeapObject(ret);
@@ -4,6 +4,7 @@ export const memory: WebAssembly.Memory;
4
4
  export const analyze_page: (a: number) => number;
5
5
  export const analyze_page_with_options: (a: number, b: number) => number;
6
6
  export const decide_and_act: (a: number) => void;
7
+ export const prune_for_api: (a: number) => number;
7
8
  export const __wbindgen_export: (a: number, b: number) => number;
8
9
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
9
10
  export const __wbindgen_export3: (a: number) => void;
@@ -0,0 +1,115 @@
1
+ {
2
+ "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/273122615",
3
+ "assets_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/273122615/assets",
4
+ "upload_url": "https://uploads.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/273122615/assets{?name,label}",
5
+ "html_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/tag/v2.0.7",
6
+ "id": 273122615,
7
+ "author": {
8
+ "login": "github-actions[bot]",
9
+ "id": 41898282,
10
+ "node_id": "MDM6Qm90NDE4OTgyODI=",
11
+ "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
12
+ "gravatar_id": "",
13
+ "url": "https://api.github.com/users/github-actions%5Bbot%5D",
14
+ "html_url": "https://github.com/apps/github-actions",
15
+ "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
16
+ "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
17
+ "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
18
+ "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
19
+ "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
20
+ "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
21
+ "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
22
+ "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
23
+ "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
24
+ "type": "Bot",
25
+ "user_view_type": "public",
26
+ "site_admin": false
27
+ },
28
+ "node_id": "RE_kwDOQshiJ84QR4U3",
29
+ "tag_name": "v2.0.7",
30
+ "target_commitish": "main",
31
+ "name": "Release v2.0.7",
32
+ "draft": false,
33
+ "immutable": false,
34
+ "prerelease": false,
35
+ "created_at": "2025-12-29T03:56:13Z",
36
+ "updated_at": "2025-12-29T03:57:09Z",
37
+ "published_at": "2025-12-29T03:57:08Z",
38
+ "assets": [
39
+ {
40
+ "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/333966751",
41
+ "id": 333966751,
42
+ "node_id": "RA_kwDOQshiJ84T5-2f",
43
+ "name": "extension-files.tar.gz",
44
+ "label": "",
45
+ "uploader": {
46
+ "login": "github-actions[bot]",
47
+ "id": 41898282,
48
+ "node_id": "MDM6Qm90NDE4OTgyODI=",
49
+ "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
50
+ "gravatar_id": "",
51
+ "url": "https://api.github.com/users/github-actions%5Bbot%5D",
52
+ "html_url": "https://github.com/apps/github-actions",
53
+ "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
54
+ "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
55
+ "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
56
+ "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
57
+ "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
58
+ "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
59
+ "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
60
+ "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
61
+ "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
62
+ "type": "Bot",
63
+ "user_view_type": "public",
64
+ "site_admin": false
65
+ },
66
+ "content_type": "application/gzip",
67
+ "state": "uploaded",
68
+ "size": 78091,
69
+ "digest": "sha256:e281f8b755b61da4b8015d6172064aa9a337c14133ceceff4ab29199ee53307e",
70
+ "download_count": 2,
71
+ "created_at": "2025-12-29T03:57:09Z",
72
+ "updated_at": "2025-12-29T03:57:09Z",
73
+ "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.0.7/extension-files.tar.gz"
74
+ },
75
+ {
76
+ "url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/assets/333966752",
77
+ "id": 333966752,
78
+ "node_id": "RA_kwDOQshiJ84T5-2g",
79
+ "name": "extension-package.zip",
80
+ "label": "",
81
+ "uploader": {
82
+ "login": "github-actions[bot]",
83
+ "id": 41898282,
84
+ "node_id": "MDM6Qm90NDE4OTgyODI=",
85
+ "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
86
+ "gravatar_id": "",
87
+ "url": "https://api.github.com/users/github-actions%5Bbot%5D",
88
+ "html_url": "https://github.com/apps/github-actions",
89
+ "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
90
+ "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
91
+ "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
92
+ "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
93
+ "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
94
+ "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
95
+ "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
96
+ "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
97
+ "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
98
+ "type": "Bot",
99
+ "user_view_type": "public",
100
+ "site_admin": false
101
+ },
102
+ "content_type": "application/zip",
103
+ "state": "uploaded",
104
+ "size": 80179,
105
+ "digest": "sha256:a025edeb8b6d05bfb25c57f913b68507060653ecbdf616000a46df4cb8dec377",
106
+ "download_count": 0,
107
+ "created_at": "2025-12-29T03:57:09Z",
108
+ "updated_at": "2025-12-29T03:57:09Z",
109
+ "browser_download_url": "https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/releases/download/v2.0.7/extension-package.zip"
110
+ }
111
+ ],
112
+ "tarball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/tarball/v2.0.7",
113
+ "zipball_url": "https://api.github.com/repos/SentienceAPI/Sentience-Geometry-Chrome-Extension/zipball/v2.0.7",
114
+ "body": "**Full Changelog**: https://github.com/SentienceAPI/Sentience-Geometry-Chrome-Extension/compare/v2.0.6...v2.0.7"
115
+ }
@@ -0,0 +1,4 @@
1
+ // test-content.js - Simple test script
2
+ console.log('TEST: Extension content script is loading!');
3
+ window.testExtension = true;
4
+ alert('Extension loaded!');