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

@polka-codes/core

v0.10.32

Published

[![npm version](https://img.shields.io/npm/v/@polka-codes/core.svg)](https://www.npmjs.com/package/@polka-codes/core) [![npm downloads](https://img.shields.io/npm/dm/@polka-codes/core.svg)](https://www.npmjs.com/package/@polka-codes/core) [![License](http

Downloads

2,263

Readme

Polka Codes Core

npm version npm downloads License

Core AI services and agent implementations for Polka Codes framework.

Features

  • Multiple AI provider support (Anthropic, DeepSeek, GoogleVertex, OpenAI, and OpenRouter)
  • Extensible agent architecture
  • Tool integration system with safety enhancements
  • Type-safe API
  • Logging and monitoring
  • File operation safety (read-first enforcement, line numbers, partial reading)

Installation

bun add @polka-codes/core

Usage

The core of @polka-codes/core is the agentWorkflow. You can use it to create a workflow that interacts with an AI model.

import {
  agentWorkflow,
  createContext,
  makeStepFn,
  type ToolResponse,
} from '@polka-codes/core';
import { z } from 'zod';

// Define a tool
const getCurrentWeather = {
  name: 'getCurrentWeather',
  description: 'Get the current weather in a given location',
  parameters: z.object({
    location: z.string().describe("The city and state, e.g. San Francisco, CA"),
  }),
};

async function main() {
  // Create a context for the workflow
  const context = createContext({
    // Implement the tool
    invokeTool: async ({ toolName, input }) => {
      if (toolName === 'getCurrentWeather') {
        const { location } = input as z.infer<typeof getCurrentWeather.parameters>;
        // In a real app, you would call a weather API here
        const weather = `The weather in ${location} is 70°F and sunny.`;
        const response: ToolResponse = { success: true, message: { type: 'text', value: weather } };
        return response;
      }
      const response: ToolResponse = { success: false, message: { type: 'error-text', value: 'Tool not found' } };
      return response;
    },
    // A simple text generation function
    generateText: async ({ messages }) => {
        // In a real app, you would call an AI provider here (e.g. Anthropic, OpenAI)
        console.log('--- Assistant Turn ---');
        console.log(messages);
        // This is a mock response for demonstration purposes
        return [{
          role: 'assistant',
          content: [{
            type: 'tool-call',
            toolName: 'getCurrentWeather',
            toolCallId: '123',
            input: { location: 'San Francisco, CA' }
          }]
        }];
    },
    taskEvent: async (event) => {
      console.log('Task Event:', event.kind);
    }
  }, makeStepFn());

  // Run the agent workflow
  const result = await agentWorkflow(
    {
      tools: [getCurrentWeather],
      systemPrompt: "You are a helpful assistant.",
      userMessage: [{ role: 'user', content: "What's the weather in San Francisco, CA?" }],
    },
    context
  );

  console.log('--- Workflow Result ---');
  console.log(result);
}

main();

Development

Building

cd packages/core
bun run build

Testing

bun test

Line Numbers

All file reads include line numbers for easy reference:

     1→import React from 'react';
     2→
     3→function App() {
     4→  return <div>Hello</div>;
     5→}

Partial File Reading

You can read specific sections of a file using offset and limit parameters:

// Read lines 100-150 of a large file
await readFile.handler(provider, {
  path: 'large-file.ts',
  offset: 100,  // Skip first 100 lines
  limit: 50     // Read 50 lines
});

This README was generated by polka.codes