From 753a1da6c978489979812a601bce4e95a0fdaae6 Mon Sep 17 00:00:00 2001 From: SentienceDEV Date: Tue, 10 Feb 2026 21:19:44 -0800 Subject: [PATCH 1/2] rebrand 2 with Predicate* --- src/agent.ts | 6 ++++++ src/backends/index.ts | 1 + src/backends/sentience-context.ts | 6 ++++++ src/browser.ts | 6 ++++++ src/debugger.ts | 6 ++++++ src/index.ts | 8 ++++---- src/visual-agent.ts | 6 ++++++ tests/predicate-aliases.test.ts | 33 +++++++++++++++++++++++++++++++ 8 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 tests/predicate-aliases.test.ts diff --git a/src/agent.ts b/src/agent.ts index e50c1e4..5963579 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -535,3 +535,9 @@ export class SentienceAgent { } } } + +/** + * Predicate rebrand alias for SentienceAgent. + * Kept as a runtime alias to avoid breaking existing integrations. + */ +export const PredicateAgent = SentienceAgent; diff --git a/src/backends/index.ts b/src/backends/index.ts index 4b4f51d..76238c5 100644 --- a/src/backends/index.ts +++ b/src/backends/index.ts @@ -108,6 +108,7 @@ export { // SentienceContext (Token-Slasher Context Middleware) export { SentienceContext, + PredicateContext, SentienceContextState, SentienceContextOptions, TopElementSelector, diff --git a/src/backends/sentience-context.ts b/src/backends/sentience-context.ts index 084044d..785ff6c 100644 --- a/src/backends/sentience-context.ts +++ b/src/backends/sentience-context.ts @@ -474,3 +474,9 @@ export class SentienceContext { return this._selector; } } + +/** + * Predicate rebrand alias for SentienceContext. + * Kept as a runtime alias to avoid breaking existing integrations. + */ +export const PredicateContext = SentienceContext; diff --git a/src/browser.ts b/src/browser.ts index 9894a2f..01a776e 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1021,3 +1021,9 @@ export class SentienceBrowser implements IBrowser { return finalPath; } } + +/** + * Predicate rebrand alias for SentienceBrowser. + * Kept as a runtime alias to avoid breaking existing integrations. + */ +export const PredicateBrowser = SentienceBrowser; diff --git a/src/debugger.ts b/src/debugger.ts index bea3bec..4b4d33e 100644 --- a/src/debugger.ts +++ b/src/debugger.ts @@ -131,3 +131,9 @@ export class SentienceDebugger { return new DebuggerAssertionHandle(this, predicate, label, required, true, openedStepId); } } + +/** + * Predicate rebrand alias for SentienceDebugger. + * Kept as a runtime alias to avoid breaking existing integrations. + */ +export const PredicateDebugger = SentienceDebugger; diff --git a/src/index.ts b/src/index.ts index 81f741a..fdbb4de 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ * Sentience TypeScript SDK - AI Agent Browser Automation */ -export { SentienceBrowser, PermissionPolicy } from './browser'; +export { SentienceBrowser, PredicateBrowser, PermissionPolicy } from './browser'; export { snapshot, SnapshotOptions, SnapshotGatewayError } from './snapshot'; export { query, find, parseSelector } from './query'; export { @@ -46,8 +46,8 @@ export { AnthropicProvider, GLMProvider, } from './llm-provider'; -export { SentienceAgent, AgentActResult, HistoryEntry, TokenStats } from './agent'; -export { SentienceVisualAgent } from './visual-agent'; +export { SentienceAgent, PredicateAgent, AgentActResult, HistoryEntry, TokenStats } from './agent'; +export { SentienceVisualAgent, PredicateVisualAgent } from './visual-agent'; // Conversational Agent Layer (v0.3.0+) export { @@ -87,7 +87,7 @@ export { isCollapsed, } from './verification'; export { AgentRuntime, AssertionHandle, AssertionRecord, EventuallyOptions } from './agent-runtime'; -export { SentienceDebugger } from './debugger'; +export { SentienceDebugger, PredicateDebugger } from './debugger'; export { RuntimeAgent } from './runtime-agent'; export type { RuntimeStep, StepVerification } from './runtime-agent'; export { parseVisionExecutorAction, executeVisionExecutorAction } from './vision-executor'; diff --git a/src/visual-agent.ts b/src/visual-agent.ts index 66ca138..1692345 100644 --- a/src/visual-agent.ts +++ b/src/visual-agent.ts @@ -906,3 +906,9 @@ Return ONLY the integer ID number from the label, nothing else.`; } } } + +/** + * Predicate rebrand alias for SentienceVisualAgent. + * Kept as a runtime alias to avoid breaking existing integrations. + */ +export const PredicateVisualAgent = SentienceVisualAgent; diff --git a/tests/predicate-aliases.test.ts b/tests/predicate-aliases.test.ts new file mode 100644 index 0000000..42b5e90 --- /dev/null +++ b/tests/predicate-aliases.test.ts @@ -0,0 +1,33 @@ +import { + PredicateAgent, + PredicateBrowser, + PredicateDebugger, + PredicateVisualAgent, + SentienceAgent, + SentienceBrowser, + SentienceDebugger, + SentienceVisualAgent, + backends, +} from '../src'; + +describe('Predicate rebrand aliases', () => { + it('aliases browser constructor', () => { + expect(PredicateBrowser).toBe(SentienceBrowser); + }); + + it('aliases agent constructor', () => { + expect(PredicateAgent).toBe(SentienceAgent); + }); + + it('aliases visual agent constructor', () => { + expect(PredicateVisualAgent).toBe(SentienceVisualAgent); + }); + + it('aliases debugger constructor', () => { + expect(PredicateDebugger).toBe(SentienceDebugger); + }); + + it('exports backend PredicateContext alias', () => { + expect(backends.PredicateContext).toBe(backends.SentienceContext); + }); +}); From 041d02f69c5ba8c0c8ed0ca5aaa5d6dba7886787 Mon Sep 17 00:00:00 2001 From: SentienceDEV Date: Tue, 10 Feb 2026 21:34:09 -0800 Subject: [PATCH 2/2] fix tests --- CHANGELOG.md | 23 ++++++++++++++++++++++ README.md | 20 +++++++++++++++++++ src/actions.ts | 8 +++++++- tests/README.md | 51 +++++++++++++++++++++++++++++-------------------- 4 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0681884 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +All notable changes to `@predicatelabs/sdk` will be documented in this file. + +## Unreleased + +### Deprecated + +- Soft-deprecated legacy `Sentience*` class names in favor of `Predicate*` names: + - `SentienceBrowser` -> `PredicateBrowser` + - `SentienceAgent` -> `PredicateAgent` + - `SentienceVisualAgent` -> `PredicateVisualAgent` + - `SentienceDebugger` -> `PredicateDebugger` + - `backends.SentienceContext` -> `backends.PredicateContext` +- Legacy names remain supported as runtime aliases for compatibility during a transition window of **1-2 releases**. + +### Added + +- Runtime alias exports for `Predicate*` counterparts to preserve backwards compatibility while enabling rebrand migration. + +### Fixed + +- 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. diff --git a/README.md b/README.md index 90f6664..c494781 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,26 @@ npm install @predicatelabs/sdk npx playwright install chromium ``` +## Naming migration (Predicate rebrand) + +Use the new `Predicate*` class names for all new code: + +- `PredicateBrowser` +- `PredicateAgent` +- `PredicateVisualAgent` +- `PredicateDebugger` +- `backends.PredicateContext` + +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**. + +Mapping: + +- `SentienceBrowser` -> `PredicateBrowser` +- `SentienceAgent` -> `PredicateAgent` +- `SentienceVisualAgent` -> `PredicateVisualAgent` +- `SentienceDebugger` -> `PredicateDebugger` +- `backends.SentienceContext` -> `backends.PredicateContext` + ## Conceptual example (why this exists) - Steps are **gated by verifiable UI assertions** diff --git a/src/actions.ts b/src/actions.ts index f73d99e..27485f7 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1134,7 +1134,13 @@ export async function search( const urlBefore = page.url(); const url = buildSearchUrl(query, engine); await browser.goto(url); - await page.waitForLoadState('networkidle'); + // Some search engines keep long-lived background requests open in CI, + // so treat networkidle as a best-effort signal instead of a hard requirement. + try { + await page.waitForLoadState('networkidle', { timeout: 5000 }); + } catch { + // no-op: page is already loaded enough for URL/result assertions + } const durationMs = Date.now() - startTime; const urlAfter = page.url(); diff --git a/tests/README.md b/tests/README.md index 80573a3..f6572b8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,5 +1,10 @@ # Running Tests - TypeScript SDK +## Naming for new tests + +Use `Predicate*` names in new test code (for example `PredicateBrowser`, `PredicateAgent`, `PredicateDebugger`). +Legacy `Sentience*` names still work as compatibility aliases, but new tests should prefer the rebranded names. + ## Prerequisites ```bash @@ -82,30 +87,30 @@ Create test files in `tests/` directory: ### Example: `tests/inspector.test.ts` ```typescript -import { SentienceBrowser, inspect } from '../src'; +import { PredicateBrowser, inspect } from '../src'; describe('Inspector', () => { it('should start and stop', async () => { - const browser = new SentienceBrowser(undefined, undefined, false); + const browser = new PredicateBrowser(undefined, undefined, false); await browser.start(); - + try { await browser.getPage().goto('https://example.com'); await browser.getPage().waitForLoadState('networkidle'); - + const inspector = inspect(browser); await inspector.start(); - - const active = await browser.getPage().evaluate( - () => (window as any).__sentience_inspector_active === true - ); + + const active = await browser + .getPage() + .evaluate(() => (window as any).__sentience_inspector_active === true); expect(active).toBe(true); - + await inspector.stop(); - - const inactive = await browser.getPage().evaluate( - () => (window as any).__sentience_inspector_active === true - ); + + const inactive = await browser + .getPage() + .evaluate(() => (window as any).__sentience_inspector_active === true); expect(inactive).toBe(false); } finally { await browser.close(); @@ -117,27 +122,27 @@ describe('Inspector', () => { ### Example: `tests/recorder.test.ts` ```typescript -import { SentienceBrowser, record } from '../src'; +import { PredicateBrowser, record } from '../src'; describe('Recorder', () => { it('should record click events', async () => { - const browser = new SentienceBrowser(undefined, undefined, false); + const browser = new PredicateBrowser(undefined, undefined, false); await browser.start(); - + try { await browser.getPage().goto('https://example.com'); await browser.getPage().waitForLoadState('networkidle'); - + const rec = record(browser); rec.start(); - + rec.recordClick(1, 'role=button'); - + const trace = rec.getTrace(); expect(trace.steps.length).toBe(1); expect(trace.steps[0].type).toBe('click'); expect(trace.steps[0].element_id).toBe(1); - + rec.stop(); } finally { await browser.close(); @@ -202,25 +207,29 @@ npm test -- tests/inspector.test.ts -t "should start" ## Troubleshooting ### TypeScript compilation errors + ```bash npm run build ``` ### Browser not found + ```bash npx playwright install chromium ``` ### Extension not found + Make sure the extension is built: + ```bash cd ../sentience-chrome ./build.sh ``` ### Module not found errors + ```bash npm install npm run build ``` -