UNPKG

agentlang

Version:

The easiest way to build the most reliable AI agents - enterprise-grade teams of AI agents that collaborate with each other and humans

48 lines 1.42 kB
import { AppConfig } from '../state.js'; // TODO: AdminUserId must be dynamically set based on auth-service-config and a valid admin-login export const AdminUserId = '00000000-0000-0000-0000-000000000000'; export function isAuthEnabled() { var _a; if (((_a = AppConfig === null || AppConfig === void 0 ? void 0 : AppConfig.auth) === null || _a === void 0 ? void 0 : _a.enabled) == true) { return true; } else { return false; } } export let InternalRbacEnabled = false; export function isRbacEnabled() { var _a; return InternalRbacEnabled || (isAuthEnabled() && ((_a = AppConfig === null || AppConfig === void 0 ? void 0 : AppConfig.rbac) === null || _a === void 0 ? void 0 : _a.enabled) == true); } export async function callWithRbac(f) { const old = InternalRbacEnabled; InternalRbacEnabled = true; try { await f(); } finally { InternalRbacEnabled = old; } } export const AdminSession = { sessionId: crypto.randomUUID(), userId: AdminUserId, }; export const BypassSession = AdminSession; export const NoSession = { sessionId: 'nil', userId: 'nil', }; export function isNoSession(sess) { return sess == NoSession; } const LocalEnv = new Map(); export function setLocalEnv(k, v) { LocalEnv.set(k, v); return v; } export function getLocalEnv(k) { return LocalEnv.get(k); } //# sourceMappingURL=defs.js.map