Interface: ExtensionContext
Makaio Framework / contracts / ExtensionContext
Interface: ExtensionContext
Section titled “Interface: 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.
Extended by
Section titled “Extended by”Properties
Section titled “Properties”
readonlybus:IMakaioBus
Defined in: ../../../packages/contracts/src/extension/extension-context.ts:15
Bus instance for registering handlers and emitting events.
config?
Section titled “config?”
readonlyoptionalconfig?: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);dataDir
Section titled “dataDir”
readonlydataDir: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.).
hasExtension
Section titled “hasExtension”
readonlyhasExtension: (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.
Parameters
Section titled “Parameters”string
Extension name to check.
Returns
Section titled “Returns”boolean
true when the extension is active.
identity
Section titled “identity”
readonlyidentity:ExtensionIdentity
Defined in: ../../../packages/contracts/src/extension/extension-context.ts:17
Coordinator-minted identity for the extension being created.
machineId
Section titled “machineId”
readonlymachineId: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.
signal
Section titled “signal”
readonlysignal: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.
tryImport
Section titled “tryImport”
readonlytryImport: <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.
Type Parameters
Section titled “Type Parameters”T
Expected module shape (caller-asserted, not runtime-verified).
Parameters
Section titled “Parameters”specifier
Section titled “specifier”string
Package specifier to import.
Returns
Section titled “Returns”Promise<T | null>
The imported module cast to T, or null when the package is not installed.
Methods
Section titled “Methods”getService()
Section titled “getService()”getService<
T>(token):T|undefined
Defined in: ../../../packages/contracts/src/extension/extension-context.ts:48
Retrieve a service exposed by another active extension.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Extension-owned token identifying the desired service.
Returns
Section titled “Returns”T | undefined
The active service instance, or undefined when unavailable.