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

@thenajs/agentflow

v0.13.1

Published

Engine de execução do ThenaJS: pipeline, providers (Ollama/OpenAI), estado e tools (Zod).

Readme

@thenajs/agentflow

O engine de execução do ThenaJS: pipeline, providers, estado, tools e memória vetorial.

Você provavelmente não quer instalar este pacote diretamente. Use o @thenajs/core, que reexporta tudo o que é público daqui e acrescenta os decorators e o runtime.

npm install @thenajs/agentflow zod

zod é peerDependency: o schema das tools tem que vir da mesma instância que o engine usa para gerar o JSON Schema.

O que ele é

Este pacote não conhece política. Ele oferece o mecanismo; quem decide o que fazer com ele é a camada de cima. É o motivo de ToolOutput ter um campo isError em vez de o engine decidir se um erro derruba a execução.

| Módulo | O quê | | --- | --- | | Pipeline | Encadeia passos, com os combinadores parallel e loop | | StateManager | history, tasks e memory, projetados nas mensagens que o modelo lê | | Providers | Classe base dos providers, com OllamaProvider e OpenAIProvider | | HttpTransport | fetch com retry, backoff com full jitter e Retry-After | | VectorStore / VectorMemory | Contrato de banco vetorial e a memória semântica sobre ele | | ToolType | O formato de tool que o provider executa |

Escrever um provider

Implemente um método. A classe base cuida do resto — remove blocos de raciocínio, decide entre tool call nativa e resgatada do texto, valida os argumentos contra o schema, executa a tool, calcula o custo e aplica o retry.

import { Providers } from "@thenajs/agentflow";
import type {
  Message,
  ProviderCredentials,
  RawAssistant,
  SamplingParams,
  ToolType,
} from "@thenajs/agentflow";

type MinhasCredentials = ProviderCredentials & { apiKey: string };

export class MeuProvider extends Providers {
  constructor(credentials: MinhasCredentials) {
    super();
    this.configure(credentials); // absorve sampling, raw, retry, custo…
  }

  protected async chatInternal(
    tools: ToolType[],
    messages: Message[],
    sampling?: SamplingParams,
  ): Promise<RawAssistant> {
    const { response, attempts } = await this.request(url, { /* … */ });
    const data = await response.json();
    return { content: data.text, usage: { /* … */ }, attempts };
  }
}

Use this.request() no lugar do fetch — é o que faz sua implementação herdar retry e timeout sem código.

Escrever um banco vetorial

Mesmo modelo: estenda VectorStore, implemente as seis operações, e o transporte vem de graça. O @thenajs/qdrant-client é a implementação de referência.

Resgate de tool call

Modelos locais raramente acertam o formato nativo. Quando o provider não devolve tool calls prontas, o engine tenta extrair uma do texto — cinco estratégias em cascata, da mais específica para a mais permissiva, mais a normalização de envelope ({name, parameters}, {function:{…}}, <tool_call>…, arrays, argumentos como string JSON).

A chamada resgatada só vale se o nome for de uma tool registrada, e o turno é marcado com toolCallSource: "rescued" — dá para medir o quanto um modelo depende disso.

Desligue com rescueToolCalls: false nas credentials para diagnosticar.

Requisitos

Node ≥ 20.

Licença

MIT