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

@truto/langchain-toolset

v0.1.3

Published

SuperAI toolset for TypeScript. Works in Langchain.js.

Readme

Truto's SuperAI Toolset for Langchain.js

A powerful toolset for integrating Truto's Proxy APIs with Langchain.js applications. This package provides all the Proxy APIs configured to be used as a tool on Truto as tools to Langchain. Read more about configuring tools on Truto here.

tool_calling

Installation

npm install @truto/langchain-toolset
# or
yarn add @truto/langchain-toolset

Prerequisites

  • Node.js 22.14.0 or higher
  • Yarn 1.22.19 or higher
  • Truto API credentials
  • Bun (for running examples)
  • OpenAI API key (only needed for running examples)

Environment Setup

Create a .env file in your project root with the following variables:

TRUTO_API_TOKEN=your_truto_api_token

#OPTIONAL
OPENAI_API_KEY=your_openai_api_key # if you are using OpenAI models
TRUTO_API_BASE_URL=your_truto_api_base_url

Usage

Here's a complete example showing how to use the toolset with Langchain.js, including handling multiple tool executions:

To create or modify tools, please refer this Truto guide.

import { ChatOpenAI } from '@langchain/openai';
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
import { isEmpty, values } from 'lodash-es';
import { ToolCall } from '@langchain/core/dist/messages/tool';
import { getTools } from '@truto/langchain-toolset';

// Initialize the LLM
const llm = new ChatOpenAI({
  model: 'o3-mini',
});

const INTEGRATED_ACCOUNT_ID = 'your_account_id';

async function main() {
  // Get all available tools for a customer connection
  const tools = await getTools(INTEGRATED_ACCOUNT_ID, {
    truto: {
      baseUrl: process.env.TRUTO_API_BASE_URL,
      token: process.env.TRUTO_API_TOKEN as string,
    },
    // Optional: Filter tools by specific methods
    methods: ['list', 'get', 'create', 'update', 'delete', 'read', 'write', 'custom', 'your_custom_method_name']
  });

  // Bind tools to the LLM
  const llmWithTools = llm.bindTools(values(tools));

  // Create your messages
  const messages = [
    new SystemMessage(
      'You are an assistant who uses the available tools to give the user an answer. Make sure you respect the arguments required for a tool call, use them to filter down the results wherever necessary. All the tools return a JSON string response, so parse the output correctly and use them in the arguments.'
    ),
    new HumanMessage('Your question here'),
  ];

  let toolCalls: ToolCall[] = [];
  do {
    // Execute any pending tool calls
    for (const toolCall of toolCalls) {
      const toolResponse = await tools[toolCall.name].invoke(toolCall);
      console.log('\n===================\n');
      console.log(
        'Called tool',
        toolCall.name,
        toolCall.args,
        toolResponse.content
      );
      messages.push(toolResponse);
    }

    // Get the next AI response
    const aiMessage = await llmWithTools.invoke(messages);
    messages.push(aiMessage);

    // Check if there are more tool calls to execute
    if (isEmpty(aiMessage.tool_calls)) {
      console.log('\n\n===================\n\n');
      console.log(aiMessage.content);
      break;
    }
    toolCalls = aiMessage.tool_calls || [];
  } while (!isEmpty(toolCalls));
}

main();

This example demonstrates:

  • How to initialize the tools with Truto credentials
  • How to bind tools to a Langchain.js LLM
  • How to handle multiple tool calls in sequence
  • How to process tool responses and continue the conversation
  • How to properly handle the conversation flow until all tool calls are complete

API Reference

getTools

getTools(
  integratedAccountId: string,
  config: {
    truto: {
      baseUrl?: string;
      token: string;
    };
    methods?: Array<'list' | 'get' | 'create' | 'update' | 'delete' | 'read' | 'write' | 'custom' | string>;
  }
): Promise<Record<string, Tool>>

Returns a promise that resolves to an object containing all available tools for the specified integrated account. Each tool is a Langchain.js Tool instance that can be used with Langchain.js supported LLMs.

Parameters

  • integratedAccountId (string): The ID of the integrated account to get tools for
  • config (object): Configuration object
    • truto (object): Truto API configuration
      • baseUrl (string, optional): Custom base URL for the Truto API
      • token (string): Truto API token
    • methods (array, optional): Array of method names to filter tools by. Can include:
      • Standard CRUD operations: 'list', 'get', 'create', 'update', 'delete'
      • Permission-based methods: 'read', 'write'
      • Custom methods: 'custom'
      • Specific custom method names (string)

Returns

A promise that resolves to a Record<string, Tool> where each key is the tool name and the value is a Langchain.js Tool instance.

Running Examples

The repository includes example code in the examples directory. To run the examples:

  1. First, install Bun if you haven't already:

    • Visit bun.sh to install Bun for your platform
    • Or use the following command:
    curl -fsSL https://bun.sh/install | bash
  2. Install dependencies:

bun install
  1. Set up your environment variables in .env as described above.

  2. Run the example:

bun run examples/index.ts

The example demonstrates how to:

  • Initialize the tools with Truto credentials
  • Bind tools to a Langchain.js LLM
  • Make tool calls and handle responses
  • Process multi-turn conversations with tool usage

Development

To build the package locally:

yarn build

To run type checking:

yarn check

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.