sentienceapi 0.90.16__py3-none-any.whl → 0.98.0__py3-none-any.whl

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.

Potentially problematic release.


This version of sentienceapi might be problematic. Click here for more details.

Files changed (90) hide show
  1. sentience/__init__.py +120 -6
  2. sentience/_extension_loader.py +156 -1
  3. sentience/action_executor.py +217 -0
  4. sentience/actions.py +758 -30
  5. sentience/agent.py +806 -293
  6. sentience/agent_config.py +3 -0
  7. sentience/agent_runtime.py +840 -0
  8. sentience/asserts/__init__.py +70 -0
  9. sentience/asserts/expect.py +621 -0
  10. sentience/asserts/query.py +383 -0
  11. sentience/async_api.py +89 -1141
  12. sentience/backends/__init__.py +137 -0
  13. sentience/backends/actions.py +372 -0
  14. sentience/backends/browser_use_adapter.py +241 -0
  15. sentience/backends/cdp_backend.py +393 -0
  16. sentience/backends/exceptions.py +211 -0
  17. sentience/backends/playwright_backend.py +194 -0
  18. sentience/backends/protocol.py +216 -0
  19. sentience/backends/sentience_context.py +469 -0
  20. sentience/backends/snapshot.py +483 -0
  21. sentience/base_agent.py +95 -0
  22. sentience/browser.py +678 -39
  23. sentience/browser_evaluator.py +299 -0
  24. sentience/canonicalization.py +207 -0
  25. sentience/cloud_tracing.py +507 -42
  26. sentience/constants.py +6 -0
  27. sentience/conversational_agent.py +77 -43
  28. sentience/cursor_policy.py +142 -0
  29. sentience/element_filter.py +136 -0
  30. sentience/expect.py +98 -2
  31. sentience/extension/background.js +56 -185
  32. sentience/extension/content.js +150 -287
  33. sentience/extension/injected_api.js +1088 -1368
  34. sentience/extension/manifest.json +1 -1
  35. sentience/extension/pkg/sentience_core.d.ts +22 -22
  36. sentience/extension/pkg/sentience_core.js +275 -433
  37. sentience/extension/pkg/sentience_core_bg.wasm +0 -0
  38. sentience/extension/release.json +47 -47
  39. sentience/failure_artifacts.py +241 -0
  40. sentience/formatting.py +9 -53
  41. sentience/inspector.py +183 -1
  42. sentience/integrations/__init__.py +6 -0
  43. sentience/integrations/langchain/__init__.py +12 -0
  44. sentience/integrations/langchain/context.py +18 -0
  45. sentience/integrations/langchain/core.py +326 -0
  46. sentience/integrations/langchain/tools.py +180 -0
  47. sentience/integrations/models.py +46 -0
  48. sentience/integrations/pydanticai/__init__.py +15 -0
  49. sentience/integrations/pydanticai/deps.py +20 -0
  50. sentience/integrations/pydanticai/toolset.py +468 -0
  51. sentience/llm_interaction_handler.py +191 -0
  52. sentience/llm_provider.py +765 -66
  53. sentience/llm_provider_utils.py +120 -0
  54. sentience/llm_response_builder.py +153 -0
  55. sentience/models.py +595 -3
  56. sentience/ordinal.py +280 -0
  57. sentience/overlay.py +109 -2
  58. sentience/protocols.py +228 -0
  59. sentience/query.py +67 -5
  60. sentience/read.py +95 -3
  61. sentience/recorder.py +223 -3
  62. sentience/schemas/trace_v1.json +128 -9
  63. sentience/screenshot.py +48 -2
  64. sentience/sentience_methods.py +86 -0
  65. sentience/snapshot.py +599 -55
  66. sentience/snapshot_diff.py +126 -0
  67. sentience/text_search.py +120 -5
  68. sentience/trace_event_builder.py +148 -0
  69. sentience/trace_file_manager.py +197 -0
  70. sentience/trace_indexing/index_schema.py +95 -7
  71. sentience/trace_indexing/indexer.py +105 -48
  72. sentience/tracer_factory.py +120 -9
  73. sentience/tracing.py +172 -8
  74. sentience/utils/__init__.py +40 -0
  75. sentience/utils/browser.py +46 -0
  76. sentience/{utils.py → utils/element.py} +3 -42
  77. sentience/utils/formatting.py +59 -0
  78. sentience/verification.py +618 -0
  79. sentience/visual_agent.py +2058 -0
  80. sentience/wait.py +68 -2
  81. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/METADATA +199 -40
  82. sentienceapi-0.98.0.dist-info/RECORD +92 -0
  83. sentience/extension/test-content.js +0 -4
  84. sentienceapi-0.90.16.dist-info/RECORD +0 -50
  85. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/WHEEL +0 -0
  86. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/entry_points.txt +0 -0
  87. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/licenses/LICENSE +0 -0
  88. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/licenses/LICENSE-APACHE +0 -0
  89. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/licenses/LICENSE-MIT +0 -0
  90. {sentienceapi-0.90.16.dist-info → sentienceapi-0.98.0.dist-info}/top_level.txt +0 -0
