// ══════════════════════════════════════════════════════════════════
// Gateway Wiring Layer — Connects remaining modules to enforcement
// ══════════════════════════════════════════════════════════════════
// Thin adapter + re-export layer. The gateway imports this single
// module to access hooks from 13 previously disconnected modules.
// Each hook translates gateway context into module-specific calls.
// ══════════════════════════════════════════════════════════════════
import { commercePreflight } from './commerce.js';
export function checkCommerceConstraint(passport, delegation, tool, spend) {
    if (!spend || !delegation.scope?.some(s => s.startsWith('commerce'))) {
        return { passed: true };
    }
    const result = commercePreflight({
        signedPassport: passport,
        delegation: delegation,
        merchantName: tool,
        estimatedTotal: { amount: spend.amount, currency: spend.currency },
    });
    if (!result.permitted) {
        return {
            passed: false,
            reason: `Commerce preflight failed: ${result.checks.filter((c) => !c.passed).map((c) => c.detail).join('; ')}`,
            failure: {
                facet: 'spend', status: 'fail', code: 'COMMERCE_PREFLIGHT_FAILED',
                limit: delegation.spendLimit, actual: spend.amount,
                severity: 'hard', retryable: false,
                message: `Commerce preflight: ${result.checks.filter((c) => !c.passed).map((c) => c.check).join(', ')}`,
            },
        };
    }
    return { passed: true };
}
// ── Charter: institutional rule hydration ──
import { verifyCharter } from './charter.js';
export function extractCharterPolicy(charter) {
    try {
        const verification = verifyCharter(charter);
        return {
            charterId: charter.charterId,
            valid: verification.valid,
            scopeRestrictions: charter.offices?.flatMap((o) => o.scopeRestrictions ?? []),
            requireWitness: charter.offices?.some((o) => o.requiresWitness),
        };
    }
    catch {
        return { charterId: charter.charterId, valid: false };
    }
}
// ── Re-exports: Precedent ──
export { createPrecedentLibrary, checkAlignment, addToLibrary, markAsNormative, analyzeDrift } from './precedent.js';
// ── Re-exports: Routing ──
export { capabilityMatches, capabilityCoverage, checkDelegationScope } from './routing.js';
// ── Re-exports: EU AI Act ──
// generateComplianceReport moved to @aeoess/gateway. See MIGRATION.md.
// ── Re-exports: Federation ──
export { importReceipt, verifyReceiptEnvelope, vouchReputation, verifyVouchedReputation, applyReputationDowngrade } from './federation.js';
// ── Re-exports: Coordination ──
export { createTaskBrief, assignTask, acceptTask, submitEvidence, reviewEvidence, submitDeliverable, completeTask, } from './coordination.js';
// ── Re-exports: Oracle/Witness ──
export { createWitnessPool, createAttestation, verifyWitnessAttestation, addAttestation, evaluateWitnessConsensus, computeDiversityScore, } from './oracle-witness.js';
// ── Re-exports: Reserve ──
export { createReserveAttestation, verifyReserveAttestation, meetsAssuranceRequirement } from './reserve.js';
// ── Re-exports: Agent Context ──
// AgentContext and createAgentContext moved to @aeoess/gateway. See MIGRATION.md.
// ── Re-exports: Governance Consumer ──
export { checkHTMLGovernance, checkHeaderGovernance, governanceLoop360 } from './governance-consumer.js';
// ── Re-exports: Encrypted Messaging ──
export { generateEncryptionKeypair, deriveEncryptionKeypair, createKeyAnnouncement, verifyKeyAnnouncement, encryptPayload, decryptPayload, createEncryptedAgoraMessage, decryptAgoraMessage, verifyOuterSignature, } from './encrypted-messaging.js';
// ── Re-exports: Messaging Audit ──
export { createMessageAuditLog, createAuditRecord, verifyAuditRecord, appendToAuditLog, queryBySender, queryCrossChainMessages, } from './messaging-audit.js';
//# sourceMappingURL=gateway-wiring.js.map