New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@onkernel/ai-sdk

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onkernel/ai-sdk

Vercel AI SDK-compatible tools for Onkernel Kernel SDK (Playwright execution).

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
2
Created
Source

@onkernel/ai-sdk

Vercel AI SDK-compatible tools for the Kernel SDK. This package exposes a Playwright execution tool wired to an existing Kernel browser session, so LLMs can browse and act via structured tools.

Install

npm install @onkernel/ai-sdk zod
# Ensure your app depends on the Vercel AI SDK and @onkernel/sdk
npm install ai @onkernel/sdk

Note: @onkernel/sdk is a peer dependency; install it in your application.

Usage

import { playwrightExecuteTool } from "@onkernel/ai-sdk";
import Kernel from "@onkernel/sdk";
import { generateText } from "ai";

// 1) Create Kernel client and start a browser session
const client = new Kernel({
  apiKey: process.env["KERNEL_API_KEY"], // optional, default env lookup
});
const browser = await client.browsers.create({ browser: "chromium" });
const sessionId = browser.session_id;
console.log(sessionId);

// 2) Create the Playwright execution tool
const playwrightTool = playwrightExecuteTool({ client, sessionId });

// 3) Use with Vercel AI SDK
const model = ...; // your AI model instance

const result = await generateText({
  model,
  prompt: "Open example.com and click the first link",
  tools: {
    playwright_execute: playwrightTool,
  },
});

Tool shape

playwrightExecuteTool returns a single Vercel AI SDK tool instance. The tool's input mirrors PlaywrightExecuteParams from the Kernel SDK:

{
  code: string;        // required JavaScript/TypeScript snippet
  timeout_sec?: number; // optional execution timeout in seconds (default 60)
}

Under the hood we call client.browsers.playwright.execute(sessionId, { code, timeout_sec }), so any code you can run through the SDK can be run via the tool.

API

function playwrightExecuteTool(options: {
  client: Kernel; // Kernel SDK client instance (@onkernel/sdk)
  sessionId: string; // Existing browser session id
}): ReturnType<typeof tool>;

Examples

Run the sample script in examples/basic.ts after exporting both KERNEL_API_KEY and a model provider key (the example uses OpenAI):

export KERNEL_API_KEY=...
export OPENAI_API_KEY=...
pnpm exec tsx examples/basic.ts

The script mirrors the usage above: it starts a browser session, registers the playwright_execute tool, calls generateText from the Vercel AI SDK (forcing the model to invoke the tool), logs the model response/tool results, and then cleans up the browser session.

License

MIT © Kernel

Keywords

vercel

FAQs

Package last updated on 20 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts