Skip to content

Commit 29caae1

Browse files
authored
Merge pull request #199 from SentienceAPI/new_fields
new fields with ml_rerank metadata
2 parents 6dc4b5b + ad30b2e commit 29caae1

File tree

14 files changed

+172
-91
lines changed

14 files changed

+172
-91
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,3 @@ If the video tag doesn’t render in your GitHub README view, use this link: [`s
174174
- **LangChain:** [examples/lang-chain](examples/lang-chain/)
175175
- **LangGraph:** [examples/langgraph](examples/langgraph/)
176176
- **Pydantic AI:** [examples/pydantic_ai](examples/pydantic_ai/)
177-

sentience/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
# Agent Layer (Phase 1 & 2)
5757
from .base_agent import BaseAgent
5858
from .browser import AsyncSentienceBrowser, SentienceBrowser
59-
from .permissions import PermissionPolicy
6059
from .captcha import CaptchaContext, CaptchaHandlingError, CaptchaOptions, CaptchaResolution
6160
from .captcha_strategies import ExternalSolver, HumanHandoffSolver, VisionSolver
6261

@@ -106,6 +105,7 @@
106105
# Ordinal support (Phase 3)
107106
from .ordinal import OrdinalIntent, boost_ordinal_elements, detect_ordinal_intent, select_by_ordinal
108107
from .overlay import clear_overlay, show_overlay
108+
from .permissions import PermissionPolicy
109109
from .query import find, query
110110
from .read import extract, extract_async, read, read_best_effort
111111
from .recorder import Recorder, Trace, TraceStep, record

sentience/agent_runtime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def _is_captcha_detected(self, snapshot: Snapshot) -> bool:
457457
# interactive runs will “do nothing” and time out.
458458
evidence = getattr(captcha, "evidence", None)
459459
if evidence is not None:
460+
460461
def _list(name: str) -> list[str]:
461462
try:
462463
v = getattr(evidence, name, None)

sentience/extension/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ async function handleSnapshotProcessing(rawData, options = {}) {
2828
const startTime = performance.now();
2929
try {
3030
if (!Array.isArray(rawData)) throw new Error("rawData must be an array");
31-
if (rawData.length > 1e4 && (rawData = rawData.slice(0, 1e4)), await initWASM(),
31+
if (rawData.length > 1e4 && (rawData = rawData.slice(0, 1e4)), await initWASM(),
3232
!wasmReady) throw new Error("WASM module not initialized");
3333
let analyzedElements, prunedRawData;
3434
try {
3535
const wasmPromise = new Promise((resolve, reject) => {
3636
try {
3737
let result;
38-
result = options.limit || options.filter ? analyze_page_with_options(rawData, options) : analyze_page(rawData),
38+
result = options.limit || options.filter ? analyze_page_with_options(rawData, options) : analyze_page(rawData),
3939
resolve(result);
4040
} catch (e) {
4141
reject(e);
@@ -101,4 +101,4 @@ initWASM().catch(err => {}), chrome.runtime.onMessage.addListener((request, send
101101
event.preventDefault();
102102
}), self.addEventListener("unhandledrejection", event => {
103103
event.preventDefault();
104-
});
104+
});

sentience/extension/content.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
const elementsArray = Array.isArray(elements) ? elements : Array.from(elements);
8484
removeOverlay();
8585
const host = document.createElement("div");
86-
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
86+
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
8787
document.body.appendChild(host);
8888
const shadow = host.attachShadow({
8989
mode: "closed"
@@ -95,15 +95,15 @@
9595
let color;
9696
color = isTarget ? "#FF0000" : isPrimary ? "#0066FF" : "#00FF00";
9797
const importanceRatio = maxImportance > 0 ? importance / maxImportance : .5, borderOpacity = isTarget ? 1 : isPrimary ? .9 : Math.max(.4, .5 + .5 * importanceRatio), fillOpacity = .2 * borderOpacity, borderWidth = isTarget ? 2 : isPrimary ? 1.5 : Math.max(.5, Math.round(2 * importanceRatio)), hexOpacity = Math.round(255 * fillOpacity).toString(16).padStart(2, "0"), box = document.createElement("div");
98-
if (box.style.cssText = `\n position: absolute;\n left: ${bbox.x}px;\n top: ${bbox.y}px;\n width: ${bbox.width}px;\n height: ${bbox.height}px;\n border: ${borderWidth}px solid ${color};\n background-color: ${color}${hexOpacity};\n box-sizing: border-box;\n opacity: ${borderOpacity};\n pointer-events: none;\n `,
98+
if (box.style.cssText = `\n position: absolute;\n left: ${bbox.x}px;\n top: ${bbox.y}px;\n width: ${bbox.width}px;\n height: ${bbox.height}px;\n border: ${borderWidth}px solid ${color};\n background-color: ${color}${hexOpacity};\n box-sizing: border-box;\n opacity: ${borderOpacity};\n pointer-events: none;\n `,
9999
importance > 0 || isPrimary) {
100100
const badge = document.createElement("span");
101-
badge.textContent = isPrimary ? `⭐${importance}` : `${importance}`, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
101+
badge.textContent = isPrimary ? `⭐${importance}` : `${importance}`, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
102102
box.appendChild(badge);
103103
}
104104
if (isTarget) {
105105
const targetIndicator = document.createElement("span");
106-
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
106+
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
107107
box.appendChild(targetIndicator);
108108
}
109109
shadow.appendChild(box);
@@ -123,7 +123,7 @@
123123
if (!grids || !Array.isArray(grids)) return;
124124
removeOverlay();
125125
const host = document.createElement("div");
126-
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
126+
host.id = OVERLAY_HOST_ID, host.style.cssText = "\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n pointer-events: none !important;\n z-index: 2147483647 !important;\n margin: 0 !important;\n padding: 0 !important;\n ",
127127
document.body.appendChild(host);
128128
const shadow = host.attachShadow({
129129
mode: "closed"
@@ -139,10 +139,10 @@
139139
let labelText = grid.label ? `Grid ${grid.grid_id}: ${grid.label}` : `Grid ${grid.grid_id}`;
140140
grid.is_dominant && (labelText = `⭐ ${labelText} (dominant)`);
141141
const badge = document.createElement("span");
142-
if (badge.textContent = labelText, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
142+
if (badge.textContent = labelText, badge.style.cssText = `\n position: absolute;\n top: -18px;\n left: 0;\n background: ${color};\n color: white;\n font-size: 11px;\n font-weight: bold;\n padding: 2px 6px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n opacity: 0.95;\n white-space: nowrap;\n pointer-events: none;\n `,
143143
box.appendChild(badge), isTarget) {
144144
const targetIndicator = document.createElement("span");
145-
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
145+
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
146146
box.appendChild(targetIndicator);
147147
}
148148
shadow.appendChild(box);
@@ -156,7 +156,7 @@
156156
let overlayTimeout = null;
157157
function removeOverlay() {
158158
const existing = document.getElementById(OVERLAY_HOST_ID);
159-
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
159+
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
160160
overlayTimeout = null);
161161
}
162-
}();
162+
}();

0 commit comments

Comments
 (0)