@covia/covia-sdk 1.3.0 → 1.5.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/LICENSE.md +190 -21
- package/README.md +592 -528
- package/dist/index.d.mts +155 -2
- package/dist/index.d.ts +155 -2
- package/dist/index.js +164 -5
- package/dist/index.mjs +163 -6
- package/package.json +66 -66
package/README.md
CHANGED
|
@@ -1,528 +1,592 @@
|
|
|
1
|
-
# @covia/covia-sdk
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@covia/covia-sdk)
|
|
4
|
-
[](https://www.typescriptlang.org/)
|
|
5
|
-
[ — The Universal Grid for AI Orchestration & Multi-Agent Workflows.
|
|
8
|
-
|
|
9
|
-
Covia.ai provides federated execution, cryptographic verification, and shared state management for AI agents across organizations, clouds, and platforms.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install @covia/covia-sdk
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
pnpm add @covia/covia-sdk
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn add @covia/covia-sdk
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Quick Start
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { Grid, KeyPairAuth } from "@covia/covia-sdk";
|
|
29
|
-
|
|
30
|
-
// Connect to a venue (URL, DNS name, or DID)
|
|
31
|
-
const venue = await Grid.connect("https://venue.covia.ai");
|
|
32
|
-
|
|
33
|
-
// Or connect with keypair authentication
|
|
34
|
-
const auth = KeyPairAuth.generate();
|
|
35
|
-
const venue = await Grid.connect("did:web:venue.covia.ai", auth);
|
|
36
|
-
|
|
37
|
-
// Run an operation and get the result
|
|
38
|
-
const result = await venue.operations.run("
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const venue = await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
|
|
112
|
-
| `venue.
|
|
113
|
-
| `venue.
|
|
114
|
-
| `venue.
|
|
115
|
-
| `venue.
|
|
116
|
-
| `venue.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
await venue.jobs.
|
|
207
|
-
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
await job.
|
|
256
|
-
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
|
278
|
-
|
|
279
|
-
| `job.
|
|
280
|
-
| `job.
|
|
281
|
-
| `job.
|
|
282
|
-
| `job.
|
|
283
|
-
| `job.
|
|
284
|
-
| `job.
|
|
285
|
-
| `job.
|
|
286
|
-
| `job.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
//
|
|
341
|
-
const
|
|
342
|
-
await
|
|
343
|
-
await
|
|
344
|
-
await
|
|
345
|
-
await
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
|
390
|
-
|
|
391
|
-
| `
|
|
392
|
-
| `
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
//
|
|
406
|
-
await venue.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
|
420
|
-
|
|
421
|
-
| `
|
|
422
|
-
| `
|
|
423
|
-
| `
|
|
424
|
-
| `
|
|
425
|
-
| `
|
|
426
|
-
|
|
427
|
-
---
|
|
428
|
-
|
|
429
|
-
###
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
```typescript
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
1
|
+
# @covia/covia-sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@covia/covia-sdk)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
6
|
+
|
|
7
|
+
TypeScript SDK for [Covia.ai](https://covia.ai) — The Universal Grid for AI Orchestration & Multi-Agent Workflows.
|
|
8
|
+
|
|
9
|
+
Covia.ai provides federated execution, cryptographic verification, and shared state management for AI agents across organizations, clouds, and platforms.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @covia/covia-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @covia/covia-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @covia/covia-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Grid, KeyPairAuth } from "@covia/covia-sdk";
|
|
29
|
+
|
|
30
|
+
// Connect to a venue (URL, DNS name, or DID)
|
|
31
|
+
const venue = await Grid.connect("https://venue.covia.ai");
|
|
32
|
+
|
|
33
|
+
// Or connect with keypair authentication
|
|
34
|
+
const auth = KeyPairAuth.generate();
|
|
35
|
+
const venue = await Grid.connect("did:web:venue.covia.ai", auth);
|
|
36
|
+
|
|
37
|
+
// Run an operation and get the result
|
|
38
|
+
const result = await venue.operations.run("v/ops/schema/infer", {
|
|
39
|
+
value: { name: "Ada", age: 36, admin: true },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Invoke an operation asynchronously and track the job
|
|
43
|
+
const job = await venue.operations.invoke("v/ops/schema/infer", {
|
|
44
|
+
value: { name: "Ada", age: 36, admin: true },
|
|
45
|
+
});
|
|
46
|
+
console.log(`Job ${job.id} status: ${job.metadata.status}`);
|
|
47
|
+
const output = await job.result({ timeout: 30000 });
|
|
48
|
+
|
|
49
|
+
// Work with assets
|
|
50
|
+
const assets = await venue.listAssets();
|
|
51
|
+
const operation = await venue.getAsset("my-operation-id");
|
|
52
|
+
await operation.invoke({ param: "value" });
|
|
53
|
+
|
|
54
|
+
// Upload data
|
|
55
|
+
const dataAsset = await venue.getAsset("my-data-id");
|
|
56
|
+
await dataAsset.putContent(new Blob(["Hello World"], { type: "text/plain" }));
|
|
57
|
+
const stream = await dataAsset.getContent();
|
|
58
|
+
|
|
59
|
+
// Clean up
|
|
60
|
+
venue.close();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Connecting to a Venue
|
|
64
|
+
|
|
65
|
+
The SDK supports three connection methods:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { Grid, Venue, KeyPairAuth, BearerAuth } from "@covia/covia-sdk";
|
|
69
|
+
|
|
70
|
+
// Via Grid (cached — same ID returns the same Venue instance)
|
|
71
|
+
const venue = await Grid.connect("https://venue.covia.ai");
|
|
72
|
+
const venue = await Grid.connect("did:web:venue.covia.ai");
|
|
73
|
+
const venue = await Grid.connect("venue.covia.ai"); // DNS name → https://
|
|
74
|
+
|
|
75
|
+
// Via Venue directly (no caching)
|
|
76
|
+
const venue = await Venue.connect("https://venue.covia.ai");
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Authentication
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// No auth (default)
|
|
83
|
+
const venue = await Grid.connect("https://venue.covia.ai");
|
|
84
|
+
|
|
85
|
+
// Ed25519 keypair (self-issued JWT per request)
|
|
86
|
+
const auth = KeyPairAuth.generate();
|
|
87
|
+
console.log(auth.getDID()); // did:key:z6Mk...
|
|
88
|
+
const venue = await Grid.connect("https://venue.covia.ai", auth);
|
|
89
|
+
|
|
90
|
+
// From a saved private key
|
|
91
|
+
const auth = KeyPairAuth.fromHex("abcdef1234...");
|
|
92
|
+
|
|
93
|
+
// Bearer token
|
|
94
|
+
const auth = new BearerAuth("my-api-token");
|
|
95
|
+
const venue = await Grid.connect("https://venue.covia.ai", auth);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## API Reference
|
|
99
|
+
|
|
100
|
+
### Venue
|
|
101
|
+
|
|
102
|
+
The `Venue` is the primary entry point. All domain-specific functionality is accessed through manager objects.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
venue.baseUrl; // string — the venue's base URL
|
|
106
|
+
venue.venueId; // string — the venue's DID
|
|
107
|
+
venue.metadata; // { name, description }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Method | Description |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `venue.status()` | Get venue status (health, stats) |
|
|
113
|
+
| `venue.getAsset(assetId)` | Get an asset by ID (returns `Operation` or `DataAsset`) |
|
|
114
|
+
| `venue.listAssets(options?)` | List assets with pagination (`{ offset, limit }`) |
|
|
115
|
+
| `venue.agent(agentId)` | Get a lazy `Agent` handle (no round-trip) |
|
|
116
|
+
| `venue.getJob(jobId)` | Get a job by ID |
|
|
117
|
+
| `venue.listJobs()` | List all job IDs |
|
|
118
|
+
| `venue.didDocument()` | Get the venue's DID document |
|
|
119
|
+
| `venue.mcpDiscovery()` | Get MCP (Model Context Protocol) discovery info |
|
|
120
|
+
| `venue.agentCard()` | Get A2A (Agent-to-Agent) agent card |
|
|
121
|
+
| `venue.close()` | Release resources and clear caches |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### Operations — `venue.operations`
|
|
126
|
+
|
|
127
|
+
Execute named operations or asset-based operations.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// List available operations
|
|
131
|
+
const ops = await venue.operations.list();
|
|
132
|
+
ops.forEach((op) => console.log(`${op.name}: ${op.description}`));
|
|
133
|
+
|
|
134
|
+
// Get operation details
|
|
135
|
+
const info = await venue.operations.get("v/ops/schema/infer");
|
|
136
|
+
|
|
137
|
+
// Run synchronously (invoke + wait for result)
|
|
138
|
+
const result = await venue.operations.run("v/ops/schema/infer", {
|
|
139
|
+
value: { name: "Ada", age: 36 },
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Invoke asynchronously (returns a Job)
|
|
143
|
+
const job = await venue.operations.invoke("v/ops/schema/infer", {
|
|
144
|
+
value: { name: "Ada", age: 36 },
|
|
145
|
+
});
|
|
146
|
+
const output = await job.result({ timeout: 10000 });
|
|
147
|
+
|
|
148
|
+
// With UCAN capability tokens
|
|
149
|
+
const job = await venue.operations.invoke("sensitive:op", input, {
|
|
150
|
+
ucans: ["eyJhbGc..."],
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Method | Returns | Description |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `operations.list()` | `OperationInfo[]` | List all named operations |
|
|
157
|
+
| `operations.get(name)` | `OperationInfo` | Get operation details |
|
|
158
|
+
| `operations.run(id, input, options?)` | `any` | Execute and wait for result |
|
|
159
|
+
| `operations.invoke(id, input, options?)` | `Job` | Execute and return a Job |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Assets — `venue.assets`
|
|
164
|
+
|
|
165
|
+
Manage data assets and operations registered on the venue.
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// List and retrieve assets
|
|
169
|
+
const list = await venue.assets.list({ offset: 0, limit: 50 });
|
|
170
|
+
const asset = await venue.assets.get("asset-id");
|
|
171
|
+
|
|
172
|
+
// Register a new asset
|
|
173
|
+
const newAsset = await venue.assets.register({
|
|
174
|
+
name: "My Dataset",
|
|
175
|
+
description: "Training data",
|
|
176
|
+
content: { contentType: "text/csv", sha256: "abc123..." },
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Upload and download content
|
|
180
|
+
await venue.assets.putContent("asset-id", new Blob(["data"]));
|
|
181
|
+
const stream = await venue.assets.getContent("asset-id");
|
|
182
|
+
|
|
183
|
+
// Get metadata
|
|
184
|
+
const meta = await venue.assets.getMetadata("asset-id");
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
| Method | Returns | Description |
|
|
188
|
+
|---|---|---|
|
|
189
|
+
| `assets.get(assetId)` | `Asset` | Get asset by ID (`Operation` or `DataAsset`) |
|
|
190
|
+
| `assets.list(options?)` | `AssetList` | List assets with pagination |
|
|
191
|
+
| `assets.register(data)` | `Asset` | Register a new asset |
|
|
192
|
+
| `assets.getMetadata(assetId)` | `AssetMetadata` | Get asset metadata |
|
|
193
|
+
| `assets.putContent(assetId, content)` | `ContentHashResult` | Upload content |
|
|
194
|
+
| `assets.getContent(assetId)` | `ReadableStream \| null` | Download content stream |
|
|
195
|
+
| `assets.clearCache()` | `void` | Clear the asset cache |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### Jobs — `venue.jobs`
|
|
200
|
+
|
|
201
|
+
Manage job lifecycle. Jobs are also returned by `operations.invoke()` and `asset.invoke()`.
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
// List and retrieve jobs
|
|
205
|
+
const jobIds = await venue.jobs.list();
|
|
206
|
+
const job = await venue.jobs.get(jobIds[0]);
|
|
207
|
+
|
|
208
|
+
// Job lifecycle via manager
|
|
209
|
+
await venue.jobs.pause(jobId);
|
|
210
|
+
await venue.jobs.resume(jobId);
|
|
211
|
+
await venue.jobs.cancel(jobId);
|
|
212
|
+
await venue.jobs.delete(jobId);
|
|
213
|
+
|
|
214
|
+
// Send a message to a running job
|
|
215
|
+
await venue.jobs.sendMessage(jobId, { text: "user input" });
|
|
216
|
+
|
|
217
|
+
// Stream server-sent events
|
|
218
|
+
for await (const event of venue.jobs.stream(jobId)) {
|
|
219
|
+
console.log(event.event, event.json());
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| Method | Returns | Description |
|
|
224
|
+
|---|---|---|
|
|
225
|
+
| `jobs.list()` | `string[]` | List all job IDs |
|
|
226
|
+
| `jobs.get(jobId)` | `Job` | Get a job by ID |
|
|
227
|
+
| `jobs.cancel(jobId)` | `JobMetadata` | Cancel a job |
|
|
228
|
+
| `jobs.delete(jobId)` | `void` | Delete a job |
|
|
229
|
+
| `jobs.pause(jobId)` | `JobMetadata` | Pause a job |
|
|
230
|
+
| `jobs.resume(jobId)` | `JobMetadata` | Resume a paused job |
|
|
231
|
+
| `jobs.sendMessage(jobId, msg)` | `any` | Send a message to a job |
|
|
232
|
+
| `jobs.stream(jobId)` | `AsyncGenerator<SSEEvent>` | Stream SSE events |
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Job Instance
|
|
237
|
+
|
|
238
|
+
Once you have a `Job` object, you can interact with it directly.
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
const job = await venue.operations.invoke("long:task", input);
|
|
242
|
+
|
|
243
|
+
// Status helpers
|
|
244
|
+
job.isFinished; // true for COMPLETE, FAILED, CANCELLED, REJECTED, TIMEOUT
|
|
245
|
+
job.isComplete; // true only for COMPLETE
|
|
246
|
+
job.isPaused; // true for PAUSED, INPUT_REQUIRED, AUTH_REQUIRED
|
|
247
|
+
job.needsInput; // true for INPUT_REQUIRED
|
|
248
|
+
job.needsAuth; // true for AUTH_REQUIRED
|
|
249
|
+
|
|
250
|
+
// Wait for completion
|
|
251
|
+
await job.wait({ timeout: 60000 });
|
|
252
|
+
const output = job.output; // throws JobFailedError if not COMPLETE
|
|
253
|
+
|
|
254
|
+
// Or wait + get output in one call
|
|
255
|
+
const result = await job.result({ timeout: 60000 });
|
|
256
|
+
|
|
257
|
+
// Refresh status from server
|
|
258
|
+
await job.refresh();
|
|
259
|
+
|
|
260
|
+
// Lifecycle
|
|
261
|
+
await job.cancel();
|
|
262
|
+
await job.delete();
|
|
263
|
+
await job.pause();
|
|
264
|
+
await job.resume();
|
|
265
|
+
|
|
266
|
+
// Interactive jobs
|
|
267
|
+
if (job.needsInput) {
|
|
268
|
+
await job.sendMessage({ text: "user response" });
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Stream events
|
|
272
|
+
for await (const event of job.stream()) {
|
|
273
|
+
console.log(event.event, event.json());
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
| Property / Method | Type | Description |
|
|
278
|
+
|---|---|---|
|
|
279
|
+
| `job.id` | `string` | Job identifier |
|
|
280
|
+
| `job.metadata` | `JobMetadata` | Status, input, output, timestamps |
|
|
281
|
+
| `job.isFinished` | `boolean` | Terminal state reached |
|
|
282
|
+
| `job.isComplete` | `boolean` | Completed successfully |
|
|
283
|
+
| `job.isPaused` | `boolean` | Paused / awaiting input or auth |
|
|
284
|
+
| `job.needsInput` | `boolean` | Requires user input |
|
|
285
|
+
| `job.needsAuth` | `boolean` | Requires authentication |
|
|
286
|
+
| `job.output` | `any` | Get output (throws if not complete) |
|
|
287
|
+
| `job.refresh()` | `Promise<void>` | Poll latest status from server |
|
|
288
|
+
| `job.wait(options?)` | `Promise<void>` | Wait until finished (exponential backoff) |
|
|
289
|
+
| `job.result(options?)` | `Promise<any>` | Wait and return output |
|
|
290
|
+
| `job.cancel()` | `Promise<JobMetadata>` | Cancel the job |
|
|
291
|
+
| `job.delete()` | `Promise<void>` | Delete the job |
|
|
292
|
+
| `job.pause()` | `Promise<JobMetadata>` | Pause the job |
|
|
293
|
+
| `job.resume()` | `Promise<JobMetadata>` | Resume the job |
|
|
294
|
+
| `job.sendMessage(msg)` | `Promise<any>` | Send a message to the job |
|
|
295
|
+
| `job.stream()` | `AsyncGenerator<SSEEvent>` | Stream SSE events |
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Asset Instance
|
|
300
|
+
|
|
301
|
+
Assets returned by `venue.getAsset()` or `venue.assets.get()` are either an `Operation` or a `DataAsset`.
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
const asset = await venue.getAsset("my-asset-id");
|
|
305
|
+
|
|
306
|
+
// Metadata
|
|
307
|
+
const meta = await asset.getMetadata();
|
|
308
|
+
|
|
309
|
+
// Content (DataAsset)
|
|
310
|
+
await asset.putContent(new Blob(["data"], { type: "text/plain" }));
|
|
311
|
+
const stream = await asset.getContent();
|
|
312
|
+
const url = asset.getContentURL(); // direct download URL
|
|
313
|
+
|
|
314
|
+
// Execution (Operation)
|
|
315
|
+
const result = await asset.run({ param: "value" }); // sync
|
|
316
|
+
const job = await asset.invoke({ param: "value" }); // async → Job
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
| Method | Returns | Description |
|
|
320
|
+
|---|---|---|
|
|
321
|
+
| `asset.id` | `string` | Asset identifier |
|
|
322
|
+
| `asset.metadata` | `AssetMetadata` | Asset metadata |
|
|
323
|
+
| `asset.getMetadata()` | `Promise<AssetMetadata>` | Fetch metadata (cached) |
|
|
324
|
+
| `asset.putContent(content)` | `Promise<ContentHashResult>` | Upload content |
|
|
325
|
+
| `asset.getContent()` | `Promise<ReadableStream \| null>` | Download content stream |
|
|
326
|
+
| `asset.getContentURL()` | `string` | Direct content download URL |
|
|
327
|
+
| `asset.run(input)` | `Promise<any>` | Execute and wait for result |
|
|
328
|
+
| `asset.invoke(input)` | `Promise<Job>` | Execute and return a Job |
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
### Agents — `venue.agent(id)` / `venue.agents`
|
|
333
|
+
|
|
334
|
+
The preferred way to work with agents is through the `Agent` instance returned by `venue.agent(id)`. This is a lazy handle — no network call is made until you invoke a method.
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
// Get a handle to an agent (no round-trip)
|
|
338
|
+
const mina = venue.agent("Mina");
|
|
339
|
+
|
|
340
|
+
// Interact
|
|
341
|
+
const response = await mina.request({ text: "hello" });
|
|
342
|
+
await mina.message({ event: "update" });
|
|
343
|
+
await mina.trigger();
|
|
344
|
+
const state = await mina.query();
|
|
345
|
+
const info = await mina.info();
|
|
346
|
+
|
|
347
|
+
// Session-scoped chat — ChatSession manages the sessionId for you
|
|
348
|
+
const chat = mina.chatSession();
|
|
349
|
+
await chat.send("hi"); // mints a new session
|
|
350
|
+
await chat.send("and now?"); // reuses the session automatically
|
|
351
|
+
chat.sessionId; // available for persistence
|
|
352
|
+
|
|
353
|
+
// Resume a previous session
|
|
354
|
+
const resumed = mina.chatSession(storedSessionId);
|
|
355
|
+
await resumed.send("I'm back");
|
|
356
|
+
|
|
357
|
+
// Lifecycle
|
|
358
|
+
await mina.suspend();
|
|
359
|
+
await mina.resume();
|
|
360
|
+
await mina.update({ config: { model: "gpt-4" } });
|
|
361
|
+
await mina.cancelTask("task-123");
|
|
362
|
+
await mina.delete();
|
|
363
|
+
|
|
364
|
+
// Fork into a new agent
|
|
365
|
+
const clone = await mina.fork("Mina-v2", { includeTimeline: true });
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### Agent Instance
|
|
369
|
+
|
|
370
|
+
| Method | Returns | Description |
|
|
371
|
+
|---|---|---|
|
|
372
|
+
| `agent.request(input?, wait?)` | `AgentRequestResult` | Send request to agent |
|
|
373
|
+
| `agent.message(message)` | `AgentMessageResult` | Send a message |
|
|
374
|
+
| `agent.chat(message, sessionId?)` | `AgentChatResult` | Single chat call (manual sessionId) |
|
|
375
|
+
| `agent.chatSession(sessionId?)` | `ChatSession` | Create a session that manages sessionId |
|
|
376
|
+
| `agent.trigger()` | `AgentTriggerResult` | Trigger agent execution |
|
|
377
|
+
| `agent.query()` | `AgentQueryResult` | Query agent state |
|
|
378
|
+
| `agent.info()` | `AgentInfoResult` | Get agent info |
|
|
379
|
+
| `agent.context(task?)` | `string` | Get agent context |
|
|
380
|
+
| `agent.suspend()` | `AgentSuspendResult` | Suspend the agent |
|
|
381
|
+
| `agent.resume(autoWake?)` | `AgentSuspendResult` | Resume the agent |
|
|
382
|
+
| `agent.update(options)` | `any` | Update agent config/state |
|
|
383
|
+
| `agent.cancelTask(taskId)` | `any` | Cancel an agent task |
|
|
384
|
+
| `agent.fork(agentId, options?)` | `Agent` | Fork into a new agent |
|
|
385
|
+
| `agent.delete(remove?)` | `AgentDeleteResult` | Delete the agent |
|
|
386
|
+
|
|
387
|
+
#### ChatSession
|
|
388
|
+
|
|
389
|
+
| Property / Method | Type | Description |
|
|
390
|
+
|---|---|---|
|
|
391
|
+
| `chat.sessionId` | `string \| undefined` | Current session ID (undefined until first send) |
|
|
392
|
+
| `chat.send(message)` | `Promise<AgentChatResult>` | Send a message, auto-managing sessionId |
|
|
393
|
+
|
|
394
|
+
#### AgentManager — `venue.agents`
|
|
395
|
+
|
|
396
|
+
The `AgentManager` is still available for collection-level operations and flat-style dispatch.
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
// Create an agent
|
|
400
|
+
await venue.agents.create({ agentId: "my-agent", config: { ... } });
|
|
401
|
+
|
|
402
|
+
// List agents
|
|
403
|
+
const agents = await venue.agents.list();
|
|
404
|
+
|
|
405
|
+
// Flat-style dispatch (all manager methods still work)
|
|
406
|
+
await venue.agents.chat("my-agent", "hi");
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
| Method | Returns | Description |
|
|
410
|
+
|---|---|---|
|
|
411
|
+
| `agents.create(input)` | `AgentCreateResult` | Create an agent |
|
|
412
|
+
| `agents.list(includeTerminated?)` | `AgentListResult` | List agents |
|
|
413
|
+
| `agents.request(id, input?, wait?)` | `AgentRequestResult` | Send request to agent |
|
|
414
|
+
| `agents.message(id, message)` | `AgentMessageResult` | Send a message |
|
|
415
|
+
| `agents.chat(id, message, sessionId?)` | `AgentChatResult` | Session-scoped chat |
|
|
416
|
+
| `agents.trigger(id)` | `AgentTriggerResult` | Trigger agent execution |
|
|
417
|
+
| `agents.query(id)` | `AgentQueryResult` | Query agent state |
|
|
418
|
+
| `agents.info(id)` | `AgentInfoResult` | Get agent info |
|
|
419
|
+
| `agents.suspend(id)` | `AgentSuspendResult` | Suspend an agent |
|
|
420
|
+
| `agents.resume(id, autoWake?)` | `AgentSuspendResult` | Resume an agent |
|
|
421
|
+
| `agents.update(input)` | `any` | Update agent config/state |
|
|
422
|
+
| `agents.cancelTask(agentId, taskId)` | `any` | Cancel an agent task |
|
|
423
|
+
| `agents.fork(input)` | `AgentForkResult` | Fork an agent |
|
|
424
|
+
| `agents.context(id, task?)` | `string` | Get agent context |
|
|
425
|
+
| `agents.delete(id, remove?)` | `AgentDeleteResult` | Delete an agent |
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
### Workspace — `venue.workspace`
|
|
430
|
+
|
|
431
|
+
Read and write shared state in the venue's workspace.
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
// CRUD
|
|
435
|
+
await venue.workspace.write("w/my-app/config", { theme: "dark" });
|
|
436
|
+
const data = await venue.workspace.read("w/my-app/config");
|
|
437
|
+
await venue.workspace.append("w/my-app/log", "new entry");
|
|
438
|
+
await venue.workspace.delete("w/my-app/config");
|
|
439
|
+
|
|
440
|
+
// List and slice
|
|
441
|
+
const entries = await venue.workspace.list("w/my-app/", 100, 0);
|
|
442
|
+
const slice = await venue.workspace.slice("w/my-app/log", 0, 10);
|
|
443
|
+
|
|
444
|
+
// Discovery
|
|
445
|
+
const funcs = await venue.workspace.functions();
|
|
446
|
+
const desc = await venue.workspace.describe("myFunction");
|
|
447
|
+
const adapters = await venue.workspace.adapters();
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
| Method | Returns | Description |
|
|
451
|
+
|---|---|---|
|
|
452
|
+
| `workspace.read(path, maxSize?)` | `WorkspaceReadResult` | Read a value |
|
|
453
|
+
| `workspace.write(path, value)` | `WorkspaceWriteResult` | Write a value |
|
|
454
|
+
| `workspace.delete(path)` | `WorkspaceDeleteResult` | Delete an entry |
|
|
455
|
+
| `workspace.append(path, value)` | `WorkspaceAppendResult` | Append to an entry |
|
|
456
|
+
| `workspace.list(path?, limit?, offset?)` | `WorkspaceListResult` | List entries |
|
|
457
|
+
| `workspace.slice(path, offset?, limit?)` | `WorkspaceSliceResult` | Slice an entry |
|
|
458
|
+
| `workspace.functions()` | `FunctionsResult` | List available functions |
|
|
459
|
+
| `workspace.describe(name)` | `any` | Describe a function |
|
|
460
|
+
| `workspace.adapters()` | `AdaptersResult` | List adapters |
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
### Secrets — `venue.secrets`
|
|
465
|
+
|
|
466
|
+
Manage secrets stored on the venue.
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
// Store and retrieve
|
|
470
|
+
await venue.secrets.put("API_KEY", "sk-...");
|
|
471
|
+
await venue.secrets.set("API_KEY", "sk-..."); // via secret:set operation
|
|
472
|
+
|
|
473
|
+
// List
|
|
474
|
+
const names = await venue.secrets.list(); // ["API_KEY", "DB_PASS"]
|
|
475
|
+
|
|
476
|
+
// Extract (requires UCAN capability)
|
|
477
|
+
const secret = await venue.secrets.extract("API_KEY");
|
|
478
|
+
|
|
479
|
+
// Delete
|
|
480
|
+
await venue.secrets.delete("API_KEY");
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
| Method | Returns | Description |
|
|
484
|
+
|---|---|---|
|
|
485
|
+
| `secrets.list()` | `string[]` | List secret names |
|
|
486
|
+
| `secrets.put(name, value)` | `void` | Store a secret via REST |
|
|
487
|
+
| `secrets.set(name, value)` | `SecretSetResult` | Store via `secret:set` operation |
|
|
488
|
+
| `secrets.extract(name)` | `SecretExtractResult` | Extract value (requires UCAN) |
|
|
489
|
+
| `secrets.delete(name)` | `void` | Delete a secret |
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
### UCAN — `venue.ucan`
|
|
494
|
+
|
|
495
|
+
Issue UCAN (User Controlled Authorization Network) capability tokens.
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
const att = [{ with: "/w/my-app/", can: "crud/read" }];
|
|
499
|
+
const exp = Math.floor(Date.now() / 1000) + 3600; // 1 hour
|
|
500
|
+
|
|
501
|
+
const token = await venue.ucan.issue("did:key:z6MkBob", att, exp);
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
| Method | Returns | Description |
|
|
505
|
+
|---|---|---|
|
|
506
|
+
| `ucan.issue(aud, att, exp)` | `UCANIssueResult` | Issue a UCAN token |
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Error Handling
|
|
511
|
+
|
|
512
|
+
The SDK provides a hierarchy of typed errors:
|
|
513
|
+
|
|
514
|
+
```typescript
|
|
515
|
+
import {
|
|
516
|
+
CoviaError, // Base error
|
|
517
|
+
GridError, // HTTP API errors (4xx/5xx)
|
|
518
|
+
NotFoundError, // 404 responses
|
|
519
|
+
AssetNotFoundError, // Asset not found
|
|
520
|
+
JobNotFoundError, // Job not found
|
|
521
|
+
CoviaConnectionError,// Connection failures
|
|
522
|
+
CoviaTimeoutError, // Timeout exceeded
|
|
523
|
+
JobFailedError, // Job finished with non-COMPLETE status
|
|
524
|
+
} from "@covia/covia-sdk";
|
|
525
|
+
|
|
526
|
+
try {
|
|
527
|
+
const asset = await venue.getAsset("nonexistent");
|
|
528
|
+
} catch (err) {
|
|
529
|
+
if (err instanceof AssetNotFoundError) {
|
|
530
|
+
console.log(`Asset ${err.assetId} not found`);
|
|
531
|
+
} else if (err instanceof GridError) {
|
|
532
|
+
console.log(`HTTP ${err.statusCode}: ${err.message}`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
try {
|
|
537
|
+
const result = await job.result({ timeout: 5000 });
|
|
538
|
+
} catch (err) {
|
|
539
|
+
if (err instanceof CoviaTimeoutError) {
|
|
540
|
+
console.log("Job took too long");
|
|
541
|
+
} else if (err instanceof JobFailedError) {
|
|
542
|
+
console.log(`Job failed: ${err.jobData.status}`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
## Job Status
|
|
548
|
+
|
|
549
|
+
```typescript
|
|
550
|
+
import { RunStatus } from "@covia/covia-sdk";
|
|
551
|
+
|
|
552
|
+
RunStatus.PENDING; // Queued, not yet started
|
|
553
|
+
RunStatus.STARTED; // Running
|
|
554
|
+
RunStatus.COMPLETE; // Finished successfully
|
|
555
|
+
RunStatus.FAILED; // Finished with error
|
|
556
|
+
RunStatus.CANCELLED; // Cancelled by user
|
|
557
|
+
RunStatus.TIMEOUT; // Timed out
|
|
558
|
+
RunStatus.REJECTED; // Rejected by venue
|
|
559
|
+
RunStatus.PAUSED; // Paused
|
|
560
|
+
RunStatus.INPUT_REQUIRED; // Waiting for user input
|
|
561
|
+
RunStatus.AUTH_REQUIRED; // Waiting for authentication
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Requirements
|
|
565
|
+
|
|
566
|
+
- Node.js >= 18
|
|
567
|
+
- TypeScript >= 5.3 (for TypeScript users)
|
|
568
|
+
|
|
569
|
+
## TypeScript
|
|
570
|
+
|
|
571
|
+
`@covia/covia-sdk` is written in TypeScript and ships with full type declarations. No `@types/` package is needed.
|
|
572
|
+
|
|
573
|
+
```typescript
|
|
574
|
+
import {
|
|
575
|
+
Venue, Grid, Job, Agent, ChatSession, Asset, Operation, DataAsset,
|
|
576
|
+
AssetManager, OperationManager, JobManager,
|
|
577
|
+
AgentManager, WorkspaceManager, SecretManager, UCANManager,
|
|
578
|
+
KeyPairAuth, BearerAuth,
|
|
579
|
+
RunStatus, CoviaError,
|
|
580
|
+
} from "@covia/covia-sdk";
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
## Resources
|
|
584
|
+
|
|
585
|
+
- [Covia.ai Platform](https://covia.ai)
|
|
586
|
+
- [Documentation](https://docs.covia.ai/)
|
|
587
|
+
- [GitHub Repository](https://github.com/covia-ai/covia-sdk)
|
|
588
|
+
- [npm Package](https://www.npmjs.com/package/@covia/covia-sdk)
|
|
589
|
+
|
|
590
|
+
## License
|
|
591
|
+
|
|
592
|
+
Apache-2.0 - [Covia AI](https://covia.ai)
|