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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@runloop/runloop

v0.0.5

Published

Runloop.ai library to support long running lambda functions and devboxes

Downloads

27,467

Readme

Runloop

The Runloop Library is a powerful tool for managing asynchronous operations in TypeScript or JavaScript. It provides a simple and intuitive way to declare and execute Runloop lambda functions and developer boxes, allowing you to control the flow of your asynchronous AI agents.

Installation

To install the Runloop Library, simply run the following command:

npm install @runloop/runloop

Getting started

To use the Runloop Library in your project, first import the package and use RLFunc providing an async function to execute and a function ID which will also be used to execute against your function.

import { RLFunc } from '@runloop/runloop';

export const lintCode = RLFunc({
    id: "add",
    run: async function ({ a: number, b: number }) {
        return a + b;
    },
});

Make sure to install the Runloop github app Once you've installed the app and selected your project you can run your add function above with the following cURL:

curl -X 'POST' 'https://api.runloop.pro/v1/projects/<project_id>/functions/lintCode/invoke_blocking' -H 'accept: application/json' -H "Authorization: Bearer <api_key>" --data '{"request": {"a": 2, "b": 2 }}'
> '{ "result": 4 }'

Create a Devbox

Now that you've made a basic function, let's create a devbox and run some commands on it.

import { RLFunc } from '@runloop/runloop';

export const useDevbox = RLFunc({
    id: "useDevbox",
    run: async function ({}, { systemCoordinator }) {
        let devbox = await systemCoordinator.createDevbox();
        let result = await devbox.execTool.exec("echo 'Hello, World!'");
        return result.stdout;
    },
});

Devboxes allow you to interact with them through the FileTool and ExecTool interfaces.


/**
 * A Runloop devbox allowing for remote development. This is a virtual machine that can be used for development.
 */
export type IDevbox = {
    /**
     * Tools that can be used with the Devbox
     */
    id: string;

    /**
     * This allows for reading and writing files on the remote machine.
     */
    fileTool: IFileTool;

    /**
     * This allows for executing commands on the remote machine.
     */
    execTool: IExecTool;
};

export type FileTool = {
    /**
     * Write content to a file on the remote machine.
     * @param path the path to the file to write on the remote machine
     * @param content the content to write to the file
     * @returns when the file has been written
     */
    writeFile: (path: string, content: string) => Promise<void>;

    /**
     * Read the contents of a file on the remote machine.
     * @param path the path to the file to read on the remote machine
     * @returns the contents of the file in utf-8 encoding
     */
    readFile: (path: string) => Promise<string>;

    /**
     * Delete a file on the remote machine.
     * @param path the path to the file to delete on the remote machine
     * @returns when the file has been deleted
     */
    deleteFile: (path: string) => Promise<void>;

    /**
     * Create a file on the remote machine with the given content
     * @param path the path to the file to create on the remote machine
     * @param content the content to write to the file
     * @returns
     */
    createFile: (path: string, content: string) => Promise<void>;
};

/**
 * A tool for executing commands on a remote machine.
 */
export type ExecTool = {
    /**
     * Execute a command on the remote machine.
     * @param command the command to execute on the remote machine
     * @returns the result of executing the command
     */
    exec: (command: string) => Promise<ExecResult>;
};