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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agentified/ai-sdk

v2.0.0

Published

Vercel AI SDK adapter for [Agentified](../../../README.md) — wraps SDK classes with AI SDK-typed shells via composition. Tools are exposed as AI SDK `tool()` objects for direct use with `generateText`/`streamText`.

Downloads

324

Readme

@agentified/ai-sdk

Vercel AI SDK adapter for Agentified — wraps SDK classes with AI SDK-typed shells via composition. Tools are exposed as AI SDK tool() objects for direct use with generateText/streamText.

Install

npm install @agentified/ai-sdk agentified

Peer dependencies: ai >= 6.0.0, zod >= 3.0.0

Quick Start

import { Agentified } from "agentified";
import { aiSdk } from "@agentified/ai-sdk";
import { openai } from "@ai-sdk/openai";
import { generateText, stepCountIs } from "ai";

const ag = new Agentified().adaptTo(aiSdk());
await ag.connect("http://localhost:9119");

const instance = await ag.dataset("my-agent").register({
  tools: [
    { name: "get_weather", description: "Get weather", parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"] }, handler: async (args) => ({ temp: 22 }) },
  ],
});

const session = instance.session("chat-1");

// All tools passed upfront, prepareStep controls activeTools per step
const result = await generateText({
  model: openai("gpt-4o"),
  tools: session.tools,
  prepareStep: session.prepareStep,
  stopWhen: stepCountIs(10),
  prompt: "Use agentified_discover to find tools, then call them.",
});

// Persist final step's messages (prepareStep only flushes previous steps)
await session.flushMessages(result.steps);

With Context Builder

const ctx = await session.context
  .tools({ agentified_discover: session.discoverTool })
  .messages({ strategy: "recent", maxTokens: 4000 })
  .recall({ tools: true })
  .assemble();

const result = await generateText({
  model: openai("gpt-4o"),
  tools: ctx.tools,
  prepareStep: ctx.prepareStep,
  stopWhen: stepCountIs(10),
  messages: ctx.messages.map(m => ({ role: m.role as any, content: m.content })),
});

await ctx.flushMessages(result.steps);

Key Differences from Mastra Adapter

| Concern | Mastra (@agentified/mastra) | AI SDK (@agentified/ai-sdk) | |---|---|---| | Tool delivery | prepareStep returns { tools } per step | tools property upfront; prepareStep returns { activeTools: string[] } | | Tool creation | createTool() from @mastra/core | tool() from ai | | Final step | Handled by Mastra | Call flushMessages(result.steps) after generateText | | Streaming | streamSSE() export | Use streamText() from ai directly |

Adapter Pattern

Agentified.adaptTo(aiSdk()) → AiSdkAgentified
  └─ .dataset(name) → AiSdkDatasetRef
       └─ .register({ tools }) → AiSdkInstance
            ├─ .tools            — Record<string, CoreTool> (all tools upfront)
            ├─ .discoverTool     — AI SDK tool()
            ├─ .prepareStep      — returns { activeTools: string[] }
            ├─ .session(id)      → AiSdkSession
            │    ├─ .tools             — includes discover + getMessages + backend
            │    ├─ .discoverTool      — AI SDK tool()
            │    ├─ .getMessagesTool   — AI SDK tool()
            │    ├─ .prepareStep       — returns { activeTools: string[] }
            │    ├─ .flushMessages(steps) — persist final step
            │    ├─ .context           → AiSdkContextBuilder
            │    │    ├─ .tools() / .messages() / .recall() / .limitTokens()
            │    │    └─ .assemble()   → AiSdkAssembledContext
            │    │         ├─ .tools          — explicit + discovered
            │    │         ├─ .prepareStep    — returns { activeTools }
            │    │         └─ .flushMessages  — persist final step
            │    ├─ .conversation (SDK passthrough)
            │    └─ .getMessages / .updateConversation
            └─ .namespace(id)    → AiSdkNamespace
                 └─ .session(id) → AiSdkSession

API Reference

aiSdk()

Returns an adapter object for Agentified.adaptTo().

AiSdkInstance

Wraps SDK Instance. Exposes tools (all registered tools as AI SDK objects) and prepareStep (returns { activeTools }).

AiSdkSession

Wraps SDK Session. Exposes tools, prepareStep, flushMessages, and context builder. discoverTool and getMessagesTool are AI SDK tool() results.

flushMessages(steps)

Call after generateText/streamText completes to persist the final step's messages. The SDK's prepareStep persists messages from previous steps, but the last step has no subsequent prepareStep call.

jsonSchemaToZod(schema)

Converts a JSON Schema object to a Zod schema. Used internally to hydrate AI SDK tools.

Links

License

MIT