// Copyright (c) 2026 Hellmai Ltd
// SPDX-License-Identifier: AGPL-3.0-only
/** Default ADR-014 axes for a wu:delegate launch receipt. */
export const DEFAULT_DELEGATION_LIFECYCLE_ROLE = 'implementer';
export const DEFAULT_DELEGATION_SPECIALTY_PROFILE = 'general';
export const DEFAULT_DELEGATION_RESPONSIBILITY_KIND = 'implement';
/**
 * Map of human-friendly agent aliases to their canonical role descriptors.
 *
 * Sourced from ADR-014 §3 alias table. Pack-owned vocabulary — additive
 * extensions land here, not in the kernel schema.
 */
const ALIAS_ROLE_MAP = {
    'general-purpose': { lifecycle_role: 'implementer', specialty_profile: 'general' },
    'lumenflow-pm': { lifecycle_role: 'orchestrator', specialty_profile: 'delivery' },
    'test-engineer': { lifecycle_role: 'implementer', specialty_profile: 'test' },
    'code-reviewer': { lifecycle_role: 'reviewer', specialty_profile: 'general' },
    'bug-triage': { lifecycle_role: 'reviewer', specialty_profile: 'triage' },
    'lumenflow-enforcer': { lifecycle_role: 'finisher', specialty_profile: 'compliance' },
    'lumenflow-doc-sync': { lifecycle_role: 'reviewer', specialty_profile: 'docs' },
};
function resolveRoleDescriptor(agentAlias, capabilities) {
    const match = agentAlias ? ALIAS_ROLE_MAP[agentAlias] : undefined;
    const lifecycle_role = match?.lifecycle_role ?? DEFAULT_DELEGATION_LIFECYCLE_ROLE;
    const specialty_profile = match?.specialty_profile ?? DEFAULT_DELEGATION_SPECIALTY_PROFILE;
    const descriptor = {
        lifecycle_role,
        specialty_profile,
        capabilities,
    };
    if (agentAlias) {
        descriptor.role_alias = agentAlias;
    }
    return descriptor;
}
function resolveOwnershipScope(input) {
    const scope = {
        responsibility_kinds: [DEFAULT_DELEGATION_RESPONSIBILITY_KIND],
    };
    if (input.initiativeId) {
        scope.initiative_id = input.initiativeId;
    }
    if (input.targetWuId) {
        scope.wu_ids = [input.targetWuId];
    }
    if (input.lane) {
        scope.lane = input.lane;
    }
    return scope;
}
/**
 * Builds the default v2 DelegationRoleContract for a wu:delegate launch
 * receipt. The `requested_role` and `actual_role` start identical — session
 * lifecycle (WU-2754) will overwrite `actual_role` when the live worker
 * reports a mismatch.
 */
export function resolveDefaultRoleContract(input) {
    const capabilities = input.capabilities ?? [];
    const requested_role = resolveRoleDescriptor(input.agentAlias, capabilities);
    const actual_role = resolveRoleDescriptor(input.agentAlias, capabilities);
    const ownership_scope = resolveOwnershipScope(input);
    return {
        requested_role,
        actual_role,
        capabilities,
        ownership_scope,
    };
}
//# sourceMappingURL=delegation-role-resolver.js.map