"use strict";
/**
 * CompositeWorkflowProvider — primary/fallback composite for workflows.
 *
 * Story 1.3 — OpenLife v1.3 Agent OS Integration.
 *
 * Aligns the workflow provider stack with the established Composite{X}
 * pattern (Agent, Skill, Squad, Capability). Pure refactor: existing
 * FileWorkflowProvider already searches two roots internally, so the
 * composite layer is for *external* sources like cloud catalogs in v1.4.
 *
 * For v1.3 we just wrap the existing FileWorkflowProvider so callers can
 * upgrade to the composite shape without changing the loader.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompositeWorkflowProvider = void 0;
exports.defaultWorkflowProvider = defaultWorkflowProvider;
const FileWorkflowProvider_1 = require("./FileWorkflowProvider");
class CompositeWorkflowProvider {
    primary;
    fallback;
    constructor(primary, fallback) {
        this.primary = primary;
        this.fallback = fallback;
    }
    list() {
        const data = this.primary.list();
        if (data.length)
            return data;
        return this.fallback ? this.fallback.list() : [];
    }
    load(id) {
        const primaryHit = this.primary.load(id);
        if (primaryHit)
            return primaryHit;
        return this.fallback ? this.fallback.load(id) : null;
    }
}
exports.CompositeWorkflowProvider = CompositeWorkflowProvider;
/**
 * Factory: the default v1.3 composite — FileWorkflowProvider only.
 * v1.4 will add a CloudWorkflowProvider as fallback.
 */
function defaultWorkflowProvider() {
    return new CompositeWorkflowProvider(new FileWorkflowProvider_1.FileWorkflowProvider());
}
