Getting Started

JavaScript/Node.js Device Agent

Test Sulala using the JavaScript/Node.js device agent built with Electron.

Overview

The JavaScript/Node.js device agent is an Electron-based desktop application that connects your device to Sulala.ai. It's perfect for desktop development and testing on Windows, macOS, and Linux.

Features

Simple GUI - No command line needed
One-click start - Just enter API key and click start
System tray - Runs in background
Auto-reconnect - Automatically reconnects if connection drops
Status indicator - See connection status at a glance
Cross-platform - Works on Mac, Windows, Linux

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager
  • API Key from Sulala dashboard

Quick Start (Development Mode)

The easiest way to test is to run the agent in development mode:

# Navigate to the device-agent directory
cd device-agent

# Install dependencies
npm install

# Start the agent in development mode
npm start

The app will open! Enter your API key and click "Start Agent".

Installation Steps

Step 1: Navigate to Device Agent Directory

cd device-agent

Step 2: Install Dependencies

npm install

This will install all required dependencies including Electron and other Node.js packages.

Step 3: Configure API Key

When you run the app, you'll see a GUI where you can:

  1. Enter your API key (from Dashboard → Devices → Your Device → API Key)
  2. Enter server URL (default: http://localhost:3000, change to your production URL if needed)
  3. Click "Start Agent"

The API key and server URL are automatically saved for future use.

Step 4: Start the Agent

npm start

The Electron app will launch. After entering your API key and clicking "Start Agent", your device will be connected to Sulala.ai.

Building for Production

If you want to build a distributable version of the agent:

Build for Your Platform

# macOS
npm run build:mac

# Windows
npm run build:win

# Linux
npm run build:linux

Build for All Platforms

npm run build

Build Without Code Signing (For Testing)

If you want to build without code signing (users will see a warning but it works):

# macOS example
CSC_IDENTITY_AUTO_DISCOVERY=false npm run build:mac

Output

Built apps will be in device-agent/dist/:

  • macOS: .dmg file
  • Windows: .exe installer
  • Linux: .AppImage file

How It Works

The JavaScript agent:

  1. User enters API key in the GUI
  2. App connects to Sulala.ai cloud
  3. Sends heartbeat every 30 seconds
  4. Polls for search requests from the cloud
  5. Executes searches locally (files, apps, system info)
  6. Sends results back automatically
  7. Handles file upload requests when needed

All automatic - user doesn't need to do anything after starting!

Project Structure

device-agent/
├── main.js              # Electron main process
├── index.html           # UI interface
├── package.json         # Dependencies and scripts
├── README.md            # Documentation
└── dist/                # Built applications

API Endpoints

The agent communicates with the following Sulala.ai endpoints:

  • POST /api/devices/heartbeat - Send device heartbeat
  • GET /api/devices/search/pending - Poll for search requests
  • POST /api/devices/search - Submit search results
  • GET /api/devices/files/upload-requests/pending - Poll for upload requests
  • POST /api/devices/files/upload - Upload file to cloud

Configuration

The agent uses the following configuration:

  • API Key: Stored locally in the app settings
  • Server URL: Defaults to http://localhost:3000, can be changed in the GUI
  • Heartbeat Interval: 30 seconds (hardcoded)
  • Polling Interval: 30 seconds (hardcoded)

Troubleshooting

App won't start

  • Make sure Node.js 18+ is installed: node --version
  • Run npm install to ensure all dependencies are installed
  • Check that you're in the device-agent directory

Connection errors

  • Verify your API key is correct (from Dashboard → Devices)
  • Check that the server URL is accessible
  • Ensure your internet connection is working
  • Make sure the Sulala server is running

Device shows as "Offline"

  • Restart the device agent
  • Check your internet connection
  • Verify the API key matches the device in the dashboard
  • Check the agent console for error messages

System tray not working

  • System tray is optional and may not work on all platforms
  • The app will continue to function without tray support
  • You can keep the main window open instead

Development Tips

Running in Debug Mode

The agent runs in development mode when you use npm start. You can see console output in the terminal and use Chrome DevTools for debugging.

Viewing Logs

The agent outputs logs to the console. Watch for:

  • Heartbeat status messages
  • Search request notifications
  • Error messages

Testing Different Server URLs

You can test against different Sulala instances by changing the server URL in the GUI:

  • Local development: http://localhost:3000
  • Staging: https://staging.sulala.ai
  • Production: https://sulala.ai

Next Steps