Skip to content

Interface: NodeExtensionContext

Makaio Framework


Makaio Framework / contracts / NodeExtensionContext

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

Node.js host extension context.

Adds the OS and filesystem fields supplied by Node-based composition roots. Extensions that need these fields should opt into this context explicitly; host-agnostic extensions can type themselves against ExtensionContext.

readonly bus: IMakaioBus

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

Bus instance for registering handlers and emitting events.

ExtensionContext.bus


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);

ExtensionContext.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.).

ExtensionContext.dataDir


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.

ExtensionContext.hasExtension


readonly homedir: string

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

User’s home directory path.


readonly identity: ExtensionIdentity

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

Coordinator-minted identity for the extension being created.

ExtensionContext.identity


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.

ExtensionContext.machineId


readonly makaioHome: string

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

Resolved .makaio directory root (e.g., ~/.makaio).


readonly platform: Platform

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

Current platform identifier (e.g., 'darwin', 'linux', 'win32').


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.

ExtensionContext.signal


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.

ExtensionContext.tryImport


readonly username: string

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

Current OS username.

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.

ExtensionContext.getService