npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@uplink-code/ai

v0.0.0

Published

AI agent extensions for Uplink browser automation

Readme

@uplink-code/ai

AI agent plugin for Uplink browser automation. This package provides AI-powered methods (act and extract) for natural language browser automation.

Installation

npm install @uplink-code/ai

Note: This package has a peer dependency on @uplink-code/uplink. The zod package is included as a dependency, so you don't need to install it separately.

Usage

Basic Setup

import uplink from '@uplink-code/uplink'
import ai from '@uplink-code/ai'

// Create an agent with your LLM provider configuration
const agent = ai.createAgent({
  provider: 'anthropic',
  options: {
    apiKey: process.env.ANTHROPIC_API_KEY
  }
})

// Connect to uplink with agent support
const client = await uplink.client.connect('ws://localhost:8080', { agent })
const browser = await client.launch()
const page = await browser.newPage()

// Now you can use AI-powered methods
await page.goto('https://example.com')

Act - Natural Language Actions

Execute browser actions using natural language instructions:

// Single action
await page.act('click the sign in button')

// Multiple actions
await page.act('fill in the email field with "[email protected]" and click submit')

// Get typed results from complex workflows
const result = await page.act('search for "TypeScript" and click the first result')
console.log(result.success, result.actions, result.reasoning)

// TypeScript automatically knows the result structure:
// - result.success: boolean
// - result.actions: Array<{ type: string, params: unknown[], result?: unknown, error?: string }>
// - result.reasoning?: string

Extract - Structured Data Extraction

Extract data from pages with optional schema validation:

import { z } from 'zod'

// Extract without schema - returns unstructured string
const textResult = await page.extract('extract the product name and price')
// textResult.data is typed as { extraction: string } | undefined
if (textResult.success && textResult.data) {
  console.log(textResult.data.extraction)
}

// Extract with Zod schema - automatic type inference!
const productSchema = z.object({
  name: z.string(),
  price: z.number(),
  inStock: z.boolean()
})

const productResult = await page.extract('extract product details', productSchema)
// TypeScript automatically infers productResult.data type from the schema!
// productResult.data is typed as { name: string, price: number, inStock: boolean } | undefined

if (productResult.success && productResult.data) {
  // No type assertions needed - TypeScript knows the exact shape
  console.log(productResult.data.name)      // string
  console.log(productResult.data.price)     // number
  console.log(productResult.data.inStock)   // boolean
}

// Extract arrays of structured data
const accountSchema = z.array(
  z.object({
    routing: z.string(),
    account: z.string()
  })
)

const accountResult = await page.extract('extract all account details', accountSchema)
// accountResult.data is automatically typed as Array<{ routing: string, account: string }> | undefined
if (accountResult.success && accountResult.data) {
  accountResult.data.forEach(account => {
    console.log(`Routing: ${account.routing}, Account: ${account.account}`)
  })
}

Configuration

Anthropic (Claude)

import ai from '@uplink-code/ai'

const agent = ai.createAgent({
  provider: 'anthropic',
  model: 'claude-sonnet-4-5-20250929', // optional, this is the default
  maxTokens: 4096, // optional
  options: {
    apiKey: 'your-api-key',
    dangerouslyAllowBrowser: true // optional, defaults to true
  }
})

Configuration options:

  • provider: Must be 'anthropic'
  • model (optional): Model to use. Default: 'claude-sonnet-4-5-20250929'
  • maxTokens (optional): Maximum tokens for responses
  • options: Accepts all Anthropic SDK ClientOptions:
    • apiKey (optional): Your Anthropic API key. Can also use ANTHROPIC_API_KEY env var
    • dangerouslyAllowBrowser (optional): Allow browser usage. Default: false
    • All other Anthropic SDK options (baseURL, timeout, etc.)

OpenAI (Coming Soon)

import ai from '@uplink-code/ai'

const agent = ai.createAgent({
  provider: 'openai',
  model: 'gpt-4', // optional
  options: {
    apiKey: 'your-api-key'
  }
})

Why a Separate Package?

The @uplink-code/ai package is separate from the core @uplink-code/uplink package to:

  • Reduce bundle size: The AI dependencies (@anthropic-ai/sdk and zod) add ~580KB. Users who don't need AI features don't pay this cost.
  • Optional functionality: AI features are opt-in. Install this package only when you need them.
  • Plugin architecture: The core @uplink-code/uplink package defines the Agent interface, and this package implements it. Clean separation of concerns.
  • Lightweight core: Keep the core automation API focused and lightweight (~44KB).

Type Safety

This package provides full TypeScript support with automatic type inference for extracted data:

  • With Zod schema: TypeScript automatically infers the exact type from your schema - no manual type annotations or assertions needed
  • Without schema: Returns { extraction: string } for unstructured text extraction
  • Zero boilerplate: The return type is inferred directly from the schema parameter using TypeScript's advanced type system

License

Proprietary