Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
8 changes: 7 additions & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/backends/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export {
// SentienceContext (Token-Slasher Context Middleware)
export {
SentienceContext,
PredicateContext,
SentienceContextState,
SentienceContextOptions,
TopElementSelector,
Expand Down
6 changes: 6 additions & 0 deletions src/backends/sentience-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions src/visual-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
51 changes: 30 additions & 21 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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
```

33 changes: 33 additions & 0 deletions tests/predicate-aliases.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading