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

ai-sdk-agentic

v1.0.1

Published

Orchestration layer for Vercel AI SDK agents: shared context, mission lifecycle hooks, and tool wrapping.

Readme

ai-sdk-agentic (Core) 🤖

The core package of the AI SDK Agentic framework. This package provides the low-level immutable proxy, the global event bus, and the AgenticHooks infrastructure.

Note: For general usage, installation, and built-in plugins (withHandoff, withConsoleLogger), please refer to the Global Documentation.

Create Your Own Plugin

Plugins are simple functions that receive the current AgenticMission and return AgenticHooks. They allow you to modify options, intercept prompts, or wrap execution.

Plugin Hooks Reference

Specialized Hooks

| Hook | Signature | Description | | :--- | :--- | :--- | | onText | (text: string) => void \| Promise<void> | Intercept real-time text chunks. | | wrapAgent | (proceed: () => Promise<any>) => Promise<any> | Wraps the entire generate/stream call. | | wrapTool | (proceed: () => Promise<any>, info: { toolName: string, args: any, toolCallId?: string, parameters: any }) => Promise<any> | Wraps every individual tool execution. | | wrapResult | (result: any) => any | Modifies the final agent output object before returning it. | | transformPrompt | (params: any) => any \| Promise<any> | Modifies LLM parameters (system, prompt, messages) before the call. | | onError | (error: any) => void \| Promise<void> | Called when the agent execution crashes. | | options | any | Object to inject or override default agent options (e.g., additional tools). |

Lifecycle Hooks (Stable API)

These hooks map exactly to the Vercel AI SDK lifecycle callbacks.

| Hook | Signature | Native Mapping | Description | | :--- | :--- | :--- | :--- | | onStart | (event: OnStartEvent) => void \| Promise<void> | experimental_onStart | Mission begins. | | onStepStart | (event: OnStepStartEvent) => void \| Promise<void> | experimental_onStepStart | Before each LLM step. | | onToolCallStart | (event: OnToolCallStartEvent) => void \| Promise<void> | experimental_onToolCallStart | Before a tool is called. | | onToolCallFinish| (event: OnToolCallFinishEvent) => void \| Promise<void>| experimental_onToolCallFinish| After a tool has finished. | | onStepFinish | (event: OnStepFinishEvent) => void \| Promise<void> | onStepFinish | End of each step. | | onFinish | (event: OnFinishEvent) => void \| Promise<void> | onFinish | Entire mission completed. |

Example: Custom Logger Plugin

export const withSimpleLogger: AgentPlugin = (options, mission) => ({
  onStart: ({ model }) => {
    console.log(`Mission ${mission.id} started with model ${model.modelId}`);
  },
  onText: (text) => {
    process.stdout.write(text);
  },
  onFinish: ({ totalUsage }) => {
    console.log(`Mission finished. Total tokens: ${totalUsage.totalTokens}`);
  },
});

Example: Tool Retry Plugin

export const withRetry: AgentPlugin = () => ({
  wrapTool: async (proceed, { toolName }) => {
    let attempts = 0;
    while (attempts < 3) {
      try {
        return await proceed(); // Triggers the actual tool execution
      } catch (err) {
        attempts++;
        console.warn(`Retry ${toolName} (Attempt ${attempts}/3)`);
        if (attempts === 3) throw err;
      }
    }
  },
});

License

MIT