@vorim/sdk 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +186 -51
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # @vorim/sdk
2
2
 
3
- Official TypeScript SDK for **Vorim AI** — the AI Agent Identity & Trust Layer.
3
+ The official TypeScript SDK for **[Vorim AI](https://vorim.ai)** — the identity and trust layer for AI agents.
4
4
 
5
- Register agents with cryptographic identities, enforce fine-grained permissions, emit immutable audit trails, and verify trust scores.
5
+ Register agents with cryptographic identities, enforce scoped permissions, emit tamper-evident audit trails, and verify trust scores — all in a few lines of code.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@vorim/sdk.svg)](https://www.npmjs.com/package/@vorim/sdk)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
9
 
7
10
  ## Install
8
11
 
@@ -10,92 +13,224 @@ Register agents with cryptographic identities, enforce fine-grained permissions,
10
13
  npm install @vorim/sdk
11
14
  ```
12
15
 
16
+ ```bash
17
+ yarn add @vorim/sdk
18
+ ```
19
+
20
+ ```bash
21
+ pnpm add @vorim/sdk
22
+ ```
23
+
13
24
  ## Quick Start
14
25
 
15
26
  ```typescript
16
- import createVorim from '@vorim/sdk';
27
+ import createVorim from "@vorim/sdk";
17
28
 
18
29
  const vorim = createVorim({
19
- apiKey: 'agid_sk_live_your_api_key_here',
30
+ apiKey: "agid_sk_live_...",
20
31
  });
21
32
 
22
- // Register an agent with Ed25519 keypair
33
+ // 1. Register an agent returns Ed25519 keypair (private key shown once)
23
34
  const { agent, private_key } = await vorim.register({
24
- name: 'InvoiceBot',
25
- capabilities: ['api_access', 'email_send'],
26
- scopes: ['agent:read', 'agent:write'],
35
+ name: "invoice-processor",
36
+ capabilities: ["read_documents", "extract_data"],
37
+ scopes: ["agent:read", "agent:execute"],
27
38
  });
28
39
 
29
- // Check permissions (sub-5ms via Redis cache)
30
- const { allowed } = await vorim.check(agent.agent_id, 'agent:write');
40
+ console.log(agent.agent_id); // agid_acme_a1b2c3d4
41
+ console.log(agent.trust_score); // 50 (initial score)
42
+
43
+ // 2. Check permissions before acting (sub-5ms via Redis cache)
44
+ const { allowed } = await vorim.check(agent.agent_id, "agent:execute");
45
+
46
+ if (allowed) {
47
+ // 3. Perform the action, then emit an audit event
48
+ await vorim.emit({
49
+ agent_id: agent.agent_id,
50
+ event_type: "tool_call",
51
+ action: "process_invoice",
52
+ resource: "INV-2026-0042",
53
+ result: "success",
54
+ latency_ms: 142,
55
+ });
56
+ }
57
+
58
+ // 4. Verify any agent's trust (public API, no auth needed)
59
+ const trust = await vorim.verify(agent.agent_id);
60
+ console.log(trust.trust_score); // 0–100
61
+ console.log(trust.active_scopes); // ['agent:read', 'agent:execute']
62
+ ```
63
+
64
+ ## Features
31
65
 
32
- // Emit audit event
66
+ | Feature | Description |
67
+ |---------|-------------|
68
+ | **Cryptographic Identity** | Ed25519 keypairs with SHA-256 fingerprints for every agent |
69
+ | **7 Permission Scopes** | `read`, `write`, `execute`, `transact`, `communicate`, `delegate`, `elevate` |
70
+ | **Immutable Audit Trail** | ULID-ordered events with input/output content hashing |
71
+ | **Trust Scoring** | 5-factor algorithm producing a 0–100 score |
72
+ | **Payload Signing** | Client-side Ed25519 signatures via Web Crypto or Node.js |
73
+ | **Dual Runtime** | Works in Node.js 18+ and modern browsers |
74
+ | **Zero Dependencies** | Types are bundled — no external dependencies |
75
+
76
+ ## API Reference
77
+
78
+ ### Identity
79
+
80
+ ```typescript
81
+ // Register a new agent (returns keypair — private key shown once)
82
+ const result = await vorim.register({
83
+ name: "my-agent",
84
+ description: "Processes invoices",
85
+ capabilities: ["read_documents"],
86
+ scopes: ["agent:read", "agent:execute"],
87
+ });
88
+
89
+ // Get agent details
90
+ const agent = await vorim.getAgent("agid_acme_a1b2c3d4");
91
+
92
+ // List all agents in your organisation
93
+ const { agents, meta } = await vorim.listAgents({ page: 1, per_page: 20 });
94
+
95
+ // Permanently revoke an agent
96
+ await vorim.revoke("agid_acme_a1b2c3d4");
97
+ ```
98
+
99
+ ### Permissions
100
+
101
+ ```typescript
102
+ // Check if an agent has a specific permission
103
+ const { allowed, remaining_quota } = await vorim.check(
104
+ "agid_acme_a1b2c3d4",
105
+ "agent:execute"
106
+ );
107
+
108
+ // Grant a time-bounded permission with rate limiting
109
+ await vorim.grant("agid_acme_a1b2c3d4", "agent:transact", {
110
+ valid_until: "2026-06-01T00:00:00Z",
111
+ rate_limit: { max: 100, window: "1h" },
112
+ });
113
+ ```
114
+
115
+ ### Permission Scopes
116
+
117
+ | Scope | Description |
118
+ |-------|-------------|
119
+ | `agent:read` | Read data and resources |
120
+ | `agent:write` | Create or modify resources |
121
+ | `agent:execute` | Execute tools and functions |
122
+ | `agent:transact` | Perform financial transactions |
123
+ | `agent:communicate` | Send messages and notifications |
124
+ | `agent:delegate` | Delegate tasks to other agents |
125
+ | `agent:elevate` | Request elevated privileges |
126
+
127
+ ### Audit
128
+
129
+ ```typescript
130
+ // Emit a single audit event
33
131
  await vorim.emit({
34
- agent_id: agent.agent_id,
35
- event_type: 'api_request',
36
- action: 'POST /invoices',
37
- result: 'success',
132
+ agent_id: "agid_acme_a1b2c3d4",
133
+ event_type: "tool_call",
134
+ action: "send_email",
135
+ resource: "user@example.com",
136
+ result: "success",
137
+ latency_ms: 230,
138
+ metadata: { template: "invoice_reminder" },
38
139
  });
39
140
 
40
- // Verify trust (public API, no auth needed)
41
- const trust = await vorim.verify(agent.agent_id);
42
- console.log(trust.trust_score); // 0-100
141
+ // Batch emit up to 1,000 events
142
+ await vorim.emitBatch([
143
+ { agent_id: "agid_acme_a1b2c3d4", event_type: "api_request", action: "GET /users", result: "success" },
144
+ { agent_id: "agid_acme_a1b2c3d4", event_type: "api_request", action: "POST /orders", result: "denied" },
145
+ ]);
43
146
  ```
44
147
 
45
- ## Features
148
+ ### Trust Verification
149
+
150
+ ```typescript
151
+ // Public endpoint — no API key required
152
+ const trust = await vorim.verify("agid_acme_a1b2c3d4");
153
+
154
+ console.log(trust.verified); // true
155
+ console.log(trust.trust_score); // 82
156
+ console.log(trust.status); // 'active'
157
+ console.log(trust.owner.org_name); // 'Acme Corp'
158
+ console.log(trust.active_scopes); // ['agent:read', 'agent:execute']
159
+ console.log(trust.key_fingerprint); // 'a1b2c3d4...'
160
+ console.log(trust.revocation_status); // false
161
+ ```
46
162
 
47
- - **Cryptographic Identity** — Ed25519 keypairs, SHA-256 fingerprints
48
- - **7 Permission Scopes** `agent:read`, `write`, `execute`, `transact`, `communicate`, `delegate`, `elevate`
49
- - **Immutable Audit Trail** ULID-ordered events with content hashes
50
- - **Trust Scoring** Multi-factor algorithm (0-100)
51
- - **Payload Signing** Client-side Ed25519 signatures via Web Crypto or Node.js crypto
52
- - **Dual Runtime** Works in Node.js 18+ and modern browsers
53
-
54
- ## API
55
-
56
- | Method | Description |
57
- |---|---|
58
- | `vorim.register(input)` | Register agent with keypair |
59
- | `vorim.getAgent(agentId)` | Get agent details |
60
- | `vorim.listAgents(params?)` | List organisation agents |
61
- | `vorim.revoke(agentId)` | Permanently revoke agent |
62
- | `vorim.check(agentId, scope)` | Check permission |
63
- | `vorim.grant(agentId, scope, options?)` | Grant permission |
64
- | `vorim.emit(event)` | Emit single audit event |
65
- | `vorim.emitBatch(events)` | Emit up to 1,000 events |
66
- | `vorim.verify(agentId)` | Public trust verification |
67
- | `vorim.sign(payload, privateKey)` | Ed25519 payload signing |
163
+ **Trust Score Factors:**
164
+ - Agent status (active, suspended, revoked)
165
+ - Account age (older = more trusted)
166
+ - Success rate over last 30 days
167
+ - Denial ratio (high denials = lower trust)
168
+ - Scope breadth (too many scopes = higher risk)
169
+
170
+ ### Payload Signing
171
+
172
+ ```typescript
173
+ // Sign a payload with the agent's Ed25519 private key
174
+ const signature = await vorim.sign(
175
+ JSON.stringify({ action: "transfer", amount: 500 }),
176
+ privateKeyPem
177
+ );
178
+ // Returns: "ed25519:base64signature..."
179
+
180
+ // Include signature in audit events for non-repudiation
181
+ await vorim.emit({
182
+ agent_id: "agid_acme_a1b2c3d4",
183
+ event_type: "tool_call",
184
+ action: "transfer_funds",
185
+ result: "success",
186
+ signature,
187
+ });
188
+ ```
68
189
 
69
190
  ## Configuration
70
191
 
71
192
  ```typescript
193
+ import createVorim from "@vorim/sdk";
194
+
72
195
  const vorim = createVorim({
73
- apiKey: 'agid_sk_live_...', // Required — your API key
74
- baseUrl: 'https://api.vorim.ai', // Optional — API base URL
75
- timeout: 10000, // Optional — request timeout (ms)
196
+ apiKey: "agid_sk_live_...", // Required
197
+ baseUrl: "https://api.vorim.ai", // Optional (default)
198
+ timeout: 10000, // Optional — ms (default: 10000)
76
199
  });
77
200
  ```
78
201
 
79
202
  ## Error Handling
80
203
 
81
204
  ```typescript
82
- import { VorimError } from '@vorim/sdk';
205
+ import createVorim, { VorimError } from "@vorim/sdk";
83
206
 
84
207
  try {
85
- await vorim.check('invalid_id', 'agent:read');
208
+ await vorim.check("invalid_id", "agent:read");
86
209
  } catch (err) {
87
210
  if (err instanceof VorimError) {
88
- console.log(err.status); // 404
89
- console.log(err.code); // 'AGENT_NOT_FOUND'
90
- console.log(err.message); // 'Agent not found'
211
+ console.log(err.status); // 404
212
+ console.log(err.code); // 'AGENT_NOT_FOUND'
213
+ console.log(err.message); // 'Agent invalid_id not found in the trust registry'
214
+ console.log(err.details); // Additional error context
91
215
  }
92
216
  }
93
217
  ```
94
218
 
95
- ## Documentation
219
+ ## Protocol
220
+
221
+ `@vorim/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.
222
+
223
+ Read the full specification: [SPEC.md](https://github.com/Kzino/vorim-protocol/blob/main/SPEC.md)
96
224
 
97
- Full documentation at [vorim.dev/docs](https://vorim.dev/docs)
225
+ ## Requirements
226
+
227
+ - Node.js 18+ or modern browser with Web Crypto API
228
+ - TypeScript 5.0+ (optional, but recommended)
98
229
 
99
230
  ## License
100
231
 
101
- MIT
232
+ MIT — see [LICENSE](LICENSE) for details.
233
+
234
+ ---
235
+
236
+ Built by [Vorim AI](https://vorim.ai)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vorim/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Official TypeScript SDK for Vorim AI — AI Agent Identity, Permissions & Audit",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",