@@ -1,112 +1,247 @@
1
- let wasm;
1
+ export function analyze_page(val) {
2
+ return takeObject(wasm.analyze_page(addHeapObject(val)));
3
+ }
4
+
5
+ export function analyze_page_with_options(val, options) {
6
+ return takeObject(wasm.analyze_page_with_options(addHeapObject(val), addHeapObject(options)));
7
+ }
8
+
9
+ export function decide_and_act(_raw_elements) {
10
+ wasm.decide_and_act(addHeapObject(_raw_elements));
11
+ }
12
+
13
+ export function prune_for_api(val) {
14
+ return takeObject(wasm.prune_for_api(addHeapObject(val)));
15
+ }
16
+
17
+ function __wbg_get_imports() {
18
+ const import0 = {
19
+ __proto__: null,
20
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
21
+ return addHeapObject(Error(getStringFromWasm0(arg0, arg1)));
22
+ },
23
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
24
+ return Number(getObject(arg0));
25
+ },
26
+ __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
27
+ const v = getObject(arg1), ret = "bigint" == typeof v ? v : void 0;
28
+ getDataViewMemory0().setBigInt64(arg0 + 8, isLikeNone(ret) ? BigInt(0) : ret, !0),
29
+ getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), !0);
30
+ },
31
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
32
+ const v = getObject(arg0), ret = "boolean" == typeof v ? v : void 0;
33
+ return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
34
+ },
35
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
36
+ const ptr1 = passStringToWasm0(debugString(getObject(arg1)), wasm.__wbindgen_export, wasm.__wbindgen_export2), len1 = WASM_VECTOR_LEN;
37
+ getDataViewMemory0().setInt32(arg0 + 4, len1, !0), getDataViewMemory0().setInt32(arg0 + 0, ptr1, !0);
38
+ },
39
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
40
+ return getObject(arg0) in getObject(arg1);
41
+ },
42
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
43
+ return "bigint" == typeof getObject(arg0);
44
+ },
45
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
46
+ return "function" == typeof getObject(arg0);
47
+ },
48
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
49
+ const val = getObject(arg0);
50
+ return "object" == typeof val && null !== val;
51
+ },
52
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
53
+ return void 0 === getObject(arg0);
54
+ },
55
+ __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
56
+ return getObject(arg0) === getObject(arg1);
57
+ },
58
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
59
+ return getObject(arg0) == getObject(arg1);
60
+ },
61
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
62
+ const obj = getObject(arg1), ret = "number" == typeof obj ? obj : void 0;
63
+ getDataViewMemory0().setFloat64(arg0 + 8, isLikeNone(ret) ? 0 : ret, !0), getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), !0);
64
+ },
65
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
66
+ const obj = getObject(arg1), ret = "string" == typeof obj ? obj : void 0;
67
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2), len1 = WASM_VECTOR_LEN;
68
+ getDataViewMemory0().setInt32(arg0 + 4, len1, !0), getDataViewMemory0().setInt32(arg0 + 0, ptr1, !0);
69
+ },
70
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
71
+ throw new Error(getStringFromWasm0(arg0, arg1));
72
+ },
73
+ __wbg_call_389efe28435a9388: function() {
74
+ return handleError(function(arg0, arg1) {
75
+ return addHeapObject(getObject(arg0).call(getObject(arg1)));
76
+ }, arguments);
77
+ },
78
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
79
+ return getObject(arg0).done;
80
+ },
81
+ __wbg_error_9a7fe3f932034cde: function(arg0) {},
82
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
83
+ return addHeapObject(getObject(arg0)[arg1 >>> 0]);
84
+ },
85
+ __wbg_get_b3ed3ad4be2bc8ac: function() {
86
+ return handleError(function(arg0, arg1) {
87
+ return addHeapObject(Reflect.get(getObject(arg0), getObject(arg1)));
88
+ }, arguments);
89
+ },
90
+ __wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
91
+ return addHeapObject(getObject(arg0)[getObject(arg1)]);
92
+ },
93
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
94
+ let result;
95
+ try {
96
+ result = getObject(arg0) instanceof ArrayBuffer;
97
+ } catch (_) {
98
+ result = !1;
99
+ }
100
+ return result;
101
+ },
102
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
103
+ let result;
104
+ try {
105
+ result = getObject(arg0) instanceof Uint8Array;
106
+ } catch (_) {
107
+ result = !1;
108
+ }
109
+ return result;
110
+ },
111
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
112
+ return Array.isArray(getObject(arg0));
113
+ },
114
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
115
+ return Number.isSafeInteger(getObject(arg0));
116
+ },
117
+ __wbg_iterator_6ff6560ca1568e55: function() {
118
+ return addHeapObject(Symbol.iterator);
119
+ },
120
+ __wbg_js_click_element_2fe1e774f3d232c7: function(arg0) {
121
+ js_click_element(arg0);
122
+ },
123
+ __wbg_length_32ed9a279acd054c: function(arg0) {
124
+ return getObject(arg0).length;
125
+ },
126
+ __wbg_length_35a7bace40f36eac: function(arg0) {
127
+ return getObject(arg0).length;
128
+ },
129
+ __wbg_new_361308b2356cecd0: function() {
130
+ return addHeapObject(new Object);
131
+ },
132
+ __wbg_new_3eb36ae241fe6f44: function() {
133
+ return addHeapObject(new Array);
134
+ },
135
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
136
+ return addHeapObject(new Uint8Array(getObject(arg0)));
137
+ },
138
+ __wbg_next_3482f54c49e8af19: function() {
139
+ return handleError(function(arg0) {
140
+ return addHeapObject(getObject(arg0).next());
141
+ }, arguments);
142
+ },
143
+ __wbg_next_418f80d8f5303233: function(arg0) {
144
+ return addHeapObject(getObject(arg0).next);
145
+ },
146
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
147
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
148
+ },
149
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
150
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
151
+ },
152
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
153
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
154
+ },
155
+ __wbg_value_0546255b415e96c1: function(arg0) {
156
+ return addHeapObject(getObject(arg0).value);
157
+ },
158
+ __wbindgen_cast_0000000000000001: function(arg0) {
159
+ return addHeapObject(arg0);
160
+ },
161
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
162
+ return addHeapObject(getStringFromWasm0(arg0, arg1));
163
+ },
164
+ __wbindgen_cast_0000000000000003: function(arg0) {
165
+ return addHeapObject(BigInt.asUintN(64, arg0));
166
+ },
167
+ __wbindgen_object_clone_ref: function(arg0) {
168
+ return addHeapObject(getObject(arg0));
169
+ },
170
+ __wbindgen_object_drop_ref: function(arg0) {
171
+ takeObject(arg0);
172
+ }
173
+ };
174
+ return {
175
+ __proto__: null,
176
+ "./sentience_core_bg.js": import0
177
+ };
178
+ }
2
179
 
