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

@fancyrobot/fred-baml

v1.0.0

Published

BAML integration helpers for the Fred AI framework

Readme

@fancyrobot/fred-baml

Lightweight BAML integration surface for Fred.

See the Phase 68 migration matrix for the compatible core line and the Stanza BAML import recipe.

Installation

bun add @fancyrobot/[email protected] \
  @fancyrobot/[email protected] effect@^3.21.5

Current package contract

This scaffold intentionally avoids importing any generated baml_client module at package top level. You can safely import @fancyrobot/fred-baml before a consumer has a BAML project or generated output.

Current public exports:

  • createBamlTool - create a Fred-compatible tool from a lazy BAML-backed executor
  • BamlAgent - helper object for building explicit Fred agent configs with baml.<functionName> tool ids
  • BamlPromptSourceLayer - connect BAML prompt functions through a caller-owned renderer
  • initFredBamlRuntime - runtime helper that defers generated client loading until explicitly requested
  • createStubBamlRuntime / loadStubBamlClient - test helpers for import-safe and deterministic tests (also available from @fancyrobot/fred-baml/testing)
  • typed errors from errors.ts

Example

import { Schema } from 'effect';
import { BamlAgent, createBamlTool, initFredBamlRuntime } from '@fancyrobot/fred-baml';

const runtime = initFredBamlRuntime({
  loadClient: () => import('../baml_client'),
});

const summarize = createBamlTool({
  id: BamlAgent.toolId('summarize'),
  description: 'Summarize text via BAML',
  inputSchema: Schema.Struct({ text: Schema.String }),
  successSchema: Schema.String,
  runtime,
  execute: async ({ text }, activeRuntime) => {
    const client = await activeRuntime.loadClient();
    void client;
    return `summary:${text}`;
  },
});

BAML prompt sources

Fred agents can name a BAML function as their system prompt without making core depend on BAML. Supply a renderer that calls your generated client, then provide the resulting layer when composing the Fred runtime:

import { makeFredRuntimeLayer } from '@fancyrobot/fred';
import { BamlPromptSourceLayer } from '@fancyrobot/fred-baml';
import { b } from '../baml_client';

const promptSourceLayer = BamlPromptSourceLayer(
  async ({ functionName, agentId, input }) => {
    if (functionName !== 'BuildSupportPrompt') {
      throw new Error(
        `Unknown BAML prompt function for ${agentId}: ${functionName}`,
      );
    }

    // The modular request API renders BAML without making its model call.
    // This BAML function is authored with exactly one string system message.
    const request = await b.request.BuildSupportPrompt(String(input));
    const body = request.body.json() as {
      messages?: Array<{ role: string; content: string }>;
    };
    const systemPrompt = body.messages?.find(
      (message) => message.role === 'system',
    )?.content;
    if (!systemPrompt) {
      throw new Error('BuildSupportPrompt did not render one system message');
    }
    return systemPrompt;
  },
);

const supportAgent = {
  id: 'support',
  platform: 'openai',
  model: 'gpt-4o-mini',
  systemMessage: { baml: { function: 'BuildSupportPrompt' } },
};

const runtimeLayer = makeFredRuntimeLayer({ promptSourceLayer });

The renderer is explicit by design: @fancyrobot/fred-baml never imports your generated client or assumes its module path. The first adapter contract expects one text system prompt; multi-role or multimodal BAML requests should stay on the BAML execution path until Fred exposes a richer resolved-prompt contract.

Dependency posture

@fancyrobot/fred-baml does not import @boundaryml/baml directly. Consumers own their BAML toolchain version and generated client output; this package only consumes caller-provided loaders and renderers.

Non-goals in this scaffold

  • no CLI plugin wiring
  • no implicit code generation
  • no generated-client imports in module initialization paths