"use strict";
/**
 * CapabilityPackSchema — TypeScript types for OpenLife Capability Packs.
 *
 * A Capability Pack is a bundle that ships together: one or more
 * workflows, the squads/agents/skills they depend on, plus checklists,
 * templates, and policies. Packs live under `.catalog/capabilities/<id>/`
 * and follow the established `.catalog/`-as-runtime-SoT contract.
 *
 * Story 1.1 — OpenLife v1.3 Agent OS Integration.
 *
 * Why packs instead of just composing the existing registries on the fly?
 *  - Authoring: CapabilityGenesisEngine produces a coherent draft bundle
 *    from a brief; callers want a single id to canonize, version, and
 *    promote — not 4 separate ids to keep in sync.
 *  - Sharing: a pack is the unit of import/export between projects.
 *  - Lifecycle: draft → tested → active → deprecated is a pack-level
 *    state machine (Story 1.4).
 *
 * The pack manifest is `capability.yaml`. References inside it
 * (agents[], skills[], squads[], workflows[]) point at ids resolved by
 * the existing Agent/Skill/Squad/Workflow registries. References are
 * validated by CapabilityPackParser (Story 1.1 below) — broken refs
 * surface as stable error codes.
 *
 * NEW IDs are tolerated when the pack is in status `draft` (the genesis
 * engine creates skills/squads in the same pass that writes the pack
 * manifest, so a forward-reference is OK). For `active` packs, every
 * reference MUST resolve.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.CAPABILITY_ERRORS = void 0;
exports.isCapabilityStatus = isCapabilityStatus;
exports.isCapabilityAssetRef = isCapabilityAssetRef;
// ─────────────────────────────────────────────────────────────
// Stable error codes — exported so callers + tests assert on strings,
// not error messages.
// ─────────────────────────────────────────────────────────────
exports.CAPABILITY_ERRORS = {
    INVALID_YAML: 'capability_invalid_yaml',
    INVALID_SCHEMA: 'capability_invalid_schema',
    MISSING_ROOT: 'capability_missing_root',
    MISSING_REQUIRED_FIELD: 'capability_missing_required_field',
    INVALID_TYPE: 'capability_invalid_type',
    INVALID_STATUS: 'capability_invalid_status',
    DUPLICATE_ASSET_REF: 'capability_duplicate_asset_ref',
    UNKNOWN_ASSET_REF: 'capability_unknown_asset_ref',
    ID_DIR_MISMATCH: 'capability_id_dir_mismatch',
    EMBEDDED_REF_MISSING_FILE: 'capability_embedded_ref_missing_file',
};
// ─────────────────────────────────────────────────────────────
// Type guards
// ─────────────────────────────────────────────────────────────
function isCapabilityStatus(s) {
    return s === 'draft' || s === 'tested' || s === 'active' || s === 'deprecated';
}
function isCapabilityAssetRef(x) {
    if (x === null || typeof x !== 'object')
        return false;
    const r = x;
    return typeof r.id === 'string' && (r.source === 'embedded' || r.source === 'referenced');
}
