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

@caleblawson/client-js

v0.10.6-alpha.0

Published

The official TypeScript library for the Mastra Client API

Readme

Mastra Client

JavaScript/TypeScript client library for the Mastra AI framework. This client provides a simple interface to interact with Mastra AI's APIs for agents, vectors, memory, tools, and workflows.

Installation

npm install @mastra/client-js

Quick Start

import { MastraClient } from '@mastra/client-js';

// Initialize the client
const client = new MastraClient({
  baseUrl: 'http://localhost:4111', // Your Mastra API endpoint
});

// Example: Working with an Agent
async function main() {
  // Get an agent instance
  const agent = client.getAgent('your-agent-id');

  // Generate a response
  const response = await agent.generate({
    messages: [{ role: 'user', content: "What's the weather like today?" }],
  });

  console.log(response);
}

Client Configuration

The client can be configured with several options:

const client = new MastraClient({
    baseUrl: string;           // Base URL for the Mastra API
    retries?: number;          // Number of retry attempts (default: 3)
    backoffMs?: number;        // Initial backoff time in ms (default: 300)
    maxBackoffMs?: number;     // Maximum backoff time in ms (default: 5000)
    headers?: Record<string, string>; // Custom headers
});

Available Methods

Agents

  • getAgents(): Get all available agents
  • getAgent(agentId): Get a specific agent instance
    • agent.details(): Get agent details
    • agent.generate(params): Generate a response
    • agent.stream(params): Stream a response
    • agent.getTool(toolId): Get agent tool details
    • agent.evals(): Get agent evaluations
    • agent.liveEvals(): Get live evaluations

Memory

  • getMemoryThreads(params): Get memory threads
  • createMemoryThread(params): Create a new memory thread
  • getMemoryThread(threadId): Get a memory thread instance
  • saveMessageToMemory(params): Save messages to memory
  • getMemoryStatus(): Get memory system status

Tools

  • getTools(): Get all available tools
  • getTool(toolId): Get a tool instance
    • tool.details(): Get tool details
    • tool.execute(params): Execute the tool

Workflows

  • getWorkflows(): Get all workflows
  • getWorkflow(workflowId): Get a workflow instance
    • workflow.details(): Get workflow details
    • workflow.createRun(): Create workflow run
    • workflow.startAsync(params): Execute the workflow and wait for execution results
    • workflow.resumeAsync(parmas): Resume suspended workflow step async
    • workflow.watch({runId},(record)=>{}): Watch the step transitions of the workflow run
    • workflow.start({runId, triggerData}): Start a workflow run sync
    • workflow.resume(params): Resume the workflow run sync

Vectors

  • getVector(vectorName): Get a vector instance
    • vector.details(indexName): Get vector index details
    • vector.delete(indexName): Delete a vector index
    • vector.getIndexes(): Get all indexes
    • vector.createIndex(params): Create a new index
    • vector.upsert(params): Upsert vectors
    • vector.query(params): Query vectors

Logs

  • getLogs(params): Get system logs
  • getLog(params): Get specific log entry
  • getLogTransports(): Get configured Log transports

Telemetry

  • getTelemetry(params): Get telemetry data

Error Handling

The client includes built-in retry logic for failed requests:

  • Automatically retries failed requests with exponential backoff
  • Configurable retry count and backoff timing
  • Throws error after max retries reached

Internal Implementation

The client uses the native fetch API internally for making HTTP requests. All requests are automatically handled with:

  • JSON serialization/deserialization
  • Retry logic with exponential backoff
  • Custom header management
  • Error handling

License

MIT