3
180
  function addHeapObject(obj) {
4
- if (heap_next === heap.length) heap.push(heap.length + 1);
181
+ heap_next === heap.length && heap.push(heap.length + 1);
5
182
  const idx = heap_next;
6
- heap_next = heap[idx];
7
-
8
- heap[idx] = obj;
9
- return idx;
183
+ return heap_next = heap[idx], heap[idx] = obj, idx;
10
184
  }
11
185
 
12
186
  function debugString(val) {
13
- // primitive types
14
187
  const type = typeof val;
15
- if (type == 'number' || type == 'boolean' || val == null) {
16
- return `${val}`;
17
- }
18
- if (type == 'string') {
19
- return `"${val}"`;
20
- }
21
- if (type == 'symbol') {
188
+ if ("number" == type || "boolean" == type || null == val) return `${val}`;
189
+ if ("string" == type) return `"${val}"`;
190
+ if ("symbol" == type) {
22
191
  const description = val.description;
23
- if (description == null) {
24
- return 'Symbol';
25
- } else {
26
- return `Symbol(${description})`;
27
- }
192
+ return null == description ? "Symbol" : `Symbol(${description})`;
28
193
  }
29
- if (type == 'function') {
194
+ if ("function" == type) {
30
195
  const name = val.name;
31
- if (typeof name == 'string' && name.length > 0) {
32
- return `Function(${name})`;
33
- } else {
34
- return 'Function';
35
- }
196
+ return "string" == typeof name && name.length > 0 ? `Function(${name})` : "Function";
36
197
  }
37
- // objects
38
198
  if (Array.isArray(val)) {
39
199
  const length = val.length;
40
- let debug = '[';
41
- if (length > 0) {
42
- debug += debugString(val[0]);
43
- }
44
- for(let i = 1; i < length; i++) {
45
- debug += ', ' + debugString(val[i]);
46
- }
47
- debug += ']';
48
- return debug;
200
+ let debug = "[";
201
+ length > 0 && (debug += debugString(val[0]));
202
+ for (let i = 1; i < length; i++) debug += ", " + debugString(val[i]);
203
+ return debug += "]", debug;
49
204
  }
50
- // Test for built-in
51
205
  const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
52
206
  let className;
53
- if (builtInMatches && builtInMatches.length > 1) {
54
- className = builtInMatches[1];
55
- } else {
56
- // Failed to match the standard '[object ClassName]'
57
- return toString.call(val);
58
- }
59
- if (className == 'Object') {
60
- // we're a user defined class or Object
61
- // JSON.stringify avoids problems with cycles, and is generally much
62
- // easier than looping through ownProperties of `val`.
63
- try {
64
- return 'Object(' + JSON.stringify(val) + ')';
65
- } catch (_) {
66
- return 'Object';
67
- }
68
- }
69
- // errors
70
- if (val instanceof Error) {
71
- return `${val.name}: ${val.message}\n${val.stack}`;
207
+ if (!(builtInMatches && builtInMatches.length > 1)) return toString.call(val);
208
+ if (className = builtInMatches[1], "Object" == className) try {
209
+ return "Object(" + JSON.stringify(val) + ")";
210
+ } catch (_) {
211
+ return "Object";
72
212
  }
73
- // TODO we could test for more things here, like `Set`s and `Map`s.
74
- return className;
213
+ return val instanceof Error ? `${val.name}: ${val.message}\n${val.stack}` : className;
75
214
  }
76
215
 
77
216
  function dropObject(idx) {
78
- if (idx < 132) return;
79
- heap[idx] = heap_next;
80
- heap_next = idx;
217
+ idx < 132 || (heap[idx] = heap_next, heap_next = idx);
81
218
  }
82
219
 
83
220
  function getArrayU8FromWasm0(ptr, len) {
84
- ptr = ptr >>> 0;
85
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
221
+ return ptr >>>= 0, getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
86
222
  }
87
223
 
88
224
  let cachedDataViewMemory0 = null;
225
+
89
226
  function getDataViewMemory0() {
90
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
- }
93
- return cachedDataViewMemory0;
227
+ return (null === cachedDataViewMemory0 || !0 === cachedDataViewMemory0.buffer.detached || void 0 === cachedDataViewMemory0.buffer.detached && cachedDataViewMemory0.buffer !== wasm.memory.buffer) && (cachedDataViewMemory0 = new DataView(wasm.memory.buffer)),
228
+ cachedDataViewMemory0;
94
229
  }
95
230
 
96
231
  function getStringFromWasm0(ptr, len) {
97
- ptr = ptr >>> 0;
98
- return decodeText(ptr, len);
232
+ return decodeText(ptr >>>= 0, len);
99
233
  }
100
234
 
101
235
  let cachedUint8ArrayMemory0 = null;
236
+
102
237
  function getUint8ArrayMemory0() {
103
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
104
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
105
- }
106
- return cachedUint8ArrayMemory0;
238
+ return null !== cachedUint8ArrayMemory0 && 0 !== cachedUint8ArrayMemory0.byteLength || (cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer)),
239
+ cachedUint8ArrayMemory0;
107
240
  }
