/**
 * Tool registry contract — shared types used by AgentLoop and SdkAgentLoop.
 *
 * This is the single source of truth for the tool surface. Concrete
 * registries (in-memory, CC-traced, remote-proxy) all implement
 * `ToolRegistry` defined here.
 */
/**
 * Weighted aggregate risk score in [0, 1].
 *
 * Default weights bias toward reversibility + blast radius per EU AI Act
 * Art. 14 oversight requirements. Callers may override individual weights;
 * unspecified dimensions inherit the defaults.
 *
 * Note: `confidence` contributes as `(1 - v.confidence)` so that uncertain
 * classifications raise, not lower, the aggregate risk.
 */
export function riskScore(v, weights) {
    const w = {
        reversibility: 0.3,
        blastRadius: 0.25,
        dataSensitivity: 0.2,
        externalSideEffect: 0.2,
        confidence: 0.05,
        ...weights,
    };
    return (v.reversibility * w.reversibility +
        v.blastRadius * w.blastRadius +
        v.dataSensitivity * w.dataSensitivity +
        v.externalSideEffect * w.externalSideEffect +
        (1 - v.confidence) * w.confidence // low confidence = higher risk
    );
}
/**
 * Bridge for the legacy `dangerous: boolean` flag.
 *
 * `dangerous: true`  → high-risk vector (reversibility 0.9, blast 0.7, …).
 * `dangerous: false` → low-risk vector (read-like defaults).
 * `dangerous: undefined` → same as false.
 *
 * Preserved for backward compatibility; prefer explicit `RiskVector` on new tools.
 */
export function dangerousToRiskVector(dangerous) {
    return dangerous
        ? {
            reversibility: 0.9,
            blastRadius: 0.7,
            dataSensitivity: 0.5,
            externalSideEffect: 0.5,
            confidence: 0.5,
        }
        : {
            reversibility: 0.1,
            blastRadius: 0.1,
            dataSensitivity: 0.1,
            externalSideEffect: 0.1,
            confidence: 0.95,
        };
}
// ─── Tool name validation ──────────────────────────────────────────────────
const TOOL_NAME_REGEX = /^[a-z][a-z0-9_]{0,62}$/;
export function isValidToolName(name) {
    return TOOL_NAME_REGEX.test(name);
}
//# sourceMappingURL=types.js.map