diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33e8fcd..d934da9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -170,7 +170,7 @@ jobs: npm profile get --registry https://registry.npmjs.org --json || echo "WARN: cannot read npm profile (continuing)" echo "" echo "=== Sanity: does package already exist? (ok if 404) ===" - npm view @predicatesystems/sdk version --registry https://registry.npmjs.org --json || echo "INFO: @predicatesystems/sdk not found yet (expected for first publish)" + npm view @predicatesystems/runtime version --registry https://registry.npmjs.org --json || echo "INFO: @predicatesystems/runtime not found yet (expected for first publish)" - name: Publish to npm run: | @@ -185,14 +185,55 @@ jobs: tag_name: v${{ steps.version.outputs.version }} name: Release v${{ steps.version.outputs.version }} body: | - Release v${{ steps.version.outputs.version }} of @predicatesystems/sdk + Release v${{ steps.version.outputs.version }} of @predicatesystems/runtime ## Installation ```bash - npm install @predicatesystems/sdk@${{ steps.version.outputs.version }} + npm install @predicatesystems/runtime@${{ steps.version.outputs.version }} ``` draft: false prerelease: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-compat-shim: + runs-on: ubuntu-latest + needs: build-and-publish + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + scope: '@predicatesystems' + always-auth: true + + - name: Extract version from tag or input + id: version + run: | + if [ "${{ github.event_name }}" == "release" ]; then + TAG_NAME="${{ github.event.release.tag_name }}" + VERSION=${TAG_NAME#v} + else + VERSION="${{ github.event.inputs.version }}" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + + - name: Sync shim version and runtime dependency + run: | + VERSION="${{ steps.version.outputs.version }}" + npm pkg set version=$VERSION --prefix compat/sdk-shim + npm pkg set dependencies."@predicatesystems/runtime"=$VERSION --prefix compat/sdk-shim + + - name: Publish compatibility shim to npm + run: | + cd compat/sdk-shim + npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 77852f9..a21ccd1 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,4 +1,4 @@ { - "*.ts": ["eslint --fix --max-warnings=-1", "prettier --write"], + "*.ts": ["eslint --fix --max-warnings=-1 --no-warn-ignored", "prettier --write"], "*.{json,md}": ["prettier --write"] } diff --git a/CHANGELOG.md b/CHANGELOG.md index efbf6b8..43da20b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `@predicatesystems/sdk` will be documented in this file. +All notable changes to `@predicatesystems/runtime` will be documented in this file. ## Unreleased @@ -24,7 +24,7 @@ import { PredicateBrowserAgent, type RuntimeStep, LocalLLMProvider, // or OpenAIProvider / AnthropicProvider / DeepInfraProvider -} from '@predicatesystems/sdk'; +} from '@predicatesystems/runtime'; const runtime = new AgentRuntime(browserLike, page, tracer); const llm = new LocalLLMProvider({ model: 'qwen2.5:7b', baseUrl: 'http://localhost:11434/v1' }); @@ -65,7 +65,7 @@ const agent = new PredicateBrowserAgent({ If you set `captcha.policy="callback"`, you must provide a handler. The SDK does **not** include a public CAPTCHA solver. ```ts -import { HumanHandoffSolver } from '@predicatesystems/sdk'; +import { HumanHandoffSolver } from '@predicatesystems/runtime'; const agent = new PredicateBrowserAgent({ runtime, diff --git a/README.md b/README.md index b4920a4..916743d 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,16 @@ The core loop is: ## Install ```bash -npm install @predicatesystems/sdk +npm install @predicatesystems/runtime npx playwright install chromium ``` +Legacy install compatibility remains available through the shim package: + +```bash +npm install @predicatesystems/sdk +``` + ## Naming migration (Predicate rebrand) Use the new `Predicate*` class names for all new code: @@ -51,9 +57,9 @@ Use the new `Predicate*` class names for all new code: ## Quickstart: a verification-first loop ```ts -import { PredicateBrowser, AgentRuntime } from '@predicatesystems/sdk'; -import { JsonlTraceSink, Tracer } from '@predicatesystems/sdk'; -import { exists, urlContains } from '@predicatesystems/sdk'; +import { PredicateBrowser, AgentRuntime } from '@predicatesystems/runtime'; +import { JsonlTraceSink, Tracer } from '@predicatesystems/runtime'; +import { exists, urlContains } from '@predicatesystems/runtime'; import type { Page } from 'playwright'; async function main(): Promise { @@ -102,7 +108,7 @@ import { JsonlTraceSink, exists, urlContains, -} from '@predicatesystems/sdk'; +} from '@predicatesystems/runtime'; async function runExistingAgent(page: Page): Promise { const tracer = new Tracer('run-123', new JsonlTraceSink('trace.jsonl')); @@ -129,7 +135,14 @@ async function runExistingAgent(page: Page): Promise { If you want Predicate to drive the loop end-to-end, you can use the SDK primitives directly: take a snapshot, select elements, act, then verify. ```ts -import { PredicateBrowser, snapshot, find, typeText, click, waitFor } from '@predicatesystems/sdk'; +import { + PredicateBrowser, + snapshot, + find, + typeText, + click, + waitFor, +} from '@predicatesystems/runtime'; async function loginExample(): Promise { const browser = new PredicateBrowser(); @@ -207,7 +220,7 @@ if (!ok) { ## ToolRegistry (LLM-callable tools) ```ts -import { ToolRegistry, registerDefaultTools } from '@predicatesystems/sdk'; +import { ToolRegistry, registerDefaultTools } from '@predicatesystems/runtime'; const registry = new ToolRegistry(); registerDefaultTools(registry); @@ -219,8 +232,8 @@ const toolsForLLM = registry.llmTools(); Chrome permission prompts are outside the DOM and can be invisible to snapshots. Prefer setting a policy **before navigation**. ```ts -import { PredicateBrowser } from '@predicatesystems/sdk'; -import type { PermissionPolicy } from '@predicatesystems/sdk'; +import { PredicateBrowser } from '@predicatesystems/runtime'; +import type { PermissionPolicy } from '@predicatesystems/runtime'; const policy: PermissionPolicy = { default: 'clear', @@ -254,7 +267,7 @@ If your backend supports it, you can also use ToolRegistry permission tools (`gr ## Downloads (verification predicate) ```ts -import { downloadCompleted } from '@predicatesystems/sdk'; +import { downloadCompleted } from '@predicatesystems/runtime'; runtime.assert(downloadCompleted('report.csv'), 'download_ok', true); ``` diff --git a/compat/sdk-shim/README.md b/compat/sdk-shim/README.md new file mode 100644 index 0000000..15bb845 --- /dev/null +++ b/compat/sdk-shim/README.md @@ -0,0 +1,10 @@ +# @predicatesystems/sdk compatibility shim + +This package preserves install/import compatibility for users still on: + +```bash +npm install @predicatesystems/sdk +``` + +It re-exports from `@predicatesystems/runtime`. New code should import from +`@predicatesystems/runtime` directly. diff --git a/compat/sdk-shim/index.d.ts b/compat/sdk-shim/index.d.ts new file mode 100644 index 0000000..8d55840 --- /dev/null +++ b/compat/sdk-shim/index.d.ts @@ -0,0 +1 @@ +export * from '@predicatesystems/runtime'; diff --git a/compat/sdk-shim/index.js b/compat/sdk-shim/index.js new file mode 100644 index 0000000..42bfe95 --- /dev/null +++ b/compat/sdk-shim/index.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = require("@predicatesystems/runtime"); diff --git a/compat/sdk-shim/package.json b/compat/sdk-shim/package.json new file mode 100644 index 0000000..3652239 --- /dev/null +++ b/compat/sdk-shim/package.json @@ -0,0 +1,19 @@ +{ + "name": "@predicatesystems/sdk", + "version": "1.1.0", + "description": "Compatibility shim for @predicatesystems/runtime", + "main": "index.js", + "types": "index.d.ts", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@predicatesystems/runtime": "1.1.0" + }, + "files": [ + "index.js", + "index.d.ts", + "README.md" + ], + "license": "(MIT OR Apache-2.0)" +} diff --git a/eslint.config.js b/eslint.config.js index e1ab76a..1d4fac7 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -49,6 +49,7 @@ module.exports = tseslint.config( 'node_modules/**', '*.js', 'src/extension/**', + 'compat/**', 'examples/**', 'tests/**', ], diff --git a/examples/agent-runtime-captcha-strategies.ts b/examples/agent-runtime-captcha-strategies.ts index 62b966c..3675633 100644 --- a/examples/agent-runtime-captcha-strategies.ts +++ b/examples/agent-runtime-captcha-strategies.ts @@ -5,8 +5,8 @@ import { HumanHandoffSolver, SentienceBrowser, VisionSolver, -} from '@predicatesystems/sdk'; -import { createTracer } from '@predicatesystems/sdk'; +} from '@predicatesystems/runtime'; +import { createTracer } from '@predicatesystems/runtime'; async function notifyWebhook(ctx: any): Promise { console.log(`[captcha] external resolver notified: url=${ctx.url} run_id=${ctx.runId}`); diff --git a/examples/lang-chain/README.md b/examples/lang-chain/README.md index 41a7812..39cc663 100644 --- a/examples/lang-chain/README.md +++ b/examples/lang-chain/README.md @@ -5,7 +5,7 @@ These examples show how to wrap Sentience TS SDK primitives as LangChain JS tool Install (example): ```bash -npm install @predicatesystems/sdk @langchain/core zod +npm install @predicatesystems/runtime @langchain/core zod ``` Run: diff --git a/examples/lang-chain/sentience-tools-demo.ts b/examples/lang-chain/sentience-tools-demo.ts index 4060927..9c840f2 100644 --- a/examples/lang-chain/sentience-tools-demo.ts +++ b/examples/lang-chain/sentience-tools-demo.ts @@ -2,7 +2,7 @@ * Example: Wrap Sentience TS SDK primitives as LangChain JS tools. * * Install (example): - * npm install @predicatesystems/sdk @langchain/core zod + * npm install @predicatesystems/runtime @langchain/core zod * * Run: * npx ts-node examples/lang-chain/sentience-tools-demo.ts diff --git a/package-lock.json b/package-lock.json index 54a02e3..5f67204 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@predicatesystems/sdk", + "name": "@predicatesystems/runtime", "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@predicatesystems/sdk", + "name": "@predicatesystems/runtime", "version": "1.1.0", "license": "(MIT OR Apache-2.0)", "dependencies": { diff --git a/package.json b/package.json index 75d5552..9c11403 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@predicatesystems/sdk", + "name": "@predicatesystems/runtime", "version": "1.1.0", "description": "TypeScript SDK for Sentience AI Agent Browser Automation", "main": "dist/index.js", diff --git a/src/visual-agent.ts b/src/visual-agent.ts index 93c548e..b050a6a 100644 --- a/src/visual-agent.ts +++ b/src/visual-agent.ts @@ -675,7 +675,7 @@ Return ONLY the integer ID number from the label, nothing else.`; playgroundPath = path.join(cwd, 'playground', 'images'); } else { // Check if we're in a playground context via module path - const modulePaths = require.resolve.paths('@predicatesystems/sdk') || []; + const modulePaths = require.resolve.paths('@predicatesystems/runtime') || []; for (const modulePath of modulePaths) { const potentialPlayground = path.join(modulePath, '..', 'playground', 'images'); if (fs.existsSync(path.dirname(potentialPlayground))) {