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

alpha-tools

v0.1.0

Published

Provider-agnostic tool wrapper with first-class Vercel AI SDK support.

Downloads

11

Readme

Alpha Tools

Provider-agnostic tool SDK with a first-class adapter for the Vercel AI SDK. Define tools once, then expose them to AI providers through thin adapters (alpha-tools/ai today; alpha-tools/openai, alpha-tools/google, etc. later).

Features

  • Single entrypoint: createTools wraps your tools and returns one AI SDK tool: execute_js.
  • Vendor-neutral core: keep using your Tool definitions when you add new providers.
  • Implicit returns: last expression is auto-returned (Jupyter-style) to reduce prompt noise.
  • Built-in docs: getToolDoc(toolFn) lives in the execution scope for lazy, per-tool help.
  • CDP-ready context: Network, Page, Runtime, and client are injected for implementations.

Install

npm install alpha-tools ai
  • ai is a peer dependency (you own the version).
  • zod ships with this package because AI SDK tools use it at runtime.

Quick start (AI SDK)

import { generateText } from 'ai';
import type { Tool, ToolContext } from 'alpha-tools';
import { createTools } from 'alpha-tools/ai';

const tools: Tool[] = [
  {
    name: 'getWeather',
    description: 'Get the weather in a location',
    parameters: [{ name: 'location', type: 'string', description: 'City', required: true }],
    output: { type: 'object', description: 'Weather info' },
    implementation: async ({ location }, ctx) => {
      // ctx.Network / ctx.Page / ctx.Runtime / ctx.client are available
      return { location, temperature: 72, condition: 'Sunny' };
    },
  },
];

const cdpContext: ToolContext = { Network, Page, Runtime, client };
const aiTools = createTools(tools, cdpContext); // -> { execute_js }

const result = await generateText({
  model: 'openai/gpt-4o',
  prompt: 'Weather in SF?',
  tools: aiTools,
});

Using existing AI SDK tools

If you already have native AI SDK tools, you can bring them in unchanged:

import { tool } from 'ai';
import { createTools } from 'alpha-tools/ai';

const nativeTools = {
  ping: tool({
    description: 'Ping the server',
    inputSchema: z.object({}),
    async execute() {
      return 'pong';
    },
  }),
};

const aiTools = createTools(nativeTools); // context optional when using native tools

API

createTools(tools: Tool[], context: ToolContext): Record<string, any>;
createTools(tools: Record<string, any>, context?: ToolContext): Record<string, any>;
createTools({ tools, context }: { tools: Tool[] | Record<string, any>; context?: ToolContext }): Record<string, any>;
  • Always returns { execute_js } in AI SDK format.
  • Tool[] path requires a CDP-style ToolContext so your implementations can call Network/Page/Runtime/client.
  • Native AI SDK tools skip context; they are wrapped and injected for JS execution.

Tool shape (vendor-neutral)

type Tool = {
  name: string;
  description: string;
  parameters: ToolParameter[];
  output: ToolOutput;
  implementation: (params: Record<string, any>, context: ToolContext) => Promise<any>;
};

See types.ts for the complete schema.

Package structure

  • types.ts — Core type definitions (Tool, ToolParameter, ToolOutput, ToolContext, etc.)
  • builder.tsToolEnvironmentBuilder injects tools + CDP domains; exposes execute(code)
  • documentation.tsgenerateDocumentation and generateToolList for prompt-time docs
  • ai-sdk/adapter.tstoAISDKTool, toAISDKTools, and the user-facing createTools
  • Subpath exports:
    • alpha-tools — generic SDK
    • alpha-tools/ai — Vercel AI SDK adapter

Adding other providers

Follow the AI SDK adapter pattern:

  1. Create a folder for the provider (e.g., openai/adapter.ts or anthropic/adapter.ts).
  2. Import the generic Tool / ToolEnvironmentBuilder.
  3. Map between the provider’s tool format and the generic SDK, or wrap execute_js into the provider’s tool contract.

The core SDK (types.ts, builder.ts, documentation.ts, index.ts) stays stable and provider-neutral.

Development

npm run build   # compile to dist/ with types
npm run clean   # remove dist/

npm pack/publish uses prepare to build automatically. README.md is what GitHub and npm will display.