import { getAllProviders, init_providers, isProviderConfiguredSync } from "../providers/index.js";
//#region src/extensions/when-context.ts
init_providers();
/**
* Flat payload for `GET /api/context` and client-side `when` evaluation.
*/
function buildWhenContextSnapshot(config, loader) {
	const out = {
		platform: process.platform,
		isElectron: Boolean(process.versions.electron),
		gatewayAuthenticated: true,
		sessionActive: false,
		agentRunning: false
	};
	for (const p of getAllProviders()) out[`hasProvider.${p}`] = isProviderConfiguredSync(p);
	const channels = config.channels;
	if (channels && typeof channels === "object") for (const [id, raw] of Object.entries(channels)) if (raw && typeof raw === "object" && raw !== null && "enabled" in raw) out[`hasChannel.${id}`] = raw.enabled === true;
	else out[`hasChannel.${id}`] = Boolean(raw);
	if (loader) try {
		loader.setConfig(config);
		for (const ext of loader.discoverExtensions()) out[`extensionEnabled.${ext.id}`] = true;
	} catch {}
	return out;
}
//#endregion
export { buildWhenContextSnapshot };

//# sourceMappingURL=when-context.js.map