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

@shift-preflight/runtime

v0.9.3

Published

Multimodal preflight for any AI agent — AI SDK middleware for transparent image optimization

Downloads

1,606

Readme

@shift-preflight/runtime

npm License: Apache-2.0

Multimodal preflight for any AI agent — transparent image optimization before images reach the LLM.

Two integration modes:

  1. AI SDK Middleware — in-process, zero-config for any Vercel AI SDK app (OpenCode, Next.js, custom agents)
  2. HTTP Proxy — transparent reverse proxy for any agent in any language (Claude Code, Codex CLI, Gemini CLI, Python, curl)

Both use SHIFT (shift-ai CLI) as the optimization engine.

Install

npm install @shift-preflight/runtime

# SHIFT CLI is required for optimization (graceful no-op if missing)
brew install alohaninja/shift/shift-ai

Mode 1: AI SDK Middleware

import { shiftMiddleware } from "@shift-preflight/runtime";
import { wrapLanguageModel, generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";

const model = wrapLanguageModel({
  model: anthropic("claude-sonnet-4-20250514"),
  middleware: shiftMiddleware({ mode: "balanced" }),
});

const result = await generateText({
  model,
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What's in this screenshot?" },
      { type: "file", data: largeBase64, mediaType: "image/png" },
    ],
  }],
});

The middleware intercepts transformParams and optimizes all images in all messages (user, assistant, tool results) before they reach the provider. Already-optimized images are tagged and skipped on subsequent turns.

Configuration

shiftMiddleware({
  mode: "balanced",     // "performance" | "balanced" | "economy"
  minSize: 100_000,     // skip images < 100KB (default)
  disabled: false,      // kill switch
  provider: undefined,  // auto-detected from model
  model: undefined,     // override model for SHIFT profile
  binary: undefined,    // path to shift-ai binary
  onOptimize: (metrics) => {
    console.log(`Saved ${metrics[0].savedBytes} bytes`);
  },
});

Mode 2: HTTP Proxy

npx @shift-preflight/runtime proxy --port 8787 --mode balanced

Then point your agent at http://localhost:8787:

# Claude Code
export ANTHROPIC_BASE_URL=http://localhost:8787

# Codex CLI
export OPENAI_BASE_URL=http://localhost:8787

# Gemini CLI
export GEMINI_API_BASE=http://localhost:8787

# Python
client = Anthropic(base_url="http://localhost:8787")
client = OpenAI(base_url="http://localhost:8787/v1")

The proxy intercepts requests, optimizes images via SHIFT, and forwards to the real API. Auth headers pass through. SSE streams pipe directly.

Routes

| Route | Provider | |---|---| | POST /v1/messages | Anthropic | | POST /v1/chat/completions | OpenAI | | POST /v1beta/models/* | Google (passthrough, native support pending) |

Programmatic

import { startProxy } from "@shift-preflight/runtime/proxy";

const server = await startProxy({
  port: 8787,
  mode: "balanced",
  verbose: true,
});

Drive Modes

| Mode | Behavior | |---|---| | performance | Only enforce hard provider limits. Preserve fidelity. | | balanced | Resize oversized, recompress bloated. Remove obvious waste. | | economy | Downscale everything to 1024px. Minimize tokens. |

Provider Support

| Provider | Middleware | Proxy | Constraints | |---|:---:|:---:|---| | Anthropic | Yes | Yes | 5MB max, 1.15 MP, 8000px | | OpenAI | Yes | Yes | 20MB max, 2048px, tile tokens | | Google | Yes | Passthrough* | 20MB max, 3072px |

* Google proxy optimization pending native SHIFT support for Gemini payload format.

Requirements

  • Node.js >= 18
  • shift-ai CLI (install) — graceful no-op if missing

License

Apache-2.0