/**
 * SquadCreator — authoring system for squads under `.catalog/squads/`.
 *
 * Story 5.1 — OpenLife v1.2 Royal Stack.
 *
 * Replaces the old `aiobuilder create-squad` stub (which wrote a 16-line
 * markdown file with hardcoded frontmatter) with a real authoring
 * pipeline that renders `dist-templates/squad-template/` into a
 * structured squad directory including agents, tasks, and a checklist.
 *
 * v1.2 implements 4 of the 8 methods promised by the SQUAD.md spec:
 *   - create   — full template rendering + directory layout
 *   - validate — frontmatter + components reference check
 *   - list     — delegate to SquadRegistry composite read
 *   - analyze  — surface coverage gaps (missing tasks/orphan agents)
 *
 * 4 are placeholders for v1.3 (Capability Genesis Engine):
 *   - design   — LLM-driven proposal from a brief (needs Brain wiring)
 *   - migrate  — schema migration between versions
 *   - extend   — append components to an existing squad
 *   - publish  — promote draft→active, sync to remote registry
 */
import { TemplateVars } from './util/TemplateRenderer';
export interface SquadMigrationResult {
    ok: boolean;
    squadId: string;
    fromVersion?: string;
    toVersion?: string;
    filesChanged?: string[];
    error?: string;
    detail?: string;
}
export type SquadExtensionComponent = {
    kind: 'agent';
    spec: SquadAgentSpec;
} | {
    kind: 'task';
    spec: SquadTaskSpec;
} | {
    kind: 'checklist';
    spec: SquadChecklistSpec;
} | {
    kind: 'workflow';
    id: string;
    content: string;
};
export interface SquadExtensionResult {
    ok: boolean;
    squadId: string;
    kind?: string;
    filesAdded?: string[];
    error?: string;
    detail?: string;
}
export interface SquadPublishResult {
    ok: boolean;
    squadId: string;
    sha256?: string;
    ledgerEntry?: string;
    status?: string;
    error?: string;
    detail?: string;
    /** Story 14.1 (v1.5) — populated only when `publishWithRemote(...)` is used. */
    remote?: import('./RemotePublisher').RemotePublishResult;
}
export interface SquadAgentSpec {
    id: string;
    name: string;
    role: string;
    /** Optional persona body — if omitted, agent-template.md is rendered with defaults. */
    vars?: Partial<TemplateVars>;
}
export interface SquadTaskSpec {
    id: string;
    ownerAgentId: string;
    purpose: string;
    vars?: Partial<TemplateVars>;
}
export interface SquadChecklistSpec {
    id: string;
    purpose: string;
    items: string[];
}
export interface SquadProposal {
    id: string;
    name: string;
    description: string;
    shortTitle?: string;
    version?: string;
    slashPrefix?: string;
    tags?: string[];
    author?: string;
    license?: string;
    agents: SquadAgentSpec[];
    tasks?: SquadTaskSpec[];
    workflows?: string[];
    checklists?: SquadChecklistSpec[];
    status?: 'active' | 'draft';
    source?: string;
}
export interface SquadCreateResult {
    ok: true;
    squadId: string;
    squadDir: string;
    filesCreated: string[];
}
export interface SquadCreateError {
    ok: false;
    error: string;
    detail?: string;
}
export interface SquadValidationResult {
    ok: boolean;
    squadId: string;
    errors: string[];
    warnings: string[];
}
export interface SquadAnalysisResult {
    squadId: string;
    agentCount: number;
    taskCount: number;
    workflowCount: number;
    checklistCount: number;
    orphanAgents: string[];
    unreferencedTasks: string[];
    suggestions: string[];
}
export interface SquadCreatorOptions {
    /** Override .catalog/squads/ root. */
    catalogRoot?: string;
    /** Override dist-templates/squad-template/ root. */
    templateRoot?: string;
}
export declare class SquadCreator {
    private readonly catalogRoot;
    private readonly templateRoot;
    constructor(opts?: SquadCreatorOptions);
    create(proposal: SquadProposal): SquadCreateResult | SquadCreateError;
    validate(squadId: string): SquadValidationResult;
    list(filter?: {
        status?: 'active' | 'draft' | 'archived';
    }): Array<{
        id: string;
        name: string;
        status: string;
    }>;
    analyze(squadId: string): SquadAnalysisResult | null;
    /**
     * Propose a SquadProposal from a free-text brief.
     *
     * Story 3.1 — OpenLife v1.3.
     *
     * Heuristic mode: produces a minimum-viable squad that the caller can
     * pass directly to create(). No API call — works offline, no keys
     * needed. Returns the proposal; caller decides whether to call create()
     * with it or refine first. The heuristic picks 3 default agents
     * (lead, executor, reviewer) and one task; for richer drafts, the
     * CapabilityGenesisEngine wires this together with deep-research-style
     * patterns.
     *
     * Brain-mode (live LLM proposal) lands in v1.4; the signature stays
     * stable so callers don't change.
     */
    design(brief: string, opts?: {
        mode?: 'quick' | 'professional' | 'elite';
        id?: string;
    }): {
        ok: true;
        proposal: SquadProposal;
    } | {
        ok: false;
        error: string;
    };
    /**
     * Story 8.1 — LLM-driven design.
     *
     * If `brain.isAnyProviderAvailable()` returns true, asks the Brain for a
     * structured JSON proposal and parses it. On any parse / API failure,
     * falls back to the heuristic `design()` so the call is never lossy.
     *
     * Signature is additive: existing callers continue using sync `design()`.
     * No env flag — the presence of an API key IS the opt-in (locked decision
     * 2 of the v1.4 plan).
     */
    designWithBrain(brain: {
        isAnyProviderAvailable(): boolean;
        think(systemPrompt: string, userMessage: string): Promise<string>;
    }, brief: string, opts?: {
        mode?: 'quick' | 'professional' | 'elite';
        id?: string;
    }): Promise<{
        ok: true;
        proposal: SquadProposal;
        source: 'brain' | 'heuristic';
    } | {
        ok: false;
        error: string;
    }>;
    migrate(squadId: string, fromVersion: string, toVersion: string): SquadMigrationResult;
    private findSquadVersion;
    private rewriteSquadVersion;
    extend(squadId: string, component: SquadExtensionComponent): SquadExtensionResult;
    publish(squadId: string): SquadPublishResult;
    /**
     * Story 14.1 (v1.5) — Publish + push to a remote registry.
     *
     * Composes the existing local-ledger publish with RemotePublisher.
     * The local seal lands first (so callers still have a sealed asset
     * if the remote push fails). The returned envelope carries both
     * results: `ok` reflects the LOCAL publish; the remote outcome lives
     * on the `remote` field so failures can be inspected without
     * losing the local seal.
     *
     * Refuses to attempt the remote push if RemotePublisher is not
     * configured — returns `remote.error='remote_publish_not_configured'`.
     */
    publishWithRemote(squadId: string): Promise<SquadPublishResult>;
    private isValidVersion;
    private rewriteFrontmatterField;
    private appendExtensionLog;
    private buildSquadVars;
    private buildAgentVars;
    private buildTaskVars;
    private parseFrontmatter;
    private parseComponentRefs;
    private isValidId;
}
/**
 * Story 8.1 helper — extract the first JSON object from raw model output.
 * Tolerates markdown fences (```json ... ```) and surrounding prose.
 * Returns the parsed object or null. Never throws.
 */
export declare function extractFirstJson(raw: string): unknown;
