@covia/covia-sdk 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,17 +2,88 @@ declare class Job {
2
2
  id: string;
3
3
  venue: VenueInterface;
4
4
  metadata: JobMetadata;
5
+ private _jobs;
5
6
  constructor(id: string, venue: VenueInterface, metadata: JobMetadata);
6
7
  /**
7
- * Cancels the execution of the job
8
- * @returns {Promise<number>}
9
- */
10
- cancelJob(): Promise<number>;
8
+ * Whether the job has reached a terminal state
9
+ */
10
+ get isFinished(): boolean;
11
+ /**
12
+ * Whether the job completed successfully
13
+ */
14
+ get isComplete(): boolean;
15
+ /**
16
+ * The job output.
17
+ * @throws {Error} If the job has not finished yet.
18
+ * @throws {JobFailedError} If the job finished with a non-COMPLETE status.
19
+ */
20
+ get output(): any;
21
+ /**
22
+ * Poll the venue for the latest job status.
23
+ * @throws {Error} If the job has no ID.
24
+ */
25
+ refresh(): Promise<void>;
26
+ /**
27
+ * Wait until the job reaches a terminal state.
28
+ * Uses exponential backoff polling (initial 300ms, factor 1.5, max 10s).
29
+ * @param options.timeout - Maximum milliseconds to wait. Undefined waits indefinitely.
30
+ * @throws {CoviaTimeoutError} If timeout is exceeded.
31
+ */
32
+ wait(options?: {
33
+ timeout?: number;
34
+ }): Promise<void>;
35
+ /**
36
+ * Wait for the job to complete and return its output.
37
+ * @param options.timeout - Maximum milliseconds to wait.
38
+ * @returns The job output.
39
+ * @throws {JobFailedError} If the job finishes with a non-COMPLETE status.
40
+ * @throws {CoviaTimeoutError} If timeout is exceeded.
41
+ */
42
+ result(options?: {
43
+ timeout?: number;
44
+ }): Promise<any>;
45
+ /**
46
+ * Stream server-sent events for this job.
47
+ * @returns AsyncGenerator yielding SSEEvent objects
48
+ */
49
+ stream(): AsyncGenerator<SSEEvent>;
50
+ /**
51
+ * Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
52
+ */
53
+ get isPaused(): boolean;
54
+ /**
55
+ * Whether the job requires user input
56
+ */
57
+ get needsInput(): boolean;
58
+ /**
59
+ * Whether the job requires authentication
60
+ */
61
+ get needsAuth(): boolean;
62
+ /**
63
+ * Send a message to the running job
64
+ * @param message - Message payload
65
+ * @returns {Promise<any>}
66
+ */
67
+ sendMessage(message: any): Promise<any>;
68
+ /**
69
+ * Pause the job
70
+ * @returns {Promise<JobMetadata>} Updated job metadata
71
+ */
72
+ pause(): Promise<JobMetadata>;
73
+ /**
74
+ * Resume the job
75
+ * @returns {Promise<JobMetadata>} Updated job metadata
76
+ */
77
+ resume(): Promise<JobMetadata>;
78
+ /**
79
+ * Cancel the job
80
+ * @returns {Promise<JobMetadata>} Updated job metadata
81
+ */
82
+ cancel(): Promise<JobMetadata>;
11
83
  /**
12
84
  * Delete the job
13
- * @returns {Promise<number>}
14
85
  */
15
- deleteJob(): Promise<number>;
86
+ delete(): Promise<void>;
16
87
  }
17
88
 
