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

@primero.ai/agents-helpers

v1.3.1

Published

primero.ai - Agents helpers.

Readme

@primero.ai/agents-helpers

Utilities for Primero agents. Currently ships typed clients for resource query and resource ontology endpoints, plus a Mastra-compatible tool adapter.

Installation

npm install @primero.ai/agents-helpers
# or
pnpm add @primero.ai/agents-helpers
# or
yarn add @primero.ai/agents-helpers

The package targets Node.js 18+ and ships ESM.

Quick start

import { ResourceQueryClient } from '@primero.ai/agents-helpers'

const client = new ResourceQueryClient({
  baseUrl: 'https://primero.ai/',
  tokenId: process.env.PRIMERO_API_KEY_ID,
  tokenSecret: process.env.PRIMERO_API_KEY_SECRET,
})

const result = await client.query({
  sql: 'select 1 as ok',
  limit: 1,
})

console.log(result.rows)

Resource Ontology

import { ResourceOntologyClient } from '@primero.ai/agents-helpers'

const client = new ResourceOntologyClient({
  baseUrl: 'https://primero.ai/',
  tokenId: process.env.PRIMERO_API_KEY_ID,
  tokenSecret: process.env.PRIMERO_API_KEY_SECRET,
})

const ontology = await client.get()

console.log(ontology)

Mastra

Mastra can consume this package through an AI SDK-compatible tool factory. That keeps this package decoupled from Mastra internals while still letting a Mastra agent call Primero resources through the helper.

import { tool } from 'ai'
import { Agent } from '@mastra/core/agent'
import { openai } from '@ai-sdk/openai'
import { createMastraResourceQueryTool } from '@primero.ai/agents-helpers/mastra'

const primeroResourceQuery = createMastraResourceQueryTool({
  toolFactory: tool,
  baseUrl: process.env.PRIMERO_API_BASE_URL,
  tokenId: process.env.PRIMERO_API_KEY_ID,
  tokenSecret: process.env.PRIMERO_API_KEY_SECRET,
})

const agent = new Agent({
  name: 'Primero Analyst',
  instructions: 'Use primeroResourceQuery whenever you need Primero data.',
  model: openai('gpt-4.1-mini'),
  tools: {
    primeroResourceQuery,
  },
})

For the ontology endpoint:

import { tool } from 'ai'
import { createMastraResourceOntologyTool } from '@primero.ai/agents-helpers/mastra'

const primeroResourceOntology = createMastraResourceOntologyTool({
  toolFactory: tool,
  baseUrl: process.env.PRIMERO_API_BASE_URL,
  tokenId: process.env.PRIMERO_API_KEY_ID,
  tokenSecret: process.env.PRIMERO_API_KEY_SECRET,
})

Environment variables

The client reads defaults from environment variables when options are omitted.

  • PRIMERO_API_BASE_URL (default: https://primero.ai/)
  • PRIMERO_API_KEY_ID (default: primero-api-key-id)
  • PRIMERO_API_KEY_SECRET (default: primero-api-key-secret)
  • PRIMERO_API_TIMEOUT_MS (default: 60000)

API

new ResourceQueryClient(options?)

Options:

  • baseUrl: Base URL for the Primero API.
  • tokenId: API token id.
  • tokenSecret: API token secret.
  • timeoutMs: Request timeout in milliseconds.

client.query(input)

Input:

  • sql: SQL string to execute.
  • limit: Optional row limit (max 5000).

Returns { rows, rowCount?, columns? }.

new ResourceOntologyClient(options?)

Options:

  • baseUrl: Base URL for the Primero API.
  • tokenId: API token id.
  • tokenSecret: API token secret.
  • timeoutMs: Request timeout in milliseconds.

client.get()

Fetches the resource ontology from api/resources/ontology.

createMastraResourceQueryTool(options)

Builds a Mastra-compatible tool by wrapping ResourceQueryClient.

Options:

  • toolFactory: Usually tool from ai.
  • description: Optional tool description exposed to the model.
  • All ResourceQueryClient options: baseUrl, tokenId, tokenSecret, timeoutMs.

createMastraResourceOntologyTool(options)

Builds a Mastra-compatible tool by wrapping ResourceOntologyClient.

Options:

  • toolFactory: Usually tool from ai.
  • description: Optional tool description exposed to the model.
  • All ResourceOntologyClient options: baseUrl, tokenId, tokenSecret, timeoutMs.

Example script

pnpm install
pnpm tsx example/resource-query.ts
pnpm tsx example/resource-ontology.ts
pnpm tsx example/mastra-resource-query.ts
pnpm tsx example/mastra-resource-ontology.ts