import { T as TransactionFeatures, D as Decision, A as AgentFirewallSDK } from '../client-DFxKbDns.mjs'; export { a as AgentStatus, C as ClassifyResult, E as EvaluateActionResult, F as FirewallConfig, R as ResolveResult, S as SubmitActionResult } from '../client-DFxKbDns.mjs'; import 'starknet'; /** * ObelyZK Agent Middleware * * Wraps agent tool execution with automatic ZKML classification. * Designed for use with the Claude Agent SDK or any tool-calling agent framework. * * @example * ```typescript * import { createPolicyEnforcer } from '@obelyzk/sdk/firewall'; * * const enforcer = createPolicyEnforcer({ * proverUrl: 'http://localhost:8080', * agentId: 'my-agent-001', * }); * * // Check before executing an on-chain action * const decision = await enforcer.checkAction({ * target: '0x049d...', * value: '1000000000', * selector: '0xa9059cbb', * }); * * if (decision.allowed) { * // safe to execute * } else { * console.log(decision.reason); // "Blocked: threat_score=85000" * } * * // Get MCP server config for Claude Agent SDK * const mcpConfig = enforcer.getMcpServerConfig(); * // Pass to agent's mcpServers option * * // Get allowed tools list * const tools = enforcer.getAllowedTools(); * // Pass to agent's allowedTools option * ``` */ /** Policy enforcer configuration. */ interface PolicyEnforcerConfig { /** Prove-server base URL. */ proverUrl: string; /** Agent ID for firewall registration. */ agentId?: string; /** Starknet RPC URL (for on-chain queries). */ rpcUrl?: string; /** Firewall contract address (for on-chain queries). */ firewallContract?: string; /** Verifier contract address. */ verifierContract?: string; /** API key for prove-server. */ apiKey?: string; /** Threat score threshold for blocking (default: 70000). */ blockThreshold?: number; /** Threat score threshold for escalation (default: 40000). */ escalateThreshold?: number; /** Path to MCP server entry point (for getMcpServerConfig). */ mcpServerPath?: string; } /** Result from checking an action. */ interface ActionCheck { /** Whether the action is allowed to proceed. */ allowed: boolean; /** Classifier decision. */ decision: Decision; /** Threat score (0-100000). */ threatScore: number; /** Human-readable reason for the decision. */ reason: string; /** IO commitment from the proof (for audit trail). */ ioCommitment: string; /** Policy commitment hash. */ policyCommitment: string; /** Proving time in milliseconds. */ proveTimeMs: number; } /** * Create a policy enforcer for programmatic agent use. * * The enforcer wraps the AgentFirewallSDK and provides a simplified API * for checking actions, getting MCP server configs, and building * allowedTools lists for the Claude Agent SDK. */ declare function createPolicyEnforcer(config: PolicyEnforcerConfig): PolicyEnforcer; declare class PolicyEnforcer { private sdk; private config; private blockThreshold; private escalateThreshold; constructor(config: PolicyEnforcerConfig); /** * Check whether an action should be allowed. * Calls the ZKML classifier and returns a structured decision. */ checkAction(tx: TransactionFeatures): Promise; /** * Check if a Bash command contains an on-chain transaction pattern. * Returns the target address if found, null otherwise. */ extractTarget(command: string): string | null; /** * Build a canUseTool callback for the Claude Agent SDK. * * Returns an async function that: * - Auto-allows ObelyZK policy tools * - Auto-allows safe read-only tools (Read, Glob, Grep) * - Classifies Bash commands containing on-chain transactions * - Blocks everything else */ buildCanUseTool(): (tool: string, input: Record) => Promise<{ approved: boolean; reason?: string; }>; /** * Get the MCP server configuration for .claude/settings.json * or Claude Agent SDK's mcpServers option. */ getMcpServerConfig(): Record; /** * Get the list of allowed tools for Claude Agent SDK. * Includes safe read-only tools and all ObelyZK policy tools. */ getAllowedTools(): string[]; /** Get the underlying AgentFirewallSDK for advanced use. */ getSDK(): AgentFirewallSDK; } /** * CIRO Intelligence Client — Runtime Enrichment * * Fetches real-time address risk, transaction enrichment, and alerts * from CIRO's blockchain data lake. Used by the classifier to augment * the 48-feature input with on-chain intelligence before classification. * * @example * ```typescript * import { CiroClient } from '@obelyzk/sdk/firewall'; * * const ciro = new CiroClient({ * baseUrl: 'https://ciro.bitsage.network', * apiKey: process.env.CIRO_API_KEY!, * }); * * // Enrich a transaction before classification * const enrichment = await ciro.enrichTransaction({ * target: '0x049d...', * value: '1000000000', * selector: '0xa9059cbb', * }); * * // Check address risk * const risk = await ciro.getAddressRisk('0x049d...'); * console.log(risk.riskLevel, risk.riskScore); // "LOW", 12 * * // Get recent alerts * const alerts = await ciro.getRecentAlerts({ severity: 'CRITICAL' }); * ``` */ /** CIRO client configuration. */ interface CiroConfig { /** CIRO Intelligence API base URL. */ baseUrl: string; /** API key for authentication. */ apiKey: string; /** Organization slug (default: "obelyzk"). */ org?: string; /** Request timeout in ms (default: 10000). */ timeout?: number; } /** Address risk level. */ type RiskLevel = "clean" | "low" | "medium" | "high" | "critical" | "unknown"; /** Enrichment response from CIRO. */ interface EnrichmentResult { targetRisk: RiskLevel; targetRiskScore: number; targetVerified: boolean; targetIsProxy: boolean; targetHasSource: boolean; targetInteractionCount: number; targetUniqueCallers: number; targetFirstSeenBlocksAgo: number; isSanctioned: boolean; sanctionLists: string[]; fortaAlerts24h: number; fortaSeverityMax: string | null; senderTxFrequency: number; senderUniqueTargets24h: number; senderAvgValue24h: number; senderMaxValue24h: number; senderAgeBlocks: number; dataFreshnessS: number; enrichmentTimeMs: number; } /** Address risk assessment. */ interface AddressRisk { address: string; chain: string; riskLevel: RiskLevel; riskScore: number; isContract: boolean; isVerified: boolean; isProxy: boolean; isSanctioned: boolean; sanctionLists: string[]; fortaAlertsCount: number; knownExploitInvolvement: boolean; exploitNames: string[]; totalTxCount: number; clusterSize: number; } /** Alert from CIRO's detection pipeline. */ interface CiroAlert { alertId: string; source: string; severity: string; chain: string; timestamp: string; addresses: string[]; txHash: string | null; name: string; description: string; } /** Data lake statistics. */ interface DataLakeStats { totalTransactions: number; labeledTransactions: number; labelDistribution: Record; lastUpdated: string; fortaBotsActive: number; addressesIndexed: number; sanctionedAddresses: number; } declare class CiroClient { private baseUrl; private apiKey; private org; private timeout; constructor(config: CiroConfig); private get apiBase(); private request; /** * Enrich a transaction with CIRO intelligence. * Returns target risk, sanctions status, Forta alerts, and behavioral context. */ enrichTransaction(params: { target: string; sender?: string; value?: string; selector?: string; }): Promise; /** * Get risk assessment for a specific address. */ getAddressRisk(address: string): Promise; /** * Get recent alerts from CIRO's detection pipeline. */ getRecentAlerts(params?: { severity?: string; limit?: number; }): Promise; /** * Get data lake statistics. */ getStats(): Promise; } export { type ActionCheck, type AddressRisk, AgentFirewallSDK, type CiroAlert, CiroClient, type CiroConfig, type DataLakeStats, Decision, type EnrichmentResult, PolicyEnforcer, type PolicyEnforcerConfig, type RiskLevel, TransactionFeatures, createPolicyEnforcer };