Skip to content

Interface: ExtensionContext

Makaio Framework


Makaio Framework / contracts / ExtensionContext

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:13

Generic context provided by a host runtime when creating an extension’s service.

Contains host-agnostic runtime seams: the bus instance, extension identity, extension-local data directory, machine identity, config, service lookup, and lifecycle controls. Host-specific environment details belong on explicit context extensions such as NodeExtensionContext.

readonly bus: IMakaioBus

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:15

Bus instance for registering handlers and emitting events.


readonly optional config?: unknown

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:42

Resolved configuration for this extension, merged from stored values and descriptor defaults. Present only when the extension declared a configSchema on its MakaioExtension.

Extensions should parse this with their Zod schema to get typed config:

const config = parseExtensionConfig(MyConfigSchema, ctx.config);

readonly dataDir: string

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:23

Per-extension writable data directory resolved by the host runtime.

Use this for extension-local persistence (caches, state files, etc.).


readonly hasExtension: (name) => boolean

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:75

Check whether an extension with the given name is active.

Returns true when the named extension has been loaded and reached active state. Use this for optional integration checks without requiring an ExtensionToken.

string

Extension name to check.

boolean

true when the extension is active.


readonly identity: ExtensionIdentity

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:17

Coordinator-minted identity for the extension being created.


readonly machineId: string

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:31

Stable machine identifier used for machine-scoped persistence and encryption key derivation.

Resolved by the composition root (e.g., node-machine-id) before extensions are started.


readonly signal: AbortSignal

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:65

Abort signal triggered during graceful shutdown.

Extensions can pass this to long-running operations (fetch, timers, streams) so they cancel promptly when the runtime is stopping.


readonly tryImport: <T>(specifier) => Promise<T | null>

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:58

Attempt a dynamic import, returning null when the package is not installed.

Only swallows errors caused by the package itself being absent. Transitive dependency failures and module evaluation errors are re-thrown.

T

Expected module shape (caller-asserted, not runtime-verified).

string

Package specifier to import.

Promise<T | null>

The imported module cast to T, or null when the package is not installed.

getService<T>(token): T | undefined

Defined in: ../../../packages/contracts/src/extension/extension-context.ts:48

Retrieve a service exposed by another active extension.

T

ExtensionToken<T>

Extension-owned token identifying the desired service.

T | undefined

The active service instance, or undefined when unavailable.