import { buildProbeContext } from '../probe/context.js';
import { probe as defaultProbeRegistry } from '../probe/registry.js';
export function wrapVaultWithProbes(vault, opts = {}) {
    const probes = opts.probes ?? defaultProbeRegistry;
    const runId = opts.runId;
    const vaultId = opts.vaultId ?? vault.constructor.name;
    const tenantIdHint = opts.tenantId;
    return {
        store(tenantId, connectorId, label, auth) {
            return vault.store(tenantId, connectorId, label, auth);
        },
        async retrieve(credentialId) {
            const result = await vault.retrieve(credentialId);
            probes.dispatch({
                type: 'vault_lookup',
                vaultId,
                credentialId,
                tenantId: tenantIdHint,
                found: result !== undefined,
                runId,
            }, buildProbeContext({ runId }));
            return result;
        },
        revoke(credentialId) {
            return vault.revoke(credentialId);
        },
        list(tenantId, connectorId) {
            return vault.list(tenantId, connectorId);
        },
    };
}
//# sourceMappingURL=instrumentation.js.map