Skip to content
mercury framework
GitHub

ChannelRuntimeContext

ChannelRuntimeContext = object

Defined in: types/channel-types/index.ts:414

The minimal capabilities every channel gets from the core — the intersection across terminal, HTTP and Google Chat, nothing channel-specific. Anything specific (Google Chat’s credentials, HTTP’s port) the channel reads from env in its own build(). This is the dependency-inversion seam: the core injects these, the channel imports none of them.

env, log, confirm and admit are the floor every channel relies on. resolveConfirmation, reads, authenticate, logins, linking and settings are optional in-process capabilities that can’t come from env: the core populates them, only a channel that needs them (HTTP) reads them, the others ignore them.

admit: (principal, hint?) => Promise<Admission>

Defined in: types/channel-types/index.ts:437

Whether the core talks to principal at all (see Admission). A channel that authenticates its own callers checks it before anything else and answers with message when it’s refused; the core checks again on every turn, confirmation and read, so a channel that doesn’t still can’t let anyone in. message is in the language hint asks for (see ChannelI18n).

Principal

string

Promise<Admission>


optional assistantName?: string

Defined in: types/channel-types/index.ts:453

The assistant’s name (the app’s persona.name), for what the channel tells people itself (a login page, a card). The core always sets it; absent on an older core.


optional authenticate?: Authenticate

Defined in: types/channel-types/index.ts:445

The configured auth provider, built; absent when the app declares none or it failed to build.


confirm: (token, sessionKey, principal, hint?) => Promise<ConfirmReply | null>

Defined in: types/channel-types/index.ts:429

Resolves a confirmation token against the core’s single ConfirmationStore, already bound to this instance’s store/vault/writer. The channel calls it and holds no state: staging and the store stay the core’s. The token resolves only for the principal who staged it, in the same session. Returns what to tell the person, in their language (hint as in ChannelI18n), or null when the input wasn’t token-shaped (see resolveConfirmation). A link code (xxxx-xxxx-xxxx, see ChannelLinking) is taken here too, from whoever sends it.

string

string

Principal

string

Promise<ConfirmReply | null>


env: Record<string, string | undefined>

Defined in: types/channel-types/index.ts:416

The process env, so a channel reads its own config (subscription, credentials, port) without the core knowing which keys it needs.


optional frameworkVersion?: string

Defined in: types/channel-types/index.ts:455

The framework’s version (major.minor.patch), for a channel that tells people which Mercury they’re talking to (HTTP’s /version). The core always sets it; absent on an older core.


i18n: ChannelI18n

Defined in: types/channel-types/index.ts:441

The texts the channel shows a person itself, in their language (see ChannelI18n).


optional linking?: ChannelLinking

Defined in: types/channel-types/index.ts:449

Linking another account to a person (see ChannelLinking).


log: (msg) => void

Defined in: types/channel-types/index.ts:418

stderr logger for the channel’s own lifecycle/errors.

string

void


optional logins?: ChannelLogins

Defined in: types/channel-types/index.ts:447

People’s logins to the plugins’ services (see ChannelLogins).


optional reads?: ChannelHostReads

Defined in: types/channel-types/index.ts:443

In-process introspection getters for a channel that exposes an API/UI.


optional resolveConfirmation?: (token, sessionKey, principal, hint?) => Promise<ResolvedConfirmation>

Defined in: types/channel-types/index.ts:439

The structured sibling of confirm (see ResolvedConfirmation), for a channel that branches on whether the token was accepted.

string

string

Principal

string

Promise<ResolvedConfirmation>


optional settings?: ChannelSettings

Defined in: types/channel-types/index.ts:451

The person’s own settings (see ChannelSettings); absent on an older core.