@greenhelix/sdk 1.0.7
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 +97 -0
- package/dist/client.d.ts +195 -0
- package/dist/client.js +467 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +92 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/test/client.test.d.ts +7 -0
- package/dist/test/client.test.js +265 -0
- package/dist/test/client.test.js.map +1 -0
- package/dist/test/convenience.test.d.ts +11 -0
- package/dist/test/convenience.test.js +487 -0
- package/dist/test/convenience.test.js.map +1 -0
- package/dist/test/errors.test.d.ts +4 -0
- package/dist/test/errors.test.js +126 -0
- package/dist/test/errors.test.js.map +1 -0
- package/dist/types.d.ts +224 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A2A Commerce Gateway — TypeScript SDK Client.
|
|
4
|
+
*
|
|
5
|
+
* Zero-dependency client using native fetch (Node 18+).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const client = new A2AClient({ apiKey: "ak_pro_..." });
|
|
10
|
+
* const health = await client.health();
|
|
11
|
+
* const balance = await client.getBalance("my-agent");
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.A2AClient = void 0;
|
|
16
|
+
const errors_1 = require("./errors");
|
|
17
|
+
class A2AClient {
|
|
18
|
+
baseUrl;
|
|
19
|
+
apiKey;
|
|
20
|
+
timeout;
|
|
21
|
+
maxRetries;
|
|
22
|
+
retryBaseDelay;
|
|
23
|
+
pricingCacheTtl;
|
|
24
|
+
pricingCache = null;
|
|
25
|
+
pricingCacheTime = 0;
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
this.baseUrl = (options.baseUrl ?? "http://localhost:8000").replace(/\/+$/, "");
|
|
28
|
+
this.apiKey = options.apiKey;
|
|
29
|
+
this.timeout = options.timeout ?? 30_000;
|
|
30
|
+
this.maxRetries = options.maxRetries ?? 3;
|
|
31
|
+
this.retryBaseDelay = options.retryBaseDelay ?? 1_000;
|
|
32
|
+
this.pricingCacheTtl = options.pricingCacheTtl ?? 300_000;
|
|
33
|
+
}
|
|
34
|
+
// ── Internal HTTP ──────────────────────────────────────────────────
|
|
35
|
+
headers() {
|
|
36
|
+
const h = { "Content-Type": "application/json" };
|
|
37
|
+
if (this.apiKey) {
|
|
38
|
+
h["Authorization"] = `Bearer ${this.apiKey}`;
|
|
39
|
+
}
|
|
40
|
+
return h;
|
|
41
|
+
}
|
|
42
|
+
async request(method, path, body) {
|
|
43
|
+
let lastResponse;
|
|
44
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
47
|
+
try {
|
|
48
|
+
const resp = await fetch(`${this.baseUrl}${path}`, {
|
|
49
|
+
method,
|
|
50
|
+
headers: this.headers(),
|
|
51
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
52
|
+
signal: controller.signal,
|
|
53
|
+
});
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
if (!errors_1.RETRYABLE_STATUS_CODES.has(resp.status)) {
|
|
56
|
+
return resp;
|
|
57
|
+
}
|
|
58
|
+
lastResponse = resp;
|
|
59
|
+
if (attempt === this.maxRetries) {
|
|
60
|
+
return resp;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
if (attempt === this.maxRetries) {
|
|
66
|
+
throw new errors_1.A2AError(`Request failed: ${err.message}`, "network_error");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Exponential backoff
|
|
70
|
+
let delay = this.retryBaseDelay * 2 ** attempt;
|
|
71
|
+
// Respect Retry-After header on 429
|
|
72
|
+
if (lastResponse?.status === 429) {
|
|
73
|
+
const retryAfter = lastResponse.headers.get("retry-after");
|
|
74
|
+
if (retryAfter) {
|
|
75
|
+
const parsed = parseFloat(retryAfter);
|
|
76
|
+
if (!isNaN(parsed)) {
|
|
77
|
+
delay = Math.max(delay, parsed * 1000);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
82
|
+
}
|
|
83
|
+
// Should not reach here
|
|
84
|
+
return lastResponse;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Internal helper for REST endpoint calls with auth and error handling.
|
|
88
|
+
*/
|
|
89
|
+
async rest(method, path, options = {}) {
|
|
90
|
+
let url = path;
|
|
91
|
+
if (options.params) {
|
|
92
|
+
const filtered = Object.entries(options.params).filter(([, v]) => v !== undefined && v !== null);
|
|
93
|
+
if (filtered.length > 0) {
|
|
94
|
+
const qs = new URLSearchParams(filtered.map(([k, v]) => [k, String(v)])).toString();
|
|
95
|
+
url = `${path}?${qs}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const resp = await this.request(method, url, options.body);
|
|
99
|
+
const data = await resp.json();
|
|
100
|
+
if (!resp.ok)
|
|
101
|
+
(0, errors_1.raiseForStatus)(resp.status, data);
|
|
102
|
+
return data;
|
|
103
|
+
}
|
|
104
|
+
// ── Core endpoints ─────────────────────────────────────────────────
|
|
105
|
+
/** GET /v1/health */
|
|
106
|
+
async health() {
|
|
107
|
+
const resp = await this.request("GET", "/v1/health");
|
|
108
|
+
if (!resp.ok)
|
|
109
|
+
(0, errors_1.raiseForStatus)(resp.status, await resp.json());
|
|
110
|
+
return (await resp.json());
|
|
111
|
+
}
|
|
112
|
+
/** GET /v1/pricing — full catalog (cached). */
|
|
113
|
+
async pricing(useCache = true) {
|
|
114
|
+
const now = Date.now();
|
|
115
|
+
if (useCache &&
|
|
116
|
+
this.pricingCache !== null &&
|
|
117
|
+
now - this.pricingCacheTime < this.pricingCacheTtl) {
|
|
118
|
+
return this.pricingCache;
|
|
119
|
+
}
|
|
120
|
+
const resp = await this.request("GET", "/v1/pricing");
|
|
121
|
+
if (!resp.ok)
|
|
122
|
+
(0, errors_1.raiseForStatus)(resp.status, await resp.json());
|
|
123
|
+
const data = (await resp.json());
|
|
124
|
+
this.pricingCache = data.tools;
|
|
125
|
+
this.pricingCacheTime = now;
|
|
126
|
+
return data.tools;
|
|
127
|
+
}
|
|
128
|
+
/** GET /v1/pricing/:tool — single tool pricing. */
|
|
129
|
+
async pricingTool(toolName) {
|
|
130
|
+
const resp = await this.request("GET", `/v1/pricing/${toolName}`);
|
|
131
|
+
const body = await resp.json();
|
|
132
|
+
if (!resp.ok)
|
|
133
|
+
(0, errors_1.raiseForStatus)(resp.status, body);
|
|
134
|
+
return body.tool;
|
|
135
|
+
}
|
|
136
|
+
/** POST /v1/execute — execute a tool. */
|
|
137
|
+
async execute(tool, params = {}) {
|
|
138
|
+
const resp = await this.request("POST", "/v1/execute", { tool, params });
|
|
139
|
+
const body = await resp.json();
|
|
140
|
+
if (!resp.ok)
|
|
141
|
+
(0, errors_1.raiseForStatus)(resp.status, body);
|
|
142
|
+
return body;
|
|
143
|
+
}
|
|
144
|
+
/** POST /v1/checkout — create a Stripe Checkout session. */
|
|
145
|
+
async checkout(options) {
|
|
146
|
+
const body = {};
|
|
147
|
+
if (options.package)
|
|
148
|
+
body.package = options.package;
|
|
149
|
+
if (options.credits)
|
|
150
|
+
body.credits = options.credits;
|
|
151
|
+
if (options.successUrl)
|
|
152
|
+
body.success_url = options.successUrl;
|
|
153
|
+
if (options.cancelUrl)
|
|
154
|
+
body.cancel_url = options.cancelUrl;
|
|
155
|
+
const resp = await this.request("POST", "/v1/checkout", body);
|
|
156
|
+
const data = await resp.json();
|
|
157
|
+
if (!resp.ok)
|
|
158
|
+
(0, errors_1.raiseForStatus)(resp.status, data);
|
|
159
|
+
return data.result;
|
|
160
|
+
}
|
|
161
|
+
/** Clear the pricing cache. */
|
|
162
|
+
invalidatePricingCache() {
|
|
163
|
+
this.pricingCache = null;
|
|
164
|
+
this.pricingCacheTime = 0;
|
|
165
|
+
}
|
|
166
|
+
// ── Convenience wrappers ───────────────────────────────────────────
|
|
167
|
+
/** Get wallet balance for an agent. */
|
|
168
|
+
async getBalance(agentId) {
|
|
169
|
+
return this.rest("GET", `/v1/billing/wallets/${agentId}/balance`);
|
|
170
|
+
}
|
|
171
|
+
/** Deposit credits into a wallet. Returns new balance. */
|
|
172
|
+
async deposit(agentId, amount, description = "") {
|
|
173
|
+
const r = await this.rest("POST", `/v1/billing/wallets/${agentId}/deposit`, {
|
|
174
|
+
body: { amount, description },
|
|
175
|
+
});
|
|
176
|
+
return r.new_balance;
|
|
177
|
+
}
|
|
178
|
+
/** Get usage summary for an agent. */
|
|
179
|
+
async getUsageSummary(agentId, since) {
|
|
180
|
+
const params = {};
|
|
181
|
+
if (since !== undefined)
|
|
182
|
+
params.since = since;
|
|
183
|
+
return this.rest("GET", `/v1/billing/wallets/${agentId}/usage`, { params });
|
|
184
|
+
}
|
|
185
|
+
/** Create a payment intent. */
|
|
186
|
+
async createPaymentIntent(payer, payee, amount, description = "", idempotencyKey) {
|
|
187
|
+
// Note: idempotency key should be a header, but we keep it simple here
|
|
188
|
+
return this.rest("POST", "/v1/payments/intents", {
|
|
189
|
+
body: { payer, payee, amount, description },
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/** Capture a pending payment intent. */
|
|
193
|
+
async capturePayment(intentId) {
|
|
194
|
+
return this.rest("POST", `/v1/payments/intents/${intentId}/capture`);
|
|
195
|
+
}
|
|
196
|
+
/** Create an escrow. */
|
|
197
|
+
async createEscrow(payer, payee, amount, description = "", timeoutHours) {
|
|
198
|
+
const body = { payer, payee, amount, description };
|
|
199
|
+
if (timeoutHours !== undefined)
|
|
200
|
+
body.timeout_hours = timeoutHours;
|
|
201
|
+
return this.rest("POST", "/v1/payments/escrows", { body });
|
|
202
|
+
}
|
|
203
|
+
/** Release an escrow to the payee. */
|
|
204
|
+
async releaseEscrow(escrowId) {
|
|
205
|
+
return this.rest("POST", `/v1/payments/escrows/${escrowId}/release`);
|
|
206
|
+
}
|
|
207
|
+
/** Search the marketplace. */
|
|
208
|
+
async searchServices(options = {}) {
|
|
209
|
+
const params = { limit: options.limit ?? 20 };
|
|
210
|
+
if (options.query)
|
|
211
|
+
params.query = options.query;
|
|
212
|
+
if (options.category)
|
|
213
|
+
params.category = options.category;
|
|
214
|
+
if (options.tags)
|
|
215
|
+
params.tags = options.tags.join(",");
|
|
216
|
+
if (options.maxCost !== undefined)
|
|
217
|
+
params.max_cost = options.maxCost;
|
|
218
|
+
const r = await this.rest("GET", "/v1/marketplace/services", { params });
|
|
219
|
+
return r.services;
|
|
220
|
+
}
|
|
221
|
+
/** Find best matching services. */
|
|
222
|
+
async bestMatch(query, options = {}) {
|
|
223
|
+
const params = {
|
|
224
|
+
query,
|
|
225
|
+
prefer: options.prefer ?? "trust",
|
|
226
|
+
limit: options.limit ?? 5,
|
|
227
|
+
};
|
|
228
|
+
if (options.budget !== undefined)
|
|
229
|
+
params.budget = options.budget;
|
|
230
|
+
if (options.minTrustScore !== undefined)
|
|
231
|
+
params.min_trust_score = options.minTrustScore;
|
|
232
|
+
const r = await this.rest("GET", "/v1/marketplace/match", { params });
|
|
233
|
+
return r.matches;
|
|
234
|
+
}
|
|
235
|
+
/** Get trust score for a server. */
|
|
236
|
+
async getTrustScore(serverId, window = "24h", recompute = false) {
|
|
237
|
+
const params = { window };
|
|
238
|
+
if (recompute)
|
|
239
|
+
params.recompute = "true";
|
|
240
|
+
return this.rest("GET", `/v1/trust/servers/${serverId}/score`, { params });
|
|
241
|
+
}
|
|
242
|
+
/** Get payment history for an agent. */
|
|
243
|
+
async getPaymentHistory(agentId, limit = 100, offset = 0) {
|
|
244
|
+
return this.rest("GET", "/v1/payments/history", {
|
|
245
|
+
params: { agent_id: agentId, limit, offset },
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/** Register a new agent identity. */
|
|
249
|
+
async registerAgent(agentId, displayName, capabilities = []) {
|
|
250
|
+
return this.rest("POST", "/v1/identity/agents", {
|
|
251
|
+
body: { agent_id: agentId, display_name: displayName, capabilities },
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Send a message between agents. */
|
|
255
|
+
async sendMessage(sender, recipient, content, messageType = "text") {
|
|
256
|
+
return this.rest("POST", "/v1/messaging/messages", {
|
|
257
|
+
body: { sender, recipient, body: content, message_type: messageType },
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
// ── Payment convenience methods ───────────────────────────────────
|
|
261
|
+
/** Cancel a held escrow and refund the payer. */
|
|
262
|
+
async cancelEscrow(escrowId) {
|
|
263
|
+
return this.rest("POST", `/v1/payments/escrows/${escrowId}/cancel`);
|
|
264
|
+
}
|
|
265
|
+
/** Refund a settled payment (full or partial). */
|
|
266
|
+
async refundSettlement(settlementId, options = {}) {
|
|
267
|
+
const body = {};
|
|
268
|
+
if (options.amount !== undefined)
|
|
269
|
+
body.amount = options.amount;
|
|
270
|
+
if (options.reason !== undefined)
|
|
271
|
+
body.reason = options.reason;
|
|
272
|
+
return this.rest("POST", `/v1/payments/settlements/${settlementId}/refund`, { body });
|
|
273
|
+
}
|
|
274
|
+
/** Refund a payment intent: voids if pending, reverse-transfers if settled. */
|
|
275
|
+
async refundIntent(intentId) {
|
|
276
|
+
return this.rest("POST", `/v1/payments/intents/${intentId}/refund`);
|
|
277
|
+
}
|
|
278
|
+
/** Void a pending payment (alias for refundIntent). */
|
|
279
|
+
async voidPayment(intentId) {
|
|
280
|
+
return this.refundIntent(intentId);
|
|
281
|
+
}
|
|
282
|
+
/** Create a recurring payment subscription. */
|
|
283
|
+
async createSubscription(payer, payee, amount, interval, options = {}) {
|
|
284
|
+
const body = { payer, payee, amount, interval };
|
|
285
|
+
if (options.description !== undefined)
|
|
286
|
+
body.description = options.description;
|
|
287
|
+
return this.rest("POST", "/v1/payments/subscriptions", { body });
|
|
288
|
+
}
|
|
289
|
+
/** Cancel an active or suspended subscription. */
|
|
290
|
+
async cancelSubscription(subscriptionId, options = {}) {
|
|
291
|
+
const body = {};
|
|
292
|
+
if (options.cancelledBy !== undefined)
|
|
293
|
+
body.cancelled_by = options.cancelledBy;
|
|
294
|
+
return this.rest("POST", `/v1/payments/subscriptions/${subscriptionId}/cancel`, { body });
|
|
295
|
+
}
|
|
296
|
+
/** Get subscription details by ID. */
|
|
297
|
+
async getSubscription(subscriptionId) {
|
|
298
|
+
return this.rest("GET", `/v1/payments/subscriptions/${subscriptionId}`);
|
|
299
|
+
}
|
|
300
|
+
/** List subscriptions for an agent. */
|
|
301
|
+
async listSubscriptions(options = {}) {
|
|
302
|
+
return this.rest("GET", "/v1/payments/subscriptions", {
|
|
303
|
+
params: {
|
|
304
|
+
agent_id: options.agentId,
|
|
305
|
+
status: options.status,
|
|
306
|
+
limit: options.limit,
|
|
307
|
+
offset: options.offset,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// ── Marketplace convenience methods ───────────────────────────────
|
|
312
|
+
/** Register a new service in the marketplace. */
|
|
313
|
+
async registerService(options) {
|
|
314
|
+
const body = {
|
|
315
|
+
provider_id: options.providerId,
|
|
316
|
+
name: options.name,
|
|
317
|
+
description: options.description,
|
|
318
|
+
category: options.category,
|
|
319
|
+
};
|
|
320
|
+
if (options.tools !== undefined)
|
|
321
|
+
body.tools = options.tools;
|
|
322
|
+
if (options.tags !== undefined)
|
|
323
|
+
body.tags = options.tags;
|
|
324
|
+
if (options.endpoint !== undefined)
|
|
325
|
+
body.endpoint = options.endpoint;
|
|
326
|
+
if (options.pricing !== undefined)
|
|
327
|
+
body.pricing = options.pricing;
|
|
328
|
+
return this.rest("POST", "/v1/marketplace/services", { body });
|
|
329
|
+
}
|
|
330
|
+
/** Get a marketplace service by ID. */
|
|
331
|
+
async getService(serviceId) {
|
|
332
|
+
return this.rest("GET", `/v1/marketplace/services/${serviceId}`);
|
|
333
|
+
}
|
|
334
|
+
/** Rate a marketplace service (1-5). */
|
|
335
|
+
async rateService(serviceId, agentId, rating, options = {}) {
|
|
336
|
+
const body = { agent_id: agentId, rating };
|
|
337
|
+
if (options.review !== undefined)
|
|
338
|
+
body.review = options.review;
|
|
339
|
+
return this.rest("POST", `/v1/marketplace/services/${serviceId}/ratings`, { body });
|
|
340
|
+
}
|
|
341
|
+
// ── Trust convenience methods ─────────────────────────────────────
|
|
342
|
+
/** Search for servers by name or minimum trust score. */
|
|
343
|
+
async searchServers(options = {}) {
|
|
344
|
+
return this.rest("GET", "/v1/trust/servers", {
|
|
345
|
+
params: {
|
|
346
|
+
name_contains: options.nameContains,
|
|
347
|
+
min_score: options.minScore,
|
|
348
|
+
limit: options.limit,
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// ── Identity convenience methods ──────────────────────────────────
|
|
353
|
+
/** Get the cryptographic identity for an agent. */
|
|
354
|
+
async getAgentIdentity(agentId) {
|
|
355
|
+
return this.rest("GET", `/v1/identity/agents/${agentId}`);
|
|
356
|
+
}
|
|
357
|
+
/** Verify that a message was signed by the claimed agent. */
|
|
358
|
+
async verifyAgent(agentId, message, signature) {
|
|
359
|
+
return this.rest("POST", `/v1/identity/agents/${agentId}/verify`, {
|
|
360
|
+
body: { message, signature },
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/** Submit trading bot metrics for platform attestation. */
|
|
364
|
+
async submitMetrics(agentId, metrics, options = {}) {
|
|
365
|
+
const body = { metrics };
|
|
366
|
+
if (options.dataSource !== undefined)
|
|
367
|
+
body.data_source = options.dataSource;
|
|
368
|
+
return this.rest("POST", `/v1/identity/agents/${agentId}/metrics`, { body });
|
|
369
|
+
}
|
|
370
|
+
/** Get all verified metric claims for an agent. */
|
|
371
|
+
async getVerifiedClaims(agentId) {
|
|
372
|
+
return this.rest("GET", `/v1/identity/agents/${agentId}/claims`);
|
|
373
|
+
}
|
|
374
|
+
// ── Webhook convenience methods ───────────────────────────────────
|
|
375
|
+
/** Register a webhook endpoint. */
|
|
376
|
+
async registerWebhook(options) {
|
|
377
|
+
const body = {
|
|
378
|
+
url: options.url,
|
|
379
|
+
event_types: options.eventTypes,
|
|
380
|
+
};
|
|
381
|
+
if (options.secret !== undefined)
|
|
382
|
+
body.secret = options.secret;
|
|
383
|
+
if (options.filterAgentIds !== undefined)
|
|
384
|
+
body.filter_agent_ids = options.filterAgentIds;
|
|
385
|
+
return this.rest("POST", "/v1/infra/webhooks", { body });
|
|
386
|
+
}
|
|
387
|
+
/** List all registered webhooks for an agent. */
|
|
388
|
+
async listWebhooks(agentId) {
|
|
389
|
+
return this.rest("GET", "/v1/infra/webhooks");
|
|
390
|
+
}
|
|
391
|
+
/** Delete (deactivate) a webhook by ID. */
|
|
392
|
+
async deleteWebhook(webhookId) {
|
|
393
|
+
return this.rest("DELETE", `/v1/infra/webhooks/${webhookId}`);
|
|
394
|
+
}
|
|
395
|
+
// ── API key convenience methods ───────────────────────────────────
|
|
396
|
+
/** Create a new API key for an agent. */
|
|
397
|
+
async createApiKey(agentId, options = {}) {
|
|
398
|
+
const body = {};
|
|
399
|
+
if (options.tier !== undefined)
|
|
400
|
+
body.tier = options.tier;
|
|
401
|
+
return this.rest("POST", "/v1/infra/keys", { body });
|
|
402
|
+
}
|
|
403
|
+
/** Rotate an API key: revoke current and create new with same tier. */
|
|
404
|
+
async rotateKey(currentKey) {
|
|
405
|
+
return this.rest("POST", "/v1/infra/keys/rotate", {
|
|
406
|
+
body: { current_key: currentKey },
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
// ── Event convenience methods ─────────────────────────────────────
|
|
410
|
+
/** Publish an event to the cross-product event bus. */
|
|
411
|
+
async publishEvent(eventType, source, payload = {}) {
|
|
412
|
+
return this.rest("POST", "/v1/infra/events", {
|
|
413
|
+
body: { event_type: eventType, source, payload },
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/** Query events from the event bus. */
|
|
417
|
+
async getEvents(options = {}) {
|
|
418
|
+
return this.rest("GET", "/v1/infra/events", {
|
|
419
|
+
params: {
|
|
420
|
+
event_type: options.eventType,
|
|
421
|
+
since_id: options.sinceId,
|
|
422
|
+
limit: options.limit,
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
// ── Org convenience methods ───────────────────────────────────────
|
|
427
|
+
/** Create a new organization. */
|
|
428
|
+
async createOrg(orgName) {
|
|
429
|
+
return this.rest("POST", "/v1/identity/orgs", { body: { org_name: orgName } });
|
|
430
|
+
}
|
|
431
|
+
/** Get organization details and members. */
|
|
432
|
+
async getOrg(orgId) {
|
|
433
|
+
return this.rest("GET", `/v1/identity/orgs/${orgId}`);
|
|
434
|
+
}
|
|
435
|
+
/** Add an agent to an organization. */
|
|
436
|
+
async addAgentToOrg(orgId, agentId) {
|
|
437
|
+
return this.rest("POST", `/v1/identity/orgs/${orgId}/members`, {
|
|
438
|
+
body: { agent_id: agentId },
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/** Get organization members (convenience alias for getOrg). */
|
|
442
|
+
async getOrgMembers(orgId) {
|
|
443
|
+
return this.getOrg(orgId);
|
|
444
|
+
}
|
|
445
|
+
// ── Messaging convenience methods ─────────────────────────────────
|
|
446
|
+
/** Start a price negotiation with another agent. */
|
|
447
|
+
async negotiatePrice(options) {
|
|
448
|
+
const body = {
|
|
449
|
+
initiator: options.initiator,
|
|
450
|
+
responder: options.responder,
|
|
451
|
+
amount: options.amount,
|
|
452
|
+
};
|
|
453
|
+
if (options.serviceId !== undefined)
|
|
454
|
+
body.service_id = options.serviceId;
|
|
455
|
+
if (options.expiresHours !== undefined)
|
|
456
|
+
body.expires_hours = options.expiresHours;
|
|
457
|
+
return this.rest("POST", "/v1/messaging/negotiations", { body });
|
|
458
|
+
}
|
|
459
|
+
/** Get messages for an agent. */
|
|
460
|
+
async getMessages(agentId, options = {}) {
|
|
461
|
+
return this.rest("GET", "/v1/messaging/messages", {
|
|
462
|
+
params: { agent_id: agentId, thread_id: options.threadId, limit: options.limit },
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
exports.A2AClient = A2AClient;
|
|
467
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,qCAIkB;AAuClB,MAAa,SAAS;IACH,OAAO,CAAS;IAChB,MAAM,CAAqB;IAC3B,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,cAAc,CAAS;IACvB,eAAe,CAAS;IAEjC,YAAY,GAAyB,IAAI,CAAC;IAC1C,gBAAgB,GAAG,CAAC,CAAC;IAE7B,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,uBAAuB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC;IAC5D,CAAC;IAED,sEAAsE;IAE9D,OAAO;QACb,MAAM,CAAC,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;QACzE,IAAI,IAAI,CAAC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AI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,WAAW,CACf,OAAe,EACf,UAAiD,EAAE;QAEnD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,wBAAwB,EAAE;YAChD,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE;SACjF,CAAC,CAAC;IACL,CAAC;CACF;AAzmBD,8BAymBC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Typed exceptions mapped from HTTP status codes. */
|
|
2
|
+
export declare class A2AError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
constructor(message: string, code?: string, status?: number);
|
|
6
|
+
}
|
|
7
|
+
export declare class AuthenticationError extends A2AError {
|
|
8
|
+
constructor(message: string, code?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class InsufficientBalanceError extends A2AError {
|
|
11
|
+
constructor(message: string, code?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class InsufficientTierError extends A2AError {
|
|
14
|
+
constructor(message: string, code?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class ToolNotFoundError extends A2AError {
|
|
17
|
+
constructor(message: string, code?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class RateLimitError extends A2AError {
|
|
20
|
+
constructor(message: string, code?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class ServerError extends A2AError {
|
|
23
|
+
constructor(message: string, code?: string, status?: number);
|
|
24
|
+
}
|
|
25
|
+
/** Status codes that are safe to retry. */
|
|
26
|
+
export declare const RETRYABLE_STATUS_CODES: Set<number>;
|
|
27
|
+
/** Throw the appropriate error for an HTTP error response.
|
|
28
|
+
*
|
|
29
|
+
* Supports both legacy execute format `{error: {message, code}}`
|
|
30
|
+
* and RFC 9457 format `{type, title, status, detail}`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function raiseForStatus(status: number, body: Record<string, any>): never;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Typed exceptions mapped from HTTP status codes. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RETRYABLE_STATUS_CODES = exports.ServerError = exports.RateLimitError = exports.ToolNotFoundError = exports.InsufficientTierError = exports.InsufficientBalanceError = exports.AuthenticationError = exports.A2AError = void 0;
|
|
5
|
+
exports.raiseForStatus = raiseForStatus;
|
|
6
|
+
class A2AError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
status;
|
|
9
|
+
constructor(message, code = "error", status = 0) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "A2AError";
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.status = status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.A2AError = A2AError;
|
|
17
|
+
class AuthenticationError extends A2AError {
|
|
18
|
+
constructor(message, code = "invalid_key") {
|
|
19
|
+
super(message, code, 401);
|
|
20
|
+
this.name = "AuthenticationError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.AuthenticationError = AuthenticationError;
|
|
24
|
+
class InsufficientBalanceError extends A2AError {
|
|
25
|
+
constructor(message, code = "insufficient_balance") {
|
|
26
|
+
super(message, code, 402);
|
|
27
|
+
this.name = "InsufficientBalanceError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.InsufficientBalanceError = InsufficientBalanceError;
|
|
31
|
+
class InsufficientTierError extends A2AError {
|
|
32
|
+
constructor(message, code = "insufficient_tier") {
|
|
33
|
+
super(message, code, 403);
|
|
34
|
+
this.name = "InsufficientTierError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.InsufficientTierError = InsufficientTierError;
|
|
38
|
+
class ToolNotFoundError extends A2AError {
|
|
39
|
+
constructor(message, code = "unknown_tool") {
|
|
40
|
+
super(message, code, 404);
|
|
41
|
+
this.name = "ToolNotFoundError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ToolNotFoundError = ToolNotFoundError;
|
|
45
|
+
class RateLimitError extends A2AError {
|
|
46
|
+
constructor(message, code = "rate_limit_exceeded") {
|
|
47
|
+
super(message, code, 429);
|
|
48
|
+
this.name = "RateLimitError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.RateLimitError = RateLimitError;
|
|
52
|
+
class ServerError extends A2AError {
|
|
53
|
+
constructor(message, code = "internal_error", status = 500) {
|
|
54
|
+
super(message, code, status);
|
|
55
|
+
this.name = "ServerError";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ServerError = ServerError;
|
|
59
|
+
/** Status codes that are safe to retry. */
|
|
60
|
+
exports.RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
|
|
61
|
+
const STATUS_MAP = {
|
|
62
|
+
400: ToolNotFoundError,
|
|
63
|
+
401: AuthenticationError,
|
|
64
|
+
402: InsufficientBalanceError,
|
|
65
|
+
403: InsufficientTierError,
|
|
66
|
+
404: ToolNotFoundError,
|
|
67
|
+
429: RateLimitError,
|
|
68
|
+
};
|
|
69
|
+
/** Throw the appropriate error for an HTTP error response.
|
|
70
|
+
*
|
|
71
|
+
* Supports both legacy execute format `{error: {message, code}}`
|
|
72
|
+
* and RFC 9457 format `{type, title, status, detail}`.
|
|
73
|
+
*/
|
|
74
|
+
function raiseForStatus(status, body) {
|
|
75
|
+
let message;
|
|
76
|
+
let code;
|
|
77
|
+
if (body.detail !== undefined && body.type !== undefined) {
|
|
78
|
+
// RFC 9457 format (REST endpoints)
|
|
79
|
+
message = body.detail ?? "Unknown error";
|
|
80
|
+
const typeUrl = body.type ?? "";
|
|
81
|
+
code = typeUrl.includes("/") ? typeUrl.split("/").pop() : "error";
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Legacy execute format
|
|
85
|
+
const error = body.error ?? {};
|
|
86
|
+
message = error.message ?? body.detail ?? "Unknown error";
|
|
87
|
+
code = error.code ?? "error";
|
|
88
|
+
}
|
|
89
|
+
const ErrorClass = STATUS_MAP[status] ?? ServerError;
|
|
90
|
+
throw new ErrorClass(message, code);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;AAyEtD,wCAkBC;AAzFD,MAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,CAAC;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAVD,4BAUC;AAED,MAAa,mBAAoB,SAAQ,QAAQ;IAC/C,YAAY,OAAe,EAAE,IAAI,GAAG,aAAa;QAC/C,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAED,MAAa,wBAAyB,SAAQ,QAAQ;IACpD,YAAY,OAAe,EAAE,IAAI,GAAG,sBAAsB;QACxD,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,4DAKC;AAED,MAAa,qBAAsB,SAAQ,QAAQ;IACjD,YAAY,OAAe,EAAE,IAAI,GAAG,mBAAmB;QACrD,KAAK,CAAC,OAAO,EAAE,IAA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KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzD,mCAAmC;QACnC,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC;QACzC,MAAM,OAAO,GAAW,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QACxC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,CAAC,CAAC,OAAO,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,wBAAwB;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC;QAC1D,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC;IACrD,MAAM,IAAI,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @a2a/sdk — TypeScript SDK for the A2A Commerce Gateway. */
|
|
2
|
+
export { A2AClient } from "./client";
|
|
3
|
+
export { A2AError, AuthenticationError, InsufficientBalanceError, InsufficientTierError, ToolNotFoundError, RateLimitError, ServerError, } from "./errors";
|
|
4
|
+
export type { A2AClientOptions, AgentIdentityResponse, ApiKeyResponse, BalanceResponse, CheckoutResult, Escrow, EscrowResponse, EventListResponse, EventPublishResponse, EventRecord, ExecuteResponse, HealthResponse, KeyRotationResponse, MessageListResponse, MetricsSubmissionResponse, NegotiationResponse, OrgDetailResponse, OrgMemberResponse, OrgResponse, PaymentHistoryResponse, PaymentIntent, RefundResponse, ServerSearchResponse, ServerSearchResult, ServiceDetailResponse, ServiceRatingResponse, ServiceRegistrationResponse, SubscriptionDetailResponse, SubscriptionListResponse, SubscriptionResponse, ToolPricing, TrustScore, UsageSummaryResponse, VerifiedClaim, VerifiedClaimsResponse, VerifyAgentResponse, WebhookDeleteResponse, WebhookListResponse, WebhookResponse, } from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @a2a/sdk — TypeScript SDK for the A2A Commerce Gateway. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ServerError = exports.RateLimitError = exports.ToolNotFoundError = exports.InsufficientTierError = exports.InsufficientBalanceError = exports.AuthenticationError = exports.A2AError = exports.A2AClient = void 0;
|
|
5
|
+
var client_1 = require("./client");
|
|
6
|
+
Object.defineProperty(exports, "A2AClient", { enumerable: true, get: function () { return client_1.A2AClient; } });
|
|
7
|
+
var errors_1 = require("./errors");
|
|
8
|
+
Object.defineProperty(exports, "A2AError", { enumerable: true, get: function () { return errors_1.A2AError; } });
|
|
9
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
|
|
10
|
+
Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return errors_1.InsufficientBalanceError; } });
|
|
11
|
+
Object.defineProperty(exports, "InsufficientTierError", { enumerable: true, get: function () { return errors_1.InsufficientTierError; } });
|
|
12
|
+
Object.defineProperty(exports, "ToolNotFoundError", { enumerable: true, get: function () { return errors_1.ToolNotFoundError; } });
|
|
13
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
14
|
+
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return errors_1.ServerError; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAClB,mCAQkB;AAPhB,kGAAA,QAAQ,OAAA;AACR,6GAAA,mBAAmB,OAAA;AACnB,kHAAA,wBAAwB,OAAA;AACxB,+GAAA,qBAAqB,OAAA;AACrB,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AACd,qGAAA,WAAW,OAAA"}
|