albertonline.org docs
Packages

Effect infrastructure

Shared Effect v4 building blocks for HTTP clients, React glue, realtime pub/sub, and telemetry capture.

These five packages give apps a consistent Effect v4 foundation: typed HTTP client helpers, a React↔Effect runtime bridge, in-process realtime pub/sub, and telemetry/observability capture — so each app wires the same primitives instead of re-deriving them.

@repo/effect-http

Small, dependency-light helpers shared by the monorepo's typed Effect HTTP clients (CvmClient, LilaClient, ImagesClient, AiHeroHttpClient, etc.). It standardizes the error-shape conventions (*HttpError / *NetworkError / *DecodeError) those clients already follow, without unifying the error types themselves — each client keeps its own tagged errors.

  • httpClientErrorLabel — turns a client's tagged error into a user-facing string, matching on the tag suffix so wording is shared across clients
  • transientRetry — exponential-backoff Schedule for transient failures (network blips, 5xx, rate limits), for use with Effect.retry
  • makeJsonTransport (JsonTransport, TransportErrors) — builds a typed JSON get/post transport from a caller-supplied set of error constructors

@repo/react-effect

The React-side bridge to Effect: a ManagedRuntime boundary plus hooks so components can run Effects, queries, actions, and streams without each component wiring its own runtime. No README yet — treat src/index.ts as the source of truth for the public surface.

  • createRuntimeBoundary, RuntimeProvider / useRuntime — provides a scoped ManagedRuntime to a component subtree
  • useManagedRuntime — lower-level runtime-creation hook
  • useEffectQuery, useEffectAction, useEffectStream (+ StreamStatus) — data-fetching, mutation, and streaming hooks over Effect
  • createEffectStore (EffectStore) — Effect-backed store glue, independent of any specific runtime instance
  • WithRuntime (under @repo/react-effect/test/with-runtime) — test helper for rendering components that need a runtime in scope

@repo/realtime

In-process pub/sub built on Effect's PubSub, used by the chess (lila-*) realtime path. EventBus fans out domain game events; SignalBus layers a small per-game buffer on top so WebRTC signaling (offer/answer/ICE/ping) can be replayed to a client that reconnects mid-negotiation. Depends on @repo/chess-domain for its event/signal types, so it is chess-specific rather than a general-purpose bus.

  • EventBusContext.Service wrapping an unbounded PubSub of ChessGame.GameEvent; publish, subscribe, subscribeForGame, and a subscribeScoped variant that registers the subscription eagerly to avoid missing events published before a forked consumer starts draining
  • SignalBus — layers on EventBus; buffers up to 40 signals per game (capped at 256 tracked games, LRU-evicted) for reconnect catch-up

@repo/observability

A Sentry (@sentry/nextjs) + Logtail (@logtail/next) wrapper for Next.js apps. Unlike the other packages here it has no exports map or src/ directory — its files sit at the package root and are imported by direct subpath (e.g. @repo/observability/client), matching the Sentry Next.js convention of separate client/server/edge config entry points. Only keys.ts uses Effect (Schema for env validation via @t3-oss/env-nextjs); the rest is plain Sentry/Logtail glue, not Effect-native.

  • client.ts / server.ts / edge.ts — Sentry init per Next.js runtime
  • instrumentation.tsinitializeSentry(options) for a Next.js instrumentation.ts hook
  • next-config.ts — wraps a Next config with Logtail + Sentry's webpack/build plugin
  • log.tslog, a console/Logtail logger switched on NODE_ENV
  • error.ts, sentry-options.ts, keys.ts — error capture helper, shared Sentry init options, and validated env (createEnv)
  • status/ — a status-page React component

@repo/telemetry

Effect v4 telemetry capture and OTLP export for the agent runtime: a custom Tracer and Logger that capture every span/log event and forward it to pluggable sinks (a DB-backed sink lives in @repo/db; a no-op sink covers tests), plus process metrics and OTLP/JSON serialization. The same capture pipeline feeds both in-app telemetry views and an external OTLP backend.

Sink implementations (SpanSinkDbLayer / LogSinkDbLayer) are not bundled here — the caller provides them, keeping @repo/telemetry free of a DB dependency.

  • TelemetryTracerLayer — installs a span-capturing Tracer; depends on a SpanSink
  • CapturingLoggerLayer — installs a log-capturing Logger; depends on a LogSink
  • rpcRequests, rpcErrors, rpcLatencyMs, activeSessions — module-level Effect Metrics (counter/histogram/gauge)
  • httpRequestCounterMiddleware(name, description) — Effect HTTP middleware incrementing a per-service request counter
  • toOtlpTracesPayload — maps captured spans to an OTLP/HTTP JSON traces payload
  • telemetryResourceConfig — resolves the OTel Resource from OTEL_* env vars
  • Observability.layer({ endpoint, resource }) (also ./prometheus entry point) — one composed layer bundling the capturing logger, capturing tracer, runtime metrics, and the OTLP metrics/logger exporters

See the packages overview and the architecture guide.

On this page