18
89
  declare abstract class Asset {
@@ -21,6 +92,8 @@ declare abstract class Asset {
21
92
  metadata: AssetMetadata;
22
93
  status?: RunStatus;
23
94
  error?: string;
95
+ private _assets;
96
+ private _operations;
24
97
  constructor(id: AssetID, venue: VenueInterface, metadata?: AssetMetadata);
25
98
  /**
26
99
  * Get asset metadata
@@ -28,16 +101,11 @@ declare abstract class Asset {
28
101
  */
29
102
  getMetadata(): Promise<AssetMetadata>;
30
103
  /**
31
- * Read stream from asset
32
- * @param reader - ReadableStreamDefaultReader
33
- */
34
- readStream(reader: ReadableStreamDefaultReader<Uint8Array>): Promise<void>;
35
- /**
36
- * Upload content to asset
104
+ * Put content to asset
37
105
  * @param content - Content to upload
38
- * @returns {Promise<ReadableStream<Uint8Array> | null>}
106
+ * @returns {Promise<ContentHashResult>} The content hash returned by the server
39
107
  */
40
- uploadContent(content: BodyInit): Promise<ReadableStream<Uint8Array> | null>;
108
+ putContent(content: BodyInit): Promise<ContentHashResult>;
41
109
  /**
42
110
  * Get asset content
43
111
  * @returns {Promise<ReadableStream<Uint8Array> | null>}
@@ -57,16 +125,82 @@ declare abstract class Asset {
57
125
  /**
58
126
  * Execute the operation
59
127
  * @param input - Operation input parameters
60
- * @returns {Promise<any>}
128
+ * @returns {Promise<Job>}
61
129
  */
62
130
  invoke(input: any): Promise<Job>;
63
131
  }
64
132
 
133
+ /**
134
+ * Abstract base class for authentication strategies.
135
+ * Subclass this to implement custom authentication.
136
+ *
137
+ * Example — custom API-key auth:
138
+ *
139
+ * class ApiKeyAuth extends Auth {
140
+ * constructor(private key: string) { super(); }
141
+ * apply(headers: Record<string, string>): void {
142
+ * headers["X-Api-Key"] = this.key;
143
+ * }
144
+ * }
145
+ */
146
+ declare abstract class Auth {
147
+ /** Apply authentication credentials to request headers (mutates in place). */
148
+ abstract apply(headers: Record<string, string>): void;
149
+ }
150
+ /** No-op authentication provider. Sends no credentials. */
151
+ declare class NoAuth extends Auth {
152
+ apply(_headers: Record<string, string>): void;
153
+ }
154
+ /**
155
+ * Bearer token authentication.
156
+ * Adds `Authorization: Bearer <token>` to every request.
157
+ *
158
+ * Example:
159
+ * const venue = await Grid.connect("https://venue.covia.ai", new BearerAuth("my-token"));
160
+ */
161
+ declare class BearerAuth extends Auth {
162
+ private _token;
163
+ constructor(token: string);
164
+ apply(headers: Record<string, string>): void;
165
+ }
166
+ /**
167
+ * Ed25519 keypair authentication (self-issued EdDSA JWT).
168
+ * Generates a fresh short-lived JWT for every request, signed with the
169
+ * client's Ed25519 private key. The server verifies the signature and
170
+ * extracts the caller's DID from the `sub` claim.
171
+ *
172
+ * Example:
173
+ * const auth = KeyPairAuth.generate();
174
+ * console.log(auth.getDID()); // did:key:z6Mk...
175
+ * const venue = await Grid.connect("https://venue.covia.ai", auth);
176
+ */
177
+ declare class KeyPairAuth extends Auth {
178
+ private _privateKey;
179
+ private _publicKey;
180
+ private _did;
181
+ private _lifetime;
182
+ /**
183
+ * @param privateKey - 32-byte Ed25519 private key
184
+ * @param tokenLifetimeSeconds - JWT lifetime in seconds (default 300 = 5 min)
185
+ */
186
+ constructor(privateKey: Uint8Array, tokenLifetimeSeconds?: number);
187
+ apply(headers: Record<string, string>): void;
188
+ /** The caller's DID derived from the public key. */
189
+ getDID(): string;
190
+ /** The 32-byte Ed25519 public key. */
191
+ getPublicKey(): Uint8Array;
192
+ /** Generate a new random keypair and return a KeyPairAuth instance. */
193
+ static generate(tokenLifetimeSeconds?: number): KeyPairAuth;
194
+ /** Create from a hex-encoded private key string. */
195
+ static fromHex(privateKeyHex: string, tokenLifetimeSeconds?: number): KeyPairAuth;
196
+ }
197
+ /** @deprecated Use Auth subclasses instead (NoAuth, BearerAuth, KeyPairAuth). */
65
198
  interface Credentials {
66
199
  venueId: string;
67
200
  apiKey: string;
68
201
  userId: string;
69
202
  }
203
+ /** @deprecated Use Auth subclasses instead (NoAuth, BearerAuth, KeyPairAuth). */
70
204
  declare class CredentialsHTTP implements Credentials {
71
205
  venueId: string;
72
206
  apiKey: string;
@@ -74,11 +208,203 @@ declare class CredentialsHTTP implements Credentials {
74
208
  constructor(venueId: string, apiKey: string, userId: string);
75
209
  }
76
210
 
211
+ interface AgentManagerVenue {
212
+ operations: {
213
+ run(assetId: string, input: any): Promise<any>;
214
+ };
215
+ }
216
+ declare class AgentManager {
217
+ private venue;
218
+ constructor(venue: AgentManagerVenue);
219
+ create(input: AgentCreateInput): Promise<AgentCreateResult>;
220
+ request(agentId: string, input?: any, wait?: boolean | number): Promise<AgentRequestResult>;
221
+ message(agentId: string, message: any): Promise<AgentMessageResult>;
222
+ trigger(agentId: string): Promise<AgentTriggerResult>;
223
+ query(agentId: string): Promise<AgentQueryResult>;
224
+ list(includeTerminated?: boolean): Promise<AgentListResult>;
225
+ delete(agentId: string, remove?: boolean): Promise<AgentDeleteResult>;
226
+ suspend(agentId: string): Promise<AgentSuspendResult>;
227
+ resume(agentId: string, autoWake?: boolean): Promise<AgentSuspendResult>;
228
+ update(input: AgentUpdateInput): Promise<any>;
229
+ cancelTask(agentId: string, taskId: string): Promise<any>;
230
+ }
231
+
232
+ interface JobManagerVenue {
233
+ baseUrl: string;
234
+ auth: {
235
+ apply(headers: Record<string, string>): void;
236
+ };
237
+ }
238
+ declare class JobManager {
239
+ private venue;
240
+ constructor(venue: JobManagerVenue);
241
+ list(): Promise<string[]>;
242
+ get(jobId: string): Promise<Job>;
243
+ cancel(jobId: string): Promise<JobMetadata>;
244
+ delete(jobId: string): Promise<void>;
245
+ pause(jobId: string): Promise<JobMetadata>;
246
+ resume(jobId: string): Promise<JobMetadata>;
247
+ sendMessage(jobId: string, message: any): Promise<any>;
248
+ stream(jobId: string): AsyncGenerator<SSEEvent>;
249
+ private _buildHeaders;
250
+ }
251
+
252
+ interface AssetManagerVenue {
253
+ baseUrl: string;
254
+ auth: {
255
+ apply(headers: Record<string, string>): void;
256
+ };
257
+ }
258
+ declare class AssetManager {
259
+ private venue;
260
+ constructor(venue: AssetManagerVenue);
261
+ /**
262
+ * Get asset by ID
263
+ * @param assetId - Asset identifier
264
+ * @returns Returns either an Operation or DataAsset based on the asset's metadata
265
+ */
266
+ get(assetId: AssetID): Promise<Asset>;
267
+ /**
268
+ * List assets with pagination support
269
+ * @param options - Pagination options (offset, limit)
270
+ */
271
+ list(options?: AssetListOptions): Promise<AssetList>;
272
+ /**
273
+ * Register a new asset
274
+ * @param assetData - Asset configuration
275
+ */
276
+ register(assetData: any): Promise<Asset>;
277
+ /**
278
+ * Get asset metadata
279
+ * @param assetId - Asset identifier
280
+ */
281
+ getMetadata(assetId: string): Promise<AssetMetadata>;
282
+ /**
283
+ * Put content to asset
284
+ * @param assetId - Asset identifier
285
+ * @param content - Content to upload
286
+ * @returns The content hash returned by the server
287
+ */
288
+ putContent(assetId: string, content: BodyInit): Promise<ContentHashResult>;
289
+ /**
290
+ * Get asset content
291
+ * @param assetId - Asset identifier
292
+ */
293
+ getContent(assetId: string): Promise<ReadableStream<Uint8Array> | null>;
294
+ /**
295
+ * Clear the asset cache.
296
+ */
297
+ clearCache(): void;
298
+ private _buildHeaders;
299
+ }
300
+
301
+ interface OperationManagerVenue {
302
+ baseUrl: string;
303
+ auth: {
304
+ apply(headers: Record<string, string>): void;
305
+ };
306
+ }
307
+ declare class OperationManager {
308
+ private venue;
309
+ constructor(venue: OperationManagerVenue);
310
+ /**
311
+ * List all named operations available on this venue
312
+ */
313
+ list(): Promise<OperationInfo[]>;
314
+ /**
315
+ * Get details of a named operation
316
+ * @param name - Operation name (e.g., "test:echo")
317
+ */
318
+ get(name: string): Promise<OperationInfo>;
319
+ /**
320
+ * Execute an operation and wait for the result
321
+ * @param assetId - Operation asset ID or named operation
322
+ * @param input - Operation input parameters
323
+ * @param options - Invoke options (e.g., ucans)
324
+ */
325
+ run(assetId: string, input: any, options?: InvokeOptions): Promise<any>;
326
+ /**
327
+ * Execute an operation and return a Job for tracking
328
+ * @param assetId - Operation asset ID or named operation
329
+ * @param input - Operation input parameters
330
+ * @param options - Invoke options (e.g., ucans)
331
+ */
332
+ invoke(assetId: string, input: any, options?: InvokeOptions): Promise<Job>;
333
+ private _buildHeaders;
334
+ }
335
+
336
+ interface WorkspaceManagerVenue {
337
+ operations: {
338
+ run(assetId: string, input: any): Promise<any>;
339
+ };
340
+ }
341
+ declare class WorkspaceManager {
342
+ private venue;
343
+ constructor(venue: WorkspaceManagerVenue);
344
+ read(path: string, maxSize?: number): Promise<WorkspaceReadResult>;
345
+ write(path: string, value: any): Promise<WorkspaceWriteResult>;
346
+ delete(path: string): Promise<WorkspaceDeleteResult>;
347
+ append(path: string, value: any): Promise<WorkspaceAppendResult>;
348
+ list(path?: string, limit?: number, offset?: number): Promise<WorkspaceListResult>;
349
+ slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
350
+ functions(): Promise<FunctionsResult>;
351
+ describe(name: string): Promise<any>;
352
+ adapters(): Promise<AdaptersResult>;
353
+ }
354
+
355
+ interface UCANManagerVenue {
356
+ operations: {
357
+ run(assetId: string, input: any): Promise<any>;
358
+ };
359
+ }
360
+ declare class UCANManager {
361
+ private venue;
362
+ constructor(venue: UCANManagerVenue);
363
+ issue(aud: string, att: UCANAttenuation[], exp: number): Promise<UCANIssueResult>;
364
+ }
365
+
366
+ interface SecretManagerVenue {
367
+ operations: {
368
+ run(assetId: string, input: any): Promise<any>;
369
+ };
370
+ listSecrets(): Promise<string[]>;
371
+ putSecret(name: string, value: string): Promise<void>;
372
+ deleteSecret(name: string): Promise<void>;
373
+ }
374
+ declare class SecretManager {
375
+ private venue;
376
+ constructor(venue: SecretManagerVenue);
377
+ set(name: string, value: string): Promise<SecretSetResult>;
378
+ /**
379
+ * Extract a secret value by name.
380
+ * NOTE: This operation requires a UCAN capability grant. The backend
381
+ * may reject requests that lack the appropriate capability proof.
382
+ */
383
+ extract(name: string): Promise<SecretExtractResult>;
384
+ list(): Promise<string[]>;
385
+ put(name: string, value: string): Promise<void>;
386
+ delete(name: string): Promise<void>;
387
+ }
388
+
77
389
  declare class Venue implements VenueInterface {
78
390
  baseUrl: string;
79
391
  venueId: string;
80
- credentials: Credentials;
392
+ auth: Auth;
81
393
  metadata: VenueData;
394
+ private _agents?;
395
+ private _jobs?;
396
+ private _assets?;
397
+ private _operations?;
398
+ private _workspace?;
399
+ private _ucan?;
400
+ private _secrets?;
401
+ get agents(): AgentManager;
402
+ get jobs(): JobManager;
403
+ get assets(): AssetManager;
404
+ get operations(): OperationManager;
405
+ get workspace(): WorkspaceManager;
406
+ get ucan(): UCANManager;
407
+ get secrets(): SecretManager;
82
408
  constructor(options?: VenueOptions);
83
409
  /**
84
410
  * Static method to connect to a venue
@@ -86,34 +412,24 @@ declare class Venue implements VenueInterface {
86
412
  * @param credentials - Optional credentials for venue authentication
87
413
  * @returns {Promise<Venue>} A new Venue instance configured appropriately
88
414
  */
89
- static connect(venueId: string | Venue, credentials?: CredentialsHTTP): Promise<Venue>;
90
- /**
91
- * Create a new asset
92
- * @param assetData - Asset configuration
93
- * @returns {Promise<Asset>}
94
- */
95
- createAsset(assetData: any): Promise<Asset>;
415
+ static connect(venueId: string | Venue, auth?: Auth): Promise<Venue>;
96
416
  /**
97
- * Read stream from asset
98
- * @param reader - ReadableStreamDefaultReader
99
- */
100
- readStream(reader: ReadableStreamDefaultReader<Uint8Array>): Promise<void>;
101
- /**
102
- * Get asset by ID
417
+ * Get asset by ID (convenience delegate to venue.assets.get)
103
418
  * @param assetId - Asset identifier
104
419
  * @returns {Promise<Asset>} Returns either an Operation or DataAsset based on the asset's metadata
105
420
  */
106
421
  getAsset(assetId: AssetID): Promise<Asset>;
107
422
  /**
108
- * Get all assets
109
- * @returns {Promise<Asset[]>}
423
+ * List assets with pagination support (convenience delegate to venue.assets.list)
424
+ * @param options - Pagination options (offset, limit)
425
+ * @returns {Promise<AssetList>} Paginated list of asset IDs with metadata
110
426
  */
111
- getAssets(): Promise<Asset[]>;
427
+ listAssets(options?: AssetListOptions): Promise<AssetList>;
112
428
  /**
113
- * Get all jobs
429
+ * List all jobs
114
430
  * @returns {Promise<string[]>}
115
431
  */
116
- getJobs(): Promise<string[]>;
432
+ listJobs(): Promise<string[]>;
117
433
  /**
118
434
  * Get job by ID
119
435
  * @param jobId - Job identifier
@@ -121,51 +437,51 @@ declare class Venue implements VenueInterface {
121
437
  */
122
438
  getJob(jobId: string): Promise<Job>;
123
439
  /**
124
- * Cancel job by ID
125
- * @param jobId - Job identifier
126
- * @returns {Promise<number>}
127
- */
128
- cancelJob(jobId: string): Promise<number>;
440
+ * List secret names
441
+ * @returns {Promise<string[]>}
442
+ */
443
+ listSecrets(): Promise<string[]>;
129
444
  /**
130
- * Delete job by ID
131
- * @param jobId - Job identifier
132
- * @returns {Promise<number>}
133
- */
134
- deleteJob(jobId: string): Promise<number>;
445
+ * Store a secret value
446
+ * @param name - Secret name
447
+ * @param value - Secret value
448
+ */
449
+ putSecret(name: string, value: string): Promise<void>;
135
450
  /**
136
- * Get the DID (Decentralized Identifier) for this venue
137
- * @returns {string} DID in the format did:web:domain
138
- */
139
- getStats(): Promise<StatusData>;
451
+ * Delete a secret
452
+ * @param name - Secret name
453
+ */
454
+ deleteSecret(name: string): Promise<void>;
140
455
  /**
141
- * Get asset metadata
142
- * @returns {Promise<AssetMetadata>}
456
+ * Get venue status
457
+ * @returns {Promise<StatusData>}
143
458
  */
144
- getMetadata(assetId: string): Promise<AssetMetadata>;
459
+ status(): Promise<StatusData>;
145
460
  /**
146
- * Upload content to asset
147
- * @param content - Content to upload
148
- * @returns {Promise<ReadableStream<Uint8Array> | null>}
149
- */
150
- uploadContent(assetId: string, content: BodyInit): Promise<ReadableStream<Uint8Array> | null>;
461
+ * Get the full DID document for this venue
462
+ * @returns {Promise<DIDDocument>}
463
+ */
464
+ didDocument(): Promise<DIDDocument>;
151
465
  /**
152
- * Get asset content
153
- * @returns {Promise<ReadableStream<Uint8Array> | null>}
466
+ * Get MCP (Model Context Protocol) discovery information
467
+ * @returns {Promise<MCPDiscovery>}
154
468
  */
155
- getContent(assetId: string): Promise<ReadableStream<Uint8Array> | null>;
469
+ mcpDiscovery(): Promise<MCPDiscovery>;
156
470
  /**
157
- * Execute the operation
158
- * @param input - Operation input parameters
159
- * @returns {Promise<any>}
160
- */
161
- run(assetId: string, input: any): Promise<any>;
471
+ * Get the A2A (Agent-to-Agent) agent card
472
+ * @returns {Promise<AgentCard>}
473
+ */
474
+ agentCard(): Promise<AgentCard>;
162
475
  /**
163
- * Execute the operation
164
- * @param input - Operation input parameters
165
- * @returns {Promise<Job>}
166
- */
167
- invoke(assetId: string, input: any): Promise<Job>;
168
- private setCredentialsInHeader;
476
+ * Close the venue and release resources.
477
+ * Clears cached asset data for this venue.
478
+ */
479
+ close(): void;
480
+ /**
481
+ * Disposable support — allows `using venue = await Grid.connect(...)` in TS 5.2+.
482
+ */
483
+ [Symbol.dispose](): void;
484
+ private _buildHeaders;
169
485
  }
170
486
 
171
487
  interface VenueOptions {
@@ -173,30 +489,32 @@ interface VenueOptions {
173
489
  venueId?: string;
174
490
  name?: string;
175
491
  description?: string;
176
- credentials?: Credentials;
492
+ auth?: Auth;
177
493
  }
178
494
  interface VenueConstructor {
179
495
  new (): VenueInterface;
180
- connect(venueId: string | Venue, credentials?: CredentialsHTTP): Promise<Venue>;
496
+ connect(venueId: string | Venue, auth?: Auth): Promise<Venue>;
497
+ }
498
+ interface InvokeOptions {
499
+ ucans?: string[];
181
500
  }
182
501
  interface VenueInterface {
183
502
  baseUrl: string;
184
503
  venueId: string;
185
504
  metadata: VenueData;
186
- cancelJob(jobId: string): Promise<number>;
187
- deleteJob(jobId: string): Promise<number>;
188
- getStats(): Promise<StatusData>;
505
+ auth: Auth;
506
+ status(): Promise<StatusData>;
189
507
  getJob(jobId: string): Promise<Job>;
190
- getJobs(): Promise<string[]>;
508
+ listJobs(): Promise<string[]>;
191
509
  getAsset(assetId: AssetID): Promise<Asset>;
192
- createAsset(assetData: any, userEmail: string): Promise<Asset>;
193
- getAssets(): Promise<Asset[]>;
194
- getMetadata(assetId: string): Promise<AssetMetadata>;
195
- readStream(reader: ReadableStreamDefaultReader<Uint8Array>): Promise<void>;
196
- uploadContent(assetId: string, content: BodyInit): Promise<ReadableStream<Uint8Array> | null>;
197
- getContent(assetId: string): Promise<ReadableStream<Uint8Array> | null>;
198
- run(assetId: string, input: any): Promise<any>;
199
- invoke(assetId: string, input: any): Promise<Job>;
510
+ listAssets(options?: AssetListOptions): Promise<AssetList>;
511
+ didDocument(): Promise<DIDDocument>;
512
+ mcpDiscovery(): Promise<MCPDiscovery>;
513
+ agentCard(): Promise<AgentCard>;
514
+ listSecrets(): Promise<string[]>;
515
+ putSecret(name: string, value: string): Promise<void>;
516
+ deleteSecret(name: string): Promise<void>;
517
+ close(): void;
200
518
  }
201
519
  type AssetID = string;
202
520
  interface AssetMetadata {
@@ -231,6 +549,9 @@ interface ContentDetails {
231
549
  interface OperationPayload {
232
550
  [key: string]: any;
233
551
  }
552
+ interface ContentHashResult {
553
+ hash: string;
554
+ }
234
555
  interface JobMetadata {
235
556
  name?: string;
236
557
  status?: RunStatus;
@@ -238,7 +559,9 @@ interface JobMetadata {
238
559
  updated?: string;
239
560
  input?: any;
240
561
  output?: any;
241
- op?: string;
562
+ operation?: string;
563
+ caller?: string;
564
+ error?: string;
242
565
  [key: string]: any;
243
566
  }
244
567
  interface InvokePayload {
@@ -257,6 +580,9 @@ declare enum RunStatus {
257
580
  AUTH_REQUIRED = "AUTH_REQUIRED",
258
581
  PAUSED = "PAUSED"
259
582
  }
583
+ /** Alias for RunStatus — matches Python SDK naming */
584
+ declare const JobStatus: typeof RunStatus;
585
+ type JobStatus = RunStatus;
260
586
  interface StatusData {
261
587
  url?: string;
262
588
  ts?: string;
@@ -271,10 +597,281 @@ interface StatsData {
271
597
  ops?: number;
272
598
  jobs?: number;
273
599
  }
600
+ interface AssetListOptions {
601
+ offset?: number;
602
+ limit?: number;
603
+ }
604
+ interface AssetList {
605
+ items: string[];
606
+ total: number;
607
+ offset: number;
608
+ limit: number;
609
+ }
610
+ interface MCPDiscovery {
611
+ mcp_version?: string;
612
+ server_url?: string;
613
+ description?: string;
614
+ tools_endpoint?: string;
615
+ endpoint?: Record<string, any> | string;
616
+ [key: string]: any;
617
+ }
618
+ interface AgentCard {
619
+ agentProvider?: Record<string, any>;
620
+ agentCapabilities?: Record<string, any>;
621
+ agentSkills?: Record<string, any>[];
622
+ agentInterfaces?: Record<string, any>[];
623
+ securityScheme?: Record<string, any>;
624
+ preferredTransport?: Record<string, any>;
625
+ [key: string]: any;
626
+ }
627
+ interface DIDDocument {
628
+ id: string;
629
+ '@context'?: string | string[];
630
+ [key: string]: any;
631
+ }
632
+ interface OperationInfo {
633
+ name: string;
634
+ asset: string;
635
+ description?: string;
636
+ input?: any;
637
+ output?: any;
638
+ [key: string]: any;
639
+ }
640
+ /** A single server-sent event received from a Covia venue. */
641
+ interface SSEEvent {
642
+ event: string | null;
643
+ data: string;
644
+ id: string | null;
645
+ retry: number | null;
646
+ /** Parse the event data as JSON. */
647
+ json: () => any;
648
+ }
649
+ declare enum AgentStatus {
650
+ SLEEPING = "SLEEPING",
651
+ RUNNING = "RUNNING",
652
+ SUSPENDED = "SUSPENDED",
653
+ TERMINATED = "TERMINATED"
654
+ }
655
+ interface AgentCreateInput {
656
+ agentId: string;
657
+ config?: Record<string, any>;
658
+ state?: Record<string, any>;
659
+ overwrite?: boolean;
660
+ }
661
+ interface AgentCreateResult {
662
+ agentId: string;
663
+ status: string;
664
+ created: boolean;
665
+ }
666
+ interface AgentRequestInput {
667
+ agentId: string;
668
+ input?: any;
669
+ wait?: boolean | number;
670
+ }
671
+ interface AgentRequestResult {
672
+ id: string;
673
+ status: string;
674
+ output?: any;
675
+ }
676
+ interface AgentMessageInput {
677
+ agentId: string;
678
+ message: any;
679
+ }
680
+ interface AgentMessageResult {
681
+ agentId: string;
682
+ delivered: boolean;
683
+ }
684
+ interface AgentTriggerInput {
685
+ agentId: string;
686
+ }
687
+ interface AgentTriggerResult {
688
+ agentId: string;
689
+ status: string;
690
+ result?: any;
691
+ taskResults?: any[];
692
+ }
693
+ interface AgentQueryInput {
694
+ agentId: string;
695
+ }
696
+ interface AgentQueryResult {
697
+ agentId: string;
698
+ status: string;
699
+ state?: Record<string, any>;
700
+ config?: Record<string, any>;
701
+ tasks?: any[];
702
+ [key: string]: any;
703
+ }
704
+ interface AgentListInput {
705
+ includeTerminated?: boolean;
706
+ }
707
+ interface AgentListResult {
708
+ agents: Array<{
709
+ agentId: string;
710
+ status: string;
711
+ tasks: number;
712
+ }>;
713
+ }
714
+ interface AgentDeleteInput {
715
+ agentId: string;
716
+ remove?: boolean;
717
+ }
718
+ interface AgentDeleteResult {
719
+ agentId: string;
720
+ status: string;
721
+ removed?: boolean;
722
+ }
723
+ interface AgentSuspendResult {
724
+ agentId: string;
725
+ status: string;
726
+ }
727
+ interface AgentResumeInput {
728
+ agentId: string;
729
+ autoWake?: boolean;
730
+ }
731
+ interface AgentUpdateInput {
732
+ agentId: string;
733
+ config?: Record<string, any>;
734
+ state?: Record<string, any>;
735
+ }
736
+ interface AgentCancelTaskInput {
737
+ agentId: string;
738
+ taskId: string;
739
+ }
740
+ interface WorkspaceReadInput {
741
+ path: string;
742
+ maxSize?: number;
743
+ }
744
+ interface WorkspaceReadResult {
745
+ exists: boolean;
746
+ value?: any;
747
+ truncated?: boolean;
748
+ size?: number;
749
+ }
750
+ interface WorkspaceWriteInput {
751
+ path: string;
752
+ value: any;
753
+ }
754
+ interface WorkspaceWriteResult {
755
+ written: boolean;
756
+ }
757
+ interface WorkspaceDeleteInput {
758
+ path: string;
759
+ }
760
+ interface WorkspaceDeleteResult {
761
+ deleted: boolean;
762
+ }
763
+ interface WorkspaceAppendInput {
764
+ path: string;
765
+ value: any;
766
+ }
767
+ interface WorkspaceAppendResult {
768
+ appended: boolean;
769
+ }
770
+ interface WorkspaceListInput {
771
+ path?: string;
772
+ limit?: number;
773
+ offset?: number;
774
+ }
775
+ interface WorkspaceListResult {
776
+ exists: boolean;
777
+ type: string;
778
+ count?: number;
779
+ keys?: string[];
780
+ values?: any[];
781
+ offset?: number;
782
+ }
783
+ interface WorkspaceSliceInput {
784
+ path: string;
785
+ offset?: number;
786
+ limit?: number;
787
+ }
788
+ interface WorkspaceSliceResult {
789
+ exists: boolean;
790
+ type: string;
791
+ values: any[];
792
+ count: number;
793
+ offset: number;
794
+ }
795
+ interface UCANAttenuation {
796
+ with: string;
797
+ can: string;
798
+ }
799
+ interface UCANIssueInput {
800
+ aud: string;
801
+ att: UCANAttenuation[];
802
+ exp: number;
803
+ }
804
+ interface UCANIssueResult {
805
+ [key: string]: any;
806
+ }
807
+ interface SecretSetInput {
808
+ name: string;
809
+ value: string;
810
+ }
811
+ interface SecretSetResult {
812
+ name: string;
813
+ stored: boolean;
814
+ }
815
+ interface SecretExtractInput {
816
+ name: string;
817
+ }
818
+ interface SecretExtractResult {
819
+ name: string;
820
+ value: string;
821
+ }
822
+ interface FunctionInfo {
823
+ name: string;
824
+ id: string;
825
+ description?: string;
826
+ }
827
+ interface FunctionsResult {
828
+ functions: FunctionInfo[];
829
+ }
830
+ interface AdapterInfo {
831
+ name: string;
832
+ description?: string;
833
+ operations: string[];
834
+ }
835
+ interface AdaptersResult {
836
+ adapters: AdapterInfo[];
837
+ }
274
838
  declare class CoviaError extends Error {
275
839
  code: number | null;
276
840
  constructor(message: string, code?: number | null);
277
841
  }
842
+ /** Raised when the Covia API returns an error response (4xx/5xx). */
843
+ declare class GridError extends CoviaError {
844
+ statusCode: number;
845
+ responseBody: any;
846
+ constructor(statusCode: number, message: string, responseBody?: any);
847
+ }
848
+ /** Raised when the SDK cannot connect to the venue. */
849
+ declare class CoviaConnectionError extends CoviaError {
850
+ constructor(message: string);
851
+ }
852
+ /** Raised when an operation or polling loop times out. */
853
+ declare class CoviaTimeoutError extends CoviaError {
854
+ constructor(message: string);
855
+ }
856
+ /** Raised when a job finishes with a non-COMPLETE status. */
857
+ declare class JobFailedError extends CoviaError {
858
+ jobData: JobMetadata;
859
+ constructor(jobData: JobMetadata);
860
+ }
861
+ /** Raised when a requested resource is not found (404). */
862
+ declare class NotFoundError extends GridError {
863
+ constructor(message: string);
864
+ }
865
+ /** Raised when an asset is not found (404). */
866
+ declare class AssetNotFoundError extends NotFoundError {
867
+ assetId: string;
868
+ constructor(assetId: string);
869
+ }
870
+ /** Raised when a job is not found (404). */
871
+ declare class JobNotFoundError extends NotFoundError {
872
+ jobId: string;
873
+ constructor(jobId: string);
874
+ }
278
875
 
279
876
  /**
280
877
  * Utility function to handle API calls with consistent error handling
@@ -322,14 +919,47 @@ declare function getParsedAssetId(assetId: string): string;
322
919
  */
323
920
  declare function getAssetIdFromPath(assetHex: string, assetPath: string): string;
324
921
  declare function getAssetIdFromVenueId(assetHex: string, venueId: string): string;
922
+ /**
923
+ * Create an SSEEvent object from parsed fields.
924
+ */
925
+ declare function createSSEEvent(fields: {
926
+ event?: string;
927
+ data?: string;
928
+ id?: string;
929
+ retry?: number;
930
+ }): SSEEvent;
931
+ /**
932
+ * Parse an SSE stream from a fetch Response body.
933
+ * Yields SSEEvent objects as they arrive.
934
+ */
935
+ declare function parseSSEStream(response: Response): AsyncGenerator<SSEEvent>;
936
+
937
+ /**
938
+ * Simple logger for the Covia SDK.
939
+ *
940
+ * By default logging is disabled (level = 'none'). Enable debug output with:
941
+ * import { logger } from '@covia/covia-sdk';
942
+ * logger.level = 'debug';
943
+ *
944
+ * Or provide a custom log function:
945
+ * logger.handler = (level, msg) => myLogger.log(level, msg);
946
+ */
947
+ type LogLevel = 'debug' | 'none';
948
+ type LogHandler = (level: string, message: string) => void;
949
+ declare const logger: {
950
+ level: LogLevel;
951
+ handler: LogHandler;
952
+ debug(message: string): void;
953
+ };
325
954
 
326
955
  declare class Grid {
327
956
  /**
328
957
  * Static method to connect to a venue
329
958
  * @param venueId - Can be a HTTP base URL, DNS name, or existing Venue instance
959
+ * @param auth - Optional authentication provider (BearerAuth, KeyPairAuth, etc.)
330
960
  * @returns {Promise<Venue>} A new Venue instance configured appropriately
331
961
  */
332
- static connect(venueId: string, credentials?: CredentialsHTTP): Promise<Venue>;
962
+ static connect(venueId: string, auth?: Auth): Promise<Venue>;
333
963
  }
334
964
 
335
965
  declare class Operation extends Asset {
@@ -340,4 +970,47 @@ declare class DataAsset extends Asset {
340
970
  constructor(id: AssetID, venue: VenueInterface, metadata?: AssetMetadata);
341
971
  }
342
972
 
343
- export { Asset, type AssetID, type AssetMetadata, type ContentDetails, CoviaError, type Credentials, CredentialsHTTP, DataAsset, Grid, type InvokePayload, Job, type JobMetadata, Operation, type OperationDetails, type OperationPayload, RunStatus, type StatsData, type StatusData, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, fetchStreamWithError, fetchWithError, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, isJobComplete, isJobFinished, isJobPaused };
973
+ /**
974
+ * Ed25519 keypair generation and utility functions.
975
+ */
976
+ /**
977
+ * Generate a random Ed25519 keypair.
978
+ * @returns Object with privateKey (32 bytes) and publicKey (32 bytes)
979
+ */
980
+ declare function generateKeyPair(): {
981
+ privateKey: Uint8Array;
982
+ publicKey: Uint8Array;
983
+ };
984
+ /**
985
+ * Convert a private key to hex string for storage.
986
+ */
987
+ declare function privateKeyToHex(key: Uint8Array): string;
988
+ /**
989
+ * Convert a hex string back to a private key Uint8Array.
990
+ */
991
+ declare function hexToPrivateKey(hex: string): Uint8Array;
992
+
993
+ /**
994
+ * Multikey encoding for Ed25519 public keys.
995
+ * Follows the did:key spec with multicodec prefix 0xed01 for Ed25519.
996
+ */
997
+ /**
998
+ * Encode an Ed25519 public key as a multikey string (z-prefixed base58-btc).
999
+ * @param publicKey - 32-byte Ed25519 public key
1000
+ * @returns Multikey string like "z6MkhaXgBZD..."
1001
+ */
1002
+ declare function encodePublicKey(publicKey: Uint8Array): string;
1003
+ /**
1004
+ * Decode a multikey string back to a 32-byte Ed25519 public key.
1005
+ * @param multikey - Multikey string starting with "z"
1006
+ * @returns 32-byte Ed25519 public key
1007
+ */
1008
+ declare function decodePublicKey(multikey: string): Uint8Array;
1009
+ /**
1010
+ * Create a did:key DID from an Ed25519 public key.
1011
+ * @param publicKey - 32-byte Ed25519 public key
1012
+ * @returns DID string like "did:key:z6MkhaXgBZD..."
1013
+ */
1014
+ declare function didFromPublicKey(publicKey: Uint8Array): string;
1015
+
1016
+ export { type AdapterInfo, type AdaptersResult, type AgentCancelTaskInput, type AgentCard, type AgentCreateInput, type AgentCreateResult, type AgentDeleteInput, type AgentDeleteResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentQueryInput, type AgentQueryResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, AssetNotFoundError, Auth, BearerAuth, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, DataAsset, type FunctionInfo, type FunctionsResult, Grid, GridError, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANIssueInput, type UCANIssueResult, UCANManager, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceDeleteInput, type WorkspaceDeleteResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceReadInput, type WorkspaceReadResult, type WorkspaceSliceInput, type WorkspaceSliceResult, type WorkspaceWriteInput, type WorkspaceWriteResult, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };