@vorionsys/cognigate 1.0.1 → 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 +296 -106
- package/dist/chunk-OIPPFRDP.js +35 -0
- package/dist/index.cjs +280 -1
- package/dist/index.d.cts +83 -311
- package/dist/index.d.ts +272 -0
- package/dist/index.js +250 -1
- 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 +28 -9
- 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 -270
- package/src/webhooks.ts +0 -143
- package/tsconfig.json +0 -25
- package/vitest.config.ts +0 -14
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @vorionsys/cognigate
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
---
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
@@ -8,220 +13,283 @@ Official TypeScript SDK for the [Cognigate](https://cognigate.dev) AI Governance
|
|
|
8
13
|
npm install @vorionsys/cognigate
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
##
|
|
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
|
|
12
36
|
|
|
13
37
|
```typescript
|
|
14
38
|
import { Cognigate } from '@vorionsys/cognigate';
|
|
15
39
|
|
|
16
40
|
const client = new Cognigate({
|
|
17
|
-
apiKey: process.env.COGNIGATE_API_KEY
|
|
41
|
+
apiKey: process.env.COGNIGATE_API_KEY!,
|
|
18
42
|
});
|
|
19
43
|
|
|
20
|
-
//
|
|
21
|
-
const
|
|
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);
|
|
22
53
|
console.log(`Trust Score: ${status.trustScore}`);
|
|
23
54
|
console.log(`Tier: ${status.tierName}`);
|
|
24
55
|
console.log(`Capabilities: ${status.capabilities.join(', ')}`);
|
|
25
|
-
```
|
|
26
56
|
|
|
27
|
-
|
|
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
|
+
);
|
|
28
62
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
```
|
|
34
71
|
|
|
35
|
-
|
|
72
|
+
---
|
|
36
73
|
|
|
37
|
-
|
|
74
|
+
## Usage examples
|
|
75
|
+
|
|
76
|
+
### Creating and managing agents
|
|
38
77
|
|
|
39
78
|
```typescript
|
|
40
|
-
|
|
41
|
-
apiKey: 'your-api-key', // Required
|
|
42
|
-
baseUrl: 'https://...', // Optional: custom API URL
|
|
43
|
-
timeout: 30000, // Optional: request timeout in ms
|
|
44
|
-
retries: 3, // Optional: number of retries
|
|
45
|
-
debug: false, // Optional: enable debug logging
|
|
46
|
-
webhookSecret: 'secret', // Optional: for webhook verification
|
|
47
|
-
});
|
|
48
|
-
```
|
|
79
|
+
import { Cognigate } from '@vorionsys/cognigate';
|
|
49
80
|
|
|
50
|
-
|
|
81
|
+
const client = new Cognigate({ apiKey: process.env.COGNIGATE_API_KEY! });
|
|
51
82
|
|
|
52
|
-
|
|
53
|
-
// List agents
|
|
83
|
+
// List all active agents
|
|
54
84
|
const agents = await client.agents.list({ status: 'ACTIVE' });
|
|
85
|
+
console.log(`Found ${agents.total} active agents`);
|
|
55
86
|
|
|
56
|
-
// Get agent
|
|
87
|
+
// Get a specific agent
|
|
57
88
|
const agent = await client.agents.get('agent-123');
|
|
58
89
|
|
|
59
|
-
// Create agent
|
|
90
|
+
// Create an agent
|
|
60
91
|
const newAgent = await client.agents.create({
|
|
61
92
|
name: 'DataProcessor',
|
|
62
93
|
description: 'Processes data pipelines',
|
|
63
94
|
template: 'data-processor',
|
|
95
|
+
initialCapabilities: ['read_database'],
|
|
64
96
|
});
|
|
65
97
|
|
|
66
|
-
// Update agent
|
|
67
|
-
await client.agents.update('agent-123', { name: '
|
|
98
|
+
// Update an agent
|
|
99
|
+
await client.agents.update('agent-123', { name: 'RenamedAgent' });
|
|
68
100
|
|
|
69
|
-
// Pause/Resume
|
|
101
|
+
// Pause / Resume
|
|
70
102
|
await client.agents.pause('agent-123');
|
|
71
103
|
await client.agents.resume('agent-123');
|
|
72
104
|
|
|
73
|
-
// Delete agent
|
|
105
|
+
// Delete an agent
|
|
74
106
|
await client.agents.delete('agent-123');
|
|
75
107
|
```
|
|
76
108
|
|
|
77
|
-
###
|
|
109
|
+
### Querying trust status and history
|
|
78
110
|
|
|
79
111
|
```typescript
|
|
80
|
-
// Get trust status
|
|
112
|
+
// Get current trust status
|
|
81
113
|
const status = await client.trust.getStatus('agent-123');
|
|
82
|
-
// Returns: { trustScore, trustTier, tierName, capabilities, factorScores, ... }
|
|
114
|
+
// Returns: { trustScore, trustTier, tierName, capabilities, factorScores, compliant, warnings, ... }
|
|
83
115
|
|
|
84
|
-
// Get trust history
|
|
116
|
+
// Get trust history over a time range
|
|
85
117
|
const history = await client.trust.getHistory('agent-123', {
|
|
86
|
-
from: new Date('
|
|
118
|
+
from: new Date('2026-01-01'),
|
|
87
119
|
limit: 100,
|
|
88
120
|
});
|
|
89
121
|
|
|
90
|
-
// Submit outcome
|
|
122
|
+
// Submit an outcome to update the trust score
|
|
91
123
|
const updated = await client.trust.submitOutcome('agent-123', 'proof-456', {
|
|
92
124
|
success: true,
|
|
93
125
|
metrics: { latency: 234, accuracy: 0.98 },
|
|
126
|
+
notes: 'Completed ETL run without errors',
|
|
94
127
|
});
|
|
95
128
|
```
|
|
96
129
|
|
|
97
|
-
###
|
|
130
|
+
### Submitting governance requests and checking decisions
|
|
98
131
|
|
|
99
132
|
```typescript
|
|
100
|
-
// Parse intent
|
|
133
|
+
// Option A: Parse intent, then enforce separately
|
|
101
134
|
const parsed = await client.governance.parseIntent(
|
|
102
135
|
'agent-123',
|
|
103
136
|
'Read customer data from the sales database'
|
|
104
137
|
);
|
|
138
|
+
console.log(`Parsed action: ${parsed.intent.parsedAction}`);
|
|
139
|
+
console.log(`Risk level: ${parsed.intent.riskLevel}`);
|
|
140
|
+
console.log(`Confidence: ${parsed.confidence}`);
|
|
105
141
|
|
|
106
|
-
// Enforce governance
|
|
107
142
|
const result = await client.governance.enforce(parsed.intent);
|
|
108
|
-
//
|
|
143
|
+
// result.decision is 'ALLOW' | 'DENY' | 'ESCALATE' | 'DEGRADE'
|
|
109
144
|
|
|
110
|
-
//
|
|
111
|
-
const { intent, result } = await client.governance.evaluate(
|
|
145
|
+
// Option B: Combined parse + enforce in one call
|
|
146
|
+
const { intent, result: govResult } = await client.governance.evaluate(
|
|
112
147
|
'agent-123',
|
|
113
148
|
'Send email to customer'
|
|
114
149
|
);
|
|
115
150
|
|
|
116
|
-
if (
|
|
117
|
-
// Proceed
|
|
118
|
-
} else if (
|
|
151
|
+
if (govResult.decision === 'ALLOW') {
|
|
152
|
+
// Proceed -- action is permitted
|
|
153
|
+
} else if (govResult.decision === 'ESCALATE') {
|
|
119
154
|
// Request human approval
|
|
155
|
+
} else if (govResult.decision === 'DEGRADE') {
|
|
156
|
+
// Partial access: check govResult.grantedCapabilities
|
|
120
157
|
} else {
|
|
121
|
-
//
|
|
122
|
-
console.log(
|
|
158
|
+
// DENY
|
|
159
|
+
console.log('Denied:', govResult.reasoning);
|
|
123
160
|
}
|
|
124
161
|
|
|
125
|
-
//
|
|
162
|
+
// Quick capability check (no proof record created)
|
|
126
163
|
const check = await client.governance.canPerform(
|
|
127
164
|
'agent-123',
|
|
128
165
|
'write_file',
|
|
129
166
|
['file_write', 'approved_directories']
|
|
130
167
|
);
|
|
168
|
+
console.log(check.allowed, check.reason);
|
|
131
169
|
```
|
|
132
170
|
|
|
133
|
-
###
|
|
171
|
+
### Querying the proof chain
|
|
134
172
|
|
|
135
173
|
```typescript
|
|
136
|
-
// Get proof record
|
|
174
|
+
// Get a specific proof record
|
|
137
175
|
const proof = await client.proofs.get('proof-123');
|
|
138
176
|
|
|
139
|
-
// List proofs for entity
|
|
177
|
+
// List proofs for an entity
|
|
140
178
|
const proofs = await client.proofs.list('agent-123', {
|
|
141
|
-
from: new Date('
|
|
179
|
+
from: new Date('2026-01-01'),
|
|
142
180
|
outcome: 'SUCCESS',
|
|
181
|
+
pageSize: 50,
|
|
143
182
|
});
|
|
144
183
|
|
|
145
184
|
// Get chain statistics
|
|
146
185
|
const stats = await client.proofs.getStats('agent-123');
|
|
147
186
|
// Returns: { totalRecords, successRate, averageTrustScore, chainIntegrity }
|
|
148
187
|
|
|
149
|
-
// Verify chain integrity
|
|
188
|
+
// Verify proof chain integrity (hash-chain validation)
|
|
150
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
|
+
}
|
|
151
194
|
```
|
|
152
195
|
|
|
153
|
-
###
|
|
196
|
+
### Handling webhooks
|
|
154
197
|
|
|
155
198
|
```typescript
|
|
156
199
|
import { WebhookRouter, parseWebhookPayload } from '@vorionsys/cognigate';
|
|
157
200
|
|
|
158
201
|
const router = new WebhookRouter();
|
|
159
202
|
|
|
160
|
-
// Handle specific
|
|
203
|
+
// Handle specific event types
|
|
161
204
|
router.on('trust.tier_changed', async (event) => {
|
|
162
205
|
console.log(`Agent ${event.entityId} tier changed:`, event.payload);
|
|
163
206
|
});
|
|
164
207
|
|
|
165
208
|
router.on('governance.decision', async (event) => {
|
|
166
209
|
if (event.payload.decision === 'ESCALATE') {
|
|
167
|
-
// Alert human reviewer
|
|
210
|
+
// Alert a human reviewer
|
|
168
211
|
}
|
|
169
212
|
});
|
|
170
213
|
|
|
171
|
-
// Handle all events
|
|
214
|
+
// Handle all events (logging, analytics, etc.)
|
|
172
215
|
router.onAll(async (event) => {
|
|
173
216
|
await logEvent(event);
|
|
174
217
|
});
|
|
175
218
|
|
|
176
|
-
// Express middleware
|
|
177
|
-
app.post('/webhooks/cognigate', router.middleware(process.env.WEBHOOK_SECRET));
|
|
219
|
+
// Express middleware (signature verification included)
|
|
220
|
+
app.post('/webhooks/cognigate', router.middleware(process.env.WEBHOOK_SECRET!));
|
|
178
221
|
|
|
179
|
-
// Or
|
|
222
|
+
// Or verify manually
|
|
180
223
|
app.post('/webhooks/cognigate', async (req, res) => {
|
|
181
224
|
try {
|
|
182
225
|
const event = await parseWebhookPayload(
|
|
183
226
|
req.body,
|
|
184
|
-
req.headers['x-cognigate-signature'],
|
|
185
|
-
process.env.WEBHOOK_SECRET
|
|
227
|
+
req.headers['x-cognigate-signature'] as string,
|
|
228
|
+
process.env.WEBHOOK_SECRET!
|
|
186
229
|
);
|
|
187
230
|
await router.handle(event);
|
|
188
231
|
res.json({ received: true });
|
|
189
232
|
} catch (error) {
|
|
190
|
-
res.status(400).json({ error: error.message });
|
|
233
|
+
res.status(400).json({ error: (error as Error).message });
|
|
191
234
|
}
|
|
192
235
|
});
|
|
193
236
|
```
|
|
194
237
|
|
|
195
|
-
###
|
|
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)
|
|
196
262
|
|
|
197
263
|
```typescript
|
|
198
264
|
import { Cognigate, TrustTier, TIER_THRESHOLDS } from '@vorionsys/cognigate';
|
|
199
265
|
|
|
200
|
-
//
|
|
266
|
+
// Derive tier from score
|
|
201
267
|
const tier = Cognigate.getTierFromScore(750);
|
|
202
268
|
// Returns: TrustTier.T4_STANDARD
|
|
203
269
|
|
|
204
|
-
// Get tier name
|
|
270
|
+
// Get human-readable tier name
|
|
205
271
|
const name = Cognigate.getTierName(TrustTier.T5_TRUSTED);
|
|
206
272
|
// Returns: "Trusted"
|
|
207
273
|
|
|
208
|
-
// Get
|
|
274
|
+
// Get score thresholds for a tier
|
|
209
275
|
const thresholds = Cognigate.getTierThresholds(TrustTier.T4_STANDARD);
|
|
210
276
|
// Returns: { min: 650, max: 799, name: "Standard" }
|
|
211
|
-
|
|
212
|
-
// All tiers (BASIS specification)
|
|
213
|
-
console.log(TIER_THRESHOLDS);
|
|
214
|
-
// T0_SANDBOX: 0-199 Sandbox - Isolated, no external access
|
|
215
|
-
// T1_OBSERVED: 200-349 Observed - Read-only, monitored
|
|
216
|
-
// T2_PROVISIONAL: 350-500 Provisional - Basic operations, supervised
|
|
217
|
-
// T3_MONITORED: 501-649 Monitored - Standard operations with monitoring
|
|
218
|
-
// T4_STANDARD: 650-799 Standard - External API access, policy-governed
|
|
219
|
-
// T5_TRUSTED: 800-875 Trusted - Cross-agent communication
|
|
220
|
-
// T6_CERTIFIED: 876-950 Certified - Admin tasks, minimal oversight
|
|
221
|
-
// T7_AUTONOMOUS: 951-1000 Autonomous - Full autonomy, self-governance
|
|
222
277
|
```
|
|
223
278
|
|
|
224
|
-
|
|
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
|
|
225
293
|
|
|
226
294
|
```typescript
|
|
227
295
|
import { Cognigate, CognigateError } from '@vorionsys/cognigate';
|
|
@@ -230,41 +298,163 @@ try {
|
|
|
230
298
|
const status = await client.trust.getStatus('invalid-id');
|
|
231
299
|
} catch (error) {
|
|
232
300
|
if (error instanceof CognigateError) {
|
|
233
|
-
console.log('Code:', error.code);
|
|
234
|
-
console.log('Message:', error.message);
|
|
235
|
-
console.log('Status:', error.status);
|
|
236
|
-
console.log('Details:', error.details);
|
|
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
|
|
237
305
|
}
|
|
238
306
|
}
|
|
239
307
|
```
|
|
240
308
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
244
419
|
|
|
245
420
|
```typescript
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
+
}
|
|
256
435
|
```
|
|
257
436
|
|
|
258
|
-
|
|
437
|
+
---
|
|
259
438
|
|
|
260
|
-
|
|
439
|
+
## Requirements
|
|
261
440
|
|
|
262
|
-
|
|
263
|
-
|
|
441
|
+
- Node.js >= 18.0.0
|
|
442
|
+
- TypeScript >= 5.0.0 (peer dependency)
|
|
264
443
|
|
|
265
|
-
|
|
266
|
-
```
|
|
444
|
+
---
|
|
267
445
|
|
|
268
446
|
## License
|
|
269
447
|
|
|
270
|
-
|
|
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)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/proof-bridge.ts
|
|
2
|
+
function createProofBridge(config) {
|
|
3
|
+
const { proofPlane, webhookRouter } = config;
|
|
4
|
+
let connected = true;
|
|
5
|
+
const handler = async (event) => {
|
|
6
|
+
if (!connected) return;
|
|
7
|
+
const payload = event.payload;
|
|
8
|
+
const now = /* @__PURE__ */ new Date();
|
|
9
|
+
const decision = {
|
|
10
|
+
decisionId: payload.decisionId ?? event.id,
|
|
11
|
+
intentId: payload.intentId ?? "",
|
|
12
|
+
agentId: payload.agentId ?? event.entityId,
|
|
13
|
+
correlationId: payload.correlationId ?? event.id,
|
|
14
|
+
permitted: payload.permitted ?? payload.decision === "ALLOW",
|
|
15
|
+
trustBand: payload.trustBand ?? 4,
|
|
16
|
+
trustScore: payload.trustScore ?? 0,
|
|
17
|
+
reasoning: Array.isArray(payload.reasoning) ? payload.reasoning : typeof payload.reasoning === "string" ? [payload.reasoning] : [],
|
|
18
|
+
decidedAt: payload.decidedAt ? new Date(payload.decidedAt) : now,
|
|
19
|
+
expiresAt: payload.expiresAt ? new Date(payload.expiresAt) : new Date(now.getTime() + 24 * 60 * 60 * 1e3),
|
|
20
|
+
latencyMs: payload.latencyMs ?? 0,
|
|
21
|
+
version: payload.version ?? 1
|
|
22
|
+
};
|
|
23
|
+
await proofPlane.logDecisionMade(decision, decision.correlationId);
|
|
24
|
+
};
|
|
25
|
+
webhookRouter.on("governance.decision", handler);
|
|
26
|
+
return {
|
|
27
|
+
disconnect: () => {
|
|
28
|
+
connected = false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
createProofBridge
|
|
35
|
+
};
|