import uplink from '@uplink-code/uplink'
import ai from '@uplink-code/ai'
// Create an AI agent
const agent = ai.createAgent({
provider: 'anthropic',
options: {
apiKey: process.env.ANTHROPIC_API_KEY
}
})
// Connect with the agent
const session = await uplink.session('<organization-api-key>', {
projectId: '<project-id>',
include: { ecdsa: true, ecdh: true }
})
const client = await uplink.client.fromSession(session, { agent })
const browser = await client.launch()
const page = await browser.newPage()
await page.goto('https://example.com/products')
// Use natural language to perform actions
await page.act('Find the cheapest laptop and add it to cart')
// Extract structured data with type safety
import { z } from 'zod'
const productSchema = z.object({
name: z.string(),
price: z.number(),
inStock: z.boolean()
})
const result = await page.extract(
'Get the product details from this page',
productSchema
)
console.log(result.data)
// { name: "ThinkPad X1", price: 1299.99, inStock: true }