Skip to main content
Projects @glideco/smart-router rail candidates into the parley-protocol three-tier vocabulary: turbo, fast, and batch. Agents can present these tiers in a chooser UI, pass a tier preference to payments.initiate, or ignore tiers entirely — backward-compatible with vanilla MPP. Pure functions, no IO.

Install

npmjs.com/package/@glideco/parley-tiers

Why tiers

The smart-router returns a ranked list of rails sorted by fee. That list is the right output for the dispatcher, but it’s the wrong surface for agents that need to give users a choice. “Tempo USDC — 0.05800ms"and"LightningviaSpark0.05 — 800ms" and "Lightning via Spark — 0.01 — 200ms” are both valid options, but they mean different things to a user who’s about to pay a contractor. Parley tiers give that list a name. The three tiers cover the practical range:
  • turbo — p95 latency ≤ 500ms, fee penalty acceptable.
  • fast — p95 latency ≤ 5s, lowest fee within that ceiling.
  • batch — p95 latency ≤ 10 min, cheapest path overall.
Thresholds are overridable. A B2B SLA might define fast as ≤ 500ms rather than ≤ 5s.

API surface

buildParleyTiers(candidates, thresholds?): ParleyTier[]

Within a tier, rails are sorted fee ASC → latency ASC → confidence DESC.

pickPreferredTier(tiers, preference): ParleyTier | undefined

Returns the best candidate for the requested tier. If that tier has no candidates, falls back in the order:
  • turbofastbatch
  • fastturbobatch
  • batchfastturbo

classifyTier(latencyP95Ms, thresholds?): ParleyTierName | undefined

Classify a single latency value without building the full tier list. Returns undefined when the latency exceeds the batch ceiling.

Confidence flagging

Rail candidates carry a confidence field (0–1) set by the smart-router from observed success rate. buildParleyTiers preserves confidence on each ParleyTier. Low-confidence rails will rank behind higher-confidence rails with equal fee + latency, and the caller can choose to display a warning to the user when confidence < 0.8.

Reading list