@agentsbazaar/sdk 0.2.0 → 0.3.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.
package/dist/cli.js CHANGED
@@ -28,7 +28,7 @@ const program = new Command();
28
28
  program
29
29
  .name("bazaar")
30
30
  .description("AgentBazaar CLI — register, discover, and hire AI agents on Solana")
31
- .version("0.2.0");
31
+ .version("0.3.0");
32
32
  // ── register ──
33
33
  program
34
34
  .command("register")
@@ -187,6 +187,38 @@ program
187
187
  process.exit(1);
188
188
  }
189
189
  });
190
+ // ── quote ──
191
+ program
192
+ .command("quote")
193
+ .description("Get a price quote from an agent before paying")
194
+ .requiredOption("--task <text>", "Task to get a quote for")
195
+ .option("--agent <wallet>", "Target specific agent by wallet address")
196
+ .option("--skills <skills>", "Filter agents by skills")
197
+ .option("--api <url>", "API base URL")
198
+ .action(async (opts) => {
199
+ try {
200
+ const client = createClient({ api: opts.api, wallet: false });
201
+ console.log("Requesting quote...\n");
202
+ const quote = await client.quote({
203
+ task: opts.task,
204
+ agent: opts.agent,
205
+ skills: opts.skills,
206
+ });
207
+ console.log(`Agent: ${quote.agent.name} (${quote.agent.authority})`);
208
+ console.log(`Price: ${quote.priceUsdc} USDC (${quote.source} pricing)`);
209
+ console.log(`Quote ID: ${quote.quoteId}`);
210
+ console.log(`Expires: ${new Date(Number(quote.expiresAt)).toLocaleString()}`);
211
+ if (quote.estimate)
212
+ console.log(`Estimate: ${quote.estimate}`);
213
+ if (quote.breakdown)
214
+ console.log(`Breakdown: ${quote.breakdown}`);
215
+ console.log(`\nUse with: bazaar call --task "..." --quote ${quote.quoteId}`);
216
+ }
217
+ catch (err) {
218
+ console.error(`Quote failed: ${err instanceof Error ? err.message : err}`);
219
+ process.exit(1);
220
+ }
221
+ });
190
222
  // ── call ──
191
223
  program
192
224
  .command("call")
@@ -194,6 +226,9 @@ program
194
226
  .requiredOption("--task <text>", "Task for the agent to perform")
195
227
  .option("--skills <skills>", "Filter agents by skills")
196
228
  .option("--agent <wallet>", "Target specific agent by wallet address")
229
+ .option("--quote <id>", "Use a previously obtained quote ID")
230
+ .option("--session <id>", "Continue an existing session")
231
+ .option("--new-session", "Create a new multi-turn session")
197
232
  .option("--api <url>", "API base URL")
198
233
  .action(async (opts) => {
199
234
  try {
@@ -203,11 +238,18 @@ program
203
238
  task: opts.task,
204
239
  skills: opts.skills,
205
240
  agent: opts.agent,
241
+ quoteId: opts.quote,
242
+ sessionId: opts.session,
243
+ createSession: opts.newSession || false,
206
244
  });
207
245
  console.log(`Agent: ${result.agent.name} (${result.agent.authority})`);
208
246
  console.log(`Price: ${result.agent.price} USDC`);
209
247
  console.log(`Score: ${result.verification.score}/100 — ${result.verification.action}`);
210
248
  console.log(`Job: #${result.job.id} (${result.job.status})`);
249
+ if (result.sessionId)
250
+ console.log(`Session: ${result.sessionId}`);
251
+ if (result.quoteId)
252
+ console.log(`Quote: ${result.quoteId}`);
211
253
  console.log(`Latency: ${result.meta.agentLatencyMs}ms (total: ${result.meta.totalMs}ms)`);
212
254
  console.log(`\nResult:`);
213
255
  console.log(typeof result.result === "string" ? result.result : JSON.stringify(result.result, null, 2));
@@ -264,6 +306,34 @@ program
264
306
  process.exit(1);
265
307
  }
266
308
  });
309
+ // ── sessions ──
310
+ program
311
+ .command("sessions")
312
+ .description("List your sessions")
313
+ .requiredOption("--buyer <wallet>", "Your wallet address")
314
+ .option("--status <status>", "Filter by status: active, closed, expired")
315
+ .option("--api <url>", "API base URL")
316
+ .action(async (opts) => {
317
+ try {
318
+ const client = createClient({ api: opts.api, wallet: false });
319
+ const { sessions } = await client.listSessions(opts.buyer, opts.status);
320
+ if (sessions.length === 0) {
321
+ console.log("No sessions found.");
322
+ return;
323
+ }
324
+ console.log(`${sessions.length} session(s):\n`);
325
+ for (const s of sessions) {
326
+ console.log(` ${s.id} [${s.status}]`);
327
+ console.log(` Agent: ${s.agent_auth}`);
328
+ console.log(` Messages: ${s.message_count} | Spent: ${formatUsdc(s.total_spent)} USDC`);
329
+ console.log();
330
+ }
331
+ }
332
+ catch (err) {
333
+ console.error(`Failed: ${err instanceof Error ? err.message : err}`);
334
+ process.exit(1);
335
+ }
336
+ });
267
337
  // ── stats ──
268
338
  program
269
339
  .command("stats")
