New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@defai.digital/algorithms

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@defai.digital/algorithms

Performance-critical algorithms for AutomatosX (ReScript)

latest
npmnpm
Version
11.0.1
Version published
Maintainers
1
Created
Source

@ax/algorithms

Performance-critical algorithms for AutomatosX.

Installation

pnpm add @ax/algorithms

Overview

This package contains optimized algorithms implemented in ReScript with TypeScript bindings:

  • Routing - Multi-factor provider selection
  • DAG Scheduler - Directed acyclic graph task scheduling
  • Memory Ranking - Relevance scoring for memory search

Algorithms

Provider Routing

Select the best provider based on multiple factors:

import { selectProvider, calculateProviderScore } from '@ax/algorithms';

const result = selectProvider(providers, context);
console.log(result.provider);     // Selected provider
console.log(result.score);        // Selection score
console.log(result.alternatives); // Fallback options

// Scoring factors:
// - Provider health status
// - Recent latency
// - Success rate
// - Priority configuration

DAG Scheduler

Schedule tasks with dependencies:

import {
  createDAG,
  addTask,
  addDependency,
  getExecutionOrder,
  getParallelGroups,
  getCriticalPath,
  detectCycles,
} from '@ax/algorithms';

// Create task graph
const dag = createDAG();
addTask(dag, 'setup', { name: 'Setup environment' });
addTask(dag, 'build', { name: 'Build project' });
addTask(dag, 'test', { name: 'Run tests' });
addDependency(dag, 'build', 'setup');
addDependency(dag, 'test', 'build');

// Get execution order (topological sort)
const order = getExecutionOrder(dag);
// ['setup', 'build', 'test']

// Get parallel execution groups
const groups = getParallelGroups(dag);
// [['setup'], ['build'], ['test']]

// Find critical path
const critical = getCriticalPath(dag);

// Detect cycles (returns null if valid)
const cycle = detectCycles(dag);

Memory Ranking

Rank memory entries by relevance:

import { rankMemories, calculateRelevanceScore } from '@ax/algorithms';

const ranked = rankMemories(entries, {
  query: 'authentication API',
  recencyWeight: 0.3,
  frequencyWeight: 0.2,
  typeBonus: { code: 1.2, decision: 1.1 },
  tagBonus: { important: 1.5 },
});

// Each result includes:
// - entry: The memory entry
// - score: Combined relevance score
// - components: Individual score breakdown

Scoring Details

Provider Score Components

FactorWeightDescription
Health0.4Provider availability
Latency0.3Recent response times
Success0.2Historical success rate
Priority0.1Configuration priority

Memory Relevance Components

FactorWeightDescription
FTS Score0.4Full-text search match
Recency0.3Time decay factor
Frequency0.2Access count
Type/Tag0.1Bonus multipliers

Implementation

The core algorithms are implemented in ReScript for performance:

packages/algorithms/
├── src/
│   ├── Routing.res       # Provider selection
│   ├── DagScheduler.res  # DAG operations
│   └── MemoryRank.res    # Relevance ranking
└── bindings/
    ├── routing.ts        # TypeScript bindings
    ├── dag.ts            # TypeScript bindings
    └── ranking.ts        # TypeScript bindings

License

Apache-2.0

FAQs

Package last updated on 01 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts