@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/dist/index.d.cts
CHANGED
|
@@ -1,282 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { T as TrustStatus, I as IntentParseResult, a as Intent, G as GovernanceResult, P as ProofRecord, b as PaginatedResponse, c as ProofChainStats, C as CognigateConfig, A as Agent, d as CreateAgentRequest, U as UpdateAgentRequest } from './proof-bridge-BBmb7kVP.cjs';
|
|
2
|
+
export { e as AgentSchema, f as ApiError, g as ApiResponse, h as GovernanceDecision, i as GovernanceResultSchema, j as ProofBridgeConfig, k as ProofBridgeHandle, l as ProofPlaneEmitter, m as ProofRecordSchema, n as TrustStatusSchema, W as WebhookEvent, o as WebhookEventType, p as WebhookHandler, q as WebhookRouter, r as createProofBridge, s as parseWebhookPayload, v as verifyWebhookSignature } from './proof-bridge-BBmb7kVP.cjs';
|
|
3
3
|
import { TrustTier } from '@vorionsys/shared-constants';
|
|
4
4
|
export { TIER_THRESHOLDS, TrustTier } from '@vorionsys/shared-constants';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Cognigate TypeScript SDK - Type Definitions
|
|
8
|
-
*
|
|
9
|
-
* Core types for the Cognigate AI governance API
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
type GovernanceDecision = 'ALLOW' | 'DENY' | 'ESCALATE' | 'DEGRADE';
|
|
13
|
-
interface GovernanceResult {
|
|
14
|
-
decision: GovernanceDecision;
|
|
15
|
-
trustScore: number;
|
|
16
|
-
trustTier: TrustTier;
|
|
17
|
-
grantedCapabilities: string[];
|
|
18
|
-
deniedCapabilities: string[];
|
|
19
|
-
reasoning: string;
|
|
20
|
-
constraints?: Record<string, unknown>;
|
|
21
|
-
proofId?: string;
|
|
22
|
-
timestamp: Date;
|
|
23
|
-
}
|
|
24
|
-
interface Intent {
|
|
25
|
-
id: string;
|
|
26
|
-
entityId: string;
|
|
27
|
-
rawInput: string;
|
|
28
|
-
parsedAction: string;
|
|
29
|
-
parameters: Record<string, unknown>;
|
|
30
|
-
riskLevel: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
31
|
-
requiredCapabilities: string[];
|
|
32
|
-
timestamp: Date;
|
|
33
|
-
}
|
|
34
|
-
interface IntentParseResult {
|
|
35
|
-
intent: Intent;
|
|
36
|
-
confidence: number;
|
|
37
|
-
alternativeInterpretations?: Intent[];
|
|
38
|
-
}
|
|
39
|
-
interface TrustStatus {
|
|
40
|
-
entityId: string;
|
|
41
|
-
trustScore: number;
|
|
42
|
-
trustTier: TrustTier;
|
|
43
|
-
tierName: string;
|
|
44
|
-
capabilities: string[];
|
|
45
|
-
factorScores: Record<string, number>;
|
|
46
|
-
lastEvaluated: Date;
|
|
47
|
-
compliant: boolean;
|
|
48
|
-
warnings: string[];
|
|
49
|
-
}
|
|
50
|
-
interface ProofRecord {
|
|
51
|
-
id: string;
|
|
52
|
-
entityId: string;
|
|
53
|
-
intentId: string;
|
|
54
|
-
decision: GovernanceDecision;
|
|
55
|
-
action: string;
|
|
56
|
-
outcome: 'SUCCESS' | 'FAILURE' | 'PARTIAL' | 'PENDING';
|
|
57
|
-
trustScoreBefore: number;
|
|
58
|
-
trustScoreAfter: number;
|
|
59
|
-
timestamp: Date;
|
|
60
|
-
hash: string;
|
|
61
|
-
previousHash: string;
|
|
62
|
-
metadata?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
interface ProofChainStats {
|
|
65
|
-
totalRecords: number;
|
|
66
|
-
successRate: number;
|
|
67
|
-
averageTrustScore: number;
|
|
68
|
-
chainIntegrity: boolean;
|
|
69
|
-
lastVerified: Date;
|
|
70
|
-
}
|
|
71
|
-
interface Agent {
|
|
72
|
-
id: string;
|
|
73
|
-
name: string;
|
|
74
|
-
description: string;
|
|
75
|
-
ownerId: string;
|
|
76
|
-
trustScore: number;
|
|
77
|
-
trustTier: TrustTier;
|
|
78
|
-
status: 'ACTIVE' | 'PAUSED' | 'SUSPENDED' | 'TERMINATED';
|
|
79
|
-
capabilities: string[];
|
|
80
|
-
executions: number;
|
|
81
|
-
successRate: number;
|
|
82
|
-
createdAt: Date;
|
|
83
|
-
updatedAt: Date;
|
|
84
|
-
metadata?: Record<string, unknown>;
|
|
85
|
-
}
|
|
86
|
-
interface CreateAgentRequest {
|
|
87
|
-
name: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
template?: string;
|
|
90
|
-
initialCapabilities?: string[];
|
|
91
|
-
metadata?: Record<string, unknown>;
|
|
92
|
-
}
|
|
93
|
-
interface UpdateAgentRequest {
|
|
94
|
-
name?: string;
|
|
95
|
-
description?: string;
|
|
96
|
-
status?: 'ACTIVE' | 'PAUSED';
|
|
97
|
-
metadata?: Record<string, unknown>;
|
|
98
|
-
}
|
|
99
|
-
interface ApiResponse<T> {
|
|
100
|
-
success: boolean;
|
|
101
|
-
data?: T;
|
|
102
|
-
error?: ApiError;
|
|
103
|
-
requestId: string;
|
|
104
|
-
timestamp: Date;
|
|
105
|
-
}
|
|
106
|
-
interface ApiError {
|
|
107
|
-
code: string;
|
|
108
|
-
message: string;
|
|
109
|
-
details?: Record<string, unknown>;
|
|
110
|
-
}
|
|
111
|
-
interface PaginatedResponse<T> {
|
|
112
|
-
items: T[];
|
|
113
|
-
total: number;
|
|
114
|
-
page: number;
|
|
115
|
-
pageSize: number;
|
|
116
|
-
hasMore: boolean;
|
|
117
|
-
}
|
|
118
|
-
interface WebhookEvent {
|
|
119
|
-
id: string;
|
|
120
|
-
type: WebhookEventType;
|
|
121
|
-
entityId: string;
|
|
122
|
-
payload: Record<string, unknown>;
|
|
123
|
-
timestamp: Date;
|
|
124
|
-
signature: string;
|
|
125
|
-
}
|
|
126
|
-
type WebhookEventType = 'agent.created' | 'agent.updated' | 'agent.deleted' | 'agent.status_changed' | 'trust.score_changed' | 'trust.tier_changed' | 'governance.decision' | 'proof.recorded' | 'alert.triggered';
|
|
127
|
-
interface CognigateConfig {
|
|
128
|
-
apiKey: string;
|
|
129
|
-
baseUrl?: string;
|
|
130
|
-
timeout?: number;
|
|
131
|
-
retries?: number;
|
|
132
|
-
debug?: boolean;
|
|
133
|
-
webhookSecret?: string;
|
|
134
|
-
}
|
|
135
|
-
declare const TrustStatusSchema: z.ZodObject<{
|
|
136
|
-
entityId: z.ZodString;
|
|
137
|
-
trustScore: z.ZodNumber;
|
|
138
|
-
trustTier: z.ZodNativeEnum<typeof TrustTier>;
|
|
139
|
-
tierName: z.ZodString;
|
|
140
|
-
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
141
|
-
factorScores: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
142
|
-
lastEvaluated: z.ZodDate;
|
|
143
|
-
compliant: z.ZodBoolean;
|
|
144
|
-
warnings: z.ZodArray<z.ZodString, "many">;
|
|
145
|
-
}, "strip", z.ZodTypeAny, {
|
|
146
|
-
entityId: string;
|
|
147
|
-
trustScore: number;
|
|
148
|
-
trustTier: TrustTier;
|
|
149
|
-
tierName: string;
|
|
150
|
-
capabilities: string[];
|
|
151
|
-
factorScores: Record<string, number>;
|
|
152
|
-
lastEvaluated: Date;
|
|
153
|
-
compliant: boolean;
|
|
154
|
-
warnings: string[];
|
|
155
|
-
}, {
|
|
156
|
-
entityId: string;
|
|
157
|
-
trustScore: number;
|
|
158
|
-
trustTier: TrustTier;
|
|
159
|
-
tierName: string;
|
|
160
|
-
capabilities: string[];
|
|
161
|
-
factorScores: Record<string, number>;
|
|
162
|
-
lastEvaluated: Date;
|
|
163
|
-
compliant: boolean;
|
|
164
|
-
warnings: string[];
|
|
165
|
-
}>;
|
|
166
|
-
declare const GovernanceResultSchema: z.ZodObject<{
|
|
167
|
-
decision: z.ZodEnum<["ALLOW", "DENY", "ESCALATE", "DEGRADE"]>;
|
|
168
|
-
trustScore: z.ZodNumber;
|
|
169
|
-
trustTier: z.ZodNativeEnum<typeof TrustTier>;
|
|
170
|
-
grantedCapabilities: z.ZodArray<z.ZodString, "many">;
|
|
171
|
-
deniedCapabilities: z.ZodArray<z.ZodString, "many">;
|
|
172
|
-
reasoning: z.ZodString;
|
|
173
|
-
constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
174
|
-
proofId: z.ZodOptional<z.ZodString>;
|
|
175
|
-
timestamp: z.ZodDate;
|
|
176
|
-
}, "strip", z.ZodTypeAny, {
|
|
177
|
-
trustScore: number;
|
|
178
|
-
trustTier: TrustTier;
|
|
179
|
-
decision: "ALLOW" | "DENY" | "ESCALATE" | "DEGRADE";
|
|
180
|
-
grantedCapabilities: string[];
|
|
181
|
-
deniedCapabilities: string[];
|
|
182
|
-
reasoning: string;
|
|
183
|
-
timestamp: Date;
|
|
184
|
-
constraints?: Record<string, unknown> | undefined;
|
|
185
|
-
proofId?: string | undefined;
|
|
186
|
-
}, {
|
|
187
|
-
trustScore: number;
|
|
188
|
-
trustTier: TrustTier;
|
|
189
|
-
decision: "ALLOW" | "DENY" | "ESCALATE" | "DEGRADE";
|
|
190
|
-
grantedCapabilities: string[];
|
|
191
|
-
deniedCapabilities: string[];
|
|
192
|
-
reasoning: string;
|
|
193
|
-
timestamp: Date;
|
|
194
|
-
constraints?: Record<string, unknown> | undefined;
|
|
195
|
-
proofId?: string | undefined;
|
|
196
|
-
}>;
|
|
197
|
-
declare const ProofRecordSchema: z.ZodObject<{
|
|
198
|
-
id: z.ZodString;
|
|
199
|
-
entityId: z.ZodString;
|
|
200
|
-
intentId: z.ZodString;
|
|
201
|
-
decision: z.ZodEnum<["ALLOW", "DENY", "ESCALATE", "DEGRADE"]>;
|
|
202
|
-
action: z.ZodString;
|
|
203
|
-
outcome: z.ZodEnum<["SUCCESS", "FAILURE", "PARTIAL", "PENDING"]>;
|
|
204
|
-
trustScoreBefore: z.ZodNumber;
|
|
205
|
-
trustScoreAfter: z.ZodNumber;
|
|
206
|
-
timestamp: z.ZodDate;
|
|
207
|
-
hash: z.ZodString;
|
|
208
|
-
previousHash: z.ZodString;
|
|
209
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
210
|
-
}, "strip", z.ZodTypeAny, {
|
|
211
|
-
entityId: string;
|
|
212
|
-
decision: "ALLOW" | "DENY" | "ESCALATE" | "DEGRADE";
|
|
213
|
-
timestamp: Date;
|
|
214
|
-
id: string;
|
|
215
|
-
intentId: string;
|
|
216
|
-
action: string;
|
|
217
|
-
outcome: "SUCCESS" | "FAILURE" | "PARTIAL" | "PENDING";
|
|
218
|
-
trustScoreBefore: number;
|
|
219
|
-
trustScoreAfter: number;
|
|
220
|
-
hash: string;
|
|
221
|
-
previousHash: string;
|
|
222
|
-
metadata?: Record<string, unknown> | undefined;
|
|
223
|
-
}, {
|
|
224
|
-
entityId: string;
|
|
225
|
-
decision: "ALLOW" | "DENY" | "ESCALATE" | "DEGRADE";
|
|
226
|
-
timestamp: Date;
|
|
227
|
-
id: string;
|
|
228
|
-
intentId: string;
|
|
229
|
-
action: string;
|
|
230
|
-
outcome: "SUCCESS" | "FAILURE" | "PARTIAL" | "PENDING";
|
|
231
|
-
trustScoreBefore: number;
|
|
232
|
-
trustScoreAfter: number;
|
|
233
|
-
hash: string;
|
|
234
|
-
previousHash: string;
|
|
235
|
-
metadata?: Record<string, unknown> | undefined;
|
|
236
|
-
}>;
|
|
237
|
-
declare const AgentSchema: z.ZodObject<{
|
|
238
|
-
id: z.ZodString;
|
|
239
|
-
name: z.ZodString;
|
|
240
|
-
description: z.ZodString;
|
|
241
|
-
ownerId: z.ZodString;
|
|
242
|
-
trustScore: z.ZodNumber;
|
|
243
|
-
trustTier: z.ZodNativeEnum<typeof TrustTier>;
|
|
244
|
-
status: z.ZodEnum<["ACTIVE", "PAUSED", "SUSPENDED", "TERMINATED"]>;
|
|
245
|
-
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
246
|
-
executions: z.ZodNumber;
|
|
247
|
-
successRate: z.ZodNumber;
|
|
248
|
-
createdAt: z.ZodDate;
|
|
249
|
-
updatedAt: z.ZodDate;
|
|
250
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
251
|
-
}, "strip", z.ZodTypeAny, {
|
|
252
|
-
trustScore: number;
|
|
253
|
-
trustTier: TrustTier;
|
|
254
|
-
status: "ACTIVE" | "PAUSED" | "SUSPENDED" | "TERMINATED";
|
|
255
|
-
capabilities: string[];
|
|
256
|
-
id: string;
|
|
257
|
-
name: string;
|
|
258
|
-
description: string;
|
|
259
|
-
ownerId: string;
|
|
260
|
-
executions: number;
|
|
261
|
-
successRate: number;
|
|
262
|
-
createdAt: Date;
|
|
263
|
-
updatedAt: Date;
|
|
264
|
-
metadata?: Record<string, unknown> | undefined;
|
|
265
|
-
}, {
|
|
266
|
-
trustScore: number;
|
|
267
|
-
trustTier: TrustTier;
|
|
268
|
-
status: "ACTIVE" | "PAUSED" | "SUSPENDED" | "TERMINATED";
|
|
269
|
-
capabilities: string[];
|
|
270
|
-
id: string;
|
|
271
|
-
name: string;
|
|
272
|
-
description: string;
|
|
273
|
-
ownerId: string;
|
|
274
|
-
executions: number;
|
|
275
|
-
successRate: number;
|
|
276
|
-
createdAt: Date;
|
|
277
|
-
updatedAt: Date;
|
|
278
|
-
metadata?: Record<string, unknown> | undefined;
|
|
279
|
-
}>;
|
|
5
|
+
export { z } from 'zod';
|
|
280
6
|
|
|
281
7
|
/**
|
|
282
8
|
* Cognigate TypeScript SDK - Client
|
|
@@ -448,53 +174,99 @@ declare class ProofsClient {
|
|
|
448
174
|
}
|
|
449
175
|
|
|
450
176
|
/**
|
|
451
|
-
*
|
|
177
|
+
* Worker Sandbox
|
|
452
178
|
*
|
|
453
|
-
*
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
*
|
|
179
|
+
* Provides isolated code execution for agents using Node.js worker_threads.
|
|
180
|
+
* Enforces resource limits (memory, CPU time), timeout enforcement, and
|
|
181
|
+
* message-based communication for safe agent code execution within Cognigate.
|
|
182
|
+
*
|
|
183
|
+
* @packageDocumentation
|
|
458
184
|
*/
|
|
459
|
-
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): Promise<boolean>;
|
|
460
185
|
/**
|
|
461
|
-
*
|
|
186
|
+
* Context provided to the sandbox for each execution.
|
|
187
|
+
* Determines isolation constraints and identity.
|
|
462
188
|
*/
|
|
463
|
-
|
|
189
|
+
interface SandboxContext {
|
|
190
|
+
/** Tenant that owns this agent */
|
|
191
|
+
tenantId: string;
|
|
192
|
+
/** Agent being sandboxed */
|
|
193
|
+
agentId: string;
|
|
194
|
+
/** Numeric trust level (0-7, maps to TrustTier) */
|
|
195
|
+
trustLevel: number;
|
|
196
|
+
/** List of module names the agent is permitted to require */
|
|
197
|
+
allowedModules: string[];
|
|
198
|
+
/** Maximum execution time in milliseconds */
|
|
199
|
+
timeout: number;
|
|
200
|
+
/** Maximum heap memory in megabytes for the worker */
|
|
201
|
+
memoryLimitMb: number;
|
|
202
|
+
}
|
|
464
203
|
/**
|
|
465
|
-
*
|
|
204
|
+
* Result returned from a sandbox execution.
|
|
466
205
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
206
|
+
interface SandboxResult {
|
|
207
|
+
/** Whether execution completed without errors */
|
|
208
|
+
success: boolean;
|
|
209
|
+
/** The return value from the executed code */
|
|
210
|
+
output: unknown;
|
|
211
|
+
/** Error message if execution failed */
|
|
212
|
+
error?: string;
|
|
213
|
+
/** Wall-clock execution duration in milliseconds */
|
|
214
|
+
durationMs: number;
|
|
215
|
+
/** Approximate memory used during execution in bytes */
|
|
216
|
+
memoryUsedBytes: number;
|
|
217
|
+
}
|
|
470
218
|
/**
|
|
471
|
-
*
|
|
219
|
+
* Executes agent code in an isolated worker thread with resource limits.
|
|
220
|
+
*
|
|
221
|
+
* Each call to execute() spawns a fresh worker with V8 memory limits,
|
|
222
|
+
* runs the code in a vm context with restricted globals, and enforces
|
|
223
|
+
* a timeout from the main thread. Workers are terminated after each
|
|
224
|
+
* execution to ensure complete isolation between runs.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const sandbox = new WorkerSandbox();
|
|
229
|
+
*
|
|
230
|
+
* const result = await sandbox.execute('return 2 + 2;', {
|
|
231
|
+
* tenantId: 'tenant-1',
|
|
232
|
+
* agentId: 'agent-42',
|
|
233
|
+
* trustLevel: 3,
|
|
234
|
+
* allowedModules: [],
|
|
235
|
+
* timeout: 5000,
|
|
236
|
+
* memoryLimitMb: 32,
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* console.log(result.output); // 4
|
|
240
|
+
*
|
|
241
|
+
* await sandbox.shutdown();
|
|
242
|
+
* ```
|
|
472
243
|
*/
|
|
473
|
-
declare class
|
|
474
|
-
private
|
|
475
|
-
|
|
476
|
-
* Register a handler for a specific event type
|
|
477
|
-
*/
|
|
478
|
-
on<T extends WebhookEventType>(type: T, handler: WebhookHandler<T>): this;
|
|
244
|
+
declare class WorkerSandbox {
|
|
245
|
+
private worker;
|
|
246
|
+
private isShutdown;
|
|
479
247
|
/**
|
|
480
|
-
*
|
|
248
|
+
* Execute code in an isolated worker thread.
|
|
249
|
+
*
|
|
250
|
+
* Spawns a new worker for each execution to ensure full isolation.
|
|
251
|
+
* The worker has memory limits enforced by V8 via `resourceLimits`,
|
|
252
|
+
* a vm-level timeout for synchronous code, and a main-thread timeout
|
|
253
|
+
* as a fallback for async code or hangs.
|
|
254
|
+
*
|
|
255
|
+
* @param code - JavaScript code string to execute inside the sandbox.
|
|
256
|
+
* The code is wrapped in an async IIFE, so `return` and `await` are valid.
|
|
257
|
+
* @param context - Execution context with identity and resource constraints
|
|
258
|
+
* @returns Promise resolving to a SandboxResult
|
|
481
259
|
*/
|
|
482
|
-
|
|
260
|
+
execute(code: string, context: SandboxContext): Promise<SandboxResult>;
|
|
483
261
|
/**
|
|
484
|
-
*
|
|
262
|
+
* Gracefully shut down the sandbox.
|
|
263
|
+
* Terminates any running worker and prevents future executions.
|
|
485
264
|
*/
|
|
486
|
-
|
|
265
|
+
shutdown(): Promise<void>;
|
|
487
266
|
/**
|
|
488
|
-
*
|
|
267
|
+
* Check whether the sandbox has been shut down.
|
|
489
268
|
*/
|
|
490
|
-
|
|
491
|
-
headers: Record<string, string>;
|
|
492
|
-
body: unknown;
|
|
493
|
-
}, res: {
|
|
494
|
-
status: (code: number) => {
|
|
495
|
-
json: (data: unknown) => void;
|
|
496
|
-
};
|
|
497
|
-
}) => Promise<void>;
|
|
269
|
+
get terminated(): boolean;
|
|
498
270
|
}
|
|
499
271
|
|
|
500
|
-
export {
|
|
272
|
+
export { Agent, AgentsClient, Cognigate, CognigateConfig, CognigateError, CreateAgentRequest, GovernanceClient, GovernanceResult, Intent, IntentParseResult, PaginatedResponse, ProofChainStats, ProofRecord, ProofsClient, type SandboxContext, type SandboxResult, TrustClient, TrustStatus, UpdateAgentRequest, WorkerSandbox };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { T as TrustStatus, I as IntentParseResult, a as Intent, G as GovernanceResult, P as ProofRecord, b as PaginatedResponse, c as ProofChainStats, C as CognigateConfig, A as Agent, d as CreateAgentRequest, U as UpdateAgentRequest } from './proof-bridge-BBmb7kVP.js';
|
|
2
|
+
export { e as AgentSchema, f as ApiError, g as ApiResponse, h as GovernanceDecision, i as GovernanceResultSchema, j as ProofBridgeConfig, k as ProofBridgeHandle, l as ProofPlaneEmitter, m as ProofRecordSchema, n as TrustStatusSchema, W as WebhookEvent, o as WebhookEventType, p as WebhookHandler, q as WebhookRouter, r as createProofBridge, s as parseWebhookPayload, v as verifyWebhookSignature } from './proof-bridge-BBmb7kVP.js';
|
|
3
|
+
import { TrustTier } from '@vorionsys/shared-constants';
|
|
4
|
+
export { TIER_THRESHOLDS, TrustTier } from '@vorionsys/shared-constants';
|
|
5
|
+
export { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cognigate TypeScript SDK - Client
|
|
9
|
+
*
|
|
10
|
+
* Main client class for interacting with the Cognigate API
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare class CognigateError extends Error {
|
|
14
|
+
code: string;
|
|
15
|
+
status?: number | undefined;
|
|
16
|
+
details?: Record<string, unknown> | undefined;
|
|
17
|
+
constructor(message: string, code: string, status?: number | undefined, details?: Record<string, unknown> | undefined);
|
|
18
|
+
}
|
|
19
|
+
declare class Cognigate {
|
|
20
|
+
private readonly config;
|
|
21
|
+
readonly agents: AgentsClient;
|
|
22
|
+
readonly trust: TrustClient;
|
|
23
|
+
readonly governance: GovernanceClient;
|
|
24
|
+
readonly proofs: ProofsClient;
|
|
25
|
+
constructor(config: CognigateConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Make an authenticated request to the Cognigate API
|
|
28
|
+
*/
|
|
29
|
+
request<T>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Check API health
|
|
32
|
+
*/
|
|
33
|
+
health(): Promise<{
|
|
34
|
+
status: string;
|
|
35
|
+
version: string;
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Get tier from trust score
|
|
40
|
+
*/
|
|
41
|
+
static getTierFromScore(score: number): TrustTier;
|
|
42
|
+
/**
|
|
43
|
+
* Get tier name
|
|
44
|
+
*/
|
|
45
|
+
static getTierName(tier: TrustTier): string;
|
|
46
|
+
/**
|
|
47
|
+
* Get tier thresholds
|
|
48
|
+
*/
|
|
49
|
+
static getTierThresholds(tier: TrustTier): {
|
|
50
|
+
min: number;
|
|
51
|
+
max: number;
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
declare class AgentsClient {
|
|
56
|
+
private client;
|
|
57
|
+
constructor(client: Cognigate);
|
|
58
|
+
/**
|
|
59
|
+
* List all agents
|
|
60
|
+
*/
|
|
61
|
+
list(params?: {
|
|
62
|
+
page?: number;
|
|
63
|
+
pageSize?: number;
|
|
64
|
+
status?: 'ACTIVE' | 'PAUSED' | 'SUSPENDED';
|
|
65
|
+
}): Promise<PaginatedResponse<Agent>>;
|
|
66
|
+
/**
|
|
67
|
+
* Get a specific agent
|
|
68
|
+
*/
|
|
69
|
+
get(agentId: string): Promise<Agent>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a new agent
|
|
72
|
+
*/
|
|
73
|
+
create(data: CreateAgentRequest): Promise<Agent>;
|
|
74
|
+
/**
|
|
75
|
+
* Update an agent
|
|
76
|
+
*/
|
|
77
|
+
update(agentId: string, data: UpdateAgentRequest): Promise<Agent>;
|
|
78
|
+
/**
|
|
79
|
+
* Delete an agent
|
|
80
|
+
*/
|
|
81
|
+
delete(agentId: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Pause an agent
|
|
84
|
+
*/
|
|
85
|
+
pause(agentId: string): Promise<Agent>;
|
|
86
|
+
/**
|
|
87
|
+
* Resume an agent
|
|
88
|
+
*/
|
|
89
|
+
resume(agentId: string): Promise<Agent>;
|
|
90
|
+
}
|
|
91
|
+
declare class TrustClient {
|
|
92
|
+
private client;
|
|
93
|
+
constructor(client: Cognigate);
|
|
94
|
+
/**
|
|
95
|
+
* Get trust status for an entity
|
|
96
|
+
*/
|
|
97
|
+
getStatus(entityId: string): Promise<TrustStatus>;
|
|
98
|
+
/**
|
|
99
|
+
* Get trust history
|
|
100
|
+
*/
|
|
101
|
+
getHistory(entityId: string, params?: {
|
|
102
|
+
from?: Date;
|
|
103
|
+
to?: Date;
|
|
104
|
+
limit?: number;
|
|
105
|
+
}): Promise<Array<{
|
|
106
|
+
score: number;
|
|
107
|
+
tier: TrustTier;
|
|
108
|
+
timestamp: Date;
|
|
109
|
+
}>>;
|
|
110
|
+
/**
|
|
111
|
+
* Submit an outcome to update trust score
|
|
112
|
+
*/
|
|
113
|
+
submitOutcome(entityId: string, proofId: string, outcome: {
|
|
114
|
+
success: boolean;
|
|
115
|
+
metrics?: Record<string, number>;
|
|
116
|
+
notes?: string;
|
|
117
|
+
}): Promise<TrustStatus>;
|
|
118
|
+
}
|
|
119
|
+
declare class GovernanceClient {
|
|
120
|
+
private client;
|
|
121
|
+
constructor(client: Cognigate);
|
|
122
|
+
/**
|
|
123
|
+
* Parse user intent into structured format
|
|
124
|
+
*/
|
|
125
|
+
parseIntent(entityId: string, rawInput: string): Promise<IntentParseResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Enforce governance rules on an intent
|
|
128
|
+
*/
|
|
129
|
+
enforce(intent: Intent): Promise<GovernanceResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Convenience method: parse and enforce in one call
|
|
132
|
+
*/
|
|
133
|
+
evaluate(entityId: string, rawInput: string): Promise<{
|
|
134
|
+
intent: Intent;
|
|
135
|
+
result: GovernanceResult;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Check if an action is allowed without creating a proof record
|
|
139
|
+
*/
|
|
140
|
+
canPerform(entityId: string, action: string, capabilities: string[]): Promise<{
|
|
141
|
+
allowed: boolean;
|
|
142
|
+
reason: string;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
declare class ProofsClient {
|
|
146
|
+
private client;
|
|
147
|
+
constructor(client: Cognigate);
|
|
148
|
+
/**
|
|
149
|
+
* Get a specific proof record
|
|
150
|
+
*/
|
|
151
|
+
get(proofId: string): Promise<ProofRecord>;
|
|
152
|
+
/**
|
|
153
|
+
* List proof records for an entity
|
|
154
|
+
*/
|
|
155
|
+
list(entityId: string, params?: {
|
|
156
|
+
page?: number;
|
|
157
|
+
pageSize?: number;
|
|
158
|
+
from?: Date;
|
|
159
|
+
to?: Date;
|
|
160
|
+
outcome?: 'SUCCESS' | 'FAILURE' | 'PARTIAL';
|
|
161
|
+
}): Promise<PaginatedResponse<ProofRecord>>;
|
|
162
|
+
/**
|
|
163
|
+
* Get proof chain statistics
|
|
164
|
+
*/
|
|
165
|
+
getStats(entityId: string): Promise<ProofChainStats>;
|
|
166
|
+
/**
|
|
167
|
+
* Verify proof chain integrity
|
|
168
|
+
*/
|
|
169
|
+
verify(entityId: string): Promise<{
|
|
170
|
+
valid: boolean;
|
|
171
|
+
errors: string[];
|
|
172
|
+
lastVerified: Date;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Worker Sandbox
|
|
178
|
+
*
|
|
179
|
+
* Provides isolated code execution for agents using Node.js worker_threads.
|
|
180
|
+
* Enforces resource limits (memory, CPU time), timeout enforcement, and
|
|
181
|
+
* message-based communication for safe agent code execution within Cognigate.
|
|
182
|
+
*
|
|
183
|
+
* @packageDocumentation
|
|
184
|
+
*/
|
|
185
|
+
/**
|
|
186
|
+
* Context provided to the sandbox for each execution.
|
|
187
|
+
* Determines isolation constraints and identity.
|
|
188
|
+
*/
|
|
189
|
+
interface SandboxContext {
|
|
190
|
+
/** Tenant that owns this agent */
|
|
191
|
+
tenantId: string;
|
|
192
|
+
/** Agent being sandboxed */
|
|
193
|
+
agentId: string;
|
|
194
|
+
/** Numeric trust level (0-7, maps to TrustTier) */
|
|
195
|
+
trustLevel: number;
|
|
196
|
+
/** List of module names the agent is permitted to require */
|
|
197
|
+
allowedModules: string[];
|
|
198
|
+
/** Maximum execution time in milliseconds */
|
|
199
|
+
timeout: number;
|
|
200
|
+
/** Maximum heap memory in megabytes for the worker */
|
|
201
|
+
memoryLimitMb: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Result returned from a sandbox execution.
|
|
205
|
+
*/
|
|
206
|
+
interface SandboxResult {
|
|
207
|
+
/** Whether execution completed without errors */
|
|
208
|
+
success: boolean;
|
|
209
|
+
/** The return value from the executed code */
|
|
210
|
+
output: unknown;
|
|
211
|
+
/** Error message if execution failed */
|
|
212
|
+
error?: string;
|
|
213
|
+
/** Wall-clock execution duration in milliseconds */
|
|
214
|
+
durationMs: number;
|
|
215
|
+
/** Approximate memory used during execution in bytes */
|
|
216
|
+
memoryUsedBytes: number;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Executes agent code in an isolated worker thread with resource limits.
|
|
220
|
+
*
|
|
221
|
+
* Each call to execute() spawns a fresh worker with V8 memory limits,
|
|
222
|
+
* runs the code in a vm context with restricted globals, and enforces
|
|
223
|
+
* a timeout from the main thread. Workers are terminated after each
|
|
224
|
+
* execution to ensure complete isolation between runs.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const sandbox = new WorkerSandbox();
|
|
229
|
+
*
|
|
230
|
+
* const result = await sandbox.execute('return 2 + 2;', {
|
|
231
|
+
* tenantId: 'tenant-1',
|
|
232
|
+
* agentId: 'agent-42',
|
|
233
|
+
* trustLevel: 3,
|
|
234
|
+
* allowedModules: [],
|
|
235
|
+
* timeout: 5000,
|
|
236
|
+
* memoryLimitMb: 32,
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* console.log(result.output); // 4
|
|
240
|
+
*
|
|
241
|
+
* await sandbox.shutdown();
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
declare class WorkerSandbox {
|
|
245
|
+
private worker;
|
|
246
|
+
private isShutdown;
|
|
247
|
+
/**
|
|
248
|
+
* Execute code in an isolated worker thread.
|
|
249
|
+
*
|
|
250
|
+
* Spawns a new worker for each execution to ensure full isolation.
|
|
251
|
+
* The worker has memory limits enforced by V8 via `resourceLimits`,
|
|
252
|
+
* a vm-level timeout for synchronous code, and a main-thread timeout
|
|
253
|
+
* as a fallback for async code or hangs.
|
|
254
|
+
*
|
|
255
|
+
* @param code - JavaScript code string to execute inside the sandbox.
|
|
256
|
+
* The code is wrapped in an async IIFE, so `return` and `await` are valid.
|
|
257
|
+
* @param context - Execution context with identity and resource constraints
|
|
258
|
+
* @returns Promise resolving to a SandboxResult
|
|
259
|
+
*/
|
|
260
|
+
execute(code: string, context: SandboxContext): Promise<SandboxResult>;
|
|
261
|
+
/**
|
|
262
|
+
* Gracefully shut down the sandbox.
|
|
263
|
+
* Terminates any running worker and prevents future executions.
|
|
264
|
+
*/
|
|
265
|
+
shutdown(): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Check whether the sandbox has been shut down.
|
|
268
|
+
*/
|
|
269
|
+
get terminated(): boolean;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export { Agent, AgentsClient, Cognigate, CognigateConfig, CognigateError, CreateAgentRequest, GovernanceClient, GovernanceResult, Intent, IntentParseResult, PaginatedResponse, ProofChainStats, ProofRecord, ProofsClient, type SandboxContext, type SandboxResult, TrustClient, TrustStatus, UpdateAgentRequest, WorkerSandbox };
|