package/dist/client.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { Keypair } from "@solana/web3.js";
2
- import type { Agent, Job, Rating, RegisterParams, RegisterResult, CallParams, CallResult, HireParams, HireResult, A2ATaskResult, A2AStreamEvent, PlatformStats, Pagination, AgentCard } from "./types.js";
2
+ import type { Agent, Job, Rating, RegisterParams, RegisterResult, CallParams, CallResult, HireParams, HireResult, A2ATaskResult, A2AStreamEvent, PlatformStats, Pagination, AgentCard, QuoteParams, QuoteResponse, SessionInfo, SessionMessage, UploadResult, TrustData, FeedbackEntry, LeaderboardEntry, UpdateAgentParams, TransferResult, CrawlResult } from "./types.js";
3
3
  export declare class AgentBazaarClient {
4
4
  private baseUrl;
5
5
  private keypair;
6
- constructor(options: {
6
+ private apiKey;
7
+ constructor(options?: {
7
8
  baseUrl?: string;
8
9
  keypair?: Keypair;
10
+ apiKey?: string;
9
11
  });
10
12
  private signMessage;
11
13
  private request;
@@ -50,12 +52,386 @@ export declare class AgentBazaarClient {
50
52
  status: string;
51
53
  timestamp: string;
52
54
  }>;
53
- a2aSend(slug: string, task: string): Promise<A2ATaskResult>;
55
+ a2aSend(slug: string, task: string, options?: {
56
+ files?: Array<{
57
+ url: string;
58
+ name?: string;
59
+ mimeType?: string;
60
+ }>;
61
+ }): Promise<A2ATaskResult>;
54
62
  a2aGet(slug: string, taskId: string): Promise<A2ATaskResult>;
55
63
  a2aCancel(slug: string, taskId: string): Promise<A2ATaskResult>;
56
- a2aStream(slug: string, task: string): AsyncGenerator<A2AStreamEvent>;
64
+ a2aStream(slug: string, task: string, options?: {
65
+ files?: Array<{
66
+ url: string;
67
+ name?: string;
68
+ mimeType?: string;
69
+ }>;
70
+ timeoutMs?: number;
71
+ }): AsyncGenerator<A2AStreamEvent>;
72
+ quote(params: QuoteParams): Promise<QuoteResponse>;
73
+ getQuote(quoteId: string): Promise<QuoteResponse>;
74
+ /**
75
+ * Start a session with an agent. Returns a sessionId for multi-turn conversations.
76
+ */
77
+ startSession(agentPubkey: string, budgetLimit?: number): Promise<{
78
+ sessionId: string;
79
+ agent: {
80
+ name: string;
81
+ price: number;
82
+ priceUsdc: number;
83
+ };
84
+ }>;
85
+ /**
86
+ * Send a message in an existing session. Returns a quote with an unsigned payment transaction.
87
+ * Call paySession() with the paymentId to execute.
88
+ */
89
+ sendMessage(sessionId: string, task: string, fileUrl?: string): Promise<{
90
+ sessionId: string;
91
+ price: number;
92
+ priceUsdc: number;
93
+ paymentId?: string;
94
+ pendingPayment?: {
95
+ transaction: string;
96
+ };
97
+ free?: boolean;
98
+ result?: string;
99
+ }>;
100
+ /**
101
+ * Pay for a message and get the agent's response.
102
+ * Pass the paymentId from sendMessage() and the signed transaction.
103
+ */
104
+ paySession(paymentId: string, signedTransaction: string): Promise<{
105
+ success: boolean;
106
+ txSignature: string;
107
+ result: string;
108
+ status: string;
109
+ job: {
110
+ id: number;
111
+ status: string;
112
+ };
113
+ sessionId: string;
114
+ question?: string;
115
+ taskId?: string;
116
+ }>;
117
+ listSessions(buyer?: string, status?: string): Promise<{
118
+ sessions: SessionInfo[];
119
+ }>;
120
+ getSession(sessionId: string): Promise<SessionInfo>;
121
+ getSessionMessages(sessionId: string, limit?: number): Promise<{
122
+ messages: SessionMessage[];
123
+ sessionId: string;
124
+ }>;
125
+ closeSession(sessionId: string): Promise<{
126
+ success: boolean;
127
+ sessionId: string;
128
+ totalSpent: number;
129
+ messageCount: number;
130
+ }>;
57
131
  uploadImage(imagePath: string): Promise<{
58
132
  success: boolean;
59
133
  imageUrl: string;
60
134
  }>;
135
+ /**
136
+ * Submit an on-chain review for an agent after a completed job.
137
+ * The SDK keypair signs as the reviewer, platform pays gas.
138
+ * For agent-to-agent: the hiring agent's keypair signs the review.
139
+ */
140
+ submitReview(agentPubkey: string, jobId: number, score: number, comment?: string): Promise<{
141
+ success: boolean;
142
+ txSignature: string;
143
+ }>;
144
+ getTrustData(pubkey: string): Promise<TrustData>;
145
+ getLeaderboard(options?: {
146
+ limit?: number;
147
+ minTier?: number;
148
+ }): Promise<{
149
+ agents: LeaderboardEntry[];
150
+ }>;
151
+ getFeedback(pubkey: string): Promise<{
152
+ feedback: FeedbackEntry[];
153
+ verifiedCount: number;
154
+ totalCount: number;
155
+ }>;
156
+ revokeFeedback(pubkey: string, feedbackIndex: number): Promise<{
157
+ success: boolean;
158
+ }>;
159
+ respondToFeedback(pubkey: string, feedbackIndex: number, response: string): Promise<{
160
+ success: boolean;
161
+ }>;
162
+ updateAgent(params: UpdateAgentParams): Promise<{
163
+ success: boolean;
164
+ agent: Agent;
165
+ }>;
166
+ transferAgent(newOwner: string): Promise<TransferResult>;
167
+ setOperationalWallet(wallet: string, deadline: number): Promise<{
168
+ success: boolean;
169
+ }>;
170
+ setParentAgent(parentPubkey: string): Promise<{
171
+ success: boolean;
172
+ }>;
173
+ crawlEndpoint(endpoint: string): Promise<CrawlResult>;
174
+ /**
175
+ * Create a new custodial wallet. Returns an API key — save it, it cannot be recovered.
176
+ * No keypair needed — this is for users without their own Solana wallet.
177
+ */
178
+ static createWallet(baseUrl?: string, label?: string): Promise<{
179
+ apiKey: string;
180
+ publicKey: string;
181
+ message: string;
182
+ }>;
183
+ /**
184
+ * Get wallet info and balance using API key auth.
185
+ */
186
+ getWallet(): Promise<{
187
+ publicKey: string;
188
+ balances: {
189
+ sol: string;
190
+ usdc: string;
191
+ };
192
+ }>;
193
+ /**
194
+ * Export the private key for the custodial wallet. Returns the full 64-byte keypair.
195
+ * Save this and import into Phantom/Solflare for self-custody.
196
+ */
197
+ exportKey(): Promise<{
198
+ privateKey: number[];
199
+ publicKey: string;
200
+ }>;
201
+ /**
202
+ * List emails in the agent's inbox.
203
+ */
204
+ getInbox(options?: {
205
+ limit?: number;
206
+ offset?: number;
207
+ }): Promise<{
208
+ messages: Array<{
209
+ id: string;
210
+ from: string;
211
+ to: string;
212
+ subject: string;
213
+ created_at: string;
214
+ }>;
215
+ }>;
216
+ /**
217
+ * Read a specific email from the agent's inbox.
218
+ */
219
+ readEmail(messageId: string): Promise<{
220
+ id: string;
221
+ from: string;
222
+ to: string;
223
+ subject: string;
224
+ text: string;
225
+ html?: string;
226
+ created_at: string;
227
+ }>;
228
+ /**
229
+ * Send an email from the agent's inbox.
230
+ */
231
+ sendEmail(params: {
232
+ to: string;
233
+ subject: string;
234
+ text: string;
235
+ html?: string;
236
+ }): Promise<{
237
+ success: boolean;
238
+ messageId?: string;
239
+ }>;
240
+ uploadFile(filePath: string): Promise<UploadResult>;
241
+ private authHeaders;
242
+ getCreditBalance(): Promise<{
243
+ balance: number;
244
+ balanceUsdc: number;
245
+ }>;
246
+ getCreditHistory(limit?: number): Promise<{
247
+ transactions: Array<{
248
+ type: string;
249
+ amount: number;
250
+ description: string;
251
+ created_at: string;
252
+ }>;
253
+ }>;
254
+ depositCredits(stripePaymentIntentId: string): Promise<{
255
+ success: boolean;
256
+ balance: number;
257
+ }>;
258
+ createPrepaidSession(agentPubkey: string, budgetUsdc: number): Promise<{
259
+ sessionId: string;
260
+ token: string;
261
+ budgetUsdc: number;
262
+ estimatedMessages: number;
263
+ transaction?: string;
264
+ }>;
265
+ openPrepaidSession(agentPubkey: string, budgetUsdc: number, signedTransaction: string): Promise<{
266
+ sessionId: string;
267
+ token: string;
268
+ budgetUsdc: number;
269
+ estimatedMessages: number;
270
+ txSignature: string;
271
+ }>;
272
+ extendSession(sessionId: string, additionalUsdc: number): Promise<{
273
+ sessionId: string;
274
+ budgetUsdc: number;
275
+ spentUsdc: number;
276
+ remainingUsdc: number;
277
+ }>;
278
+ sendMessageWithBudget(sessionId: string, task: string, maxBudget: number, fileUrl?: string): Promise<{
279
+ price: number;
280
+ priceUsdc: number;
281
+ negotiated?: boolean;
282
+ paymentId?: string;
283
+ pendingPayment?: {
284
+ transaction: string;
285
+ };
286
+ }>;
287
+ getNotifications(limit?: number): Promise<{
288
+ notifications: Array<{
289
+ id: number;
290
+ type: string;
291
+ title: string;
292
+ description: string;
293
+ is_read: boolean;
294
+ created_at: string;
295
+ }>;
296
+ }>;
297
+ getUnreadCount(): Promise<{
298
+ count: number;
299
+ }>;
300
+ markNotificationsRead(ids?: number[]): Promise<{
301
+ success: boolean;
302
+ }>;
303
+ registerWebhook(url: string, events?: string[]): Promise<{
304
+ success: boolean;
305
+ url: string;
306
+ events: string[];
307
+ }>;
308
+ getWebhook(): Promise<{
309
+ subscribed: boolean;
310
+ url?: string;
311
+ events?: string[];
312
+ }>;
313
+ deleteWebhook(): Promise<{
314
+ success: boolean;
315
+ }>;
316
+ getSwapQuote(inputMint: string, outputMint: string, amount: number): Promise<{
317
+ inputMint: string;
318
+ outputMint: string;
319
+ inAmount: string;
320
+ outAmount: string;
321
+ priceImpact: string;
322
+ }>;
323
+ buildSwapTransaction(inputMint: string, outputMint: string, amount: number): Promise<{
324
+ transaction: string;
325
+ inputMint: string;
326
+ outputMint: string;
327
+ }>;
328
+ getTokenPrice(token: string): Promise<{
329
+ token: string;
330
+ priceUsd: number;
331
+ }>;
332
+ getTokenPrices(): Promise<{
333
+ prices: Record<string, number>;
334
+ }>;
335
+ getSolanaPayQR(agentSlug: string): Promise<{
336
+ url: string;
337
+ qrData: string;
338
+ }>;
339
+ getBlink(agentSlug: string): Promise<{
340
+ icon: string;
341
+ title: string;
342
+ description: string;
343
+ links: {
344
+ actions: Array<{
345
+ label: string;
346
+ href: string;
347
+ }>;
348
+ };
349
+ }>;
350
+ createRecurringTask(params: {
351
+ agentAuth: string;
352
+ task: string;
353
+ intervalMs: number;
354
+ budgetPerExecution: number;
355
+ maxExecutions?: number;
356
+ }): Promise<{
357
+ id: number;
358
+ success: boolean;
359
+ }>;
360
+ listRecurringTasks(): Promise<{
361
+ tasks: Array<{
362
+ id: number;
363
+ agent_auth: string;
364
+ task: string;
365
+ status: string;
366
+ executions: number;
367
+ }>;
368
+ }>;
369
+ pauseRecurringTask(id: number): Promise<{
370
+ success: boolean;
371
+ }>;
372
+ resumeRecurringTask(id: number): Promise<{
373
+ success: boolean;
374
+ }>;
375
+ stopRecurringTask(id: number): Promise<{
376
+ success: boolean;
377
+ }>;
378
+ getAgentBalance(): Promise<{
379
+ sol: string;
380
+ usdc: string;
381
+ publicKey: string;
382
+ }>;
383
+ getAgentSpendHistory(): Promise<{
384
+ transactions: Array<{
385
+ type: string;
386
+ amount: number;
387
+ created_at: string;
388
+ }>;
389
+ }>;
390
+ getTransactionHistory(): Promise<{
391
+ transactions: Array<{
392
+ signature: string;
393
+ type: string;
394
+ amount: number;
395
+ timestamp: string;
396
+ }>;
397
+ }>;
398
+ createMandate(params: {
399
+ agentAuth: string;
400
+ budgetLimit: number;
401
+ expiresInMs: number;
402
+ allowedActions?: string[];
403
+ }): Promise<{
404
+ id: number;
405
+ success: boolean;
406
+ }>;
407
+ listMandates(): Promise<{
408
+ mandates: Array<{
409
+ id: number;
410
+ agent_auth: string;
411
+ budget_limit: number;
412
+ status: string;
413
+ }>;
414
+ }>;
415
+ revokeMandate(id: number): Promise<{
416
+ success: boolean;
417
+ }>;
418
+ getPresignedUploadUrl(fileName: string, mimeType: string, size?: number): Promise<{
419
+ uploadUrl: string;
420
+ token: string;
421
+ fileId: string;
422
+ storagePath: string;
423
+ }>;
424
+ confirmUpload(fileId: string): Promise<{
425
+ success: boolean;
426
+ url: string;
427
+ name: string;
428
+ size: number;
429
+ }>;
430
+ discover(skills: string): Promise<Agent[]>;
431
+ myAgents(): Promise<{
432
+ agents: Agent[];
433
+ }>;
434
+ claimAgent(agentPubkey: string, accessCode: string): Promise<{
435
+ success: boolean;
436
+ }>;
61
437
  }