npm package: @slabond/sdk
Description: Official TypeScript SDK for the Slabond Platform
Author: Slabond Inc.
Latest version: 0.1.7

# @slabond/sdk

TypeScript SDK for the Slabond Protocol — bonded, TEE-verified API execution for AI agents.

## Installation

```bash
npm install @slabond/sdk
```

## Quick Start

```typescript
import { Slabond, JobStatus } from '@slabond/sdk'

const slabond = new Slabond({
  baseUrl: 'http://localhost:4000', // For local development; omit for production
  apiKey: process.env.SLABOND_API_KEY,
})

async function main() {
  // Create a bonded SLA execution
  const job = await slabond.createSLA({
    slaId: '0xabc123',
    requester: 'agent-001',
    amount: '250000 USDC',
    targetUrl: 'https://api.circle.com/v1/transfers/mint',
  })

  console.log(`Job ${job.id} created — status: ${job.status}`)

  // Wait for TEE verification and on-chain settlement
  const settled = await slabond.waitForSettlement(job.id)

  if (settled.status === JobStatus.COMPLETED) {
    console.log(`Verified with proof: ${settled.proof}`)
  }
}

main()
```

## AI Agent Integration

Use Slabond as a tool in any agent framework to guarantee verifiable execution:

```typescript
import { Slabond } from '@slabond/sdk'
import { tool } from '@langchain/core/tools'

const slabond = new Slabond({ apiKey: process.env.SLABOND_API_KEY })

const bondedTransfer = tool(
  async ({ recipient, amount }) => {
    const job = await slabond.createSLA({
      slaId: `0x${Date.now().toString(16)}`,
      requester: 'ai-agent',
      amount: `${amount} USDC`,
      targetUrl: `https://api.circle.com/v1/transfers`,
    })

    const result = await slabond.waitForSettlement(job.id)
    return `Transfer ${result.status}. Proof: ${result.proof}`
  },
  {
    name: 'bonded_transfer',
    description: 'Execute a bonded, TEE-verified USDC transfer',
  }
)
```

## API Reference

### `new Slabond(config?)`

| Param | Type | Default | Description |
|-------|------|---------|-------------|
| `config.baseUrl` | `string` | `https://api.slabond.xyz` | Watcher API URL |
| `config.apiKey` | `string` | — | API key for authenticated endpoints |

### `createSLA(params): Promise<SLAJob>`

Submit a new bonded execution request.

| Param | Type | Description |
|-------|------|-------------|
| `params.slaId` | `string` | Unique intent/SLA hash |
| `params.requester` | `string` | Requester identifier |
| `params.amount` | `string` | Bond amount (e.g. `"250000 USDC"`) |
| `params.targetUrl` | `string` | Remote API endpoint to execute |

### `getSLA(id): Promise<SLAJob>`

Fetch a single job by ID.

### `listSLAs(): Promise<SLAJob[]>`

Fetch all jobs, ordered by most recent.

### `waitForSettlement(id, options?): Promise<SLAJob>`

Poll until the job reaches a terminal status (`COMPLETED`, `SETTLED`, or `FAILED`).

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `timeout` | `number` | `120000` | Max wait time in ms |
| `pollInterval` | `number` | `3000` | Polling interval in ms |

Throws `Error("Settlement timeout")` if the timeout is exceeded.

### `getStats(): Promise<WatcherStats>`

Fetch aggregate job statistics from the watcher.

### `ping(): Promise<boolean>`

Health check — returns `true` if the watcher is reachable.

## Types

```typescript
enum JobStatus {
  PENDING = 'PENDING',
  PROCESSING = 'PROCESSING',
  COMPLETED = 'COMPLETED',
  FAILED = 'FAILED',
  SETTLED = 'SETTLED',
}

interface SLAJob {
  id: string
  slaId: string
  requester: string
  amount: string
  targetUrl: string
  status: JobStatus
  proof?: string
  result?: string
  logs: string[]
  createdAt: string
  updatedAt: string
}

interface WatcherStats {
  totalJobs: number
  byStatus: Record<string, number>
  totalVolume: string
  avgSettlementMs: number
  successRate: number
}
```

## Documentation

Full docs at [docs.slabond.xyz](https://docs.slabond.xyz)

## License

MIT