@vorionsys/cognigate 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/CHANGELOG.md +45 -0
- package/LICENSE +190 -0
- package/README.md +460 -270
- package/dist/chunk-OIPPFRDP.js +35 -0
- package/dist/index.cjs +310 -54
- package/dist/index.d.cts +84 -318
- package/dist/index.d.ts +272 -0
- package/dist/index.js +279 -47
- package/dist/proof-bridge-BBmb7kVP.d.cts +394 -0
- package/dist/proof-bridge-BBmb7kVP.d.ts +394 -0
- package/dist/proof-bridge-CkzbawwC.d.cts +394 -0
- package/dist/proof-bridge-CkzbawwC.d.ts +394 -0
- package/dist/proof-bridge.cjs +59 -0
- package/dist/proof-bridge.d.cts +3 -0
- package/dist/proof-bridge.d.ts +3 -0
- package/dist/proof-bridge.js +6 -0
- package/package.json +77 -54
- package/src/__tests__/client.test.ts +0 -162
- package/src/client.ts +0 -421
- package/src/index.ts +0 -76
- package/src/types.ts +0 -272
- package/src/webhooks.ts +0 -146
- package/tsconfig.json +0 -25
- package/vitest.config.ts +0 -14
package/README.md
CHANGED
|
@@ -1,270 +1,460 @@
|
|
|
1
|
-
# @
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const client = new Cognigate({
|
|
41
|
-
apiKey:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
1
|
+
# @vorionsys/cognigate
|
|
2
|
+
|
|
3
|
+
Real-time AI governance decision engine -- the TypeScript SDK for the [Cognigate](https://cognigate.dev) API.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@vorionsys/cognigate)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @vorionsys/cognigate
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## What is Cognigate?
|
|
17
|
+
|
|
18
|
+
**Cognigate** is Vorion's real-time AI governance decision engine. It sits between your AI agents and the actions they want to perform, evaluating every request against trust scores, capability policies, and risk levels before granting or denying permission. Every decision is recorded as an immutable proof record, creating a tamper-evident audit trail.
|
|
19
|
+
|
|
20
|
+
Cognigate implements the trust-tier model defined by the **BASIS** (Baseline Authority for Safe & Interoperable Systems) specification. BASIS defines eight trust tiers (T0 through T7) that govern what an AI agent is allowed to do based on its demonstrated track record. As agents prove reliability, they earn higher trust scores and unlock broader capabilities -- all enforced automatically by Cognigate.
|
|
21
|
+
|
|
22
|
+
### Core concepts
|
|
23
|
+
|
|
24
|
+
| Concept | Description |
|
|
25
|
+
|---|---|
|
|
26
|
+
| **Trust Score** | A 0--1000 numeric score reflecting an agent's reliability. Computed from outcomes, compliance, and behavioral signals. |
|
|
27
|
+
| **Trust Tier** | One of eight BASIS tiers (T0 Sandbox through T7 Autonomous) derived from the trust score. Each tier grants a specific set of capabilities. |
|
|
28
|
+
| **Governance Decision** | The verdict for a requested action: `ALLOW`, `DENY`, `ESCALATE` (requires human approval), or `DEGRADE` (partial access). |
|
|
29
|
+
| **Intent** | A structured representation of what an agent wants to do, parsed from natural-language input. |
|
|
30
|
+
| **Proof Record** | An immutable, hash-chained audit entry recording each governance decision and its outcome. |
|
|
31
|
+
| **Proof Bridge** | Optional integration that forwards Cognigate decisions to the Vorion Proof Plane for cross-system audit trails. |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Cognigate } from '@vorionsys/cognigate';
|
|
39
|
+
|
|
40
|
+
const client = new Cognigate({
|
|
41
|
+
apiKey: process.env.COGNIGATE_API_KEY!,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// 1. Register an agent
|
|
45
|
+
const agent = await client.agents.create({
|
|
46
|
+
name: 'DataProcessor',
|
|
47
|
+
description: 'ETL pipeline agent',
|
|
48
|
+
initialCapabilities: ['read_database', 'write_s3'],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 2. Check trust status
|
|
52
|
+
const status = await client.trust.getStatus(agent.id);
|
|
53
|
+
console.log(`Trust Score: ${status.trustScore}`);
|
|
54
|
+
console.log(`Tier: ${status.tierName}`);
|
|
55
|
+
console.log(`Capabilities: ${status.capabilities.join(', ')}`);
|
|
56
|
+
|
|
57
|
+
// 3. Evaluate a governance request (parse intent + enforce)
|
|
58
|
+
const { intent, result } = await client.governance.evaluate(
|
|
59
|
+
agent.id,
|
|
60
|
+
'Read customer data from the sales database'
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (result.decision === 'ALLOW') {
|
|
64
|
+
console.log('Proceeding -- granted:', result.grantedCapabilities);
|
|
65
|
+
} else if (result.decision === 'ESCALATE') {
|
|
66
|
+
console.log('Needs human approval:', result.reasoning);
|
|
67
|
+
} else {
|
|
68
|
+
console.log('Blocked:', result.reasoning);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Usage examples
|
|
75
|
+
|
|
76
|
+
### Creating and managing agents
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { Cognigate } from '@vorionsys/cognigate';
|
|
80
|
+
|
|
81
|
+
const client = new Cognigate({ apiKey: process.env.COGNIGATE_API_KEY! });
|
|
82
|
+
|
|
83
|
+
// List all active agents
|
|
84
|
+
const agents = await client.agents.list({ status: 'ACTIVE' });
|
|
85
|
+
console.log(`Found ${agents.total} active agents`);
|
|
86
|
+
|
|
87
|
+
// Get a specific agent
|
|
88
|
+
const agent = await client.agents.get('agent-123');
|
|
89
|
+
|
|
90
|
+
// Create an agent
|
|
91
|
+
const newAgent = await client.agents.create({
|
|
92
|
+
name: 'DataProcessor',
|
|
93
|
+
description: 'Processes data pipelines',
|
|
94
|
+
template: 'data-processor',
|
|
95
|
+
initialCapabilities: ['read_database'],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Update an agent
|
|
99
|
+
await client.agents.update('agent-123', { name: 'RenamedAgent' });
|
|
100
|
+
|
|
101
|
+
// Pause / Resume
|
|
102
|
+
await client.agents.pause('agent-123');
|
|
103
|
+
await client.agents.resume('agent-123');
|
|
104
|
+
|
|
105
|
+
// Delete an agent
|
|
106
|
+
await client.agents.delete('agent-123');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Querying trust status and history
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
// Get current trust status
|
|
113
|
+
const status = await client.trust.getStatus('agent-123');
|
|
114
|
+
// Returns: { trustScore, trustTier, tierName, capabilities, factorScores, compliant, warnings, ... }
|
|
115
|
+
|
|
116
|
+
// Get trust history over a time range
|
|
117
|
+
const history = await client.trust.getHistory('agent-123', {
|
|
118
|
+
from: new Date('2026-01-01'),
|
|
119
|
+
limit: 100,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Submit an outcome to update the trust score
|
|
123
|
+
const updated = await client.trust.submitOutcome('agent-123', 'proof-456', {
|
|
124
|
+
success: true,
|
|
125
|
+
metrics: { latency: 234, accuracy: 0.98 },
|
|
126
|
+
notes: 'Completed ETL run without errors',
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Submitting governance requests and checking decisions
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Option A: Parse intent, then enforce separately
|
|
134
|
+
const parsed = await client.governance.parseIntent(
|
|
135
|
+
'agent-123',
|
|
136
|
+
'Read customer data from the sales database'
|
|
137
|
+
);
|
|
138
|
+
console.log(`Parsed action: ${parsed.intent.parsedAction}`);
|
|
139
|
+
console.log(`Risk level: ${parsed.intent.riskLevel}`);
|
|
140
|
+
console.log(`Confidence: ${parsed.confidence}`);
|
|
141
|
+
|
|
142
|
+
const result = await client.governance.enforce(parsed.intent);
|
|
143
|
+
// result.decision is 'ALLOW' | 'DENY' | 'ESCALATE' | 'DEGRADE'
|
|
144
|
+
|
|
145
|
+
// Option B: Combined parse + enforce in one call
|
|
146
|
+
const { intent, result: govResult } = await client.governance.evaluate(
|
|
147
|
+
'agent-123',
|
|
148
|
+
'Send email to customer'
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (govResult.decision === 'ALLOW') {
|
|
152
|
+
// Proceed -- action is permitted
|
|
153
|
+
} else if (govResult.decision === 'ESCALATE') {
|
|
154
|
+
// Request human approval
|
|
155
|
+
} else if (govResult.decision === 'DEGRADE') {
|
|
156
|
+
// Partial access: check govResult.grantedCapabilities
|
|
157
|
+
} else {
|
|
158
|
+
// DENY
|
|
159
|
+
console.log('Denied:', govResult.reasoning);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Quick capability check (no proof record created)
|
|
163
|
+
const check = await client.governance.canPerform(
|
|
164
|
+
'agent-123',
|
|
165
|
+
'write_file',
|
|
166
|
+
['file_write', 'approved_directories']
|
|
167
|
+
);
|
|
168
|
+
console.log(check.allowed, check.reason);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Querying the proof chain
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
// Get a specific proof record
|
|
175
|
+
const proof = await client.proofs.get('proof-123');
|
|
176
|
+
|
|
177
|
+
// List proofs for an entity
|
|
178
|
+
const proofs = await client.proofs.list('agent-123', {
|
|
179
|
+
from: new Date('2026-01-01'),
|
|
180
|
+
outcome: 'SUCCESS',
|
|
181
|
+
pageSize: 50,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Get chain statistics
|
|
185
|
+
const stats = await client.proofs.getStats('agent-123');
|
|
186
|
+
// Returns: { totalRecords, successRate, averageTrustScore, chainIntegrity }
|
|
187
|
+
|
|
188
|
+
// Verify proof chain integrity (hash-chain validation)
|
|
189
|
+
const verification = await client.proofs.verify('agent-123');
|
|
190
|
+
console.log('Chain valid:', verification.valid);
|
|
191
|
+
if (verification.errors.length > 0) {
|
|
192
|
+
console.error('Integrity errors:', verification.errors);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Handling webhooks
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { WebhookRouter, parseWebhookPayload } from '@vorionsys/cognigate';
|
|
200
|
+
|
|
201
|
+
const router = new WebhookRouter();
|
|
202
|
+
|
|
203
|
+
// Handle specific event types
|
|
204
|
+
router.on('trust.tier_changed', async (event) => {
|
|
205
|
+
console.log(`Agent ${event.entityId} tier changed:`, event.payload);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
router.on('governance.decision', async (event) => {
|
|
209
|
+
if (event.payload.decision === 'ESCALATE') {
|
|
210
|
+
// Alert a human reviewer
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Handle all events (logging, analytics, etc.)
|
|
215
|
+
router.onAll(async (event) => {
|
|
216
|
+
await logEvent(event);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Express middleware (signature verification included)
|
|
220
|
+
app.post('/webhooks/cognigate', router.middleware(process.env.WEBHOOK_SECRET!));
|
|
221
|
+
|
|
222
|
+
// Or verify manually
|
|
223
|
+
app.post('/webhooks/cognigate', async (req, res) => {
|
|
224
|
+
try {
|
|
225
|
+
const event = await parseWebhookPayload(
|
|
226
|
+
req.body,
|
|
227
|
+
req.headers['x-cognigate-signature'] as string,
|
|
228
|
+
process.env.WEBHOOK_SECRET!
|
|
229
|
+
);
|
|
230
|
+
await router.handle(event);
|
|
231
|
+
res.json({ received: true });
|
|
232
|
+
} catch (error) {
|
|
233
|
+
res.status(400).json({ error: (error as Error).message });
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Proof Bridge (Proof Plane integration)
|
|
239
|
+
|
|
240
|
+
The proof bridge forwards Cognigate `governance.decision` webhook events to the Vorion Proof Plane, creating cross-system `DECISION_MADE` audit records.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { WebhookRouter } from '@vorionsys/cognigate';
|
|
244
|
+
import { createProofBridge } from '@vorionsys/cognigate/proof-bridge';
|
|
245
|
+
import { ProofPlane, memoryStore } from '@vorionsys/proof-plane';
|
|
246
|
+
|
|
247
|
+
const router = new WebhookRouter();
|
|
248
|
+
const proofPlane = new ProofPlane({ storage: memoryStore() });
|
|
249
|
+
|
|
250
|
+
const bridge = createProofBridge({
|
|
251
|
+
proofPlane,
|
|
252
|
+
webhookRouter: router,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// governance.decision events now automatically emit DECISION_MADE proofs
|
|
256
|
+
|
|
257
|
+
// Later, disconnect the bridge:
|
|
258
|
+
bridge.disconnect();
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Trust tiers (BASIS specification)
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import { Cognigate, TrustTier, TIER_THRESHOLDS } from '@vorionsys/cognigate';
|
|
265
|
+
|
|
266
|
+
// Derive tier from score
|
|
267
|
+
const tier = Cognigate.getTierFromScore(750);
|
|
268
|
+
// Returns: TrustTier.T4_STANDARD
|
|
269
|
+
|
|
270
|
+
// Get human-readable tier name
|
|
271
|
+
const name = Cognigate.getTierName(TrustTier.T5_TRUSTED);
|
|
272
|
+
// Returns: "Trusted"
|
|
273
|
+
|
|
274
|
+
// Get score thresholds for a tier
|
|
275
|
+
const thresholds = Cognigate.getTierThresholds(TrustTier.T4_STANDARD);
|
|
276
|
+
// Returns: { min: 650, max: 799, name: "Standard" }
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The eight BASIS trust tiers:
|
|
280
|
+
|
|
281
|
+
| Tier | Score range | Name | Description |
|
|
282
|
+
|---|---|---|---|
|
|
283
|
+
| T0 | 0--199 | Sandbox | Isolated, no external access |
|
|
284
|
+
| T1 | 200--349 | Observed | Read-only, monitored |
|
|
285
|
+
| T2 | 350--499 | Provisional | Basic operations, supervised |
|
|
286
|
+
| T3 | 500--649 | Monitored | Standard operations with monitoring |
|
|
287
|
+
| T4 | 650--799 | Standard | External API access, policy-governed |
|
|
288
|
+
| T5 | 800--875 | Trusted | Cross-agent communication |
|
|
289
|
+
| T6 | 876--950 | Certified | Admin tasks, minimal oversight |
|
|
290
|
+
| T7 | 951--1000 | Autonomous | Full autonomy, self-governance |
|
|
291
|
+
|
|
292
|
+
### Error handling
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { Cognigate, CognigateError } from '@vorionsys/cognigate';
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
const status = await client.trust.getStatus('invalid-id');
|
|
299
|
+
} catch (error) {
|
|
300
|
+
if (error instanceof CognigateError) {
|
|
301
|
+
console.log('Code:', error.code); // e.g. 'NOT_FOUND'
|
|
302
|
+
console.log('Message:', error.message); // e.g. 'Entity not found'
|
|
303
|
+
console.log('Status:', error.status); // e.g. 404
|
|
304
|
+
console.log('Details:', error.details); // additional context
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
The client automatically retries server errors (5xx) with exponential backoff. Client errors (4xx) are thrown immediately.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## API reference
|
|
314
|
+
|
|
315
|
+
### Main export: `@vorionsys/cognigate`
|
|
316
|
+
|
|
317
|
+
#### Classes
|
|
318
|
+
|
|
319
|
+
| Export | Description |
|
|
320
|
+
|---|---|
|
|
321
|
+
| `Cognigate` | Main SDK client. Instantiate with `CognigateConfig` to access all sub-clients. |
|
|
322
|
+
| `CognigateError` | Error class with `code`, `status`, and `details` properties. |
|
|
323
|
+
| `WebhookRouter` | Event router for Cognigate webhooks with Express middleware support. |
|
|
324
|
+
|
|
325
|
+
#### Sub-clients (accessed via `Cognigate` instance)
|
|
326
|
+
|
|
327
|
+
| Property | Type | Description |
|
|
328
|
+
|---|---|---|
|
|
329
|
+
| `client.agents` | `AgentsClient` | CRUD operations for agents: `list`, `get`, `create`, `update`, `delete`, `pause`, `resume`. |
|
|
330
|
+
| `client.trust` | `TrustClient` | Trust score queries: `getStatus`, `getHistory`, `submitOutcome`. |
|
|
331
|
+
| `client.governance` | `GovernanceClient` | Governance enforcement: `parseIntent`, `enforce`, `evaluate`, `canPerform`. |
|
|
332
|
+
| `client.proofs` | `ProofsClient` | Proof chain access: `get`, `list`, `getStats`, `verify`. |
|
|
333
|
+
|
|
334
|
+
#### Static methods on `Cognigate`
|
|
335
|
+
|
|
336
|
+
| Method | Description |
|
|
337
|
+
|---|---|
|
|
338
|
+
| `Cognigate.getTierFromScore(score)` | Convert a 0--1000 score to a `TrustTier` enum value. |
|
|
339
|
+
| `Cognigate.getTierName(tier)` | Get the human-readable name of a tier. |
|
|
340
|
+
| `Cognigate.getTierThresholds(tier)` | Get `{ min, max, name }` for a tier. |
|
|
341
|
+
|
|
342
|
+
#### Enums and constants
|
|
343
|
+
|
|
344
|
+
| Export | Description |
|
|
345
|
+
|---|---|
|
|
346
|
+
| `TrustTier` | Enum: `T0_SANDBOX` through `T7_AUTONOMOUS`. |
|
|
347
|
+
| `TIER_THRESHOLDS` | Mapping from `TrustTier` to `{ min, max, name }`. |
|
|
348
|
+
|
|
349
|
+
#### Types
|
|
350
|
+
|
|
351
|
+
| Type | Description |
|
|
352
|
+
|---|---|
|
|
353
|
+
| `CognigateConfig` | Client configuration: `apiKey`, `baseUrl?`, `timeout?`, `retries?`, `debug?`, `webhookSecret?`. |
|
|
354
|
+
| `Agent` | Registered agent record. |
|
|
355
|
+
| `CreateAgentRequest` | Payload for creating an agent. |
|
|
356
|
+
| `UpdateAgentRequest` | Payload for updating an agent. |
|
|
357
|
+
| `TrustStatus` | Trust score, tier, capabilities, factor scores, compliance status. |
|
|
358
|
+
| `GovernanceDecision` | Union: `'ALLOW' \| 'DENY' \| 'ESCALATE' \| 'DEGRADE'`. |
|
|
359
|
+
| `GovernanceResult` | Full decision result with reasoning, capabilities, constraints, and proof ID. |
|
|
360
|
+
| `Intent` | Structured representation of a parsed action request. |
|
|
361
|
+
| `IntentParseResult` | Parse result with confidence score and alternative interpretations. |
|
|
362
|
+
| `ProofRecord` | Immutable hash-chained audit record for a single decision. |
|
|
363
|
+
| `ProofChainStats` | Aggregate stats: total records, success rate, average score, chain integrity. |
|
|
364
|
+
| `WebhookEvent` | Webhook payload with type, entity ID, and signature. |
|
|
365
|
+
| `WebhookEventType` | Union of all supported event types (e.g. `'trust.tier_changed'`). |
|
|
366
|
+
| `ApiResponse<T>` | Standard API response wrapper. |
|
|
367
|
+
| `ApiError` | API error structure. |
|
|
368
|
+
| `PaginatedResponse<T>` | Paginated list with `items`, `total`, `page`, `pageSize`, `hasMore`. |
|
|
369
|
+
| `AgentsClient` | Type of the agents sub-client. |
|
|
370
|
+
| `TrustClient` | Type of the trust sub-client. |
|
|
371
|
+
| `GovernanceClient` | Type of the governance sub-client. |
|
|
372
|
+
| `ProofsClient` | Type of the proofs sub-client. |
|
|
373
|
+
|
|
374
|
+
#### Zod schemas (runtime validation)
|
|
375
|
+
|
|
376
|
+
| Export | Validates |
|
|
377
|
+
|---|---|
|
|
378
|
+
| `TrustStatusSchema` | `TrustStatus` objects |
|
|
379
|
+
| `GovernanceResultSchema` | `GovernanceResult` objects |
|
|
380
|
+
| `ProofRecordSchema` | `ProofRecord` objects |
|
|
381
|
+
| `AgentSchema` | `Agent` objects |
|
|
382
|
+
|
|
383
|
+
#### Webhook utilities
|
|
384
|
+
|
|
385
|
+
| Export | Description |
|
|
386
|
+
|---|---|
|
|
387
|
+
| `verifyWebhookSignature(payload, signature, secret)` | HMAC-SHA256 signature verification with timing-safe comparison. |
|
|
388
|
+
| `parseWebhookPayload(body, signature, secret)` | Verify signature and parse the webhook body into a `WebhookEvent`. |
|
|
389
|
+
| `WebhookRouter` | Event router: `on(type, handler)`, `onAll(handler)`, `handle(event)`, `middleware(secret)`. |
|
|
390
|
+
|
|
391
|
+
### Sub-export: `@vorionsys/cognigate/proof-bridge`
|
|
392
|
+
|
|
393
|
+
| Export | Description |
|
|
394
|
+
|---|---|
|
|
395
|
+
| `createProofBridge(config)` | Create a bridge forwarding `governance.decision` webhooks to the Proof Plane. Returns a `ProofBridgeHandle`. |
|
|
396
|
+
| `ProofPlaneEmitter` | Structural interface for Proof Plane integration (avoids hard dependency on `@vorionsys/proof-plane`). |
|
|
397
|
+
| `ProofBridgeConfig` | Config: `{ proofPlane, webhookRouter }`. |
|
|
398
|
+
| `ProofBridgeHandle` | Handle with `disconnect()` method to stop forwarding. |
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Webhook event types
|
|
403
|
+
|
|
404
|
+
| Event type | Fired when |
|
|
405
|
+
|---|---|
|
|
406
|
+
| `agent.created` | A new agent is registered |
|
|
407
|
+
| `agent.updated` | An agent's configuration changes |
|
|
408
|
+
| `agent.deleted` | An agent is deleted |
|
|
409
|
+
| `agent.status_changed` | An agent's status changes (active/paused/suspended) |
|
|
410
|
+
| `trust.score_changed` | An agent's trust score is updated |
|
|
411
|
+
| `trust.tier_changed` | An agent's trust tier changes |
|
|
412
|
+
| `governance.decision` | A governance decision is rendered |
|
|
413
|
+
| `proof.recorded` | A proof record is committed to the chain |
|
|
414
|
+
| `alert.triggered` | A system or compliance alert fires |
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## Configuration reference
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
interface CognigateConfig {
|
|
422
|
+
/** API key (required). */
|
|
423
|
+
apiKey: string;
|
|
424
|
+
/** Base URL for the Cognigate API. Default: https://cognigate.dev/v1 */
|
|
425
|
+
baseUrl?: string;
|
|
426
|
+
/** Request timeout in milliseconds. Default: 30000 */
|
|
427
|
+
timeout?: number;
|
|
428
|
+
/** Number of retries for server errors. Default: 3 */
|
|
429
|
+
retries?: number;
|
|
430
|
+
/** Enable debug logging. Default: false */
|
|
431
|
+
debug?: boolean;
|
|
432
|
+
/** Webhook signing secret for signature verification. */
|
|
433
|
+
webhookSecret?: string;
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Requirements
|
|
440
|
+
|
|
441
|
+
- Node.js >= 18.0.0
|
|
442
|
+
- TypeScript >= 5.0.0 (peer dependency)
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## License
|
|
447
|
+
|
|
448
|
+
[Apache-2.0](./LICENSE)
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Contributing
|
|
453
|
+
|
|
454
|
+
This package is part of the [Vorion monorepo](https://github.com/vorionsys/vorion). See the root `CONTRIBUTING.md` for guidelines.
|
|
455
|
+
|
|
456
|
+
## Links
|
|
457
|
+
|
|
458
|
+
- [Cognigate API Documentation](https://cognigate.dev)
|
|
459
|
+
- [Vorion Monorepo](https://github.com/vorionsys/vorion)
|
|
460
|
+
- [npm: @vorionsys/cognigate](https://www.npmjs.com/package/@vorionsys/cognigate)
|