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

assisfy-sdk

v1.4.0

Published

Assisfy bridges the gap between AI capabilities and real-world execution on the web.

Downloads

299

Readme

Assisfy SDK

The Assisfy SDK allows developers to integrate Assisfy's AI capabilities into their applications. This SDK provides a simple interface to create and manage sessions, handle events, and interact with external resources.

Assisfy SDK

Installation

To install the Assisfy SDK, use npm:

npm install assisfy-sdk

Generating API Keys

To use the Assisfy SDK, you need to generate an API key from the Assisfy platform. Follow these steps:

  1. Visit Assisfy Platform.
  2. Onboard your agent by following the platform's instructions.
  3. Navigate to the "API Key" tab.
  4. Copy the generated API key for use in your application.

Usage

Below is an example of how to use the Assisfy SDK to create a session and handle various events.

const sdk = require('assisfy-sdk');

const assisfy = new sdk({
    apiKey: "your-api-key-here",
    environment: "production", // or "development"
});

const asyncTest = async () => {
    const session = await assisfy.session().create({
        goal: "Who is the president of the United States?",
    });

    session.on('session_created', (data) => {
        console.log('session_created', data);
    });

    session.on('session_connected', (data) => {
        console.log('session_connected', data);
    });

    session.on('session_error', (data) => {
        console.log('session_error', data);
    });

    session.on('session_disconnected', (data) => {
        console.log('session_disconnected', data);
    });

    session.on('message', (data) => {
        console.log('message', data);
        if (data.event === 'complete') {
            console.dir(data.data.cost_summary, { depth: null });
        }

        if (data.event === 'external_resource_requested') {
            console.log('external_resource_requested', data.data);
            if (data.data.resource_type === 'admin_permission_request') {
                session.handlePermissionRequest(true);
            }
            if (data.data.resource_type === 'request_user_input') {
                session.handleInput('test');
            }
        }
    });
}

asyncTest();

API Reference

Initialization

To initialize the SDK, create a new instance with your API key and environment:

const assisfy = new sdk({
    apiKey: "your-api-key-here",
    environment: "production", // or "development"
});

Creating a Session

To create a session, use the create method with a goal:

const session = await assisfy.session().create({
    goal: "Your goal here",
});

Event Handling

The session object emits several events that you can listen to:

  • session_created: Fired when a session is successfully created.
  • session_connected: Fired when a session is connected.
  • session_error: Fired when there is an error in the session.
  • session_disconnected: Fired when a session is disconnected.
  • message: Fired when a message is received. This event can include sub-events like complete and external_resource_requested.

Handling External Resources

When a message event with external_resource_requested is received, you can handle it by checking the resource_type and responding accordingly:

if (data.data.resource_type === 'admin_permission_request') {
    session.handlePermissionRequest(true);
}
if (data.data.resource_type === 'request_user_input') {
    session.handleInput('your-input-here');
}

License

This SDK is licensed under the MIT License. See the LICENSE file for more information.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Support

For support, please contact [email protected].