Skip to content

Commit 85a332d

Browse files
author
SentienceDEV
committed
P0 done
1 parent 7cbef31 commit 85a332d

File tree

13 files changed

+433
-64
lines changed

13 files changed

+433
-64
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,17 @@ jobs:
299299
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
300300
301301
print("=== Final Pre-Test Verification ===")
302-
302+
303303
# First, verify the source file directly
304304
source_file = 'sentience/agent_runtime.py'
305305
print(f"=== Checking source file: {source_file} ===")
306306
if not os.path.exists(source_file):
307307
print(f"ERROR: Source file {source_file} not found!")
308308
sys.exit(1)
309-
309+
310310
with open(source_file, 'r', encoding='utf-8') as f:
311311
source_content = f.read()
312-
312+
313313
# Check if the bug exists and try to fix it one more time (in case auto-fix didn't run)
314314
if 'self.assertTrue(' in source_content:
315315
print('WARNING: Found self.assertTrue( in source file. Attempting to fix...')
@@ -332,11 +332,11 @@ jobs:
332332
print('OK: Source file uses self.assert_( correctly')
333333
else:
334334
print('WARNING: Could not find assert_ method in source file')
335-
335+
336336
# Now check the installed package
337337
print("\n=== Checking installed package ===")
338338
import sentience.agent_runtime
339-
339+
340340
# Verify it's using local source (editable install)
341341
import sentience
342342
pkg_path = os.path.abspath(sentience.__file__)
@@ -348,7 +348,7 @@ jobs:
348348
print(f' This might be using PyPI package instead of local source!')
349349
else:
350350
print(f'OK: Package is from local source: {pkg_path}')
351-
351+
352352
src = inspect.getsource(sentience.agent_runtime.AgentRuntime.assert_done)
353353
354354
print("assert_done method source:")

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ from sentience.tracing import Tracer, JsonlTraceSink
3737
async def main():
3838
# Create tracer
3939
tracer = Tracer(run_id="my-run", sink=JsonlTraceSink("trace.jsonl"))
40-
40+
4141
# Create browser and runtime
4242
async with AsyncSentienceBrowser() as browser:
4343
page = await browser.new_page()
@@ -46,24 +46,24 @@ async def main():
4646
page=page,
4747
tracer=tracer
4848
)
49-
49+
5050
# Navigate and take snapshot
5151
await page.goto("https://example.com")
5252
runtime.begin_step("Verify page loaded")
5353
await runtime.snapshot()
54-
54+
5555
# Run assertions (Jest-style)
5656
runtime.assert_(url_contains("example.com"), label="on_correct_domain")
5757
runtime.assert_(exists("role=heading"), label="has_heading")
5858
runtime.assert_(all_of([
5959
exists("role=button"),
6060
exists("role=link")
6161
]), label="has_interactive_elements")
62-
62+
6363
# Check task completion
6464
if runtime.assert_done(exists("text~'Example'"), label="task_complete"):
6565
print("✅ Task completed!")
66-
66+
6767
print(f"Task done: {runtime.is_task_done}")
6868

6969
asyncio.run(main())

sentience/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,17 @@
114114
custom,
115115
element_count,
116116
exists,
117+
is_checked,
118+
is_collapsed,
119+
is_disabled,
120+
is_enabled,
121+
is_expanded,
122+
is_unchecked,
117123
not_exists,
118124
url_contains,
119125
url_matches,
126+
value_contains,
127+
value_equals,
120128
)
121129
from .visual_agent import SentienceVisualAgent, SentienceVisualAgentAsync
122130
from .wait import wait_for

sentience/agent_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def assert_done(
342342
Returns:
343343
True if task is complete (assertion passed), False otherwise
344344
"""
345-
ok = self.assert_(predicate, label=label, required=True)
345+
ok = self.assertTrue(predicate, label=label, required=True)
346346
if ok:
347347
self._task_done = True
348348
self._task_done_label = label

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
@@ -82,7 +82,7 @@
8282
if (!elements || !Array.isArray(elements)) return;
8383
removeOverlay();
8484
const host = document.createElement("div");
85-
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 ",
85+
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 ",
8686
document.body.appendChild(host);
8787
const shadow = host.attachShadow({
8888
mode: "closed"
@@ -94,15 +94,15 @@
9494
let color;
9595
color = isTarget ? "#FF0000" : isPrimary ? "#0066FF" : "#00FF00";
9696
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");
97-
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 `,
97+
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 `,
9898
importance > 0 || isPrimary) {
9999
const badge = document.createElement("span");
100-
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 `,
100+
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 `,
101101
box.appendChild(badge);
102102
}
103103
if (isTarget) {
104104
const targetIndicator = document.createElement("span");
105-
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
105+
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
106106
box.appendChild(targetIndicator);
107107
}
108108
shadow.appendChild(box);
@@ -122,7 +122,7 @@
122122
if (!grids || !Array.isArray(grids)) return;
123123
removeOverlay();
124124
const host = document.createElement("div");
125-
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 ",
125+
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 ",
126126
document.body.appendChild(host);
127127
const shadow = host.attachShadow({
128128
mode: "closed"
@@ -138,10 +138,10 @@
138138
let labelText = grid.label ? `Grid ${grid.grid_id}: ${grid.label}` : `Grid ${grid.grid_id}`;
139139
grid.is_dominant && (labelText = `⭐ ${labelText} (dominant)`);
140140
const badge = document.createElement("span");
141-
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 `,
141+
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 `,
142142
box.appendChild(badge), isTarget) {
143143
const targetIndicator = document.createElement("span");
144-
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
144+
targetIndicator.textContent = "🎯", targetIndicator.style.cssText = "\n position: absolute;\n top: -18px;\n right: 0;\n font-size: 16px;\n pointer-events: none;\n ",
145145
box.appendChild(targetIndicator);
146146
}
147147
shadow.appendChild(box);
@@ -155,7 +155,7 @@
155155
let overlayTimeout = null;
156156
function removeOverlay() {
157157
const existing = document.getElementById(OVERLAY_HOST_ID);
158-
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
158+
existing && existing.remove(), overlayTimeout && (clearTimeout(overlayTimeout),
159159
overlayTimeout = null);
160160
}
161-
}();
161+
}();

0 commit comments

Comments
 (0)