@vorim/sdk 1.0.0 → 1.0.2
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 +359 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
# @vorim/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The identity and trust layer for AI agents.**
|
|
4
4
|
|
|
5
|
-
Register agents with cryptographic identities, enforce
|
|
5
|
+
Register agents with cryptographic Ed25519 identities, enforce scoped permissions in under 5ms, emit tamper-evident audit trails, and verify trust scores — all in a few lines of code.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@vorim/sdk)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://www.typescriptlang.org/)
|
|
10
|
+
[](https://nodejs.org/)
|
|
11
|
+
[]()
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why Vorim?
|
|
16
|
+
|
|
17
|
+
AI agents are shipping into production without identity, permissions, or audit trails. This is a problem:
|
|
18
|
+
|
|
19
|
+
- **No identity** — agents share API keys. You can't tell which agent did what.
|
|
20
|
+
- **No permissions** — agents get all-or-nothing access. No scoped, time-bounded controls.
|
|
21
|
+
- **No audit trail** — no tamper-evident record of agent actions. Compliance teams are blind.
|
|
22
|
+
- **No trust signal** — third parties can't verify an agent before interacting with it.
|
|
23
|
+
|
|
24
|
+
Vorim solves all four. One SDK. One protocol. Ships in minutes.
|
|
25
|
+
|
|
26
|
+
> **EU AI Act** (enforced Aug 2025) mandates traceability and audit trails for high-risk AI systems. Vorim makes your agents compliant out of the box.
|
|
27
|
+
|
|
28
|
+
---
|
|
6
29
|
|
|
7
30
|
## Install
|
|
8
31
|
|
|
@@ -10,92 +33,377 @@ Register agents with cryptographic identities, enforce fine-grained permissions,
|
|
|
10
33
|
npm install @vorim/sdk
|
|
11
34
|
```
|
|
12
35
|
|
|
36
|
+
```bash
|
|
37
|
+
# or
|
|
38
|
+
yarn add @vorim/sdk
|
|
39
|
+
# or
|
|
40
|
+
pnpm add @vorim/sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
13
45
|
## Quick Start
|
|
14
46
|
|
|
15
47
|
```typescript
|
|
16
|
-
import createVorim from
|
|
48
|
+
import createVorim from "@vorim/sdk";
|
|
17
49
|
|
|
18
50
|
const vorim = createVorim({
|
|
19
|
-
apiKey:
|
|
51
|
+
apiKey: "agid_sk_live_...",
|
|
20
52
|
});
|
|
21
53
|
|
|
22
|
-
// Register an agent
|
|
54
|
+
// 1. Register an agent — Ed25519 keypair generated, private key shown once
|
|
23
55
|
const { agent, private_key } = await vorim.register({
|
|
24
|
-
name:
|
|
25
|
-
capabilities: [
|
|
26
|
-
scopes: [
|
|
56
|
+
name: "invoice-processor",
|
|
57
|
+
capabilities: ["read_documents", "extract_data"],
|
|
58
|
+
scopes: ["agent:read", "agent:execute"],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(agent.agent_id); // agid_acme_a1b2c3d4
|
|
62
|
+
console.log(agent.trust_score); // 50 (initial)
|
|
63
|
+
|
|
64
|
+
// 2. Check permissions before acting (<5ms via Redis)
|
|
65
|
+
const { allowed } = await vorim.check(agent.agent_id, "agent:execute");
|
|
66
|
+
|
|
67
|
+
if (allowed) {
|
|
68
|
+
// 3. Perform the action, then emit an audit event
|
|
69
|
+
await vorim.emit({
|
|
70
|
+
agent_id: agent.agent_id,
|
|
71
|
+
event_type: "tool_call",
|
|
72
|
+
action: "process_invoice",
|
|
73
|
+
resource: "INV-2026-0042",
|
|
74
|
+
result: "success",
|
|
75
|
+
latency_ms: 142,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 4. Verify any agent's trust (public endpoint, no auth required)
|
|
80
|
+
const trust = await vorim.verify(agent.agent_id);
|
|
81
|
+
console.log(trust.trust_score); // 0–100
|
|
82
|
+
console.log(trust.active_scopes); // ['agent:read', 'agent:execute']
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Framework Integration
|
|
88
|
+
|
|
89
|
+
### LangChain
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import createVorim from "@vorim/sdk";
|
|
93
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
94
|
+
import { AgentExecutor } from "langchain/agents";
|
|
95
|
+
|
|
96
|
+
const vorim = createVorim({ apiKey: "agid_sk_live_..." });
|
|
97
|
+
|
|
98
|
+
// Register your LangChain agent with Vorim
|
|
99
|
+
const { agent: identity } = await vorim.register({
|
|
100
|
+
name: "langchain-research-agent",
|
|
101
|
+
capabilities: ["web_browsing", "api_calls"],
|
|
102
|
+
scopes: ["agent:read", "agent:execute", "agent:communicate"],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Check permissions before every tool call
|
|
106
|
+
async function guardedToolCall(toolName: string, input: any) {
|
|
107
|
+
const { allowed } = await vorim.check(identity.agent_id, "agent:execute");
|
|
108
|
+
if (!allowed) throw new Error("Permission denied by Vorim");
|
|
109
|
+
|
|
110
|
+
const result = await executeTool(toolName, input);
|
|
111
|
+
|
|
112
|
+
// Audit every action
|
|
113
|
+
await vorim.emit({
|
|
114
|
+
agent_id: identity.agent_id,
|
|
115
|
+
event_type: "tool_call",
|
|
116
|
+
action: `${toolName}: ${JSON.stringify(input)}`,
|
|
117
|
+
result: "success",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### CrewAI
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import createVorim from "@vorim/sdk";
|
|
128
|
+
|
|
129
|
+
const vorim = createVorim({ apiKey: "agid_sk_live_..." });
|
|
130
|
+
|
|
131
|
+
// Register each crew member as a Vorim agent
|
|
132
|
+
const researcher = await vorim.register({
|
|
133
|
+
name: "crew-researcher",
|
|
134
|
+
capabilities: ["web_browsing"],
|
|
135
|
+
scopes: ["agent:read"],
|
|
27
136
|
});
|
|
28
137
|
|
|
29
|
-
|
|
30
|
-
|
|
138
|
+
const writer = await vorim.register({
|
|
139
|
+
name: "crew-writer",
|
|
140
|
+
capabilities: ["file_access"],
|
|
141
|
+
scopes: ["agent:read", "agent:write"],
|
|
142
|
+
});
|
|
31
143
|
|
|
32
|
-
//
|
|
144
|
+
// Verify permissions before delegation
|
|
145
|
+
const { allowed } = await vorim.check(writer.agent.agent_id, "agent:write");
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### OpenAI Agents SDK
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import createVorim from "@vorim/sdk";
|
|
152
|
+
import OpenAI from "openai";
|
|
153
|
+
|
|
154
|
+
const vorim = createVorim({ apiKey: "agid_sk_live_..." });
|
|
155
|
+
const openai = new OpenAI();
|
|
156
|
+
|
|
157
|
+
// Register your OpenAI agent
|
|
158
|
+
const { agent: identity } = await vorim.register({
|
|
159
|
+
name: "openai-assistant",
|
|
160
|
+
capabilities: ["api_calls", "code_execution"],
|
|
161
|
+
scopes: ["agent:read", "agent:execute"],
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Wrap function calls with Vorim permission checks
|
|
165
|
+
async function handleFunctionCall(call: any) {
|
|
166
|
+
const { allowed } = await vorim.check(identity.agent_id, "agent:execute");
|
|
167
|
+
if (!allowed) return { error: "Blocked by Vorim trust layer" };
|
|
168
|
+
|
|
169
|
+
const result = await executeFunction(call);
|
|
170
|
+
|
|
171
|
+
await vorim.emit({
|
|
172
|
+
agent_id: identity.agent_id,
|
|
173
|
+
event_type: "tool_call",
|
|
174
|
+
action: call.name,
|
|
175
|
+
resource: JSON.stringify(call.arguments),
|
|
176
|
+
result: "success",
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## API Reference
|
|
186
|
+
|
|
187
|
+
### Identity
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Register a new agent (private key returned once — store it securely)
|
|
191
|
+
const { agent, private_key } = await vorim.register({
|
|
192
|
+
name: "my-agent",
|
|
193
|
+
description: "Processes invoices",
|
|
194
|
+
capabilities: ["read_documents"],
|
|
195
|
+
scopes: ["agent:read", "agent:execute"],
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Get agent details
|
|
199
|
+
const agent = await vorim.getAgent("agid_acme_a1b2c3d4");
|
|
200
|
+
|
|
201
|
+
// List all agents in your organisation
|
|
202
|
+
const { agents, meta } = await vorim.listAgents({ page: 1, per_page: 20 });
|
|
203
|
+
|
|
204
|
+
// Permanently revoke an agent
|
|
205
|
+
await vorim.revoke("agid_acme_a1b2c3d4");
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Permissions
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// Check if an agent has a specific permission (<5ms)
|
|
212
|
+
const { allowed, remaining_quota } = await vorim.check(
|
|
213
|
+
"agid_acme_a1b2c3d4",
|
|
214
|
+
"agent:execute"
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// Grant a time-bounded, rate-limited permission
|
|
218
|
+
await vorim.grant("agid_acme_a1b2c3d4", "agent:transact", {
|
|
219
|
+
valid_until: "2026-06-01T00:00:00Z",
|
|
220
|
+
rate_limit: { max: 100, window: "1h" },
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### Permission Scopes
|
|
225
|
+
|
|
226
|
+
| Scope | Description |
|
|
227
|
+
|-------|-------------|
|
|
228
|
+
| `agent:read` | Read data and resources |
|
|
229
|
+
| `agent:write` | Create or modify resources |
|
|
230
|
+
| `agent:execute` | Execute tools and functions |
|
|
231
|
+
| `agent:transact` | Perform financial transactions |
|
|
232
|
+
| `agent:communicate` | Send messages and notifications |
|
|
233
|
+
| `agent:delegate` | Delegate tasks to other agents |
|
|
234
|
+
| `agent:elevate` | Request elevated privileges |
|
|
235
|
+
|
|
236
|
+
### Audit
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// Emit a single audit event
|
|
33
240
|
await vorim.emit({
|
|
34
|
-
agent_id:
|
|
35
|
-
event_type:
|
|
36
|
-
action:
|
|
37
|
-
|
|
241
|
+
agent_id: "agid_acme_a1b2c3d4",
|
|
242
|
+
event_type: "tool_call",
|
|
243
|
+
action: "send_email",
|
|
244
|
+
resource: "user@example.com",
|
|
245
|
+
result: "success",
|
|
246
|
+
latency_ms: 230,
|
|
247
|
+
metadata: { template: "invoice_reminder" },
|
|
38
248
|
});
|
|
39
249
|
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
250
|
+
// Batch emit up to 1,000 events
|
|
251
|
+
await vorim.emitBatch([
|
|
252
|
+
{ agent_id: "agid_acme_a1b2c3d4", event_type: "api_request", action: "GET /users", result: "success" },
|
|
253
|
+
{ agent_id: "agid_acme_a1b2c3d4", event_type: "api_request", action: "POST /orders", result: "denied" },
|
|
254
|
+
]);
|
|
43
255
|
```
|
|
44
256
|
|
|
45
|
-
|
|
257
|
+
### Trust Verification
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
// Public endpoint — no API key required
|
|
261
|
+
const trust = await vorim.verify("agid_acme_a1b2c3d4");
|
|
262
|
+
|
|
263
|
+
trust.verified; // true
|
|
264
|
+
trust.trust_score; // 82
|
|
265
|
+
trust.status; // 'active'
|
|
266
|
+
trust.owner.org_name; // 'Acme Corp'
|
|
267
|
+
trust.active_scopes; // ['agent:read', 'agent:execute']
|
|
268
|
+
trust.key_fingerprint; // 'a1b2c3d4...'
|
|
269
|
+
trust.revocation_status; // false
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Trust score factors:**
|
|
273
|
+
- Agent status (active, suspended, revoked)
|
|
274
|
+
- Account age (older = more trusted)
|
|
275
|
+
- Success rate over last 30 days
|
|
276
|
+
- Denial ratio (high denials = lower trust)
|
|
277
|
+
- Scope breadth (too many scopes = higher risk)
|
|
46
278
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
279
|
+
### Payload Signing
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
// Sign a payload with the agent's Ed25519 private key (client-side)
|
|
283
|
+
const signature = await vorim.sign(
|
|
284
|
+
JSON.stringify({ action: "transfer", amount: 500 }),
|
|
285
|
+
privateKeyPem
|
|
286
|
+
);
|
|
287
|
+
// Returns: "ed25519:base64signature..."
|
|
288
|
+
|
|
289
|
+
// Include signature in audit events for non-repudiation
|
|
290
|
+
await vorim.emit({
|
|
291
|
+
agent_id: "agid_acme_a1b2c3d4",
|
|
292
|
+
event_type: "tool_call",
|
|
293
|
+
action: "transfer_funds",
|
|
294
|
+
result: "success",
|
|
295
|
+
signature,
|
|
296
|
+
});
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Embeddable Trust Badge
|
|
300
|
+
|
|
301
|
+
Every registered agent gets a public SVG trust badge you can embed anywhere:
|
|
302
|
+
|
|
303
|
+
```html
|
|
304
|
+
<!-- Embed in your docs, landing page, or agent marketplace listing -->
|
|
305
|
+
<img src="https://api.vorim.ai/v1/trust/badge/agid_acme_a1b2c3d4.svg" alt="Vorim Trust Badge" />
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
The badge displays the agent's current trust score and updates in real-time. Use it to signal trust to end users, partners, and other agents.
|
|
309
|
+
|
|
310
|
+
---
|
|
68
311
|
|
|
69
312
|
## Configuration
|
|
70
313
|
|
|
71
314
|
```typescript
|
|
315
|
+
import createVorim from "@vorim/sdk";
|
|
316
|
+
|
|
72
317
|
const vorim = createVorim({
|
|
73
|
-
apiKey:
|
|
74
|
-
baseUrl:
|
|
75
|
-
timeout: 10000,
|
|
318
|
+
apiKey: "agid_sk_live_...", // Required — your Vorim API key
|
|
319
|
+
baseUrl: "https://api.vorim.ai", // Optional (default)
|
|
320
|
+
timeout: 10000, // Optional — request timeout in ms (default: 10000)
|
|
76
321
|
});
|
|
77
322
|
```
|
|
78
323
|
|
|
324
|
+
| Option | Type | Default | Description |
|
|
325
|
+
|--------|------|---------|-------------|
|
|
326
|
+
| `apiKey` | `string` | — | Your Vorim API key (`agid_sk_live_...` or `agid_sk_test_...`) |
|
|
327
|
+
| `baseUrl` | `string` | `https://api.vorim.ai` | API base URL (override for self-hosted) |
|
|
328
|
+
| `timeout` | `number` | `10000` | Request timeout in milliseconds |
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
79
332
|
## Error Handling
|
|
80
333
|
|
|
334
|
+
All errors throw `VorimError` with structured fields:
|
|
335
|
+
|
|
81
336
|
```typescript
|
|
82
|
-
import { VorimError } from
|
|
337
|
+
import createVorim, { VorimError } from "@vorim/sdk";
|
|
83
338
|
|
|
84
339
|
try {
|
|
85
|
-
await vorim.check(
|
|
340
|
+
await vorim.check("invalid_id", "agent:read");
|
|
86
341
|
} catch (err) {
|
|
87
342
|
if (err instanceof VorimError) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
343
|
+
err.status; // 404
|
|
344
|
+
err.code; // 'AGENT_NOT_FOUND'
|
|
345
|
+
err.message; // 'Agent invalid_id not found in the trust registry'
|
|
346
|
+
err.details; // Additional context (optional)
|
|
91
347
|
}
|
|
92
348
|
}
|
|
93
349
|
```
|
|
94
350
|
|
|
95
|
-
|
|
351
|
+
| Error Code | Status | Meaning |
|
|
352
|
+
|-----------|--------|---------|
|
|
353
|
+
| `INVALID_CREDENTIALS` | 401 | Bad or expired API key |
|
|
354
|
+
| `AGENT_NOT_FOUND` | 404 | Agent ID doesn't exist |
|
|
355
|
+
| `PERMISSION_DENIED` | 403 | Agent lacks required scope |
|
|
356
|
+
| `RATE_LIMITED` | 429 | Too many requests |
|
|
357
|
+
| `VALIDATION_ERROR` | 400 | Invalid request payload |
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Features
|
|
362
|
+
|
|
363
|
+
| Feature | Details |
|
|
364
|
+
|---------|---------|
|
|
365
|
+
| **Cryptographic Identity** | Ed25519 keypairs with SHA-256 fingerprints |
|
|
366
|
+
| **7 Permission Scopes** | `read`, `write`, `execute`, `transact`, `communicate`, `delegate`, `elevate` |
|
|
367
|
+
| **Immutable Audit Trail** | Append-only events with content hashing |
|
|
368
|
+
| **Trust Scoring** | 5-factor algorithm producing a 0–100 score |
|
|
369
|
+
| **Payload Signing** | Client-side Ed25519 via Web Crypto or Node.js crypto |
|
|
370
|
+
| **Dual Runtime** | Node.js 18+ and modern browsers |
|
|
371
|
+
| **Zero Dependencies** | Types bundled — nothing extra to install |
|
|
372
|
+
| **ESM + CJS** | Dual module output for any bundler or runtime |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Protocol
|
|
377
|
+
|
|
378
|
+
This SDK implements the **[Vorim Agent Identity Protocol (VAIP)](https://github.com/Kzino/vorim-protocol)** — an open standard for AI agent identity, permissions, and cryptographic audit trails.
|
|
379
|
+
|
|
380
|
+
VAIP defines 5 conformance levels, from basic identity to full cryptographic signing. The protocol is open-source under Apache 2.0 — anyone can implement it.
|
|
381
|
+
|
|
382
|
+
Read the full specification: **[SPEC.md](https://github.com/Kzino/vorim-protocol/blob/main/SPEC.md)**
|
|
383
|
+
|
|
384
|
+
---
|
|
96
385
|
|
|
97
|
-
|
|
386
|
+
## Requirements
|
|
387
|
+
|
|
388
|
+
- **Node.js** 18+ or modern browser with Web Crypto API
|
|
389
|
+
- **TypeScript** 5.0+ (optional but recommended)
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Links
|
|
394
|
+
|
|
395
|
+
- **Website:** [vorim.ai](https://vorim.ai)
|
|
396
|
+
- **Protocol Spec:** [github.com/Kzino/vorim-protocol](https://github.com/Kzino/vorim-protocol)
|
|
397
|
+
- **npm:** [@vorim/sdk](https://www.npmjs.com/package/@vorim/sdk)
|
|
398
|
+
- **X:** [@vorim_ai_x](https://x.com/vorim_ai_x)
|
|
399
|
+
- **Issues:** [GitHub Issues](https://github.com/Kzino/vorim-protocol/issues)
|
|
400
|
+
|
|
401
|
+
---
|
|
98
402
|
|
|
99
403
|
## License
|
|
100
404
|
|
|
101
|
-
MIT
|
|
405
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
Built by **[Vorim AI](https://vorim.ai)**
|