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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@iqai/plugin-js

v0.1.0

Published

A plugin for securely executing JavaScript code within the Brain Framework, providing a sandboxed environment for running arbitrary JavaScript snippets.

Downloads

42

Readme

🔄 Plugin JS

A plugin for securely executing JavaScript code within the Brain Framework, providing a sandboxed environment for running arbitrary JavaScript snippets.

📌 Overview

  • Execution Service: Handles secure JavaScript execution in an isolated VM.
  • Action Handler: Manages extracting code from messages and formatting responses.

🛠 Installation

Install the plugin using pnpm:

pnpm add @iqai/plugin-js

⚙ Configuration

Configure the plugin with the following parameters:

| Param Name | Description | Default Value | | ------------ | ------------------------------------------------------- | ------------- | | memoryLimit | Maximum memory available to JavaScript execution (MB) | 128 | | timeout | Maximum execution time allowed (ms) | 5000 |

🚀 Usage

Basic Configuration

import { createJsPlugin } from "@iqai/plugin-js";

// Initialize the plugin with default settings
const plugin = await createJsPlugin();

Custom Configuration

import { createJsPlugin } from "@iqai/plugin-js";

// Initialize the plugin with custom memory and timeout settings
const plugin = await createJsPlugin({
  memoryLimit: 256,  // 256MB memory limit
  timeout: 10000     // 10-second timeout
});

Once initialized, the plugin adds the JS_EXECUTE action to your agent, which can be triggered with commands like "run this JavaScript" or "execute this code" followed by the JavaScript code.

❌ Error Handling

The plugin handles various error scenarios, including:

  • Syntax Errors: Detected during code compilation.
  • Runtime Errors: Caught during code execution.
  • Timeout Errors: When execution exceeds the configured time limit.
  • Memory Errors: When the code attempts to use more memory than allowed.
  • Catastrophic Errors: Severe VM failures that require recreation of the environment.

Errors are logged and returned with informative messages to help users understand and fix issues in their code.

🔒 Security Considerations

The plugin implements several security measures:

  • Isolation: Code runs in a completely isolated virtual machine.
  • Resource Limiting: Memory and execution time are strictly limited.
  • Console Access Only: No access to Node.js modules, filesystem, or network.
  • Error Containment: Errors cannot escape the sandbox environment.
  • Automatic Resource Cleanup: VM resources are properly disposed after execution.

💻 Example Interactions

// User: Run this JavaScript:
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.map(n => n * 2));
return numbers.reduce((sum, n) => sum + n, 0);

// Agent: ✅ JavaScript Execution Successful
//
// Result: 15
//
// Console Output:
// [2, 4, 6, 8, 10]
//
// Execution Stats:
// ⏱️ CPU Time: 0.35ms
// 🧠 Memory Used: 2.45MB

Learn More

For more details on secure JavaScript execution in isolated environments, refer to: