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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shubham-01-star/chronotask-agent

v1.0.2

Published

Zero-dependency Node.js client SDK for ChronoTask AI self-healing SRE platform

Readme

🌀 ChronoTask AI Client Agent SDK

NPM Version Bundle Size License Downloads

A lightweight, zero-dependency Node.js and TypeScript client SDK for integrating scheduled cron jobs, background task runners, and queue consumers with the ChronoTask AI Self-Healing SRE Platform.


🚀 Key Features

  • ⚡ Zero Dependencies: Extremely lightweight. Built using native Node.js core modules.
  • 🧬 Closed-Loop Self-Healing: Connects to the ChronoTask AI real-time event stream. Automatically handles dynamic task suspensions and retry backoffs.
  • 🔑 Zero-Downtime Credential Rotation: Synchronizes rotated SRE API access keys in-memory on the fly without interrupting telemetry uploads.
  • 📊 Automatic Telemetry Logging: Instantly maps execution duration, status metrics, error reports, and stack traces.

🗺️ How it Works

                        ┌─────────────────────────────────┐
                        │   ChronoTask AI Dashboard UI     │
                        └────────────────┬────────────────┘
                                         │ Admin Toggles / Key Rotation
                                         ▼
   ┌──────────────────┐ Telemetry POST  ┌─────────────────────────────────┐
   │ My Cron / Worker ├────────────────►│ ChronoTask AI Backend Ingestor  │
   │   Task Runner    │                 └────────────────┬────────────────┘
   │                  │ SSE Control Stream               │ Async AI Diagnostics
   │  (Runs SDK Agent)◄──────────────────────────────────┘
   └──────────────────┘ (Task Toggle, AI Cooldown, Key Rotation)

📦 Installation

Install the package via your preferred package manager:

npm install @shubham-01-star/chronotask-agent

⚡ Quick Start

1. Basic Ingestion Setup

The most basic configuration allows logging execution durations, errors, and attempts:

import { ChronoTaskAgent } from '@shubham-01-star/chronotask-agent';

// Initialize the SRE Agent
const agent = new ChronoTaskAgent({
  apiKey: 'ct_live_your_sre_access_token_here',
  endpoint: 'http://localhost:5000/api/v1',
  enableSelfHealing: false // Standard telemetry tracking only
});

async function myTask() {
  const start = Date.now();
  try {
    // ---> Execute your task workload here <---
    
    await agent.report({
      task_name: 'database_cleanup_job',
      cron_expression: '0 0 * * *',
      status: 'SUCCESS',
      duration_ms: Date.now() - start,
      attempt_number: 1
    });
  } catch (error: any) {
    await agent.report({
      task_name: 'database_cleanup_job',
      cron_expression: '0 0 * * *',
      status: 'FAILED',
      duration_ms: Date.now() - start,
      attempt_number: 1,
      error_summary: error.message,
      stack_trace: error.stack
    });
  }
}

2. Full Self-Healing Setup (Closed-Loop)

By enabling enableSelfHealing, the agent connects to the ChronoTask control plane over SSE, applying dynamic administrative and AI-generated blocks automatically.

import { ChronoTaskAgent } from '@shubham-01-star/chronotask-agent';

const agent = new ChronoTaskAgent({
  apiKey: 'ct_live_your_sre_access_token_here',
  endpoint: 'http://localhost:5000/api/v1',
  enableSelfHealing: true // Opens real-time control connection
});

// Configure hooks to print SRE events
agent.onRemediation((remediation) => {
  console.log(`[AI Diagnostics] Recommended Backoff Action: ${remediation.action_taken}`);
  console.log(`[AI Diagnostics] Recommended Fix Code Patch:\n${remediation.suggested_fix}`);
});

agent.onTaskToggled((task) => {
  console.log(`[SRE Admin Action] Task "${task.task_name}" changed state to: ${task.status}`);
});

agent.onKeyRotated((newKey) => {
  console.log(`[Security Alert] Access key rotated! Syncing token in-memory to: ${newKey}`);
});

// Wrapping the schedule execution block:
async function runStripeInvoiceSync() {
  const taskName = 'stripe_invoice_sync';

  // 1. Safety check: Block execution if task is suspended or in AI cooldown backoff
  if (agent.isSuspended(taskName)) {
    const cooldownLeft = agent.getRemainingBackoffSeconds(taskName);
    console.warn(`[Execution Blocked] Task "${taskName}" is suspended. Cooldown: ${cooldownLeft}s`);
    return;
  }

  const start = Date.now();
  try {
    // ---> Execute Stripe Sync logic <---

    await agent.report({
      task_name: taskName,
      cron_expression: '*/10 * * * *',
      status: 'SUCCESS',
      duration_ms: Date.now() - start,
      attempt_number: 1
    });
  } catch (err: any) {
    await agent.report({
      task_name: taskName,
      cron_expression: '*/10 * * * *',
      status: 'FAILED',
      duration_ms: Date.now() - start,
      attempt_number: 1,
      error_summary: err.message,
      stack_trace: err.stack
    });
  }
}

📖 API Reference

Configurations

interface ChronoTaskAgentConfig {
  apiKey: string;              // Telemetry credentials from dashboard settings
  endpoint?: string;           // ChronoTask Ingestion endpoint. Defaults to 'http://localhost:5000/api/v1'
  enableSelfHealing?: boolean; // Toggles Server-Sent Event stream listeners. Defaults to true
}

Methods

report(payload: TelemetryPayload): Promise<{ success: boolean; execution_id?: string; error?: string }>

Sends execution logs to the database. If the status is 'FAILED', triggers the asynchronous Gemini AI agent diagnostic pipeline.

isSuspended(taskName: string): boolean

Returns true if the task has been paused manually by an SRE administrator, or is temporarily throttle-blocked during an active dynamic backoff cooldown.

getRemainingBackoffSeconds(taskName: string): number

Returns the remaining cooldown time in seconds for backoff thorttling. Returns 0 if not throttled.

disconnect(): void

Gracefully unsubscribes from the control SSE streams and releases socket connections.

SSE Event Hooks

onRemediation(callback: (remediation: any) => void): void

Subscribes to asynchronous AI diagnostic updates when Gemini finishes analysis.

onTaskToggled(callback: (task: any) => void): void

Subscribes to real-time administrative suspensions / activations.

onKeyRotated(callback: (apiKey: string) => void): void

Subscribes to zero-downtime key rotation operations.


📄 License

This SDK is open-source software licensed under the MIT License.