pay-lobster 1.0.0

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.
Files changed (120) hide show
  1. package/README.md +401 -0
  2. package/README.md.bak +401 -0
  3. package/dist/agent.d.ts +132 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +224 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/analytics.d.ts +120 -0
  8. package/dist/analytics.d.ts.map +1 -0
  9. package/dist/analytics.js +345 -0
  10. package/dist/analytics.js.map +1 -0
  11. package/dist/approvals.d.ts +168 -0
  12. package/dist/approvals.d.ts.map +1 -0
  13. package/dist/approvals.js +406 -0
  14. package/dist/approvals.js.map +1 -0
  15. package/dist/circle-client.d.ts +152 -0
  16. package/dist/circle-client.d.ts.map +1 -0
  17. package/dist/circle-client.js +266 -0
  18. package/dist/circle-client.js.map +1 -0
  19. package/dist/commission.d.ts +191 -0
  20. package/dist/commission.d.ts.map +1 -0
  21. package/dist/commission.js +475 -0
  22. package/dist/commission.js.map +1 -0
  23. package/dist/condition-builder.d.ts +98 -0
  24. package/dist/condition-builder.d.ts.map +1 -0
  25. package/dist/condition-builder.js +193 -0
  26. package/dist/condition-builder.js.map +1 -0
  27. package/dist/contacts.d.ts +179 -0
  28. package/dist/contacts.d.ts.map +1 -0
  29. package/dist/contacts.js +445 -0
  30. package/dist/contacts.js.map +1 -0
  31. package/dist/easy.d.ts +22 -0
  32. package/dist/easy.d.ts.map +1 -0
  33. package/dist/easy.js +40 -0
  34. package/dist/easy.js.map +1 -0
  35. package/dist/erc8004/constants.d.ts +152 -0
  36. package/dist/erc8004/constants.d.ts.map +1 -0
  37. package/dist/erc8004/constants.js +114 -0
  38. package/dist/erc8004/constants.js.map +1 -0
  39. package/dist/erc8004/discovery.d.ts +84 -0
  40. package/dist/erc8004/discovery.d.ts.map +1 -0
  41. package/dist/erc8004/discovery.js +217 -0
  42. package/dist/erc8004/discovery.js.map +1 -0
  43. package/dist/erc8004/identity.d.ts +91 -0
  44. package/dist/erc8004/identity.d.ts.map +1 -0
  45. package/dist/erc8004/identity.js +250 -0
  46. package/dist/erc8004/identity.js.map +1 -0
  47. package/dist/erc8004/index.d.ts +147 -0
  48. package/dist/erc8004/index.d.ts.map +1 -0
  49. package/dist/erc8004/index.js +225 -0
  50. package/dist/erc8004/index.js.map +1 -0
  51. package/dist/erc8004/reputation.d.ts +133 -0
  52. package/dist/erc8004/reputation.d.ts.map +1 -0
  53. package/dist/erc8004/reputation.js +277 -0
  54. package/dist/erc8004/reputation.js.map +1 -0
  55. package/dist/escrow-templates.d.ts +38 -0
  56. package/dist/escrow-templates.d.ts.map +1 -0
  57. package/dist/escrow-templates.js +419 -0
  58. package/dist/escrow-templates.js.map +1 -0
  59. package/dist/escrow.d.ts +320 -0
  60. package/dist/escrow.d.ts.map +1 -0
  61. package/dist/escrow.js +854 -0
  62. package/dist/escrow.js.map +1 -0
  63. package/dist/index.d.ts +11 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +33 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/invoices.d.ts +212 -0
  68. package/dist/invoices.d.ts.map +1 -0
  69. package/dist/invoices.js +393 -0
  70. package/dist/invoices.js.map +1 -0
  71. package/dist/notifications.d.ts +141 -0
  72. package/dist/notifications.d.ts.map +1 -0
  73. package/dist/notifications.js +350 -0
  74. package/dist/notifications.js.map +1 -0
  75. package/dist/tips.d.ts +171 -0
  76. package/dist/tips.d.ts.map +1 -0
  77. package/dist/tips.js +390 -0
  78. package/dist/tips.js.map +1 -0
  79. package/dist/types.d.ts +100 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/types.js +6 -0
  82. package/dist/types.js.map +1 -0
  83. package/dist/x402-client.d.ts +127 -0
  84. package/dist/x402-client.d.ts.map +1 -0
  85. package/dist/x402-client.js +350 -0
  86. package/dist/x402-client.js.map +1 -0
  87. package/dist/x402-server.d.ts +133 -0
  88. package/dist/x402-server.d.ts.map +1 -0
  89. package/dist/x402-server.js +330 -0
  90. package/dist/x402-server.js.map +1 -0
  91. package/lib/agent.ts +273 -0
  92. package/lib/analytics.ts +474 -0
  93. package/lib/analytics.ts.bak +474 -0
  94. package/lib/approvals.ts +585 -0
  95. package/lib/approvals.ts.bak +585 -0
  96. package/lib/circle-client.ts +376 -0
  97. package/lib/circle-client.ts.bak +376 -0
  98. package/lib/commission.ts +680 -0
  99. package/lib/commission.ts.bak +680 -0
  100. package/lib/condition-builder.ts +223 -0
  101. package/lib/condition-builder.ts.bak +223 -0
  102. package/lib/contacts.ts +615 -0
  103. package/lib/contacts.ts.bak +615 -0
  104. package/lib/easy.ts +46 -0
  105. package/lib/easy.ts.bak +352 -0
  106. package/lib/erc8004/constants.ts +175 -0
  107. package/lib/erc8004/discovery.ts +299 -0
  108. package/lib/erc8004/identity.ts +327 -0
  109. package/lib/erc8004/index.ts +285 -0
  110. package/lib/erc8004/reputation.ts +368 -0
  111. package/lib/escrow-templates.ts +462 -0
  112. package/lib/escrow.ts +1216 -0
  113. package/lib/index.ts +13 -0
  114. package/lib/invoices.ts +588 -0
  115. package/lib/notifications.ts +484 -0
  116. package/lib/tips.ts +570 -0
  117. package/lib/types.ts +108 -0
  118. package/lib/x402-client.ts +471 -0
  119. package/lib/x402-server.ts +462 -0
  120. package/package.json +58 -0
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Lobster Pay - Easy Mode
3
+ *
4
+ * One-liner APIs for the most common operations.
5
+ * Designed for humans AND AI agents to use with minimal setup.
6
+ */
7
+
8
+ import { CircleClient, CircleClientConfig } from './circle-client';
9
+ import { X402Client } from './x402-client';
10
+ import { EscrowManager } from './escrow';
11
+ import { EscrowTemplates } from './escrow-templates';
12
+ import { ERC8004Client, createERC8004Client } from './erc8004';
13
+ import { ContactManager } from './contacts';
14
+ import { InvoiceManager } from './invoices';
15
+
16
+ // Re-export everything for convenience
17
+ export * from './circle-client';
18
+ export * from './x402-client';
19
+ export * from './x402-server';
20
+ export * from './escrow';
21
+ export * from './escrow-templates';
22
+ export * from './condition-builder';
23
+ export * from './erc8004';
24
+ export * from './contacts';
25
+ export * from './invoices';
26
+ export * from './approvals';
27
+ export * from './notifications';
28
+ export * from './analytics';
29
+ export * from './tips';
30
+ export * from './commission';
31
+
32
+ /**
33
+ * Quick Setup - Get started in 3 lines
34
+ */
35
+ export interface QuickConfig {
36
+ // Circle credentials (required)
37
+ circleApiKey: string;
38
+ circleEntitySecret: string;
39
+
40
+ // Network (default: testnet)
41
+ network?: 'testnet' | 'mainnet';
42
+ chain?: string;
43
+
44
+ // Optional: ERC-8004 for trust
45
+ privateKey?: string;
46
+
47
+ // Optional: Your agent info
48
+ agentName?: string;
49
+ agentDescription?: string;
50
+ }
51
+
52
+ export interface LobsterAgent {
53
+ // Core
54
+ circle: CircleClient;
55
+ x402: X402Client;
56
+ escrow: EscrowManager;
57
+ contacts: ContactManager;
58
+ invoices: InvoiceManager;
59
+
60
+ // Trust (if privateKey provided)
61
+ trust?: ERC8004Client;
62
+ agentId?: number;
63
+
64
+ // Easy methods
65
+ balance: () => Promise<string>;
66
+ send: (to: string, amount: string, memo?: string) => Promise<string>;
67
+ pay: (url: string, maxAmount?: string) => Promise<any>;
68
+ createEscrow: (template: string, params: any) => Promise<any>;
69
+
70
+ // Status
71
+ status: () => Promise<AgentStatus>;
72
+ }
73
+
74
+ export interface AgentStatus {
75
+ walletId: string;
76
+ chain: string;
77
+ balance: string;
78
+ agentId?: number;
79
+ trustScore?: number;
80
+ reputation?: {
81
+ score: number;
82
+ feedbackCount: number;
83
+ level: string;
84
+ };
85
+ }
86
+
87
+ /**
88
+ * Create a Lobster Pay with one function call
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const agent = await createLobsterAgent({
93
+ * circleApiKey: process.env.CIRCLE_API_KEY!,
94
+ * circleEntitySecret: process.env.CIRCLE_ENTITY_SECRET!,
95
+ * });
96
+ *
97
+ * // Check balance
98
+ * console.log(await agent.balance());
99
+ *
100
+ * // Send USDC
101
+ * await agent.send('0x...', '10');
102
+ *
103
+ * // Pay for an API call
104
+ * const data = await agent.pay('https://api.example.com/premium');
105
+ * ```
106
+ */
107
+ export async function createLobsterAgent(config: QuickConfig): Promise<LobsterAgent> {
108
+ const network = config.network || 'testnet';
109
+ const chain = config.chain || (network === 'testnet' ? 'ETH-SEPOLIA' : 'ETH-MAINNET');
110
+
111
+ // Initialize Circle client
112
+ const circle = new CircleClient({
113
+ apiKey: config.circleApiKey,
114
+ entitySecret: config.circleEntitySecret,
115
+ });
116
+
117
+ // Setup wallet
118
+ await circle.ensureWalletSet();
119
+ const walletId = circle.getWalletId()!;
120
+
121
+ // Initialize other services
122
+ const x402 = new X402Client({
123
+ circleClient: circle,
124
+ walletId,
125
+ chain,
126
+ });
127
+
128
+ const escrow = new EscrowManager({ circleClient: circle });
129
+ const contacts = new ContactManager();
130
+ const invoices = new InvoiceManager();
131
+
132
+ // Initialize trust layer if privateKey provided
133
+ let trust: ERC8004Client | undefined;
134
+ let agentId: number | undefined;
135
+
136
+ if (config.privateKey) {
137
+ const erc8004Chain = chain.includes('SEPOLIA') ? 'ETH-SEPOLIA' :
138
+ chain.includes('AMOY') ? 'MATIC-AMOY' :
139
+ chain.includes('BASE') ? 'BASE-SEPOLIA' : 'ETH-SEPOLIA';
140
+
141
+ trust = createERC8004Client(
142
+ erc8004Chain as any,
143
+ config.privateKey,
144
+ { paymentAddress: await circle.getReceiveAddress(chain) }
145
+ );
146
+
147
+ // Register agent if name provided
148
+ if (config.agentName) {
149
+ try {
150
+ agentId = await trust.registerAgent({
151
+ name: config.agentName,
152
+ description: config.agentDescription || `${config.agentName} - USDC payment agent`,
153
+ capabilities: ['usdc-payments', 'x402', 'escrow'],
154
+ });
155
+ console.log(`Registered as Agent #${agentId}`);
156
+ } catch (e) {
157
+ console.warn('Agent registration failed (may already be registered):', e);
158
+ }
159
+ }
160
+ }
161
+
162
+ // Build the agent interface
163
+ const agent: LobsterAgent = {
164
+ circle,
165
+ x402,
166
+ escrow,
167
+ contacts,
168
+ invoices,
169
+ trust,
170
+ agentId,
171
+
172
+ // Easy balance check
173
+ balance: async () => {
174
+ const balances = await circle.getAllUSDCBalances();
175
+ const chainBalance = balances.find((b: any) => b.chain === chain);
176
+ return chainBalance?.amount || '0';
177
+ },
178
+
179
+ // Easy send
180
+ send: async (to: string, amount: string, memo?: string) => {
181
+ // Check if 'to' is a contact name
182
+ let address = to;
183
+ if (!to.startsWith('0x')) {
184
+ const contact = await contacts.resolveRecipient(to, chain);
185
+ if (contact) {
186
+ address = contact.address;
187
+ } else {
188
+ throw new Error(`Unknown recipient: ${to}. Use an address or add them as a contact.`);
189
+ }
190
+ }
191
+
192
+ const tx = await circle.sendUSDC({
193
+ fromWalletId: walletId,
194
+ toAddress: address,
195
+ amount,
196
+ chain,
197
+ });
198
+
199
+ return tx.id;
200
+ },
201
+
202
+ // Easy x402 payment
203
+ pay: async (url: string, maxAmount: string = '10') => {
204
+ const response = await x402.fetch(url, {
205
+ method: 'GET',
206
+ maxPayment: maxAmount,
207
+ });
208
+
209
+ if (!response.ok) {
210
+ throw new Error(`Payment failed: ${response.statusText}`);
211
+ }
212
+
213
+ return response.json();
214
+ },
215
+
216
+ // Easy escrow creation
217
+ createEscrow: async (template: string, params: any) => {
218
+ const templateFn = (EscrowTemplates as any)[template];
219
+ if (!templateFn) {
220
+ throw new Error(`Unknown template: ${template}. Available: freelance, realEstate, commerce, p2p`);
221
+ }
222
+
223
+ return escrow.createFromTemplate(templateFn(params));
224
+ },
225
+
226
+ // Status check
227
+ status: async () => {
228
+ const balance = await agent.balance();
229
+
230
+ const status: AgentStatus = {
231
+ walletId,
232
+ chain,
233
+ balance,
234
+ agentId,
235
+ };
236
+
237
+ if (trust && agentId) {
238
+ const rep = await trust.getMyReputation();
239
+ if (rep) {
240
+ status.trustScore = await trust.reputation.calculateTrustScore(agentId);
241
+ status.reputation = {
242
+ score: rep.averageScore,
243
+ feedbackCount: rep.totalFeedback,
244
+ level: rep.trustLevel,
245
+ };
246
+ }
247
+ }
248
+
249
+ return status;
250
+ },
251
+ };
252
+
253
+ return agent;
254
+ }
255
+
256
+ /**
257
+ * Even simpler: Environment-based setup
258
+ *
259
+ * Just set CIRCLE_API_KEY and CIRCLE_ENTITY_SECRET env vars
260
+ */
261
+ export async function quickStart(): Promise<LobsterAgent> {
262
+ const apiKey = process.env.CIRCLE_API_KEY;
263
+ const entitySecret = process.env.CIRCLE_ENTITY_SECRET;
264
+
265
+ if (!apiKey || !entitySecret) {
266
+ throw new Error(
267
+ 'Missing environment variables. Set:\n' +
268
+ ' CIRCLE_API_KEY=your-api-key\n' +
269
+ ' CIRCLE_ENTITY_SECRET=your-entity-secret\n\n' +
270
+ 'Get credentials at: https://console.circle.com'
271
+ );
272
+ }
273
+
274
+ return createLobsterAgent({
275
+ circleApiKey: apiKey,
276
+ circleEntitySecret: entitySecret,
277
+ privateKey: process.env.PRIVATE_KEY,
278
+ agentName: process.env.AGENT_NAME,
279
+ network: (process.env.NETWORK as any) || 'testnet',
280
+ });
281
+ }
282
+
283
+ /**
284
+ * CLI helper - parse command line for common operations
285
+ */
286
+ export async function runCLI(args: string[]): Promise<void> {
287
+ const agent = await quickStart();
288
+ const [command, ...rest] = args;
289
+
290
+ switch (command) {
291
+ case 'balance':
292
+ console.log(`Balance: ${await agent.balance()} USDC`);
293
+ break;
294
+
295
+ case 'send':
296
+ if (rest.length < 2) {
297
+ console.error('Usage: send <to> <amount>');
298
+ process.exit(1);
299
+ }
300
+ const txId = await agent.send(rest[0], rest[1]);
301
+ console.log(`Sent! Transaction: ${txId}`);
302
+ break;
303
+
304
+ case 'pay':
305
+ if (rest.length < 1) {
306
+ console.error('Usage: pay <url> [max-amount]');
307
+ process.exit(1);
308
+ }
309
+ const data = await agent.pay(rest[0], rest[1] || '10');
310
+ console.log('Response:', JSON.stringify(data, null, 2));
311
+ break;
312
+
313
+ case 'status':
314
+ const status = await agent.status();
315
+ console.log('Agent Status:');
316
+ console.log(` Wallet: ${status.walletId}`);
317
+ console.log(` Chain: ${status.chain}`);
318
+ console.log(` Balance: ${status.balance} USDC`);
319
+ if (status.agentId) {
320
+ console.log(` Agent ID: ${status.agentId}`);
321
+ console.log(` Trust Score: ${status.trustScore}`);
322
+ console.log(` Reputation: ${status.reputation?.level} (${status.reputation?.feedbackCount} reviews)`);
323
+ }
324
+ break;
325
+
326
+ default:
327
+ console.log(`
328
+ Lobster Pay CLI
329
+
330
+ Commands:
331
+ balance Check your USDC balance
332
+ send <to> <amount> Send USDC to an address or contact
333
+ pay <url> [max] Pay for an API call via x402
334
+ status Show agent status and trust score
335
+
336
+ Environment Variables:
337
+ CIRCLE_API_KEY Your Circle API key
338
+ CIRCLE_ENTITY_SECRET Your Circle entity secret
339
+ PRIVATE_KEY (Optional) For ERC-8004 trust features
340
+ AGENT_NAME (Optional) Register with this name
341
+ NETWORK (Optional) testnet or mainnet
342
+
343
+ Get started:
344
+ 1. Get credentials at https://console.circle.com
345
+ 2. Set environment variables
346
+ 3. Run: npx lobster-pay balance
347
+ `);
348
+ }
349
+ }
350
+
351
+ // Export templates for easy access
352
+ export { EscrowTemplates } from './escrow-templates';
@@ -0,0 +1,175 @@
1
+ /**
2
+ * ERC-8004 Constants & Contract Addresses
3
+ *
4
+ * Official registry deployments from https://github.com/erc-8004/erc-8004-contracts
5
+ */
6
+
7
+ export const ERC8004_CONTRACTS = {
8
+ // Testnets (same addresses across all testnets)
9
+ testnet: {
10
+ identityRegistry: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
11
+ reputationRegistry: '0x8004B663056A597Dffe9eCcC1965A193B7388713',
12
+ },
13
+ // Mainnets (same addresses across all mainnets)
14
+ mainnet: {
15
+ identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
16
+ reputationRegistry: '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63',
17
+ },
18
+ } as const;
19
+
20
+ export const CHAIN_CONFIG = {
21
+ 'ETH-SEPOLIA': {
22
+ chainId: 11155111,
23
+ namespace: 'eip155',
24
+ rpcUrl: 'https://rpc.sepolia.org',
25
+ explorer: 'https://sepolia.etherscan.io',
26
+ contracts: ERC8004_CONTRACTS.testnet,
27
+ },
28
+ 'BASE-SEPOLIA': {
29
+ chainId: 84532,
30
+ namespace: 'eip155',
31
+ rpcUrl: 'https://sepolia.base.org',
32
+ explorer: 'https://sepolia.basescan.org',
33
+ contracts: ERC8004_CONTRACTS.testnet,
34
+ },
35
+ 'MATIC-AMOY': {
36
+ chainId: 80002,
37
+ namespace: 'eip155',
38
+ rpcUrl: 'https://rpc-amoy.polygon.technology',
39
+ explorer: 'https://amoy.polygonscan.com',
40
+ contracts: ERC8004_CONTRACTS.testnet,
41
+ },
42
+ 'ARB-SEPOLIA': {
43
+ chainId: 421614,
44
+ namespace: 'eip155',
45
+ rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc',
46
+ explorer: 'https://sepolia.arbiscan.io',
47
+ contracts: ERC8004_CONTRACTS.testnet,
48
+ },
49
+ // Mainnets
50
+ 'ETH-MAINNET': {
51
+ chainId: 1,
52
+ namespace: 'eip155',
53
+ rpcUrl: 'https://eth.llamarpc.com',
54
+ explorer: 'https://etherscan.io',
55
+ contracts: ERC8004_CONTRACTS.mainnet,
56
+ },
57
+ 'BASE-MAINNET': {
58
+ chainId: 8453,
59
+ namespace: 'eip155',
60
+ rpcUrl: 'https://mainnet.base.org',
61
+ explorer: 'https://basescan.org',
62
+ contracts: ERC8004_CONTRACTS.mainnet,
63
+ },
64
+ } as const;
65
+
66
+ export type SupportedChain = keyof typeof CHAIN_CONFIG;
67
+
68
+ // Identity Registry ABI (ERC-721 + URIStorage extension)
69
+ export const IDENTITY_REGISTRY_ABI = [
70
+ // ERC-721 standard
71
+ 'function balanceOf(address owner) view returns (uint256)',
72
+ 'function ownerOf(uint256 tokenId) view returns (address)',
73
+ 'function tokenURI(uint256 tokenId) view returns (string)',
74
+ 'function totalSupply() view returns (uint256)',
75
+ 'function tokenByIndex(uint256 index) view returns (uint256)',
76
+ 'function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)',
77
+
78
+ // ERC-8004 Identity Registry
79
+ 'function register(string uri) returns (uint256 agentId)',
80
+ 'function setAgentURI(uint256 agentId, string uri)',
81
+ 'function getAgentURI(uint256 agentId) view returns (string)',
82
+ 'function getAgentOwner(uint256 agentId) view returns (address)',
83
+ 'function getAgentsByOwner(address owner) view returns (uint256[])',
84
+
85
+ // Events
86
+ 'event AgentRegistered(uint256 indexed agentId, address indexed owner, string uri)',
87
+ 'event AgentURIUpdated(uint256 indexed agentId, string uri)',
88
+ 'event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)',
89
+ ] as const;
90
+
91
+ // Reputation Registry ABI
92
+ export const REPUTATION_REGISTRY_ABI = [
93
+ // Post feedback
94
+ 'function postFeedback(uint256 agentId, int8 score, string context, bytes32 taskHash) returns (uint256 feedbackId)',
95
+ 'function postFeedbackWithProof(uint256 agentId, int8 score, string context, bytes32 taskHash, bytes proof) returns (uint256 feedbackId)',
96
+
97
+ // Query feedback
98
+ 'function getFeedback(uint256 feedbackId) view returns (tuple(uint256 agentId, address author, int8 score, string context, bytes32 taskHash, uint256 timestamp))',
99
+ 'function getFeedbackCount(uint256 agentId) view returns (uint256)',
100
+ 'function getFeedbackByAgent(uint256 agentId, uint256 offset, uint256 limit) view returns (uint256[])',
101
+ 'function getAverageScore(uint256 agentId) view returns (int256 average, uint256 count)',
102
+
103
+ // Authorization
104
+ 'function authorizeFeedback(uint256 agentId, address author)',
105
+ 'function revokeFeedbackAuthorization(uint256 agentId, address author)',
106
+ 'function isAuthorizedFeedbackAuthor(uint256 agentId, address author) view returns (bool)',
107
+
108
+ // Events
109
+ 'event FeedbackPosted(uint256 indexed feedbackId, uint256 indexed agentId, address indexed author, int8 score)',
110
+ 'event FeedbackAuthorizationGranted(uint256 indexed agentId, address indexed author)',
111
+ 'event FeedbackAuthorizationRevoked(uint256 indexed agentId, address indexed author)',
112
+ ] as const;
113
+
114
+ // Agent Registration File schema (per ERC-8004 spec)
115
+ export interface AgentRegistration {
116
+ type: 'https://eips.ethereum.org/EIPS/eip-8004#registration-v1';
117
+ name: string;
118
+ description: string;
119
+ image?: string;
120
+ services: AgentService[];
121
+ x402Support: boolean;
122
+ active: boolean;
123
+ registrations: {
124
+ agentId: number;
125
+ agentRegistry: string; // {namespace}:{chainId}:{identityRegistry}
126
+ }[];
127
+ supportedTrust: ('reputation' | 'crypto-economic' | 'tee-attestation' | 'zkml')[];
128
+
129
+ // Pay Lobster specific extensions
130
+ usdcAgent?: {
131
+ version: string;
132
+ capabilities: string[];
133
+ supportedChains: string[];
134
+ paymentAddress?: string;
135
+ escrowSupport: boolean;
136
+ x402Endpoint?: string;
137
+ };
138
+ }
139
+
140
+ export interface AgentService {
141
+ name: string;
142
+ endpoint: string;
143
+ version?: string;
144
+ skills?: string[];
145
+ domains?: string[];
146
+ }
147
+
148
+ // Feedback types
149
+ export interface Feedback {
150
+ feedbackId: number;
151
+ agentId: number;
152
+ author: string;
153
+ score: number; // -100 to 100
154
+ context: string;
155
+ taskHash: string;
156
+ timestamp: number;
157
+ }
158
+
159
+ export interface ReputationSummary {
160
+ agentId: number;
161
+ averageScore: number;
162
+ totalFeedback: number;
163
+ recentFeedback: Feedback[];
164
+ trustLevel: 'untrusted' | 'new' | 'emerging' | 'established' | 'trusted' | 'verified';
165
+ }
166
+
167
+ // Trust level thresholds
168
+ export const TRUST_LEVELS = {
169
+ untrusted: { minScore: -100, minFeedback: 0 },
170
+ new: { minScore: 0, minFeedback: 1 },
171
+ emerging: { minScore: 25, minFeedback: 5 },
172
+ established: { minScore: 50, minFeedback: 20 },
173
+ trusted: { minScore: 75, minFeedback: 50 },
174
+ verified: { minScore: 90, minFeedback: 100 },
175
+ } as const;