/**
 * PeerIdentity — canonical type for CANT agent persona records.
 *
 * Introduced by T1210 (v2026.4.110 Wave 0.2) as the SDK-first contract
 * for agent identity. `packages/cant/src/native-loader.ts` produces
 * `PeerIdentity[]` from the canonical seed-agents path; dispatch and
 * CLI layers consume it to drive `cleo agents list` and spawn routing.
 *
 * Design constraints (ADR-055 / D028 boundary rules):
 *  - Lives in `packages/contracts/` — ZERO runtime dependencies.
 *  - Consumed by `packages/cant/` (loader) and `packages/cleo/` (CLI).
 *  - No cross-package relative imports.
 *
 * @module peer
 * @task T1210
 * @epic T1144
 */
// ============================================================================
// Runtime validation
// ============================================================================
/**
 * Validate that an unknown value conforms to the {@link PeerIdentity} shape.
 *
 * Performs a lightweight structural check without Zod to keep `packages/contracts`
 * dependency-free at runtime. Callers that need schema-level validation
 * (e.g., test fixtures) can use {@link assertPeerIdentity}.
 *
 * @param value - Value to test.
 * @returns `true` when `value` is a valid {@link PeerIdentity}.
 *
 * @example
 * ```ts
 * if (isPeerIdentity(raw)) {
 *   console.log(raw.peerId);
 * }
 * ```
 */
export function isPeerIdentity(value) {
    if (typeof value !== 'object' || value === null)
        return false;
    const v = value;
    return (typeof v['peerId'] === 'string' &&
        v['peerId'].length > 0 &&
        typeof v['peerKind'] === 'string' &&
        ['orchestrator', 'lead', 'worker', 'subagent'].includes(v['peerKind']) &&
        typeof v['cantFile'] === 'string' &&
        v['cantFile'].length > 0 &&
        typeof v['displayName'] === 'string' &&
        typeof v['description'] === 'string');
}
/**
 * Assert that a value is a valid {@link PeerIdentity}, throwing a descriptive
 * error when the shape does not conform.
 *
 * @param value - Value to assert.
 * @throws {TypeError} When the value does not satisfy {@link isPeerIdentity}.
 *
 * @example
 * ```ts
 * assertPeerIdentity(raw); // throws if invalid
 * console.log(raw.peerId); // safe
 * ```
 */
export function assertPeerIdentity(value) {
    if (!isPeerIdentity(value)) {
        throw new TypeError(`Expected PeerIdentity { peerId, peerKind, cantFile, displayName, description } — got: ${JSON.stringify(value)}`);
    }
}
/**
 * Validate and filter an array of unknown values to {@link PeerIdentity}[].
 *
 * Invalid entries are silently dropped. This is the safe variant for loading
 * from untrusted sources (e.g., the result of parsing a directory of `.cant`
 * files whose format may vary).
 *
 * @param values - Array of unknown values.
 * @returns Array containing only values that pass {@link isPeerIdentity}.
 */
export function filterPeerIdentities(values) {
    return values.filter(isPeerIdentity);
}
//# sourceMappingURL=peer.js.map