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

@capsiynau/intelligence-client

v0.1.1

Published

Typed client for the Intelligence Layer API. Auth, tenant context, idempotency, timeouts, retry on safe operations, error normalisation, job polling. No intelligence implementation.

Readme

@capsiynau/intelligence-client

The typed client products use to reach the Intelligence Layer.

Private, unpublished, and not publishable. Capsiynau, Nodiadau and Postia consume it from the repo; nothing here reaches a public registry (ADR 0028).

What it is

The transport concerns every caller would otherwise get right five times, slightly differently:

  • service-credential auth and opaque tenant/user context
  • idempotency keys, generated when you do not supply one
  • per-attempt timeouts, with caller aborts kept distinct from them
  • retry on safe operations only
  • one typed error hierarchy, from either wire shape
  • request-ID propagation, so one trace spans product and platform
  • job polling that ends on any terminal status the contract defines

What it is not

The intelligence. There are no prompts here, no provider names, no model routing, no segmentation rules, no Welsh handling. Someone holding this package and @capsiynau/intelligence-contracts can call the platform and cannot rebuild it (ADR 0006). scripts/check-boundary-leaks.mjs enforces that on every commit rather than trusting it.

Server-side only

The credential is a service credential (ADR 0002). It does not belong in browser JavaScript, and nothing in this package can stop a bundler that is pointed at it

  • that rule lives in review and in the boundary guard.

Use

import { IntelligenceClient } from '@capsiynau/intelligence-client'

const intelligence = new IntelligenceClient({
  credential: process.env.INTELLIGENCE_API_KEY,
  baseUrl: process.env.INTELLIGENCE_API_URL,
  tenant: organisationReference,   // opaque; the platform stores no product identity
})

// Submit and wait.
const result = await intelligence.run('transcription', {
  asset_id: assetId,
  source_language: 'cy',
  quality_profile: 'welsh-broadcast',
})

// Or drive the lifecycle yourself.
const job = await intelligence.createJob('transcription', { asset_id: assetId })
const done = await intelligence.waitForJob('transcription', job.job_id, {
  onProgress: (j) => activityStrip.update(j.status),
})

Quality profiles are named intents, never models. Which model serves welsh-broadcast is the platform's business and may change without a client release (ADR 0007).

Errors

Every failure arrives as an IntelligenceError subclass carrying code, status, requestId, details and retryable. Branch on the class or on the code, never on the message.

import { QuotaError, RateLimitError } from '@capsiynau/intelligence-client'

try {
  await intelligence.run('translation', payload)
} catch (err) {
  if (err instanceof QuotaError) return showUpgradePrompt()
  if (err instanceof RateLimitError) return retryLater(err.details.retry_after)
  log.error({ code: err.code, requestId: err.requestId }, 'intelligence call failed')
  throw err
}

The client understands both the v1 envelope and the legacy { error, code } body, so it works against the platform before and after the envelope rollout (ADR 0017).

Retry rule

A GET or HEAD may be retried. A POST may be retried only when it carried an idempotency key, because that key is what makes the second attempt free rather than a second charge (ADR 0013). The failure must also be retryable

  • a validation error does not improve by being sent again.

The client generates a key for every job submission, so submissions are retried by default. client.request('POST', ...) without a key is sent exactly once.

Cancellation

cancelJob is cooperative and best-effort (ADR 0016). It records the intent; it does not promise the work stopped, and anything already inside a provider call may still be billed.

Testing

npx vitest run packages/intelligence-client

The suite runs against a real node:http fixture server rather than a mocked fetch, so headers, status codes, timeouts and aborts are exercised as they will be in production. It runs in the node environment, not the repo's default jsdom - jsdom's AbortController is not the one Node's fetch accepts.