@beeperbot/sdk 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,177 +1,316 @@
1
- # @beeperbot/sdk
1
+ # @beeper/sdk
2
2
 
3
- TypeScript SDK for [beep.works](https://beep.works) — the attention tokenization platform on Farcaster.
3
+ TypeScript SDK for [beep.works](https://beep.works) — the attention layer on Base.
4
4
 
5
- Send beeps (paid DMs) programmatically. Look up users, check prices, create payment intents, and run bulk campaigns.
5
+ Send paid messages (beeps) to Farcaster users. Look up users, check prices, run targeted campaigns.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install @beeperbot/sdk
10
+ npm install @beeper/sdk
11
11
  ```
12
12
 
13
- ## Quick Start
13
+ ## Quick Start — AI Agent
14
+
15
+ The `AgentClient` is the simplest way to integrate beeps into your AI agent or bot.
14
16
 
15
17
  ```typescript
16
- import { AgentClient } from '@beeperbot/sdk';
18
+ import { AgentClient } from '@beeper/sdk';
17
19
 
18
- const client = new AgentClient({
19
- apiKey: 'bpk_live_...',
20
- environment: 'production',
20
+ const agent = new AgentClient({
21
+ apiKey: process.env.BEEPER_API_KEY!, // bpk_live_...
21
22
  });
22
23
 
23
24
  // Look up a user
24
- const user = await client.lookup('dwr');
25
- console.log(user); // { username, fid, attentionPriceUsd, ... }
26
-
27
- // Check attention price
28
- const price = await client.getPrice('dwr');
29
- console.log(price); // { priceUsd: "0.50", priceUsdc: "500000" }
30
-
31
- // Create a payment intent (single user)
32
- const intent = await client.createIntent({
33
- to: 'dwr',
34
- amountUsd: 1.0,
35
- message: 'Hey, check this out!',
25
+ const user = await agent.lookup('dwr.eth');
26
+ console.log(`@${user.username} min beep price: $${user.attentionPriceUsd}`);
27
+
28
+ // Create a payment intent
29
+ const intent = await agent.createIntent({
30
+ to: 'dwr.eth',
31
+ amount: '$5',
32
+ message: 'Love your work on Farcaster!',
36
33
  });
37
- console.log(intent); // { intentId, recipient, amount, instruction, ... }
34
+ console.log(intent.instruction);
35
+ // → "Send 5.50 USDC to 0x1a2b... on Base ($5.00 to @dwr + $0.50 platform fee)"
38
36
  ```
39
37
 
40
- ## Agent Client API
38
+ ## API Reference — AgentClient
39
+
40
+ ### `new AgentClient(config)`
41
+
42
+ | Option | Type | Default | Description |
43
+ |--------|------|---------|-------------|
44
+ | `apiKey` | `string` | *required* | API key (`bpk_live_...` or `bpk_test_...`) |
45
+ | `environment` | `'production' \| 'staging'` | `'production'` | API environment |
46
+ | `baseUrl` | `string` | auto | Custom API base URL |
47
+ | `timeoutMs` | `number` | `30000` | Request timeout |
48
+ | `debug` | `boolean` | `false` | Enable debug logging |
41
49
 
42
- The `AgentClient` is designed for AI agents and simple integrations.
50
+ ---
43
51
 
44
- ### `lookup(query)`
45
- Search for a user by username, FID, or wallet address.
52
+ ### `agent.lookup(identifier)`
53
+
54
+ Look up a user by username, FID, or wallet address.
46
55
 
47
56
  ```typescript
48
- const user = await client.lookup('dwr');
49
- const user = await client.lookup('3'); // by FID
50
- const user = await client.lookup('0x1234...'); // by wallet
57
+ const user = await agent.lookup('dwr.eth'); // by username
58
+ const user = await agent.lookup(3); // by FID
59
+ const user = await agent.lookup('0x1a2b...'); // by wallet
51
60
  ```
52
61
 
53
- ### `getPrice(username)`
62
+ **Returns:** `User`
63
+
64
+ | Field | Type | Description |
65
+ |-------|------|-------------|
66
+ | `id` | `string` | Internal user ID |
67
+ | `fid` | `number?` | Farcaster ID |
68
+ | `username` | `string` | Username |
69
+ | `displayName` | `string?` | Display name |
70
+ | `pfpUrl` | `string?` | Profile picture URL |
71
+ | `platform` | `string` | Platform (farcaster, twitter) |
72
+ | `walletAddress` | `string?` | Verified wallet address |
73
+ | `attentionPriceUsd` | `string` | Minimum beep price in USD |
74
+ | `followerCount` | `number?` | Follower count |
75
+
76
+ ---
77
+
78
+ ### `agent.getPrice(identifier)`
79
+
54
80
  Get the attention price for a user.
55
81
 
56
82
  ```typescript
57
- const price = await client.getPrice('dwr');
58
- // { userId, username, priceUsd, priceUsdc }
83
+ const price = await agent.getPrice('dwr.eth');
84
+ console.log(`$${price.priceUsd} USD`);
59
85
  ```
60
86
 
61
- ### `createIntent(input)`
62
- Create a single payment intent.
87
+ ---
88
+
89
+ ### `agent.createIntent(input)`
90
+
91
+ Create a payment intent. Returns instructions for the user to execute the payment.
63
92
 
64
93
  ```typescript
65
- const intent = await client.createIntent({
66
- to: 'dwr', // username or FID
67
- amountUsd: 1.0, // amount in USD
68
- message: 'Hello!', // optional message
69
- chainId: 8453, // Base (default)
94
+ const intent = await agent.createIntent({
95
+ to: 'dwr.eth', // recipient
96
+ amount: '$5', // amount in USD
97
+ message: 'Hello!', // required message
98
+ chainId: 8453, // Base (default)
70
99
  });
71
100
  ```
72
101
 
73
- ### `estimate(input)`
74
- Estimate campaign costs before committing.
102
+ **Returns:** `PaymentIntent` with `intentId`, `recipient`, `amount`, `instruction`, fee breakdown, etc.
103
+
104
+ > **Note:** A 10% platform fee is added on top. `$5` beep → user pays `$5.50` USDC total.
105
+
106
+ ---
107
+
108
+ ### `agent.estimate(input)`
109
+
110
+ Estimate how many recipients you can reach within a budget.
75
111
 
76
112
  ```typescript
77
- const estimate = await client.estimate({
78
- filter: { minFollowers: 1000, platform: 'farcaster' },
79
- budgetUsd: 100,
80
- message: 'Check out our launch!',
113
+ const estimate = await agent.estimate({
114
+ filters: {
115
+ platform: 'farcaster',
116
+ neynarScoreMin: 0.5,
117
+ minFollowers: 1000,
118
+ countries: ['US'],
119
+ },
120
+ budget: '$100',
81
121
  });
82
- // { estimatedRecipients, estimatedCostUsd, averagePriceUsd }
122
+
123
+ console.log(`Can reach ${estimate.recipientCount} people`);
124
+ console.log(`Total cost: $${estimate.totalCostUsd}`);
125
+ console.log(`Budget sufficient: ${estimate.budgetSufficient}`);
83
126
  ```
84
127
 
85
- ### `preview(input)`
86
- Preview who would receive a campaign.
128
+ ---
129
+
130
+ ### `agent.preview(input)`
131
+
132
+ Preview sample users matching your filters.
87
133
 
88
134
  ```typescript
89
- const preview = await client.preview({
90
- filter: { minFollowers: 1000 },
91
- limit: 20,
135
+ const preview = await agent.preview({
136
+ filters: { neynarScoreMin: 0.7, hasBaseWallet: true },
137
+ limit: 5,
92
138
  });
93
- // { users: [...], totalMatched }
139
+
140
+ preview.users.forEach(u => {
141
+ console.log(`@${u.username} — $${u.priceUsd} — ${u.followerCount} followers`);
142
+ });
143
+ console.log(`Total matching: ${preview.totalCount}`);
94
144
  ```
95
145
 
96
- ### `createBulkIntent(input)`
97
- Create a bulk campaign targeting multiple users.
146
+ ---
147
+
148
+ ### `agent.createBulkIntent(input)`
149
+
150
+ Create payment intents for multiple recipients matching filters.
98
151
 
99
152
  ```typescript
100
- const bulk = await client.createBulkIntent({
101
- filter: { platform: 'farcaster', minFollowers: 500 },
102
- budgetUsd: 50,
103
- message: 'GM from our SDK!',
153
+ const bulk = await agent.createBulkIntent({
154
+ filters: { signalTokens: ['0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed'] },
155
+ budget: '$50',
156
+ message: 'GM DEGEN community! 🎩',
104
157
  });
105
- // { intentId, recipientCount, totalAmountUsd, ... }
106
- ```
107
158
 
108
- ## Advanced: BeeperClient
159
+ console.log(bulk.summary);
160
+ // → "Send to 120 recipients for total 42.50 USDC on Base"
161
+ ```
109
162
 
110
- For the full quote-based flow (create draft → get quote → deposit → execute → receipt):
163
+ ---
111
164
 
112
- ```typescript
113
- import { BeeperClient } from '@beeperbot/sdk';
165
+ ### `agent.describeFilters()`
114
166
 
115
- const beeper = new BeeperClient({
116
- apiKey: 'bpk_live_...',
117
- });
167
+ Get structured filter documentation for LLM system prompts.
118
168
 
119
- // Full flow
120
- const draft = await beeper.createDraft({ ... });
121
- const quote = await beeper.getQuote(draft.id);
122
- const confirmed = await beeper.confirmDeposit(quote.id, { txHash: '0x...' });
123
- const result = await beeper.execute(quote.id);
124
- const receipt = await beeper.getReceipt(quote.id);
169
+ ```typescript
170
+ const schema = agent.describeFilters();
171
+ // Use in your LLM's system prompt for filter-aware conversations
125
172
  ```
126
173
 
127
- ## Filter Builder
174
+ ### `agent.getFilterDocumentation()`
128
175
 
129
- Build complex recipient filters with a fluent API:
176
+ Get markdown-formatted filter docs.
130
177
 
131
178
  ```typescript
132
- import { FilterBuilder } from '@beeperbot/sdk';
133
-
134
- const filter = FilterBuilder.and(
135
- FilterBuilder.platform('farcaster'),
136
- FilterBuilder.minFollowers(1000),
137
- FilterBuilder.neynarScoreMin(0.8),
138
- FilterBuilder.maxAttentionPrice(2.0),
139
- );
179
+ const docs = agent.getFilterDocumentation();
180
+ // Include in system prompt: `Available filters:\n${docs}`
140
181
  ```
141
182
 
142
- ## Authentication
183
+ ---
184
+
185
+ ## Filters Reference
186
+
187
+ Use filters with `estimate`, `preview`, and `createBulkIntent`.
188
+
189
+ ### Platform & Activity
190
+ | Filter | Type | Description |
191
+ |--------|------|-------------|
192
+ | `platform` | `'all' \| 'farcaster' \| 'twitter'` | Target platform |
193
+ | `activeInLastDays` | `number` | Users active within N days |
194
+
195
+ ### Reputation & Quality
196
+ | Filter | Type | Description |
197
+ |--------|------|-------------|
198
+ | `neynarScoreMin` | `number (0-1)` | Min Neynar reputation. 0.5+ = quality, 0.8+ = top tier |
199
+ | `neynarScoreMax` | `number (0-1)` | Max Neynar reputation |
200
+ | `quotientScoreMin` | `number (0-1)` | Min Quotient engagement score |
201
+ | `quotientScoreMax` | `number (0-1)` | Max Quotient score |
202
+ | `spamLabel` | `'not_spam_only' \| 'spam_only' \| 'all'` | Spam classification |
203
+ | `verifiedOnly` | `boolean` | Only wallet-verified users |
204
+
205
+ ### Social Graph
206
+ | Filter | Type | Description |
207
+ |--------|------|-------------|
208
+ | `minFollowers` | `number` | Minimum follower count |
209
+ | `maxFollowers` | `number` | Maximum follower count |
210
+
211
+ ### Token Filters
212
+ | Filter | Type | Description |
213
+ |--------|------|-------------|
214
+ | `signalTokens` | `string[]` | Token addresses users set as interests (community affinity) |
215
+ | `tokenHolders` | `Array<{tokenAddress, chainId, minBalance?}>` | Actual onchain token holders |
216
+ | `hasBaseWallet` | `boolean` | Has a Base chain wallet |
217
+ | `hasVerifiedWallet` | `boolean` | Has a verified wallet |
218
+
219
+ ### Economics
220
+ | Filter | Type | Description |
221
+ |--------|------|-------------|
222
+ | `maxAttentionPriceUsd` | `number` | Max beep price cap |
223
+ | `minBatteryPercentage` | `number (0-100)` | Min battery (engagement metric) |
224
+ | `hasRechargedInLastDays` | `number` | Checked in within N days |
225
+ | `excludePingedToday` | `boolean` | Skip users already beeped today |
226
+
227
+ ### Geography
228
+ | Filter | Type | Description |
229
+ |--------|------|-------------|
230
+ | `countries` | `string[]` | ISO 3166-1 alpha-2 codes (`['US', 'KR']`) |
231
+
232
+ ### Sorting
233
+ | Value | Description |
234
+ |-------|-------------|
235
+ | `attention_price_asc` | Cheapest first (maximize reach) |
236
+ | `attention_price_desc` | Most expensive first |
237
+ | `neynar_score_desc` | Highest reputation first |
238
+ | `followers_desc` | Most followers first |
239
+ | `recent_activity` | Most recently active |
240
+ | `battery_desc` | Highest engagement first |
241
+ | `random` | Random order |
242
+
243
+ ---
244
+
245
+ ## Advanced — BeeperClient
246
+
247
+ For the full deposit → execute → receipt flow:
248
+
249
+ ```typescript
250
+ import { BeeperClient } from '@beeper/sdk';
251
+
252
+ const client = new BeeperClient({
253
+ apiKey: process.env.BEEPER_API_KEY!,
254
+ });
255
+
256
+ // 1. Create a draft (local, no API call)
257
+ const draft = client.createDraft({
258
+ filter: { and: [
259
+ { field: 'neynarScore', op: 'gte', value: 0.5 },
260
+ { field: 'hasBaseWallet', op: 'eq', value: true },
261
+ ]},
262
+ tokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
263
+ chainId: 8453, // Base
264
+ amountPerRecipient: '1000000', // 1 USDC (6 decimals)
265
+ budgetCap: '100000000', // 100 USDC max
266
+ });
267
+
268
+ // 2. Get a quote
269
+ const quote = await client.createQuote(draft);
143
270
 
144
- API keys use the format `bpk_live_*` (production) or `bpk_test_*` (testing).
271
+ // 3. Deposit tokens to quote.depositAddress
272
+ // 4. Confirm deposit
273
+ await client.confirmDeposit(quote.id, { txHash: '0x...' });
145
274
 
146
- Get your API key from the [beep.works dashboard](https://beep.works/settings).
275
+ // 5. Execute
276
+ await client.executeSend(quote.id);
277
+
278
+ // 6. Poll for completion
279
+ const receipt = await client.pollUntilCompleteByQuoteId(quote.id);
280
+ ```
147
281
 
148
282
  ## Error Handling
149
283
 
150
284
  ```typescript
151
- import { BeeperError } from '@beeperbot/sdk';
285
+ import { BeeperError, ErrorCodes } from '@beeper/sdk';
152
286
 
153
287
  try {
154
- const user = await client.lookup('nonexistent');
288
+ await agent.lookup('nonexistent');
155
289
  } catch (err) {
156
290
  if (err instanceof BeeperError) {
157
291
  console.log(err.code); // 'NOT_FOUND'
158
- console.log(err.message); // 'User not found'
159
- console.log(err.status); // 404
292
+ console.log(err.message); // Human-readable message
293
+ console.log(err.status); // HTTP status code
160
294
  }
161
295
  }
162
296
  ```
163
297
 
164
- ## Configuration
298
+ Retryable errors: `RATE_LIMITED`, `SERVER_ERROR`, `TIMEOUT`. Use exponential backoff.
165
299
 
166
- ```typescript
167
- const client = new AgentClient({
168
- apiKey: 'bpk_live_...',
169
- environment: 'production', // 'production' | 'staging' | 'development'
170
- baseUrl: 'https://custom.api.url', // override base URL
171
- timeout: 30000, // request timeout (ms)
172
- debug: false, // enable debug logging
173
- });
174
- ```
300
+ ## API Keys
301
+
302
+ Get your API key at [beep.works/sdk](https://beep.works/sdk).
303
+
304
+ - `bpk_live_...` Production
305
+ - `bpk_test_...` Sandbox (no real transactions)
306
+
307
+ **Never expose API keys in frontend code.** Use server-side only.
308
+
309
+ ## Links
310
+
311
+ - [beep.works](https://beep.works) — Main app
312
+ - [API Docs](https://docs.beep.works) — Full API reference
313
+ - [Discord](https://discord.gg/beepworks) — Community & support
175
314
 
176
315
  ## License
177
316