@covia/covia-sdk 1.7.4 → 1.9.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 +98 -33
- package/dist/index.d.mts +196 -64
- package/dist/index.d.ts +196 -64
- package/dist/index.js +503 -157
- package/dist/index.mjs +500 -158
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -25,14 +25,14 @@ yarn add @covia/covia-sdk
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { Grid,
|
|
28
|
+
import { Grid, Ed25519Auth } from "@covia/covia-sdk";
|
|
29
29
|
|
|
30
30
|
// Connect to a venue (URL, DNS name, or DID)
|
|
31
|
-
const venue = await Grid.connect("https://venue.
|
|
31
|
+
const venue = await Grid.connect("https://your-venue.example.com");
|
|
32
32
|
|
|
33
33
|
// Or connect with keypair authentication
|
|
34
|
-
const auth =
|
|
35
|
-
const venue = await Grid.connect("did:web:venue.
|
|
34
|
+
const auth = Ed25519Auth.generate();
|
|
35
|
+
const venue = await Grid.connect("did:web:your-venue.example.com", auth);
|
|
36
36
|
|
|
37
37
|
// Run an operation and get the result
|
|
38
38
|
const result = await venue.operations.run("v/ops/schema/infer", {
|
|
@@ -65,34 +65,34 @@ venue.close();
|
|
|
65
65
|
The SDK supports three connection methods:
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
|
-
import { Grid, Venue,
|
|
68
|
+
import { Grid, Venue, Ed25519Auth, BearerAuth } from "@covia/covia-sdk";
|
|
69
69
|
|
|
70
70
|
// Via Grid (cached — same ID returns the same Venue instance)
|
|
71
|
-
const venue = await Grid.connect("https://venue.
|
|
72
|
-
const venue = await Grid.connect("did:web:venue.
|
|
73
|
-
const venue = await Grid.connect("venue.
|
|
71
|
+
const venue = await Grid.connect("https://your-venue.example.com");
|
|
72
|
+
const venue = await Grid.connect("did:web:your-venue.example.com");
|
|
73
|
+
const venue = await Grid.connect("your-venue.example.com"); // DNS name → https://
|
|
74
74
|
|
|
75
75
|
// Via Venue directly (no caching)
|
|
76
|
-
const venue = await Venue.connect("https://venue.
|
|
76
|
+
const venue = await Venue.connect("https://your-venue.example.com");
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Authentication
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
82
|
// No auth (default)
|
|
83
|
-
const venue = await Grid.connect("https://venue.
|
|
83
|
+
const venue = await Grid.connect("https://your-venue.example.com");
|
|
84
84
|
|
|
85
85
|
// Ed25519 keypair (self-issued JWT per request)
|
|
86
|
-
const auth =
|
|
86
|
+
const auth = Ed25519Auth.generate();
|
|
87
87
|
console.log(auth.getDID()); // did:key:z6Mk...
|
|
88
|
-
const venue = await Grid.connect("https://venue.
|
|
88
|
+
const venue = await Grid.connect("https://your-venue.example.com", auth);
|
|
89
89
|
|
|
90
90
|
// From a saved private key
|
|
91
|
-
const auth =
|
|
91
|
+
const auth = Ed25519Auth.fromHex("abcdef1234...");
|
|
92
92
|
|
|
93
93
|
// Bearer token
|
|
94
94
|
const auth = new BearerAuth("my-api-token");
|
|
95
|
-
const venue = await Grid.connect("https://venue.
|
|
95
|
+
const venue = await Grid.connect("https://your-venue.example.com", auth);
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
## API Reference
|
|
@@ -118,26 +118,28 @@ venue.metadata; // { name, description }
|
|
|
118
118
|
| `venue.didDocument()` | Get the venue's DID document |
|
|
119
119
|
| `venue.mcpDiscovery()` | Get MCP (Model Context Protocol) discovery info |
|
|
120
120
|
| `venue.agentCard()` | Get A2A (Agent-to-Agent) agent card |
|
|
121
|
-
| `venue.setPrivate(enabled)` |
|
|
121
|
+
| `venue.setPrivate(enabled)` | Deprecated connection-wide private-jobs mode (see below) |
|
|
122
122
|
| `venue.close()` | Release resources and clear caches |
|
|
123
123
|
|
|
124
124
|
#### Private jobs
|
|
125
125
|
|
|
126
|
-
`
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
poll-style `operations.invoke()` throws.
|
|
126
|
+
Pass `{ private: true }` to `operations.run()` to execute as a memory-only job:
|
|
127
|
+
it is never persisted to the venue's job index and is gone on venue restart.
|
|
128
|
+
The venue must have `enablePrivateJobs` set. Because a completed private job is
|
|
129
|
+
immediately forgotten by the venue, results are collected through the
|
|
130
|
+
server-side invoke `wait` window rather than polling. Private execution works
|
|
131
|
+
with `run()`; poll-style `operations.invoke()` rejects it.
|
|
133
132
|
|
|
134
133
|
```typescript
|
|
135
|
-
venue.setPrivate(true);
|
|
136
134
|
const result = await venue.operations.run("v/ops/schema/infer", {
|
|
137
135
|
value: { name: "Ada", age: 36 },
|
|
138
|
-
});
|
|
136
|
+
}, { private: true });
|
|
139
137
|
```
|
|
140
138
|
|
|
139
|
+
`venue.setPrivate(true)` remains available for compatibility, but is
|
|
140
|
+
deprecated because it mutates execution behaviour for every user of the same
|
|
141
|
+
cached connection.
|
|
142
|
+
|
|
141
143
|
---
|
|
142
144
|
|
|
143
145
|
### Operations — `venue.operations`
|
|
@@ -375,7 +377,6 @@ const mina = venue.agent("Mina");
|
|
|
375
377
|
const response = await mina.request({ text: "hello" });
|
|
376
378
|
await mina.message({ event: "update" });
|
|
377
379
|
await mina.trigger();
|
|
378
|
-
const state = await mina.query();
|
|
379
380
|
const info = await mina.info();
|
|
380
381
|
|
|
381
382
|
// Session-scoped chat — ChatSession manages the sessionId for you
|
|
@@ -408,8 +409,9 @@ const clone = await mina.fork("Mina-v2", { includeTimeline: true });
|
|
|
408
409
|
| `agent.chat(message, sessionId?)` | `AgentChatResult` | Single chat call (manual sessionId) |
|
|
409
410
|
| `agent.chatSession(sessionId?)` | `ChatSession` | Create a session that manages sessionId |
|
|
410
411
|
| `agent.trigger()` | `AgentTriggerResult` | Trigger agent execution |
|
|
411
|
-
| `agent.query()` | `AgentQueryResult` | Query agent state |
|
|
412
412
|
| `agent.info()` | `AgentInfoResult` | Get agent info |
|
|
413
|
+
| `agent.listSessions(options?)` | `AgentSessionPage` | Page sessions (job-free) |
|
|
414
|
+
| `agent.getSession(sessionId)` | `AgentSession` | Get one session (job-free) |
|
|
413
415
|
| `agent.context(task?)` | `string` | Get agent context |
|
|
414
416
|
| `agent.suspend()` | `AgentSuspendResult` | Suspend the agent |
|
|
415
417
|
| `agent.resume(autoWake?)` | `AgentSuspendResult` | Resume the agent |
|
|
@@ -448,8 +450,9 @@ await venue.agents.chat("my-agent", "hi");
|
|
|
448
450
|
| `agents.message(id, message)` | `AgentMessageResult` | Send a message |
|
|
449
451
|
| `agents.chat(id, message, sessionId?)` | `AgentChatResult` | Session-scoped chat |
|
|
450
452
|
| `agents.trigger(id)` | `AgentTriggerResult` | Trigger agent execution |
|
|
451
|
-
| `agents.query(id)` | `AgentQueryResult` | Query agent state |
|
|
452
453
|
| `agents.info(id)` | `AgentInfoResult` | Get agent info |
|
|
454
|
+
| `agents.listSessions(id, options?)` | `AgentSessionPage` | Page sessions (job-free) |
|
|
455
|
+
| `agents.getSession(id, sessionId)` | `AgentSession` | Get one session (job-free) |
|
|
453
456
|
| `agents.suspend(id)` | `AgentSuspendResult` | Suspend an agent |
|
|
454
457
|
| `agents.resume(id, autoWake?)` | `AgentSuspendResult` | Resume an agent |
|
|
455
458
|
| `agents.update(input)` | `any` | Update agent config/state |
|
|
@@ -468,8 +471,10 @@ Read and write shared state in the venue's workspace.
|
|
|
468
471
|
`GET /api/v1/values/*` (covia #177) — synchronous, capability-checked, and **no job is
|
|
469
472
|
persisted**. This matters under load: routing reads through the invoke/job path writes a
|
|
470
473
|
durable job record per read, growing the venue's etch without bound. **Writes stay on the
|
|
471
|
-
job path** (they should leave an audit record).
|
|
472
|
-
|
|
474
|
+
job path** (they should leave an audit record). Reads that need UCAN proof tokens,
|
|
475
|
+
multi-path inspection, or a venue without the Values surface reject with
|
|
476
|
+
`UnsupportedVenueFeatureError` rather than silently creating a persisted job. Invoke
|
|
477
|
+
the corresponding operation explicitly when a persisted job is intended.
|
|
473
478
|
|
|
474
479
|
```typescript
|
|
475
480
|
// CRUD (reads are job-free; writes are jobs)
|
|
@@ -478,8 +483,8 @@ const data = await venue.workspace.read("w/my-app/config");
|
|
|
478
483
|
await venue.workspace.append("w/my-app/log", "new entry");
|
|
479
484
|
await venue.workspace.delete("w/my-app/config");
|
|
480
485
|
|
|
481
|
-
// List and slice
|
|
482
|
-
const entries = await venue.workspace.list("w/my-app/
|
|
486
|
+
// List (map keys) and slice (sequence elements)
|
|
487
|
+
const entries = await venue.workspace.list("w/my-app/config", 100, 0);
|
|
483
488
|
const slice = await venue.workspace.slice("w/my-app/log", 0, 10);
|
|
484
489
|
|
|
485
490
|
// Server-side tallies — count / group-by without reading every record
|
|
@@ -501,6 +506,40 @@ const byKind = await venue.workspace.aggregate("w/my-app/events", { depth: 2, gr
|
|
|
501
506
|
| `workspace.aggregate(path, {depth?, groupBy?})` | `WorkspaceAggregateResult` | Count, optionally grouped by a field (job-free) |
|
|
502
507
|
| `workspace.copy(from, to)` | `WorkspaceCopyResult` | Copy a value between paths (job) |
|
|
503
508
|
|
|
509
|
+
### Skills — `venue.skills`
|
|
510
|
+
|
|
511
|
+
Skills are ordinary assets with optional agent-behaviour metadata. The SDK only
|
|
512
|
+
provides exact location/path access; applications decide how to combine, search
|
|
513
|
+
or prioritise collections.
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
const skills = await venue.skills.list("w/skills");
|
|
517
|
+
const reviewer = await venue.skills.get("w/skills/reviewer");
|
|
518
|
+
|
|
519
|
+
reviewer.metadata.name;
|
|
520
|
+
reviewer.metadata.skill?.tools;
|
|
521
|
+
const content = await reviewer.getContent();
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
`list(path)` follows internal collection pagination and returns the asset objects
|
|
525
|
+
at that location. `get(path)` is the corresponding typed asset lookup.
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
### Memory — `venue.memory`
|
|
530
|
+
|
|
531
|
+
Read the conventional `w/memory` vector as structured entries. Reads are
|
|
532
|
+
job-free; edits use the venue memory operation and therefore leave an audit Job.
|
|
533
|
+
|
|
534
|
+
```typescript
|
|
535
|
+
const entries = await venue.memory.list();
|
|
536
|
+
await venue.memory.remember("Prefers concise answers");
|
|
537
|
+
await venue.memory.update(1, "Prefers concise technical answers");
|
|
538
|
+
await venue.memory.forget(1);
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
An alternative path can be passed to each method.
|
|
542
|
+
|
|
504
543
|
---
|
|
505
544
|
|
|
506
545
|
### Secrets — `venue.secrets`
|
|
@@ -667,12 +706,38 @@ RunStatus.AUTH_REQUIRED; // Waiting for authentication
|
|
|
667
706
|
import {
|
|
668
707
|
Venue, Grid, Job, Agent, ChatSession, Asset, Operation, DataAsset,
|
|
669
708
|
AdapterManager, AssetManager, OperationManager, JobManager,
|
|
670
|
-
AgentManager, WorkspaceManager, SecretManager, UCANManager,
|
|
671
|
-
|
|
709
|
+
AgentManager, WorkspaceManager, SecretManager, UCANManager, SkillManager,
|
|
710
|
+
MemoryManager,
|
|
711
|
+
Ed25519Auth, BearerAuth,
|
|
672
712
|
RunStatus, CoviaError,
|
|
673
713
|
} from "@covia/covia-sdk";
|
|
674
714
|
```
|
|
675
715
|
|
|
716
|
+
## Upgrading from 1.8
|
|
717
|
+
|
|
718
|
+
1.9.0 keeps every exported signature compatible, but three behaviours changed
|
|
719
|
+
deliberately:
|
|
720
|
+
|
|
721
|
+
- **Reads never create jobs — and no longer fall back to the job path.**
|
|
722
|
+
In 1.8.x, workspace reads with UCAN proofs, multi-path `inspect`, and
|
|
723
|
+
`agents.list()`/`info()` on older venues silently fell back to invoking an
|
|
724
|
+
operation, persisting a Job per read. These calls now throw
|
|
725
|
+
`UnsupportedVenueFeatureError` instead. If creating a persisted job is
|
|
726
|
+
genuinely intended, invoke the corresponding operation explicitly
|
|
727
|
+
(e.g. `operations.run("v/ops/covia/read", ...)`).
|
|
728
|
+
- **`Ed25519Auth` requires a venue audience.** Tokens are always bound to the
|
|
729
|
+
venue's DID (`aud` claim) so they cannot be replayed at another venue.
|
|
730
|
+
Connect via `Grid.connect()` / `Venue.connect()` and this happens
|
|
731
|
+
automatically; hand-constructed `new Venue({...})` usage must either call
|
|
732
|
+
`venue.status()`-style validation first or pin `auth.audience` explicitly.
|
|
733
|
+
Connect-time probing itself is anonymous — credentials are only ever sent to
|
|
734
|
+
a venue whose identity has been pinned.
|
|
735
|
+
- **`assets.clearCache()` clears only the in-memory cache.** Purging a
|
|
736
|
+
configured persistent metadata store (e.g. localStorage) is the new
|
|
737
|
+
`assets.clearPersistentCache()`. Cached entries are content-addressed and
|
|
738
|
+
immutable, so keeping them across sessions is safe; call
|
|
739
|
+
`clearPersistentCache()` at sign-out if your app must empty the store.
|
|
740
|
+
|
|
676
741
|
## Resources
|
|
677
742
|
|
|
678
743
|
- [Covia.ai Platform](https://covia.ai)
|