@sly_ai/sdk 0.1.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/README.md +346 -0
- package/dist/a2a.d.mts +108 -0
- package/dist/a2a.d.ts +108 -0
- package/dist/a2a.js +173 -0
- package/dist/a2a.js.map +1 -0
- package/dist/a2a.mjs +171 -0
- package/dist/a2a.mjs.map +1 -0
- package/dist/acp.d.mts +201 -0
- package/dist/acp.d.ts +201 -0
- package/dist/acp.js +143 -0
- package/dist/acp.js.map +1 -0
- package/dist/acp.mjs +141 -0
- package/dist/acp.mjs.map +1 -0
- package/dist/ap2.d.mts +188 -0
- package/dist/ap2.d.ts +188 -0
- package/dist/ap2.js +135 -0
- package/dist/ap2.js.map +1 -0
- package/dist/ap2.mjs +133 -0
- package/dist/ap2.mjs.map +1 -0
- package/dist/cards.d.mts +750 -0
- package/dist/cards.d.ts +750 -0
- package/dist/cards.js +373 -0
- package/dist/cards.js.map +1 -0
- package/dist/cards.mjs +369 -0
- package/dist/cards.mjs.map +1 -0
- package/dist/client-Cwe2CLU7.d.mts +41 -0
- package/dist/client-CyJe3uWO.d.ts +41 -0
- package/dist/index.d.mts +662 -0
- package/dist/index.d.ts +662 -0
- package/dist/index.js +2709 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2700 -0
- package/dist/index.mjs.map +1 -0
- package/dist/langchain.d.mts +11 -0
- package/dist/langchain.d.ts +11 -0
- package/dist/langchain.js +25 -0
- package/dist/langchain.js.map +1 -0
- package/dist/langchain.mjs +23 -0
- package/dist/langchain.mjs.map +1 -0
- package/dist/types-df1EICn_.d.mts +165 -0
- package/dist/types-df1EICn_.d.ts +165 -0
- package/dist/ucp.d.mts +844 -0
- package/dist/ucp.d.ts +844 -0
- package/dist/ucp.js +616 -0
- package/dist/ucp.js.map +1 -0
- package/dist/ucp.mjs +614 -0
- package/dist/ucp.mjs.map +1 -0
- package/dist/vercel.d.mts +178 -0
- package/dist/vercel.d.ts +178 -0
- package/dist/vercel.js +143 -0
- package/dist/vercel.js.map +1 -0
- package/dist/vercel.mjs +138 -0
- package/dist/vercel.mjs.map +1 -0
- package/dist/x402.d.mts +209 -0
- package/dist/x402.d.ts +209 -0
- package/dist/x402.js +476 -0
- package/dist/x402.js.map +1 -0
- package/dist/x402.mjs +471 -0
- package/dist/x402.mjs.map +1 -0
- package/package.json +118 -0
package/README.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# @sly/sdk
|
|
2
|
+
|
|
3
|
+
Unified SDK for PayOS multi-protocol settlement infrastructure in LATAM.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
PayOS SDK provides a single, unified interface for settling payments across multiple protocols and local rails. Whether you're building with x402 micropayments, Google's AP2 mandates, or Stripe's ACP checkout, PayOS completes the last mile: **USDC โ BRL/MXN via Pix/SPEI**.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ๐ **Multi-Protocol Support**: x402, AP2, ACP, and direct API
|
|
12
|
+
- ๐งช **Sandbox Mode**: Test without blockchain, gas fees, or real USDC
|
|
13
|
+
- ๐ **LATAM Rails**: Native Pix (Brazil) and SPEI (Mexico) integration
|
|
14
|
+
- ๐ค **AI-Ready**: Built for AI agents with tool discovery
|
|
15
|
+
- ๐ฆ **TypeScript**: Full type safety with comprehensive types
|
|
16
|
+
- ๐ณ **Tree-Shakeable**: Import only what you need
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @sly/sdk
|
|
22
|
+
# or
|
|
23
|
+
pnpm add @sly/sdk
|
|
24
|
+
# or
|
|
25
|
+
yarn add @sly/sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Sandbox Mode (No Blockchain)
|
|
31
|
+
|
|
32
|
+
Perfect for local development:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { PayOS } from '@sly/sdk';
|
|
36
|
+
|
|
37
|
+
const payos = new PayOS({
|
|
38
|
+
apiKey: 'payos_...',
|
|
39
|
+
environment: 'sandbox', // No EVM key needed!
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Get a settlement quote
|
|
43
|
+
const quote = await payos.getSettlementQuote({
|
|
44
|
+
fromCurrency: 'USD',
|
|
45
|
+
toCurrency: 'BRL',
|
|
46
|
+
amount: '100.00',
|
|
47
|
+
rail: 'pix',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Create settlement
|
|
51
|
+
const settlement = await payos.createSettlement({
|
|
52
|
+
quoteId: quote.id,
|
|
53
|
+
destinationAccountId: 'acc_...',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Create x402 client
|
|
57
|
+
const client = payos.x402.createClient();
|
|
58
|
+
const response = await client.fetch('https://api.example.com/premium');
|
|
59
|
+
|
|
60
|
+
// Create x402 provider
|
|
61
|
+
const provider = payos.x402.createProvider({
|
|
62
|
+
'GET /api/premium': { price: '0.01', description: 'Premium content' },
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Production Mode
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const payos = new PayOS({
|
|
70
|
+
apiKey: 'payos_...',
|
|
71
|
+
environment: 'production',
|
|
72
|
+
evmPrivateKey: '0x...', // Required for x402 on mainnet
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Protocol Modules
|
|
77
|
+
|
|
78
|
+
### x402 (Micropayments)
|
|
79
|
+
|
|
80
|
+
Coming in Story 36.3/36.4 - Client and Provider implementations
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { PayOS } from '@sly/sdk';
|
|
84
|
+
|
|
85
|
+
// Client: Make x402 payments
|
|
86
|
+
const client = payos.x402.createClient({ maxPayment: '$0.01' });
|
|
87
|
+
const response = await client.fetch('https://api.example.com/premium');
|
|
88
|
+
|
|
89
|
+
// Provider: Accept x402 payments
|
|
90
|
+
const provider = payos.x402.createProvider({
|
|
91
|
+
routes: {
|
|
92
|
+
'GET /api/premium': { price: '$0.001' },
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
app.use(provider.middleware());
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### AP2 (Agent Mandates)
|
|
99
|
+
|
|
100
|
+
Coming in Story 36.5 - Google Agent-to-Agent Protocol
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Verify and execute mandate
|
|
104
|
+
const mandate = await payos.ap2.verifyMandate(token);
|
|
105
|
+
const result = await payos.ap2.executePayment({
|
|
106
|
+
mandateId: mandate.id,
|
|
107
|
+
amount: '100.00',
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### ACP (Checkout)
|
|
112
|
+
|
|
113
|
+
Coming in Story 36.6 - Stripe/OpenAI Agentic Commerce Protocol
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// Create checkout session
|
|
117
|
+
const checkout = await payos.acp.createCheckout({
|
|
118
|
+
cartItems: [...],
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Complete with SharedPaymentToken
|
|
122
|
+
await payos.acp.completeCheckout({
|
|
123
|
+
checkoutId: checkout.id,
|
|
124
|
+
paymentToken: 'spt_...',
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Card Networks (Visa VIC & Mastercard Agent Pay)
|
|
129
|
+
|
|
130
|
+
Accept payments from AI agents using Web Bot Auth signature verification:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { PayOS } from '@sly/sdk';
|
|
134
|
+
|
|
135
|
+
const payos = new PayOS({
|
|
136
|
+
apiKey: 'pk_live_...',
|
|
137
|
+
environment: 'production',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Verify incoming agent signature
|
|
141
|
+
const result = await payos.cards.verifyAgentSignature({
|
|
142
|
+
method: request.method,
|
|
143
|
+
path: request.path,
|
|
144
|
+
headers: request.headers,
|
|
145
|
+
signatureInput: request.headers['signature-input'],
|
|
146
|
+
signature: request.headers['signature'],
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (result.valid) {
|
|
150
|
+
console.log(`Verified ${result.network} agent from ${result.agentProvider}`);
|
|
151
|
+
// Process payment...
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Check network configuration
|
|
155
|
+
const { networks, capabilities } = await payos.cards.getNetworks();
|
|
156
|
+
console.log(`Visa: ${networks.visa.status}, MC: ${networks.mastercard.status}`);
|
|
157
|
+
|
|
158
|
+
// Get analytics
|
|
159
|
+
const analytics = await payos.cards.getAnalytics(30);
|
|
160
|
+
console.log(`${analytics.verifications.total} verifications, ${analytics.verifications.successRate}% success`);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Visa VIC Operations
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// Create a payment instruction
|
|
167
|
+
const instruction = await payos.cards.visa.createInstruction({
|
|
168
|
+
amount: 100.00,
|
|
169
|
+
currency: 'USD',
|
|
170
|
+
merchant: {
|
|
171
|
+
name: 'My Store',
|
|
172
|
+
categoryCode: '5411',
|
|
173
|
+
country: 'US',
|
|
174
|
+
},
|
|
175
|
+
expiresInSeconds: 900,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Provision a VTS token
|
|
179
|
+
const token = await payos.cards.visa.createToken({
|
|
180
|
+
instructionId: instruction.instructionId,
|
|
181
|
+
cardToken: 'tok_visa_...',
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// List tokens
|
|
185
|
+
const { data: tokens } = await payos.cards.visa.listTokens();
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Mastercard Agent Pay Operations
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Register an agent with Mastercard
|
|
192
|
+
const registration = await payos.cards.mastercard.registerAgent({
|
|
193
|
+
agentId: 'agent_123',
|
|
194
|
+
publicKey: '-----BEGIN PUBLIC KEY-----...',
|
|
195
|
+
capabilities: ['payment', 'tokenization'],
|
|
196
|
+
provider: 'anthropic',
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Create an agentic token with DTVC
|
|
200
|
+
const token = await payos.cards.mastercard.createToken({
|
|
201
|
+
agentId: 'agent_123',
|
|
202
|
+
cardToken: 'tok_mc_...',
|
|
203
|
+
expiresInSeconds: 3600,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Get token with fresh DTVC
|
|
207
|
+
const refreshed = await payos.cards.mastercard.getToken(token.tokenReference, {
|
|
208
|
+
refresh: true,
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Environment Configuration
|
|
213
|
+
|
|
214
|
+
| Environment | API URL | x402 Facilitator | Use Case |
|
|
215
|
+
|-------------|---------|------------------|----------|
|
|
216
|
+
| `sandbox` | `localhost:4000` | PayOS mock | Local dev, no blockchain |
|
|
217
|
+
| `testnet` | `api.sandbox.payos.ai` | x402.org (Base Sepolia) | Integration testing |
|
|
218
|
+
| `production` | `api.payos.ai` | Coinbase CDP (Base) | Live payments |
|
|
219
|
+
|
|
220
|
+
## API Methods
|
|
221
|
+
|
|
222
|
+
### Settlements
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// Get quote
|
|
226
|
+
const quote = await payos.getSettlementQuote({
|
|
227
|
+
fromCurrency: 'USD',
|
|
228
|
+
toCurrency: 'BRL',
|
|
229
|
+
amount: '100.00',
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Create settlement
|
|
233
|
+
const settlement = await payos.createSettlement({
|
|
234
|
+
quoteId: quote.id,
|
|
235
|
+
destinationAccountId: 'acc_...',
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Check status
|
|
239
|
+
const status = await payos.getSettlement(settlement.id);
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Compliance
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
const check = await payos.checkCompliance({
|
|
246
|
+
recipientAccountId: 'acc_...',
|
|
247
|
+
amount: '100.00',
|
|
248
|
+
currency: 'USD',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (!check.approved) {
|
|
252
|
+
console.log('Compliance flags:', check.flags);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Capabilities (Tool Discovery)
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
const capabilities = await payos.getCapabilities();
|
|
260
|
+
console.log('Supported operations:', capabilities.capabilities);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## TypeScript Support
|
|
264
|
+
|
|
265
|
+
Full type definitions included:
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import type {
|
|
269
|
+
PayOSConfig,
|
|
270
|
+
Settlement,
|
|
271
|
+
SettlementQuote,
|
|
272
|
+
Currency,
|
|
273
|
+
SettlementRail,
|
|
274
|
+
} from '@sly/sdk';
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Sandbox Facilitator
|
|
278
|
+
|
|
279
|
+
The Sandbox Facilitator enables local x402 testing without blockchain:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { SandboxFacilitator } from '@sly/sdk/facilitator';
|
|
283
|
+
|
|
284
|
+
const facilitator = new SandboxFacilitator({
|
|
285
|
+
apiUrl: 'http://localhost:4000',
|
|
286
|
+
apiKey: 'payos_...',
|
|
287
|
+
settlementDelayMs: 100, // Optional: simulate delay
|
|
288
|
+
failureRate: 5, // Optional: 5% random failures
|
|
289
|
+
debug: true, // Optional: enable logging
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Verify payment
|
|
293
|
+
const verification = await facilitator.verify({ payment });
|
|
294
|
+
|
|
295
|
+
// Settle payment
|
|
296
|
+
const settlement = await facilitator.settle({ payment });
|
|
297
|
+
console.log('Transaction hash:', settlement.transactionHash);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Express Integration
|
|
301
|
+
|
|
302
|
+
Mount as API endpoints:
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
import express from 'express';
|
|
306
|
+
import { createSandboxFacilitatorRouter } from '@sly/sdk/facilitator';
|
|
307
|
+
|
|
308
|
+
const app = express();
|
|
309
|
+
app.use(express.json());
|
|
310
|
+
|
|
311
|
+
const facilitator = createSandboxFacilitatorRouter({
|
|
312
|
+
apiUrl: 'http://localhost:4000',
|
|
313
|
+
apiKey: 'payos_...',
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
app.use('/v1/x402/facilitator', facilitator);
|
|
317
|
+
app.listen(4000);
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Now x402 clients can use `http://localhost:4000/v1/x402/facilitator` as the facilitator URL.
|
|
321
|
+
|
|
322
|
+
## Development Status
|
|
323
|
+
|
|
324
|
+
This SDK is under active development as part of Epic 36:
|
|
325
|
+
|
|
326
|
+
- โ
Story 36.1: Package structure (Complete)
|
|
327
|
+
- โ
Story 36.2: Sandbox facilitator (Complete)
|
|
328
|
+
- โ
Story 36.3: x402 Client (Complete)
|
|
329
|
+
- โ
Story 36.4: x402 Provider (Complete)
|
|
330
|
+
- โ
Story 36.7: Main PayOS class (Complete)
|
|
331
|
+
- โ
Story 36.8: Facilitator API endpoints (Complete)
|
|
332
|
+
- ๐ง Story 36.9: Capabilities API (Next)
|
|
333
|
+
- ๐ง Story 36.10: Function-calling format (Pending)
|
|
334
|
+
- ๐ง Story 36.11: MCP Server (Pending)
|
|
335
|
+
- ๐ง Story 36.12: LangChain tools (Pending)
|
|
336
|
+
- ๐ง Story 36.5: AP2 Support (Pending)
|
|
337
|
+
- ๐ง Story 36.6: ACP Support (Pending)
|
|
338
|
+
|
|
339
|
+
## Contributing
|
|
340
|
+
|
|
341
|
+
See the main [PayOS repository](https://github.com/payos/payos) for contribution guidelines.
|
|
342
|
+
|
|
343
|
+
## License
|
|
344
|
+
|
|
345
|
+
MIT
|
|
346
|
+
|
package/dist/a2a.d.mts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { A2AAgentCard, A2APart, A2AConfiguration, A2ATask, A2AListTasksOptions, A2AListTasksResponse, A2ACreateCustomToolRequest, A2ACustomTool } from '@sly/types';
|
|
2
|
+
export { A2AAgentCard, A2AArtifact, A2ACapabilities, A2AConfiguration, A2ACreateCustomToolRequest, A2ACustomTool, A2ADataPart, A2AFilePart, A2AGetTaskRequest, A2AInputRequiredContext, A2AJsonRpcRequest, A2AJsonRpcResponse, A2AListTasksOptions, A2AListTasksResponse, A2AMessage, A2APart, A2ASendMessageRequest, A2ASkill, A2ATask, A2ATaskState, A2ATaskStatus, A2ATextPart } from '@sly/types';
|
|
3
|
+
import { S as SlyClient } from './client-Cwe2CLU7.mjs';
|
|
4
|
+
import './types-df1EICn_.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A2A Client - Google Agent-to-Agent Protocol
|
|
8
|
+
*
|
|
9
|
+
* SDK client for sending tasks to Sly-hosted agents, discovering agent
|
|
10
|
+
* capabilities, and managing task lifecycle.
|
|
11
|
+
*
|
|
12
|
+
* @see Epic 57: Google A2A Protocol Integration
|
|
13
|
+
* @see Epic 58: A2A Task Processor Worker (Story 58.11)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare class A2AClient {
|
|
17
|
+
private client;
|
|
18
|
+
constructor(client: SlyClient);
|
|
19
|
+
/**
|
|
20
|
+
* Discover an agent's capabilities via its Agent Card.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const card = await sly.a2a.discover('agent-uuid');
|
|
25
|
+
* console.log(card.skills);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
discover(agentId: string): Promise<A2AAgentCard>;
|
|
29
|
+
/**
|
|
30
|
+
* Send a message to an agent, creating or continuing a task.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const task = await sly.a2a.sendMessage('agent-uuid', {
|
|
35
|
+
* message: 'Check my wallet balance',
|
|
36
|
+
* });
|
|
37
|
+
* console.log(task.status.state); // 'submitted' or 'completed'
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
sendMessage(agentId: string, params: {
|
|
41
|
+
message: string | A2APart[];
|
|
42
|
+
contextId?: string;
|
|
43
|
+
configuration?: A2AConfiguration;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
skillId?: string;
|
|
46
|
+
}): Promise<A2ATask>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a task by ID.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const task = await sly.a2a.getTask('agent-uuid', 'task-uuid');
|
|
53
|
+
* console.log(task.status.state);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getTask(agentId: string, taskId: string, historyLength?: number): Promise<A2ATask>;
|
|
57
|
+
/**
|
|
58
|
+
* Cancel a task.
|
|
59
|
+
*/
|
|
60
|
+
cancelTask(agentId: string, taskId: string): Promise<A2ATask>;
|
|
61
|
+
/**
|
|
62
|
+
* List tasks for an agent (REST endpoint).
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const { data, pagination } = await sly.a2a.listTasks({
|
|
67
|
+
* agentId: 'agent-uuid',
|
|
68
|
+
* state: 'completed',
|
|
69
|
+
* limit: 20,
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
listTasks(options?: A2AListTasksOptions): Promise<A2AListTasksResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Respond to a task in input-required state (human-in-the-loop).
|
|
76
|
+
*/
|
|
77
|
+
respond(taskId: string, message: string): Promise<{
|
|
78
|
+
status: string;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Register a custom tool for an agent.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const tool = await sly.a2a.createCustomTool('agent-uuid', {
|
|
86
|
+
* toolName: 'lookup_inventory',
|
|
87
|
+
* description: 'Check product inventory levels',
|
|
88
|
+
* inputSchema: {
|
|
89
|
+
* type: 'object',
|
|
90
|
+
* properties: { sku: { type: 'string' } },
|
|
91
|
+
* required: ['sku'],
|
|
92
|
+
* },
|
|
93
|
+
* handlerUrl: 'https://api.example.com/inventory',
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
createCustomTool(agentId: string, request: A2ACreateCustomToolRequest): Promise<A2ACustomTool>;
|
|
98
|
+
/**
|
|
99
|
+
* List custom tools for an agent.
|
|
100
|
+
*/
|
|
101
|
+
listCustomTools(agentId: string): Promise<A2ACustomTool[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Delete a custom tool.
|
|
104
|
+
*/
|
|
105
|
+
deleteCustomTool(agentId: string, toolId: string): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { A2AClient };
|
package/dist/a2a.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { A2AAgentCard, A2APart, A2AConfiguration, A2ATask, A2AListTasksOptions, A2AListTasksResponse, A2ACreateCustomToolRequest, A2ACustomTool } from '@sly/types';
|
|
2
|
+
export { A2AAgentCard, A2AArtifact, A2ACapabilities, A2AConfiguration, A2ACreateCustomToolRequest, A2ACustomTool, A2ADataPart, A2AFilePart, A2AGetTaskRequest, A2AInputRequiredContext, A2AJsonRpcRequest, A2AJsonRpcResponse, A2AListTasksOptions, A2AListTasksResponse, A2AMessage, A2APart, A2ASendMessageRequest, A2ASkill, A2ATask, A2ATaskState, A2ATaskStatus, A2ATextPart } from '@sly/types';
|
|
3
|
+
import { S as SlyClient } from './client-CyJe3uWO.js';
|
|
4
|
+
import './types-df1EICn_.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A2A Client - Google Agent-to-Agent Protocol
|
|
8
|
+
*
|
|
9
|
+
* SDK client for sending tasks to Sly-hosted agents, discovering agent
|
|
10
|
+
* capabilities, and managing task lifecycle.
|
|
11
|
+
*
|
|
12
|
+
* @see Epic 57: Google A2A Protocol Integration
|
|
13
|
+
* @see Epic 58: A2A Task Processor Worker (Story 58.11)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare class A2AClient {
|
|
17
|
+
private client;
|
|
18
|
+
constructor(client: SlyClient);
|
|
19
|
+
/**
|
|
20
|
+
* Discover an agent's capabilities via its Agent Card.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const card = await sly.a2a.discover('agent-uuid');
|
|
25
|
+
* console.log(card.skills);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
discover(agentId: string): Promise<A2AAgentCard>;
|
|
29
|
+
/**
|
|
30
|
+
* Send a message to an agent, creating or continuing a task.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const task = await sly.a2a.sendMessage('agent-uuid', {
|
|
35
|
+
* message: 'Check my wallet balance',
|
|
36
|
+
* });
|
|
37
|
+
* console.log(task.status.state); // 'submitted' or 'completed'
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
sendMessage(agentId: string, params: {
|
|
41
|
+
message: string | A2APart[];
|
|
42
|
+
contextId?: string;
|
|
43
|
+
configuration?: A2AConfiguration;
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
skillId?: string;
|
|
46
|
+
}): Promise<A2ATask>;
|
|
47
|
+
/**
|
|
48
|
+
* Get a task by ID.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const task = await sly.a2a.getTask('agent-uuid', 'task-uuid');
|
|
53
|
+
* console.log(task.status.state);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
getTask(agentId: string, taskId: string, historyLength?: number): Promise<A2ATask>;
|
|
57
|
+
/**
|
|
58
|
+
* Cancel a task.
|
|
59
|
+
*/
|
|
60
|
+
cancelTask(agentId: string, taskId: string): Promise<A2ATask>;
|
|
61
|
+
/**
|
|
62
|
+
* List tasks for an agent (REST endpoint).
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const { data, pagination } = await sly.a2a.listTasks({
|
|
67
|
+
* agentId: 'agent-uuid',
|
|
68
|
+
* state: 'completed',
|
|
69
|
+
* limit: 20,
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
listTasks(options?: A2AListTasksOptions): Promise<A2AListTasksResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Respond to a task in input-required state (human-in-the-loop).
|
|
76
|
+
*/
|
|
77
|
+
respond(taskId: string, message: string): Promise<{
|
|
78
|
+
status: string;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Register a custom tool for an agent.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const tool = await sly.a2a.createCustomTool('agent-uuid', {
|
|
86
|
+
* toolName: 'lookup_inventory',
|
|
87
|
+
* description: 'Check product inventory levels',
|
|
88
|
+
* inputSchema: {
|
|
89
|
+
* type: 'object',
|
|
90
|
+
* properties: { sku: { type: 'string' } },
|
|
91
|
+
* required: ['sku'],
|
|
92
|
+
* },
|
|
93
|
+
* handlerUrl: 'https://api.example.com/inventory',
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
createCustomTool(agentId: string, request: A2ACreateCustomToolRequest): Promise<A2ACustomTool>;
|
|
98
|
+
/**
|
|
99
|
+
* List custom tools for an agent.
|
|
100
|
+
*/
|
|
101
|
+
listCustomTools(agentId: string): Promise<A2ACustomTool[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Delete a custom tool.
|
|
104
|
+
*/
|
|
105
|
+
deleteCustomTool(agentId: string, toolId: string): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { A2AClient };
|