108
241
 
109
- function getObject(idx) { return heap[idx]; }
242
+ function getObject(idx) {
243
+ return heap[idx];
244
+ }
110
245
 
111
246
  function handleError(f, args) {
112
247
  try {
@@ -116,414 +251,121 @@ function handleError(f, args) {
116
251
  }
117
252
  }
118
253
 
119
- let heap = new Array(128).fill(undefined);
120
- heap.push(undefined, null, true, false);
254
+ let heap = new Array(128).fill(void 0);
255
+
256
+ heap.push(void 0, null, !0, !1);
121
257
 
122
258
  let heap_next = heap.length;
123
259
 
124
260
  function isLikeNone(x) {
125
- return x === undefined || x === null;
261
+ return null == x;
126
262
  }
127
263
 
128
264
  function passStringToWasm0(arg, malloc, realloc) {
129
- if (realloc === undefined) {
130
- const buf = cachedTextEncoder.encode(arg);
131
- const ptr = malloc(buf.length, 1) >>> 0;
132
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
133
- WASM_VECTOR_LEN = buf.length;
134
- return ptr;
265
+ if (void 0 === realloc) {
266
+ const buf = cachedTextEncoder.encode(arg), ptr = malloc(buf.length, 1) >>> 0;
267
+ return getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf), WASM_VECTOR_LEN = buf.length,
268
+ ptr;
135
269
  }
136
-
137
- let len = arg.length;
138
- let ptr = malloc(len, 1) >>> 0;
139
-
270
+ let len = arg.length, ptr = malloc(len, 1) >>> 0;
140
271
  const mem = getUint8ArrayMemory0();
141
-
142
272
  let offset = 0;
143
-
144
- for (; offset < len; offset++) {
273
+ for (;offset < len; offset++) {
145
274
  const code = arg.charCodeAt(offset);
146
- if (code > 0x7F) break;
275
+ if (code > 127) break;
147
276
  mem[ptr + offset] = code;
148
277
  }
149
278
  if (offset !== len) {
150
- if (offset !== 0) {
151
- arg = arg.slice(offset);
152
- }
153
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
279
+ 0 !== offset && (arg = arg.slice(offset)), ptr = realloc(ptr, len, len = offset + 3 * arg.length, 1) >>> 0;
154
280
  const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
155
- const ret = cachedTextEncoder.encodeInto(arg, view);
156
-
157
- offset += ret.written;
158
- ptr = realloc(ptr, len, offset, 1) >>> 0;
281
+ offset += cachedTextEncoder.encodeInto(arg, view).written, ptr = realloc(ptr, len, offset, 1) >>> 0;
159
282
  }
160
-
161
- WASM_VECTOR_LEN = offset;
162
- return ptr;
283
+ return WASM_VECTOR_LEN = offset, ptr;
163
284
  }
164
285
 
165
286
  function takeObject(idx) {
166
287
  const ret = getObject(idx);
167
- dropObject(idx);
168
- return ret;
288
+ return dropObject(idx), ret;
169
289
  }
170
290
 
171
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
291
+ let cachedTextDecoder = new TextDecoder("utf-8", {
292
+ ignoreBOM: !0,
293
+ fatal: !0
294
+ });
295
+
172
296
  cachedTextDecoder.decode();
297
+
173
298
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
174
- let numBytesDecoded = 0;
175
- function decodeText(ptr, len) {
176
- numBytesDecoded += len;
177
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
178
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
179
- cachedTextDecoder.decode();
180
- numBytesDecoded = len;
181
- }
182
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
183
- }
184
299
 
185
- const cachedTextEncoder = new TextEncoder();
300
+ let numBytesDecoded = 0;
186
301
 
187
- if (!('encodeInto' in cachedTextEncoder)) {
188
- cachedTextEncoder.encodeInto = function (arg, view) {
189
- const buf = cachedTextEncoder.encode(arg);
190
- view.set(buf);
191
- return {
192
- read: arg.length,
193
- written: buf.length
194
- };
195
- }
302
+ function decodeText(ptr, len) {
303
+ return numBytesDecoded += len, numBytesDecoded >= MAX_SAFARI_DECODE_BYTES && (cachedTextDecoder = new TextDecoder("utf-8", {
304
+ ignoreBOM: !0,
305
+ fatal: !0
306
+ }), cachedTextDecoder.decode(), numBytesDecoded = len), cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
196
307
  }
197
308
 
198
- let WASM_VECTOR_LEN = 0;
309
+ const cachedTextEncoder = new TextEncoder;
199
310
 
200
- /**
201
- * @param {any} val
202
- * @returns {any}
203
- */
204
- export function analyze_page(val) {
205
- const ret = wasm.analyze_page(addHeapObject(val));
206
- return takeObject(ret);
207
- }
208
-
209
- /**
210
- * @param {any} val
211
- * @param {any} options
212
- * @returns {any}
213
- */
214
- export function analyze_page_with_options(val, options) {
215
- const ret = wasm.analyze_page_with_options(addHeapObject(val), addHeapObject(options));
216
- return takeObject(ret);
217
- }
311
+ "encodeInto" in cachedTextEncoder || (cachedTextEncoder.encodeInto = function(arg, view) {
312
+ const buf = cachedTextEncoder.encode(arg);
313
+ return view.set(buf), {
314
+ read: arg.length,
315
+ written: buf.length
316
+ };
317
+ });
218
318
 
219
- /**
220
- * @param {any} _raw_elements
221
- */
222
- export function decide_and_act(_raw_elements) {
223
- wasm.decide_and_act(addHeapObject(_raw_elements));
224
- }
319
+ let wasmModule, wasm, WASM_VECTOR_LEN = 0;
225
320
 
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);
321
+ function __wbg_finalize_init(instance, module) {
322
+ return wasm = instance.exports, wasmModule = module, cachedDataViewMemory0 = null,
323
+ cachedUint8ArrayMemory0 = null, wasm;
237
324
  }
238
325
 
239
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
240
-
241
326
  async function __wbg_load(module, imports) {
242
- if (typeof Response === 'function' && module instanceof Response) {
243
- if (typeof WebAssembly.instantiateStreaming === 'function') {
244
- try {
245
- return await WebAssembly.instantiateStreaming(module, imports);
246
- } catch (e) {
247
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
248
-
249
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
250
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
251
-
252
- } else {
253
- throw e;
327
+ if ("function" == typeof Response && module instanceof Response) {
328
+ if ("function" == typeof WebAssembly.instantiateStreaming) try {
329
+ return await WebAssembly.instantiateStreaming(module, imports);
330
+ } catch (e) {
331
+ if (!(module.ok && function(type) {
332
+ switch (type) {
333
+ case "basic":
334
+ case "cors":
335
+ case "default":
336
+ return !0;
254
337
  }
255
- }
338
+ return !1;
339
+ }(module.type)) || "application/wasm" === module.headers.get("Content-Type")) throw e;
256
340
  }
257
-
258
341
  const bytes = await module.arrayBuffer();
259
342
  return await WebAssembly.instantiate(bytes, imports);
260
- } else {
343
+ }
344
+ {
261
345
  const instance = await WebAssembly.instantiate(module, imports);
262
-
263
- if (instance instanceof WebAssembly.Instance) {
264
- return { instance, module };
265
- } else {
266
- return instance;
267
- }
346
+ return instance instanceof WebAssembly.Instance ? {
347
+ instance: instance,
348
+ module: module
349
+ } : instance;
268
350
  }
269
351
  }
270
352
 
271
- function __wbg_get_imports() {
272
- const imports = {};
273
- imports.wbg = {};
274
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
275
- const ret = Error(getStringFromWasm0(arg0, arg1));
276
- return addHeapObject(ret);
277
- };
278
- imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
279
- const ret = Number(getObject(arg0));
280
- return ret;
281
- };
282
- imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
283
- const v = getObject(arg1);
284
- const ret = typeof(v) === 'bigint' ? v : undefined;
285
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
286
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
287
- };
288
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
289
- const v = getObject(arg0);
290
- const ret = typeof(v) === 'boolean' ? v : undefined;
291
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
292
- };
293
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
294
- const ret = debugString(getObject(arg1));
295
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
296
- const len1 = WASM_VECTOR_LEN;
297
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
298
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
299
- };
300
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
301
- const ret = getObject(arg0) in getObject(arg1);
302
- return ret;
303
- };
304
- imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
305
- const ret = typeof(getObject(arg0)) === 'bigint';
306
- return ret;
307
- };
308
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
309
- const ret = typeof(getObject(arg0)) === 'function';
310
- return ret;
311
- };
312
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
313
- const val = getObject(arg0);
314
- const ret = typeof(val) === 'object' && val !== null;
315
- return ret;
316
- };
317
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
318
- const ret = getObject(arg0) === undefined;
319
- return ret;
320
- };
321
- imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
322
- const ret = getObject(arg0) === getObject(arg1);
323
- return ret;
324
- };
325
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
326
- const ret = getObject(arg0) == getObject(arg1);
327
- return ret;
328
- };
329
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
330
- const obj = getObject(arg1);
331
- const ret = typeof(obj) === 'number' ? obj : undefined;
332
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
333
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
334
- };
335
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
336
- const obj = getObject(arg1);
337
- const ret = typeof(obj) === 'string' ? obj : undefined;
338
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
339
- var len1 = WASM_VECTOR_LEN;
340
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
341
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
342
- };
343
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
344
- throw new Error(getStringFromWasm0(arg0, arg1));
345
- };
346
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
347
- const ret = getObject(arg0).call(getObject(arg1));
348
- return addHeapObject(ret);
349
- }, arguments) };
350
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
351
- const ret = getObject(arg0).done;
352
- return ret;
353
- };
354
- imports.wbg.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
355
- console.error(getObject(arg0));
356
- };
357
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
358
- const ret = getObject(arg0)[arg1 >>> 0];
359
- return addHeapObject(ret);
360
- };
361
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
362
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
363
- return addHeapObject(ret);
364
- }, arguments) };
365
- imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
366
- const ret = getObject(arg0)[getObject(arg1)];
367
- return addHeapObject(ret);
368
- };
369
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
370
- let result;
371
- try {
372
- result = getObject(arg0) instanceof ArrayBuffer;
373
- } catch (_) {
374
- result = false;
375
- }
376
- const ret = result;
377
- return ret;
378
- };
379
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
380
- let result;
381
- try {
382
- result = getObject(arg0) instanceof Uint8Array;
383
- } catch (_) {
384
- result = false;
385
- }
386
- const ret = result;
387
- return ret;
388
- };
389
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
390
- const ret = Array.isArray(getObject(arg0));
391
- return ret;
392
- };
393
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
394
- const ret = Number.isSafeInteger(getObject(arg0));
395
- return ret;
396
- };
397
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
398
- const ret = Symbol.iterator;
399
- return addHeapObject(ret);
400
- };
401
- imports.wbg.__wbg_js_click_element_2fe1e774f3d232c7 = function(arg0) {
402
- js_click_element(arg0);
403
- };
404
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
405
- const ret = getObject(arg0).length;
406
- return ret;
407
- };
408
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
409
- const ret = getObject(arg0).length;
410
- return ret;
411
- };
412
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
413
- const ret = new Object();
414
- return addHeapObject(ret);
415
- };
416
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
417
- const ret = new Array();
418
- return addHeapObject(ret);
419
- };
420
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
421
- const ret = new Uint8Array(getObject(arg0));
422
- return addHeapObject(ret);
423
- };
424
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
425
- const ret = getObject(arg0).next;
426
- return addHeapObject(ret);
427
- };
428
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
429
- const ret = getObject(arg0).next();
430
- return addHeapObject(ret);
431
- }, arguments) };
432
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
433
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
434
- };
435
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
436
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
437
- };
438
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
439
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
440
- };
441
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
442
- const ret = getObject(arg0).value;
443
- return addHeapObject(ret);
444
- };
445
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
446
- // Cast intrinsic for `Ref(String) -> Externref`.
447
- const ret = getStringFromWasm0(arg0, arg1);
448
- return addHeapObject(ret);
449
- };
450
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
451
- // Cast intrinsic for `U64 -> Externref`.
452
- const ret = BigInt.asUintN(64, arg0);
453
- return addHeapObject(ret);
454
- };
455
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
456
- // Cast intrinsic for `F64 -> Externref`.
457
- const ret = arg0;
458
- return addHeapObject(ret);
459
- };
460
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
461
- const ret = getObject(arg0);
462
- return addHeapObject(ret);
463
- };
464
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
465
- takeObject(arg0);
466
- };
467
-
468
- return imports;
469
- }
470
-
471
- function __wbg_finalize_init(instance, module) {
472
- wasm = instance.exports;
473
- __wbg_init.__wbindgen_wasm_module = module;
474
- cachedDataViewMemory0 = null;
475
- cachedUint8ArrayMemory0 = null;
476
-
477
-
478
-
479
- return wasm;
480
- }
481
-
482
353
  function initSync(module) {
483
- if (wasm !== undefined) return wasm;
484
-
485
-
486
- if (typeof module !== 'undefined') {
487
- if (Object.getPrototypeOf(module) === Object.prototype) {
488
- ({module} = module)
489
- } else {
490
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
491
- }
492
- }
493
-
354
+ if (void 0 !== wasm) return wasm;
355
+ void 0 !== module && Object.getPrototypeOf(module) === Object.prototype && ({module: module} = module);
494
356
  const imports = __wbg_get_imports();
495
- if (!(module instanceof WebAssembly.Module)) {
496
- module = new WebAssembly.Module(module);
497
- }
498
- const instance = new WebAssembly.Instance(module, imports);
499
- return __wbg_finalize_init(instance, module);
357
+ module instanceof WebAssembly.Module || (module = new WebAssembly.Module(module));
358
+ return __wbg_finalize_init(new WebAssembly.Instance(module, imports), module);
500
359
  }
