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

@layerinfinite/sdk

v0.3.5

Published

Decision intelligence layer for AI agents. No LLMs. Just math.

Readme

Layerinfinite TypeScript SDK (@layerinfinite/sdk)

Layerinfinite is a decision intelligence middleware for AI agents — it records action outcomes, computes composite trust scores, and recommends the highest-performing next action so your agents learn from every decision. Drop it into any TypeScript or JavaScript project with zero runtime dependencies.

Installation

npm install @layerinfinite/sdk
# or
yarn add @layerinfinite/sdk
# or
pnpm add @layerinfinite/sdk

Quick Start

import { LayerinfiniteClient } from '@layerinfinite/sdk';

const client = new LayerinfiniteClient({ apiKey: 'layerinfinite_your_key' });

// Ask Layerinfinite which action to take
const scores = await client.getScores({
  agentId: 'my-agent',
  issueType: 'billing_dispute',
});
console.log(scores.top_action?.action_name);  // e.g. "escalate_to_senior"
console.log(`Policy: ${scores.policy}`);      // exploit | explore | escalate

// Log the outcome after the action runs
await client.logOutcome({
  agent_id: 'my-agent',
  action_name: scores.top_action!.action_name,
  issue_type: 'billing_dispute',
  success: true,
  // optional: if omitted, LI infers score from success/failure + soft signals
  outcome_score: 0.9,
  business_outcome: 'resolved',
});

LangChain Integration

import { LayerinfiniteClient } from '@layerinfinite/sdk';
import { tool } from '@langchain/core/tools';

const layerinfinite = new LayerinfiniteClient({ apiKey: process.env.LAYERINFINITE_API_KEY! });

const resolveTicket = tool(
  async ({ agentId, issueType }: { agentId: string; issueType: string }) => {
    const scores = await layerinfinite.getScores({ agentId, issueType });
    const action = scores.top_action!;
    // ... run the action ...
    await layerinfinite.logOutcome({
      agent_id: agentId, action_name: action.action_name,
      issue_type: issueType,
      success: true, outcome_score: 0.85, business_outcome: 'resolved',
    });
    return action.action_name;
  },
  { name: 'resolve_ticket', description: 'Resolve a support ticket guided by Layerinfinite' }
);

CrewAI-style Integration

import { LayerinfiniteClient } from '@layerinfinite/sdk';

const layerinfinite = new LayerinfiniteClient({ apiKey: process.env.LAYERINFINITE_API_KEY! });

export async function agentDecide(agentId: string, issue: string) {
  const { top_action, context_id, policy } = await layerinfinite.getScores({
    agentId, issueType: issue,
  });
  console.log(`[Layerinfinite] Policy: ${policy}, Action: ${top_action?.action_name}`);
  return { action: top_action, contextId: context_id };
}

Error Handling

import {
  LayerinfiniteClient,
  LayerinfiniteAuthError,
  LayerinfiniteRateLimitError,
  LayerinfiniteServerError,
} from '@layerinfinite/sdk';

const client = new LayerinfiniteClient({ apiKey: 'layerinfinite_key' });

try {
  const scores = await client.getScores({ agentId: 'agent-1', issueType: 'billing' });
} catch (err) {
  if (err instanceof LayerinfiniteAuthError) {
    console.error('Invalid API key');
  } else if (err instanceof LayerinfiniteRateLimitError) {
    console.error(`Rate limited — retry after ${err.retryAfter}s`);
    await new Promise(r => setTimeout(r, err.retryAfter * 1000));
  } else if (err instanceof LayerinfiniteServerError) {
    console.error(`Server error: ${err.statusCode}`);
  }
}

Configuration

| Option | Default | Description | |--------|---------|-------------| | apiKey | required | Your Layerinfinite API key | | baseUrl | https://layerinfinite.me | Primary API base URL | | baseUrls | [] | Optional fallback API URLs used after network/timeout/5xx failures | | timeout | 10000 | Request timeout in ms | | maxRetries | 3 | Max retries on 429/5xx/timeouts/network errors |

You can also provide fallback endpoints with the LAYERINFINITE_BASE_URLS environment variable (comma-separated), for example:

LAYERINFINITE_BASE_URLS="https://api-backup-1.layerinfinite.app,https://api-backup-2.layerinfinite.app"

Production Runbook (Railway/Vercel)

Use this endpoint order in production:

  1. Primary: stable custom domain (example: https://layerinfinite.me)
  2. Fallback 1: Railway deployment URL
  3. Fallback 2: Vercel deployment URL

Recommended client setup:

const client = new LayerinfiniteClient({
  apiKey: process.env.LAYERINFINITE_API_KEY!,
  baseUrl: 'https://layerinfinite.me',
  baseUrls: [
    'https://layerinfinite-api-production.up.railway.app',
    'https://layerinfinite-api.vercel.app',
  ],
  timeout: 10_000,
  maxRetries: 3,
});

Production checklist:

  • Keep all endpoints on the same backend version and schema.
  • Point all endpoints to the same production database/project.
  • Do not use preview URLs as fallbacks.
  • Keep maxRetries low (2-3) to reduce latency spikes.
  • Run a failover drill weekly by temporarily blocking the primary URL and confirming fallback succeeds.

Links