Provides the core type definitions, configuration utilities, and the `DecisionEngine` class for evaluating classification confidence against routing thresholds. It serves as the foundational library for building custom routing logic within the confidence-router ecosystem.
Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.
Core type definitions, error classes, configuration utilities, and the DecisionEngine for the confidence-router ecosystem. This package is the single source of truth for all type shapes used throughout @reaatech/confidence-router-*.
All errors extend the standard Error class and carry a type discriminator.
Class
Type Enum
When
RouterError
(varies)
Base class for all routing errors
RouterErrorType.CONFIGURATION_ERROR
—
Invalid configuration
RouterErrorType.CLASSIFICATION_ERROR
—
Invalid classifier output
RouterErrorType.LANGUAGE_NOT_SUPPORTED
—
Unknown language code
RouterErrorType.THRESHOLD_INVALID
—
Threshold out of [0, 1] range
RouterErrorType.CLASSIFIER_NOT_FOUND
—
Named classifier not registered
RouterErrorType.DATASET_INVALID
—
Evaluation dataset invalid
typescript
import { RouterError, RouterErrorType } from "@reaatech/confidence-router-core";throw new RouterError( RouterErrorType.THRESHOLD_INVALID, "routeThreshold must be between 0 and 1", { detail: "extra context" });
DecisionEngine
typescript
import { DecisionEngine } from "@reaatech/confidence-router-core";
Method
Returns
Description
decide(classification)
RoutingDecision
Evaluates top prediction confidence against configured thresholds
evaluateThresholds(score)
DecisionType
Maps a raw confidence score to ROUTE, CLARIFY, or FALLBACK
The ConfidenceRouterDeps interface allows callers to inject custom implementations:
typescript
import type { ConfidenceRouterDeps } from "@reaatech/confidence-router-core";const deps: ConfidenceRouterDeps = { languageManager: new CustomLanguageManager(), promptGenerator: new CustomPromptGenerator(lm), classifierRegistry: new CustomRegistry(),};