EXAMPLES

    Real-world examples using the xBPP SDK.

    These examples come from the SDK repository. Each is a runnable TypeScript file you can execute with npx tsx examples/<name>/index.ts.

    Source: github.com/VanarChain/xbpp-sdk/examples

    An AI agent making purchases under different policies. Same transactions, different policy outcomes.

    index.ts
    import { evaluate, balanced, aggressive, riskAverse } from '@vanar/xbpp'
    
    const purchases = [
      { amount: 25, currency: 'USDC', recipient: 'api.openai.com' },
      { amount: 150, currency: 'USDC', recipient: 'cloud.google.com' },
      { amount: 5000, currency: 'USDC', recipient: 'aws.amazon.com' },
    ]
    
    // Under balanced policy
    purchases.forEach(p => {
      const v = evaluate(p, balanced)
      console.log(`${p.amount} → ${v.decision}`)
    })
    // $25  → ALLOW
    // $150 → ESCALATE (above askMeAbove: $100)
    // $5000 → BLOCK (exceeds maxSingle: $100)
    output
    $25 to api.openai.com → ALLOW
    $150 to cloud.google.com → ESCALATE
      reason: ABOVE_ESCALATION_THRESHOLD
    $5000 to aws.amazon.com → BLOCK
      reason: EXCEEDS_SINGLE_LIMIT