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

@vitest-evals/harness-ai-sdk

v0.11.0

Published

AI SDK harness adapter for vitest-evals.

Readme

@vitest-evals/harness-ai-sdk

ai-sdk-focused harness adapter for vitest-evals.

Install

npm install -D ai vitest-evals @vitest-evals/harness-ai-sdk

Usage

import { expect } from "vitest";
import { generateText, stepCountIs } from "ai";
import { openai } from "@ai-sdk/openai";
import { aiSdkHarness } from "@vitest-evals/harness-ai-sdk";
import {
  createJudge,
  describeEval,
  toolCalls,
  type JudgeContext,
} from "vitest-evals";

const tools = {
  lookupInvoice: {
    inputSchema: lookupInvoiceSchema,
    execute: lookupInvoice,
  },
};

const harness = aiSdkHarness({
  tools,
  toolReplay: {
    lookupInvoice: true,
  },
  run: ({ input, runtime }) =>
    generateText({
      model: openai("gpt-4o-mini"),
      prompt: input,
      tools: runtime.tools,
      stopWhen: stepCountIs(5),
    }),
  output: ({ result }) => parseRefundDecision(result.text),
});

describeEval("refund agent", { harness }, (it) => {
  it("approves a refundable invoice", async ({ run }) => {
    const result = await run("Refund invoice inv_123");

    expect(result.output).toMatchObject({
      status: "approved",
    });
    expect(toolCalls(result.session).map((call) => call.name)).toContain(
      "lookupInvoice",
    );
  });
});

If run() already returns { output } or a full HarnessRun, that typed output is used directly. The output selector above is only for the raw generateText(...) result path where the adapter should keep AI SDK diagnostics while projecting provider text into app output.

If your existing AI SDK app exposes its own entrypoint, wire that in directly:

const harness = aiSdkHarness({
  tools,
  run: ({ input, runtime }) => createRefundAgent().run(input, runtime),
});

If your app exposes an agent object instead, agent can be either that object or a per-run factory. Factories receive the eval input and harness context so input-dependent instructions, metadata, or seeded state do not require side-channel setup:

const harness = aiSdkHarness({
  tools,
  agent: ({ input, context }) =>
    createRefundAgent({
      instructions: buildInstructions(input),
      metadata: context.metadata,
    }),
});

run executes the system under test. Judges are created separately; keep judge prompts and model calls on a judge harness instead of putting them on the app harness.

import { openai } from "@ai-sdk/openai";
import { aiSdkJudgeHarness } from "@vitest-evals/harness-ai-sdk";
import { describeEval, FactualityJudge } from "vitest-evals";

const judgeHarness = aiSdkJudgeHarness({
  model: openai("gpt-4.1-mini"),
  temperature: 0,
});
const factualityJudge = FactualityJudge({ judgeHarness });

describeEval("refund agent", {
  harness,
  judges: [factualityJudge],
});

The adapter infers:

  • normalized session and tool-call traces from AI SDK steps
  • usage diagnostics from totalUsage / usage
  • typed run.output from explicit run() results that return output, from common AI SDK provider fields such as object and text, or from a typed output selector when the app deliberately returns a raw provider result
  • native app output is accepted only when it is already JSON-safe; arbitrary fields, primitive raw results, and non-JSON values require an explicit output selector
  • replay/cassette metadata for local tools configured with toolReplay

See the workspace demo app in apps/demo-ai-sdk and the RFC notes in docs/harness-first-rfc.md.