501
360
 
502
361
  async function __wbg_init(module_or_path) {
503
- if (wasm !== undefined) return wasm;
504
-
505
-
506
- if (typeof module_or_path !== 'undefined') {
507
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
508
- ({module_or_path} = module_or_path)
509
- } else {
510
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
511
- }
512
- }
513
-
514
- if (typeof module_or_path === 'undefined') {
515
- module_or_path = new URL('sentience_core_bg.wasm', import.meta.url);
516
- }
362
+ if (void 0 !== wasm) return wasm;
363
+ void 0 !== module_or_path && Object.getPrototypeOf(module_or_path) === Object.prototype && ({module_or_path: module_or_path} = module_or_path),
364
+ void 0 === module_or_path && (module_or_path = new URL("sentience_core_bg.wasm", import.meta.url));
517
365
  const imports = __wbg_get_imports();
518
-
519
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
520
- module_or_path = fetch(module_or_path);
521
- }
522
-
523
- const { instance, module } = await __wbg_load(await module_or_path, imports);
524
-
366
+ ("string" == typeof module_or_path || "function" == typeof Request && module_or_path instanceof Request || "function" == typeof URL && module_or_path instanceof URL) && (module_or_path = fetch(module_or_path));
367
+ const {instance: instance, module: module} = await __wbg_load(await module_or_path, imports);
525
368
  return __wbg_finalize_init(instance, module);
526
369
  }
527
370
 
528
- export { initSync };
529
- export default __wbg_init;
371
+ export { initSync, __wbg_init as default };