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

astor-agentic

v0.2.3

Published

A functional workflow and agent library for LLM applications

Readme

Astor

"Prompts that flow in a graceful dance"

Astor is a flexible TypeScript library for building AI workflows with a simple, intuitive API. It combines the power of workflow orchestration with the latest AI capabilities from the AI SDK.

Features

  • Workflow System: Build complex, multi-step workflows with dependencies, branching, and conditional execution
  • Intuitive API: Natural API design with method names like Workflow(), Step(), and Tool()
  • AI-Native: Seamless integration with the AI SDK for text generation, structured data, and ~~streaming responses~~
  • Type-Safe: Full TypeScript support with generics for schema validation
  • Extensible: Build your own custom steps, tools, and workflows
  • Easy to Use: Simple, declarative syntax for defining complex AI pipelines

Installation

bun add astor 
# or
npm install astor

Quick Start

import Astor from 'astor';
import { z } from 'zod';

// Initialize Astor
const astor = new Astor({
  openAIKey: Bun.env.OPENAI_API_KEY,
  defaultModel: 'gpt-4o'
});

// Create a simple AI workflow
const workflow = astor.SimpleWorkflow({
  name: 'Quick Responder',
  model: astor.openai('gpt-4o'),
  systemPrompt: 'You are a helpful assistant.'
});

// Run the workflow
async function main() {
  const run = workflow.createRun();
  const result = await run.run({
    triggerData: {
      message: 'What are three interesting facts about quantum computing?'
    }
  });
  
  console.log(result.results['generate-response'].response);
}

main().catch(console.error);

Creating Custom Workflows

import Astor from 'astor';
import { z } from 'zod';

const astor = new Astor({
  openAIKey: Bun.env.OPENAI_API_KEY
});

// Define a schema for structured data
const recipeSchema = z.object({
  name: z.string(),
  ingredients: z.array(z.object({
    name: z.string(),
    amount: z.string(),
    unit: z.string().optional()
  })),
  steps: z.array(z.string()),
  prepTime: z.number(),
  cookTime: z.number()
});

// Create a custom workflow
const recipeWorkflow = astor.Workflow({
  name: 'Recipe Generator',
  triggerSchema: z.object({
    cuisine: z.string(),
    dietary: z.string().optional(),
    mealType: z.enum(['breakfast', 'lunch', 'dinner', 'dessert'])
  })
})
// First step: generate recipe ideas
.step(astor.TextStep({
  id: 'generate-ideas',
  description: 'Generate recipe ideas',
  model: astor.openai('gpt-4o'),
  systemPrompt: 'You are a chef specialized in various cuisines.'
}), {
  variables: {
    message: { step: 'trigger', path: 'cuisine' }
  }
})
// Second step: create structured recipe data
.then(astor.ObjectStep({
  id: 'generate-recipe',
  description: 'Generate a structured recipe',
  model: astor.openai('gpt-4o'),
  schema: recipeSchema,
  systemPrompt: 'You are a recipe writer creating detailed recipes.'
}), {
  variables: {
    message: { step: 'generate-ideas', path: 'response' }
  }
})
.commit();

// Run the workflow
async function main() {
  const run = recipeWorkflow.createRun();
  const result = await run.run({
    triggerData: {
      cuisine: 'Italian',
      dietary: 'vegetarian',
      mealType: 'dinner'
    }
  });
  
  const recipe = result.results['generate-recipe'].response;
  console.log(`Recipe: ${recipe.name}`);
  console.log(`Prep Time: ${recipe.prepTime} minutes`);
  console.log(`Cook Time: ${recipe.cookTime} minutes`);
  
  console.log('Ingredients:');
  recipe.ingredients.forEach(ing => {
    console.log(`- ${ing.amount} ${ing.unit || ''} ${ing.name}`);
  });
  
  console.log('Steps:');
  recipe.steps.forEach((step, i) => {
    console.log(`${i+1}. ${step}`);
  });
}

main().catch(console.error);

Creating and Using Tools

import Astor from 'astor';
import { z } from 'zod';

const astor = new Astor({
  openAIKey: Bun.env.OPENAI_API_KEY
});

// Create an AI-powered tool
const nutritionTool = astor.AITool({
  name: 'analyze-nutrition',
  description: 'Analyze the nutritional content of ingredients',
  parameters: z.object({
    ingredients: z.array(z.string()),
    servings: z.number().default(1)
  }),
  model: astor.openai('gpt-4o-mini'),
  systemPrompt: 'You are a nutritionist specializing in food analysis.'
});

// Use the tool
async function main() {
  const result = await nutritionTool.execute({
    ingredients: [
      '200g pasta',
      '150g spinach',
      '100g feta cheese',
      '2 tbsp olive oil'
    ],
    servings: 2
  });
  
  console.log(result.result);
}

main().catch(console.error);

Advanced Features

Parallel Execution

const workflow = astor.Workflow({
  name: 'Parallel Processing'
})
.step(initialStep)
// Run these steps in parallel after the initial step
.after('initial-step').step(stepA)
.after('initial-step').step(stepB)
// This step waits for both stepA and stepB to complete
.after(['step-a', 'step-b']).step(finalStep)
.commit();

Conditional Execution

const workflow = astor.Workflow({
  name: 'Conditional Workflow'
})
.step(analyzeStep)
// Only run this step if condition is met
.step(specialStep, {
  when: {
    ref: { step: 'analyze', path: 'sentiment' },
    query: { $eq: 'positive' }
  }
})
.commit();

Custom Steps

const customStep = astor.Step({
  id: 'custom-processor',
  description: 'Custom data processing step',
  execute: async ({ input, context }) => {
    // Custom processing logic here
    return {
      processed: true,
      data: input.data.map(item => item.toUpperCase())
    };
  }
});

Why Astor?

  • Simplified AI Development: Build complex AI workflows without the boilerplate
  • Composable: Chain together steps and tools to create sophisticated pipelines
  • Maintainable: Logical separation of concerns keeps your code clean
  • Testable: Each step can be tested independently
  • Reproducible: Workflows execute consistently with deterministic results
  • Future-Proof: Uses the AI SDK for model interactions, keeping up with the latest AI capabilities

License

MIT