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