@abeyjs/runtime
v0.1.4
Published
Application **composition root** for AbeyJs: wraps an **`OmegaChannel`** (`@abeyjs/core`), an **`OmegaFlowManager`** (`@abeyjs/flows`), lightweight **DI** (**`OmegaContainer`**), **agent** registration, optional **URL → intent** bridging, and an in-memory
Readme
@abeyjs/runtime
Application composition root for AbeyJs: wraps an OmegaChannel (@abeyjs/core), an OmegaFlowManager (@abeyjs/flows), lightweight DI (OmegaContainer), agent registration, optional URL → intent bridging, and an in-memory trace ring suited for the Inspector (@abeyjs/inspector).
Most apps create one OmegaRuntime inside omegaSetup (createOmegaRuntime()), then registerModule, registerAgent, registerPlugin, and onIntent handlers.
Composition
| Member | Role |
|--------|------|
| channel | OmegaChannel shared by flows, HTTP (@abeyjs/http), agents, and UI adapters. |
| flow | OmegaFlowManager — dispatch, registerHandler (wrapped by runtime.onIntent). |
| di | OmegaContainer — provide, provideFactory, get / tryGet. |
Constructor wiring:
channel— injected orcreateChannel().createOmegaFlowManager(channel)—flowowns intent routing with correlation metadata.channel.onAllcaptures every published event into_tracewhilesetTraceEnabled(true)(default), capped at 2000 entries.
Lifecycle API (OmegaRuntime)
Intents & flows
dispatch(intent, { source? })— forwards toflow.dispatch.onIntent(name, handler)— shorthand forflow.registerHandler(FlowManagerContextmatches@abeyjs/flows).
Agents
registerAgent(factory)— invokesfactory(channel),connect()on success, replaces prior agent with sameidafterdisposeon the old instance.
Plugins
registerPlugin({ id, install })—install(runtime)may return teardown; registering the sameidruns previous teardown first.unregisterPlugin,disposeAll— teardown plugins and all agents (agents.clearafterdispose).
Modules & DI
registerModule/registerModules—OmegaModule(container, runtime) => voidexecuted once per module function (WeakSetdedupe).provide,provideFactory,get,tryGet— delegate todi.
Troubleshooting: missing provider
If the app throws OmegaContainer: missing provider for token "abeyjs:…" (literal suffix matches your omegaToken("…") name):
get/tryGetran for a token that was neverprovide‘d orprovideFactory‘d—often inside a copiedinstall…(runtime)that expects HTTP or another service registered elsewhere.- Fix: call
runtime.registerModule((c, rt) => { … })before that installer, and register the sameomegaToken("…")(or sharedconstre-export) you pass toget. omegaToken("name")usesSymbol.for("abeyjs:name"), so the error stringabeyjs:namematches theomegaTokenargument.
Trace
getTraceSnapshot()— read-only view of the ring buffer (RuntimeTraceEvent).setTraceEnabled(on)— disables/enables capture (does not clear history).
Inspectors and bridges typically read getTraceSnapshot or subscribe live via channel.onAll.
Types
RuntimeTraceEvent — mirrors channel envelopes: name, data (payload), correlationId, timestamp, optional source.
OmegaRegisteredAgent — id, connect(), dispose(); satisfied by OmegaAgent implementations in @abeyjs/agents.
OmegaPlugin — named install hook with optional unsubscribe.
OmegaModule — grouping hook for DI registration against OmegaContainer + OmegaRuntime.
URL bridge (url-bridge.ts)
Browser helpers for intent-first routing (no framework router required):
| Function | Behaviour |
|----------|-----------|
| startUrlIntentSync(maps, flow, getPath?) | On load and optional popstate, match normalized pathname against PathIntentMap.path, flow.dispatch(intentOf(...)). No-op if window is undefined. |
| setPath(path) | history.pushState without reload. |
| intentFromQuery(search) | Deep link: ?omegaIntent=Name&foo=bar → intentOf("Name", { foo: "bar" }). |
PathIntentMap: template path without leading slash, IntentType, optional toPayload, syncOnPopState.
Dependencies
@abeyjs/core— channel,Intent,intentOf, correlation metadata.@abeyjs/flows—OmegaFlowManager,FlowManagerContext.
Build
npm run build -w @abeyjs/runtime