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

@zuiio/ai-agent

v0.1.0

Published

Thin OpenAI-compatible client for DeepSeek Flash (default) or any compatible API. Provides chat completions, structured JSON output, natural-language→SQL, expense categorization, Mongolian report generation, and an agentic tool-calling loop.

Readme

@zuiio/ai-agent — LLM Client for DeepSeek / OpenAI

Thin OpenAI-compatible client for DeepSeek Flash (default) or any compatible API. Provides chat completions, structured JSON output, natural-language→SQL, expense categorization, Mongolian report generation, and an agentic tool-calling loop.

All functions accept AiOptions (apiKey, optional model/baseUrl).

Exports

| Function | Signature | Description | |---|---|---| | chatCompletion | (opts) → Promise<string> | Raw chat completion — returns model text | | structuredCompletion<T> | (opts) → Promise<T> | Chat completion that parses model response as typed JSON | | generateEveningReport | (input, opts) → Promise<string> | Mongolian daily report in Telegram Markdown from ReportInput data | | nlQuery | (input, opts) → Promise<NLQueryResult> | Natural-language question → SQL SELECT + Mongolian explanation (caller executes SQL) | | categorizeExpense | (input, opts) → Promise<CategorizeResult> | Expense description → best-matching category with confidence score | | runWithTools | (opts) → Promise<string> | Agentic tool-calling loop — model calls tools until final text answer |

Types

Message, Tool, ToolParam, ToolResult, AiOptions, ReportInput, NLQueryInput, NLQueryResult, CategorizeInput, CategorizeResult

Tool-calling pattern

import { runWithTools, type Tool } from "@zuiio/ai-agent";

const tools: Tool[] = [{
  name: "get_sales",
  description: "Fetch today's sales total",
  parameters: [
    { name: "date", type: "string", description: "ISO date", required: true },
  ],
  execute: async (args) => db.query("SELECT ...", [args.date]),
}];

const answer = await runWithTools({
  apiKey: process.env.DEEPSEEK_API_KEY,
  systemPrompt: "You are a helpful assistant.",
  userMessage: "What were today's sales?",
  tools,
  maxRounds: 5,              // default 3
  conversationHistory: [],   // optional prior messages
});

runWithTools round-trips: model returns tool_callsexecute() runs them → results fed back → loop until model produces text (up to maxRounds iterations).

Structured output

structuredCompletion<T> forces response_format: "json_object" and temperature: 0.1. The caller provides a schema description as natural-language text — the model returns valid JSON matching that schema.

import { structuredCompletion } from "@zuiio/ai-agent";

const result = await structuredCompletion<{ label: string; score: number }>({
  apiKey: process.env.DEEPSEEK_API_KEY,
  systemPrompt: "Classify the sentiment of the input.",
  userPrompt: "This product is amazing!",
  schemaDescription: '{ "label": "positive | negative | neutral", "score": 0.0-1.0 }',
});

Agent Gateway usage

apps/agent-gateway wraps this package via DeepSeekProvider (src/providers/deepseek.ts), closing over ToolContext (orgId, userId, supabase) so gateway tools can filter by tenant. The gateway converts GatewayTool (which receives context) into @zuiio/ai-agent Tool (which doesn't) at the provider boundary.

Module map

| File | Public exports | |---|---| | client.ts | chatCompletion, structuredCompletion | | report-gen.ts | generateEveningReport | | nl-query.ts | nlQuery | | categorize.ts | categorizeExpense | | tool-runner.ts | runWithTools, Message | | types.ts | All interfaces (Tool, ToolParam, ToolResult, AiOptions, …) |

Key details

  • Default model: deepseek-chat (DeepSeek Flash) via https://api.deepseek.com
  • structuredCompletion forces response_format: "json_object" and temperature: 0.1 — caller provides schema as natural-language description
  • nlQuery only generates SQL; it does NOT execute it — caller must use a read-only role with RLS
  • runWithTools round-trips: model returns tool_callsexecute() runs them → results fed back → loop until model produces text (max maxRounds iterations)
  • Mongolian (Cyrillic) prompt text in report-gen, nl-query, categorize — UI should use output directly