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

@petriflow/vercel-ai

v0.1.0

Published

Petri net gating adapter for the [Vercel AI SDK](https://sdk.vercel.ai/) (v6+). Wraps tool definitions so each `execute` call is gated by `@petriflow/gate`.

Downloads

51

Readme

@petriflow/vercel-ai

Petri net gating adapter for the Vercel AI SDK (v6+). Wraps tool definitions so each execute call is gated by @petriflow/gate.

Install

bun add @petriflow/vercel-ai
# or
npm install @petriflow/vercel-ai

Peer dependency: ai ^6.0.0

Usage

import { loadRules } from '@petriflow/rules';
import { createPetriflowGate } from '@petriflow/vercel-ai';
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const { nets } = await loadRules('./safety.rules');
const gate = createPetriflowGate(nets);

const result = await generateText({
  model: openai('gpt-4o'),
  tools: gate.wrapTools({ weather: weatherTool, bash: bashTool }),
  system: gate.systemPrompt(),
  prompt: 'What is the weather?',
});

With streamText

import { streamText } from 'ai';

const result = streamText({
  model: openai('gpt-4o'),
  tools: gate.wrapTools(myTools),
  system: gate.systemPrompt(),
  prompt: '...',
});

Manual confirmation

const gate = createPetriflowGate(nets, {
  confirm: async (title, msg) => {
    // Show a dialog, return true/false
    return showConfirmDialog(title, msg);
  },
});

Registry mode (dynamic nets)

const gate = createPetriflowGate({
  registry: { safety: safetyNet, deploy: deployNet },
  active: ['safety'],
});

gate.addNet('deploy');    // activate a registered net
gate.removeNet('safety'); // deactivate (state preserved)

Shadow mode

const gate = createPetriflowGate(nets, {
  mode: 'shadow',
  onDecision: (event, decision) => {
    console.log('Would have blocked:', event.toolName, decision);
  },
});

API

| Method | Description | |--------|-------------| | createPetriflowGate(nets, opts?) | Create a gate instance from nets or a registry config | | gate.wrapTools(tools) | Wrap tool definitions with gate logic | | gate.systemPrompt() | Get system prompt with net status | | gate.formatStatus() | Get current marking for all nets | | gate.addNet(name) | Activate a registered net (registry mode) | | gate.removeNet(name) | Deactivate a net (registry mode) | | gate.manager | Access the underlying GateManager |

Bundled net

import { vercelAiToolApprovalNet } from '@petriflow/vercel-ai/nets/tool-approval';

A generic tool-approval net with readData/fetchData as free tools and writeData/sendEmail as gated tools.

How it works

User's tools ──→ gate.wrapTools() ──→ Gated tools ──→ generateText/streamText
                      │
                      ▼
              Each tool.execute is replaced:
              1. manager.handleToolCall()  → block or allow
              2. original execute()        → run the tool
              3. manager.handleToolResult() → resolve deferreds

Blocked tools throw ToolCallBlockedError, which the SDK reports as tool-error to the model.