Skip to content

Commit fa6deb2

Browse files
authored
Merge pull request #178 from SentienceAPI/rebrand3
rebrand 3 with Predicate*
2 parents 753a1da + 041d02f commit fa6deb2

4 files changed

Lines changed: 80 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
All notable changes to `@predicatelabs/sdk` will be documented in this file.
4+
5+
## Unreleased
6+
7+
### Deprecated
8+
9+
- Soft-deprecated legacy `Sentience*` class names in favor of `Predicate*` names:
10+
- `SentienceBrowser` -> `PredicateBrowser`
11+
- `SentienceAgent` -> `PredicateAgent`
12+
- `SentienceVisualAgent` -> `PredicateVisualAgent`
13+
- `SentienceDebugger` -> `PredicateDebugger`
14+
- `backends.SentienceContext` -> `backends.PredicateContext`
15+
- Legacy names remain supported as runtime aliases for compatibility during a transition window of **1-2 releases**.
16+
17+
### Added
18+
19+
- Runtime alias exports for `Predicate*` counterparts to preserve backwards compatibility while enabling rebrand migration.
20+
21+
### Fixed
22+
23+
- Hardened `search()` in `src/actions.ts` for CI reliability by making `page.waitForLoadState('networkidle')` best-effort with a bounded timeout, preventing flaky timeouts on pages with long-lived background requests.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ npm install @predicatelabs/sdk
3232
npx playwright install chromium
3333
```
3434

35+
## Naming migration (Predicate rebrand)
36+
37+
Use the new `Predicate*` class names for all new code:
38+
39+
- `PredicateBrowser`
40+
- `PredicateAgent`
41+
- `PredicateVisualAgent`
42+
- `PredicateDebugger`
43+
- `backends.PredicateContext`
44+
45+
The legacy `Sentience*` names are still available as runtime aliases for compatibility, but are now soft-deprecated and planned for removal after **1-2 releases**.
46+
47+
Mapping:
48+
49+
- `SentienceBrowser` -> `PredicateBrowser`
50+
- `SentienceAgent` -> `PredicateAgent`
51+
- `SentienceVisualAgent` -> `PredicateVisualAgent`
52+
- `SentienceDebugger` -> `PredicateDebugger`
53+
- `backends.SentienceContext` -> `backends.PredicateContext`
54+
3555
## Conceptual example (why this exists)
3656

3757
- Steps are **gated by verifiable UI assertions**

src/actions.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,13 @@ export async function search(
11341134
const urlBefore = page.url();
11351135
const url = buildSearchUrl(query, engine);
11361136
await browser.goto(url);
1137-
await page.waitForLoadState('networkidle');
1137+
// Some search engines keep long-lived background requests open in CI,
1138+
// so treat networkidle as a best-effort signal instead of a hard requirement.
1139+
try {
1140+
await page.waitForLoadState('networkidle', { timeout: 5000 });
1141+
} catch {
1142+
// no-op: page is already loaded enough for URL/result assertions
1143+
}
11381144

11391145
const durationMs = Date.now() - startTime;
11401146
const urlAfter = page.url();

tests/README.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Running Tests - TypeScript SDK
22

3+
## Naming for new tests
4+
5+
Use `Predicate*` names in new test code (for example `PredicateBrowser`, `PredicateAgent`, `PredicateDebugger`).
6+
Legacy `Sentience*` names still work as compatibility aliases, but new tests should prefer the rebranded names.
7+
38
## Prerequisites
49

510
```bash
@@ -82,30 +87,30 @@ Create test files in `tests/` directory:
8287
### Example: `tests/inspector.test.ts`
8388

8489
```typescript
85-
import { SentienceBrowser, inspect } from '../src';
90+
import { PredicateBrowser, inspect } from '../src';
8691

8792
describe('Inspector', () => {
8893
it('should start and stop', async () => {
89-
const browser = new SentienceBrowser(undefined, undefined, false);
94+
const browser = new PredicateBrowser(undefined, undefined, false);
9095
await browser.start();
91-
96+
9297
try {
9398
await browser.getPage().goto('https://example.com');
9499
await browser.getPage().waitForLoadState('networkidle');
95-
100+
96101
const inspector = inspect(browser);
97102
await inspector.start();
98-
99-
const active = await browser.getPage().evaluate(
100-
() => (window as any).__sentience_inspector_active === true
101-
);
103+
104+
const active = await browser
105+
.getPage()
106+
.evaluate(() => (window as any).__sentience_inspector_active === true);
102107
expect(active).toBe(true);
103-
108+
104109
await inspector.stop();
105-
106-
const inactive = await browser.getPage().evaluate(
107-
() => (window as any).__sentience_inspector_active === true
108-
);
110+
111+
const inactive = await browser
112+
.getPage()
113+
.evaluate(() => (window as any).__sentience_inspector_active === true);
109114
expect(inactive).toBe(false);
110115
} finally {
111116
await browser.close();
@@ -117,27 +122,27 @@ describe('Inspector', () => {
117122
### Example: `tests/recorder.test.ts`
118123

119124
```typescript
120-
import { SentienceBrowser, record } from '../src';
125+
import { PredicateBrowser, record } from '../src';
121126

122127
describe('Recorder', () => {
123128
it('should record click events', async () => {
124-
const browser = new SentienceBrowser(undefined, undefined, false);
129+
const browser = new PredicateBrowser(undefined, undefined, false);
125130
await browser.start();
126-
131+
127132
try {
128133
await browser.getPage().goto('https://example.com');
129134
await browser.getPage().waitForLoadState('networkidle');
130-
135+
131136
const rec = record(browser);
132137
rec.start();
133-
138+
134139
rec.recordClick(1, 'role=button');
135-
140+
136141
const trace = rec.getTrace();
137142
expect(trace.steps.length).toBe(1);
138143
expect(trace.steps[0].type).toBe('click');
139144
expect(trace.steps[0].element_id).toBe(1);
140-
145+
141146
rec.stop();
142147
} finally {
143148
await browser.close();
@@ -202,25 +207,29 @@ npm test -- tests/inspector.test.ts -t "should start"
202207
## Troubleshooting
203208

204209
### TypeScript compilation errors
210+
205211
```bash
206212
npm run build
207213
```
208214

209215
### Browser not found
216+
210217
```bash
211218
npx playwright install chromium
212219
```
213220

214221
### Extension not found
222+
215223
Make sure the extension is built:
224+
216225
```bash
217226
cd ../sentience-chrome
218227
./build.sh
219228
```
220229

221230
### Module not found errors
231+
222232
```bash
223233
npm install
224234
npm run build
225235
```
226-

0 commit comments

Comments
 (0)