@sema-agent/core
Version:
Stateless, task-oriented AI agent core
23 lines (22 loc) • 1.09 kB
JavaScript
export function isolationScopeOf(holder) {
return holder.isolationScope || holder.principal || undefined;
}
export const ANONYMOUS_SCOPE = "default";
export function scopeKeyOf(holder) {
return isolationScopeOf(holder) ?? ANONYMOUS_SCOPE;
}
export function identityMembersOf(holder) {
const { principal, isolationScope } = holder;
return { ...(principal !== undefined ? { principal } : {}), ...(isolationScope !== undefined ? { isolationScope } : {}) };
}
export function legIdentityOf(holder) {
const isolationScope = isolationScopeOf(holder);
return { ...(holder.principal ? { principal: holder.principal } : {}), ...(isolationScope !== undefined ? { isolationScope } : {}) };
}
export function isolationScopeRecordOf(holder) {
const own = holder.isolationScope || undefined;
return own !== undefined && own !== (holder.principal || undefined) ? { isolationScope: own } : {};
}
export function callScopeOf(ctx, mounted, seat) {
return ctx?.isolationScope || (seat !== undefined ? isolationScopeOf(seat) : undefined) || mounted.scope || undefined;
}