/** * Runtime context for the world-model: gathers self-identity (account, instance, * IAM role) at gateway boot, caches it, and exposes a sync `getSelfRuntime()` * the prompt-assembly hot path can call without I/O. * * Sources, in priority order: * 1. Provisioning env vars (SKYKOI_KOI_ID, SKYKOI_ORG_ID, SKYKOI_AWS_ACCOUNT, * SKYKOI_INSTANCE_ID) — set by cloud-init when the gateway boots. * 2. EC2 IMDSv2 (instance-id, public-ipv4, instance-type, role) — best-effort. * 3. Hostname (`os.hostname()`) — last-resort label. * * IMDS is queried lazily on first call to `initRuntimeContext()` and the result * is cached for the process lifetime. If IMDS is unreachable (running outside * EC2 in dev) the helper returns whatever the env provided plus undefined for * the rest — never throws. */ import type { SelfRuntime } from "./types.js"; export type SelfIdentity = { koiId?: string; orgId?: string; plan?: string; runtime: SelfRuntime; }; export declare function initRuntimeContext(opts?: { fetchImpl?: typeof fetch; }): Promise; /** Synchronous accessor — returns undefined until {@link initRuntimeContext} resolves. */ export declare function getSelfRuntime(): SelfRuntime | undefined; export declare function getSelfIdentity(): SelfIdentity; /** Reset for tests. */ export declare function _resetRuntimeContextForTests(): void;