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

assisfy-sdk

v1.5.0

Published

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

Downloads

21

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@latest

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 Console.
  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?",
    });

    // start session with auto trigger
    // Auto trigger every 30 minutes, end at 2025-01-20T00:00:00Z, start at 2025-01-29T00:00:00Z, and send a web hook to https://example.com/webhook
    // include this is you'd like to auto trigger the session

    // const session = await assisfy.session().create({
    //     goal: "Go through https://assisfy.ai/blog and let me know the latest update on the blog",
    //     withAutoTrigger: {
    //         interval: 30,
    //         end_at: '2025-01-20T00:00:00Z',
    //         start_at: '2025-01-29T00:00:00Z',
    //         web_hook_url: 'https://example.com/webhook',
    //     }
    // });

    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:

session.on('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');
        }
    }
});

Auto Trigger

Auto trigger allows you to trigger a job that runs at some interval. This requires starting the session like so

    // start session with auto trigger
    // Auto trigger every 30 minutes, end at 2025-01-20T00:00:00Z, start at 2025-01-29T00:00:00Z, and send a web hook to https://example.com/webhook
    // include this is you'd like to auto trigger the session

    const session = await assisfy.session().create({
        goal: "Go through https://assisfy.ai/blog and let me know the latest update on the blog",
        withAutoTrigger: {
            interval: 30,
            end_at: '2025-01-20T00:00:00Z',
            start_at: '2025-01-29T00:00:00Z',
            web_hook_url: 'https://example.com/webhook',
        }
    });

    // your sessions will respond with the following object

With this approach, you will not be able to use the socket session but rely on the webhook events to listen to activities All activities here include:

- trigger.session.started
- trigger.action.run
- trigger.external.resource.requested
- trigger.thoughts.and.memories
- trigger.browser.started
- trigger.complete
- trigger.error

Your webhook will receive this type of event for example

{
    event: 'trigger.action.run',
    data: {
        ...other data information,
        tracking_id: activity.tracking_id
    },
}

and so on

It'll be important to handle the external resource request just like we'd normally would. As of SDK v1.5.0, we now allow .connect() method which allows you to connect to an existing session.

For every new session that is started via the auto trigger, you'll receive the trigger.session.started event which contains a sessionId on it's body This means that you can pass the sessionId to the method like so const session = await sdk.session().connect('1234567890'); After your webhook receive this event, based on your judgement of the task of the agent, you should connect to the session so you can handle the permission and resource request

const session = await sdk.session().connect('your_session_id_here');
session.on('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');
        }
    }
});

Examples

Kindly see the examples folder on how to create a session and connect with other sessions respectively

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].