@vaikora/sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -0
- package/dist/index.d.mts +1106 -0
- package/dist/index.d.ts +1106 -0
- package/dist/index.js +1780 -0
- package/dist/index.mjs +1693 -0
- package/package.json +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Vaikora SDK & Dashboard
|
|
3
|
+
* Synced with Backend Pydantic Models (Transformed to CamelCase for SDK)
|
|
4
|
+
*/
|
|
5
|
+
type AgentType = 'autonomous' | 'internal' | 'external' | 'custom';
|
|
6
|
+
type AgentStatus = 'active' | 'paused' | 'blocked' | 'inactive';
|
|
7
|
+
type ActionStatus = 'pending' | 'approved' | 'denied' | 'executed' | 'failed' | 'blocked' | 'anomaly_detected';
|
|
8
|
+
type AlertSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
9
|
+
type AlertStatus = 'open' | 'acknowledged' | 'resolved' | 'ignored';
|
|
10
|
+
declare enum ApprovalStatus {
|
|
11
|
+
PENDING = "pending",
|
|
12
|
+
APPROVED = "approved",
|
|
13
|
+
DENIED = "denied",
|
|
14
|
+
EXPIRED = "expired"
|
|
15
|
+
}
|
|
16
|
+
interface Agent {
|
|
17
|
+
id: string;
|
|
18
|
+
organizationId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
agentKey: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
agentType: AgentType;
|
|
24
|
+
status: AgentStatus;
|
|
25
|
+
riskScore: number;
|
|
26
|
+
capabilities: Record<string, any>;
|
|
27
|
+
extraData: {
|
|
28
|
+
metrics?: {
|
|
29
|
+
actions_today: number;
|
|
30
|
+
actionsToday?: number;
|
|
31
|
+
uptime: number;
|
|
32
|
+
latency: number;
|
|
33
|
+
};
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
interface AgentCreate {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
agentType?: AgentType;
|
|
43
|
+
capabilities?: Record<string, any>;
|
|
44
|
+
extraData?: Record<string, any>;
|
|
45
|
+
metadata?: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
interface AgentUpdate {
|
|
48
|
+
name?: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
agentType?: AgentType;
|
|
51
|
+
status?: AgentStatus;
|
|
52
|
+
capabilities?: Record<string, any>;
|
|
53
|
+
extraData?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface OrganizationStats {
|
|
56
|
+
activeAgents: number;
|
|
57
|
+
totalAgents: number;
|
|
58
|
+
totalActionsToday: number;
|
|
59
|
+
openAlerts: number;
|
|
60
|
+
securityScore: number;
|
|
61
|
+
}
|
|
62
|
+
interface AlertStats {
|
|
63
|
+
openAlerts: number;
|
|
64
|
+
alertsBySeverity: {
|
|
65
|
+
low: number;
|
|
66
|
+
medium: number;
|
|
67
|
+
high: number;
|
|
68
|
+
critical: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
interface Action {
|
|
72
|
+
id: string;
|
|
73
|
+
agentId: string;
|
|
74
|
+
actionType: string;
|
|
75
|
+
resourceType?: string;
|
|
76
|
+
resourceId?: string;
|
|
77
|
+
payload: Record<string, any>;
|
|
78
|
+
status: ActionStatus;
|
|
79
|
+
severity: string;
|
|
80
|
+
policyId?: string;
|
|
81
|
+
policyDecision?: string;
|
|
82
|
+
isAnomaly: boolean;
|
|
83
|
+
anomalyScore?: number;
|
|
84
|
+
anomalyReason?: string;
|
|
85
|
+
result?: any;
|
|
86
|
+
timestamp: string;
|
|
87
|
+
}
|
|
88
|
+
interface Alert {
|
|
89
|
+
id: string;
|
|
90
|
+
organizationId: string;
|
|
91
|
+
agentId?: string;
|
|
92
|
+
title: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
severity: AlertSeverity;
|
|
95
|
+
status: AlertStatus;
|
|
96
|
+
metadata?: Record<string, any>;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
}
|
|
99
|
+
interface Policy {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
policyType: string;
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
priority: number;
|
|
106
|
+
rules: Record<string, any>;
|
|
107
|
+
createdAt: string;
|
|
108
|
+
}
|
|
109
|
+
interface PaginatedResponse<T> {
|
|
110
|
+
items: T[];
|
|
111
|
+
agents?: T[];
|
|
112
|
+
alerts?: T[];
|
|
113
|
+
actions?: T[];
|
|
114
|
+
total: number;
|
|
115
|
+
page: number;
|
|
116
|
+
perPage: number;
|
|
117
|
+
}
|
|
118
|
+
type PaginatedList<T> = PaginatedResponse<T>;
|
|
119
|
+
interface ActionResponse {
|
|
120
|
+
id: string;
|
|
121
|
+
status: ActionStatus;
|
|
122
|
+
result?: any;
|
|
123
|
+
}
|
|
124
|
+
interface ActionDecision {
|
|
125
|
+
actionId: string;
|
|
126
|
+
decision: 'allow' | 'block' | 'require_approval';
|
|
127
|
+
reason?: string;
|
|
128
|
+
warnings?: string[];
|
|
129
|
+
}
|
|
130
|
+
interface VaikoraClientConfig {
|
|
131
|
+
apiKey: string;
|
|
132
|
+
baseUrl?: string;
|
|
133
|
+
timeout?: number;
|
|
134
|
+
retryCount?: number;
|
|
135
|
+
agentId?: string;
|
|
136
|
+
}
|
|
137
|
+
interface ConfigureOptions {
|
|
138
|
+
baseUrl?: string;
|
|
139
|
+
timeout?: number;
|
|
140
|
+
retryCount?: number;
|
|
141
|
+
}
|
|
142
|
+
interface RegisterOptions {
|
|
143
|
+
name: string;
|
|
144
|
+
agentType?: AgentType;
|
|
145
|
+
capabilities?: string[];
|
|
146
|
+
metadata?: Record<string, unknown>;
|
|
147
|
+
}
|
|
148
|
+
interface ValidateDataOptions {
|
|
149
|
+
checkPii?: boolean;
|
|
150
|
+
checkAnomalies?: boolean;
|
|
151
|
+
checkToxicity?: boolean;
|
|
152
|
+
autoClean?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface DataValidationResult {
|
|
155
|
+
isValid: boolean;
|
|
156
|
+
issues?: string[];
|
|
157
|
+
piiDetected?: boolean;
|
|
158
|
+
piiDetections?: any[];
|
|
159
|
+
anomalyDetected?: boolean;
|
|
160
|
+
anomalyDetections?: any[];
|
|
161
|
+
toxicityDetected?: boolean;
|
|
162
|
+
toxicityDetections?: any[];
|
|
163
|
+
}
|
|
164
|
+
interface SecureActionOptions {
|
|
165
|
+
actionType: string;
|
|
166
|
+
resource?: string;
|
|
167
|
+
agentId?: string;
|
|
168
|
+
metadata?: Record<string, unknown>;
|
|
169
|
+
}
|
|
170
|
+
interface ActionComplete {
|
|
171
|
+
status: string;
|
|
172
|
+
executionTimeMs: number;
|
|
173
|
+
errorMessage?: string;
|
|
174
|
+
resultMetadata?: Record<string, any>;
|
|
175
|
+
}
|
|
176
|
+
interface ListParams {
|
|
177
|
+
page?: number;
|
|
178
|
+
pageSize?: number;
|
|
179
|
+
startDate?: Date;
|
|
180
|
+
endDate?: Date;
|
|
181
|
+
}
|
|
182
|
+
interface AgentListParams extends ListParams {
|
|
183
|
+
status?: AgentStatus;
|
|
184
|
+
agentType?: AgentType;
|
|
185
|
+
}
|
|
186
|
+
interface PolicyListParams extends ListParams {
|
|
187
|
+
enabled?: boolean;
|
|
188
|
+
policyType?: string;
|
|
189
|
+
}
|
|
190
|
+
interface AlertListParams extends ListParams {
|
|
191
|
+
status?: AlertStatus;
|
|
192
|
+
severity?: AlertSeverity;
|
|
193
|
+
agentId?: string;
|
|
194
|
+
}
|
|
195
|
+
interface ActionListParams extends ListParams {
|
|
196
|
+
agentId?: string;
|
|
197
|
+
actionType?: string;
|
|
198
|
+
status?: ActionStatus;
|
|
199
|
+
isAnomaly?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface SDKActionSubmit {
|
|
202
|
+
agentId: string;
|
|
203
|
+
actionType: string;
|
|
204
|
+
resource?: string;
|
|
205
|
+
payload?: Record<string, any>;
|
|
206
|
+
metadata?: Record<string, any>;
|
|
207
|
+
}
|
|
208
|
+
interface ThreatDetail {
|
|
209
|
+
threatType: string;
|
|
210
|
+
severity: string;
|
|
211
|
+
confidence: number;
|
|
212
|
+
description: string;
|
|
213
|
+
}
|
|
214
|
+
interface RiskFactor {
|
|
215
|
+
factor: string;
|
|
216
|
+
score: number;
|
|
217
|
+
reason: string;
|
|
218
|
+
}
|
|
219
|
+
interface SDKActionResult {
|
|
220
|
+
actionId: string;
|
|
221
|
+
approved: boolean;
|
|
222
|
+
decision: 'allow' | 'block' | 'require_approval';
|
|
223
|
+
denialReason?: string;
|
|
224
|
+
policyId?: string;
|
|
225
|
+
threatDetected: boolean;
|
|
226
|
+
threatScore: number;
|
|
227
|
+
threatDetails: ThreatDetail[];
|
|
228
|
+
riskScore: number;
|
|
229
|
+
riskLevel: string;
|
|
230
|
+
riskFactors: string[];
|
|
231
|
+
isAnomaly: boolean;
|
|
232
|
+
anomalyScore: number;
|
|
233
|
+
anomalyReasons: string[];
|
|
234
|
+
warnings: string[];
|
|
235
|
+
requiresApproval?: boolean;
|
|
236
|
+
approvalId?: string;
|
|
237
|
+
status: string;
|
|
238
|
+
result?: any;
|
|
239
|
+
}
|
|
240
|
+
type ActionSubmit = SDKActionSubmit;
|
|
241
|
+
type ActionResult = SDKActionResult;
|
|
242
|
+
type ActionSubmitResult = SDKActionResult;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Emergency Controls - Agent Freeze/Resume Capabilities
|
|
246
|
+
*
|
|
247
|
+
* Provides:
|
|
248
|
+
* - Immediate agent freeze
|
|
249
|
+
* - Controlled resume
|
|
250
|
+
* - Emergency killswitch
|
|
251
|
+
* - Circuit breaker patterns
|
|
252
|
+
*/
|
|
253
|
+
declare enum FreezeReason {
|
|
254
|
+
MANUAL = "manual",
|
|
255
|
+
POLICY_VIOLATION = "policy_violation",
|
|
256
|
+
ANOMALY_DETECTED = "anomaly_detected",
|
|
257
|
+
RATE_LIMIT = "rate_limit",
|
|
258
|
+
SECURITY_THREAT = "security_threat",
|
|
259
|
+
SYSTEM_OVERLOAD = "system_overload",
|
|
260
|
+
CIRCUIT_BREAKER = "circuit_breaker",
|
|
261
|
+
MAINTENANCE = "maintenance"
|
|
262
|
+
}
|
|
263
|
+
declare enum FreezeScope {
|
|
264
|
+
ALL_ACTIONS = "all_actions",
|
|
265
|
+
WRITE_ACTIONS = "write_actions",
|
|
266
|
+
SPECIFIC_RESOURCE = "specific_resource",
|
|
267
|
+
SPECIFIC_ACTION_TYPE = "specific_action_type"
|
|
268
|
+
}
|
|
269
|
+
interface FreezeState {
|
|
270
|
+
isFrozen: boolean;
|
|
271
|
+
reason?: FreezeReason;
|
|
272
|
+
scope: FreezeScope;
|
|
273
|
+
frozenAt?: Date;
|
|
274
|
+
frozenBy?: string;
|
|
275
|
+
freezeUntil?: Date;
|
|
276
|
+
affectedResources: string[];
|
|
277
|
+
affectedActionTypes: string[];
|
|
278
|
+
message?: string;
|
|
279
|
+
metadata: Record<string, unknown>;
|
|
280
|
+
}
|
|
281
|
+
interface FreezeOptions {
|
|
282
|
+
reason: FreezeReason;
|
|
283
|
+
scope?: FreezeScope;
|
|
284
|
+
durationSeconds?: number;
|
|
285
|
+
frozenBy?: string;
|
|
286
|
+
message?: string;
|
|
287
|
+
affectedResources?: string[];
|
|
288
|
+
affectedActionTypes?: string[];
|
|
289
|
+
metadata?: Record<string, unknown>;
|
|
290
|
+
}
|
|
291
|
+
interface ResumeOptions {
|
|
292
|
+
resumedBy?: string;
|
|
293
|
+
verificationPassed?: boolean;
|
|
294
|
+
notes?: string;
|
|
295
|
+
}
|
|
296
|
+
interface CircuitBreakerConfig {
|
|
297
|
+
failureThreshold: number;
|
|
298
|
+
successThreshold: number;
|
|
299
|
+
timeoutSeconds: number;
|
|
300
|
+
halfOpenMaxCalls: number;
|
|
301
|
+
}
|
|
302
|
+
declare enum CircuitState {
|
|
303
|
+
CLOSED = "closed",// Normal operation
|
|
304
|
+
OPEN = "open",// Blocking all calls
|
|
305
|
+
HALF_OPEN = "half_open"
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Circuit breaker for resilient operations.
|
|
309
|
+
*/
|
|
310
|
+
declare class CircuitBreaker {
|
|
311
|
+
readonly name: string;
|
|
312
|
+
readonly config: CircuitBreakerConfig;
|
|
313
|
+
state: CircuitState;
|
|
314
|
+
failureCount: number;
|
|
315
|
+
successCount: number;
|
|
316
|
+
lastFailureTime?: number;
|
|
317
|
+
halfOpenCalls: number;
|
|
318
|
+
constructor(name: string, config?: Partial<CircuitBreakerConfig>);
|
|
319
|
+
/**
|
|
320
|
+
* Check if circuit is open (blocking).
|
|
321
|
+
*/
|
|
322
|
+
isOpen(): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Record a successful call.
|
|
325
|
+
*/
|
|
326
|
+
recordSuccess(): void;
|
|
327
|
+
/**
|
|
328
|
+
* Record a failed call.
|
|
329
|
+
*/
|
|
330
|
+
recordFailure(): void;
|
|
331
|
+
/**
|
|
332
|
+
* Check if request should be allowed.
|
|
333
|
+
*/
|
|
334
|
+
allowRequest(): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Wrap a function with circuit breaker protection.
|
|
337
|
+
*/
|
|
338
|
+
wrap<T>(fn: () => Promise<T>): Promise<T>;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Error thrown when circuit breaker is open.
|
|
342
|
+
*/
|
|
343
|
+
declare class CircuitBreakerOpenError extends Error {
|
|
344
|
+
constructor(message: string);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Error thrown when attempting an action while agent is frozen.
|
|
348
|
+
*/
|
|
349
|
+
declare class AgentFrozenError extends Error {
|
|
350
|
+
readonly freezeState: FreezeState;
|
|
351
|
+
constructor(message: string, freezeState: FreezeState);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Callback types for freeze/resume events.
|
|
355
|
+
*/
|
|
356
|
+
type FreezeCallback = (state: FreezeState) => void;
|
|
357
|
+
type ResumeCallback = (oldState: FreezeState, notes?: string) => void;
|
|
358
|
+
/**
|
|
359
|
+
* Emergency control system for AI agents.
|
|
360
|
+
*/
|
|
361
|
+
declare class EmergencyController {
|
|
362
|
+
private agentId;
|
|
363
|
+
private freezeState;
|
|
364
|
+
private circuitBreakers;
|
|
365
|
+
private freezeCallbacks;
|
|
366
|
+
private resumeCallbacks;
|
|
367
|
+
private rateLimits;
|
|
368
|
+
constructor(agentId: string);
|
|
369
|
+
/**
|
|
370
|
+
* Check if agent is currently frozen.
|
|
371
|
+
*/
|
|
372
|
+
get isFrozen(): boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Get current freeze state.
|
|
375
|
+
*/
|
|
376
|
+
getFreezeState(): FreezeState;
|
|
377
|
+
/**
|
|
378
|
+
* Check if freeze has expired.
|
|
379
|
+
*/
|
|
380
|
+
private isExpired;
|
|
381
|
+
/**
|
|
382
|
+
* Freeze the agent immediately.
|
|
383
|
+
*/
|
|
384
|
+
freeze(options: FreezeOptions): FreezeState;
|
|
385
|
+
/**
|
|
386
|
+
* Resume agent operations.
|
|
387
|
+
*/
|
|
388
|
+
resume(options?: ResumeOptions): FreezeState;
|
|
389
|
+
/**
|
|
390
|
+
* Auto-unfreeze when time expires.
|
|
391
|
+
*/
|
|
392
|
+
private autoUnfreeze;
|
|
393
|
+
/**
|
|
394
|
+
* Check if a specific action is blocked.
|
|
395
|
+
*/
|
|
396
|
+
isActionBlocked(actionType: string, resource?: string): {
|
|
397
|
+
blocked: boolean;
|
|
398
|
+
message?: string;
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Register a callback for freeze events.
|
|
402
|
+
*/
|
|
403
|
+
onFreeze(callback: FreezeCallback): void;
|
|
404
|
+
/**
|
|
405
|
+
* Register a callback for resume events.
|
|
406
|
+
*/
|
|
407
|
+
onResume(callback: ResumeCallback): void;
|
|
408
|
+
/**
|
|
409
|
+
* Get or create a circuit breaker.
|
|
410
|
+
*/
|
|
411
|
+
getCircuitBreaker(name: string, config?: Partial<CircuitBreakerConfig>): CircuitBreaker;
|
|
412
|
+
/**
|
|
413
|
+
* Check if rate limit is exceeded.
|
|
414
|
+
*/
|
|
415
|
+
checkRateLimit(key: string, maxRequests: number, windowSeconds: number): {
|
|
416
|
+
allowed: boolean;
|
|
417
|
+
remaining: number;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Get agent ID.
|
|
421
|
+
*/
|
|
422
|
+
getAgentId(): string;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Guard function that throws if action is blocked.
|
|
426
|
+
*/
|
|
427
|
+
declare function assertNotFrozen(controller: EmergencyController, actionType: string, resource?: string): void;
|
|
428
|
+
/**
|
|
429
|
+
* Decorator-like wrapper for functions that should be blocked when frozen.
|
|
430
|
+
*/
|
|
431
|
+
declare function frozenGuard<T extends (...args: unknown[]) => Promise<unknown>>(controller: EmergencyController, actionType: string, resource?: string): (fn: T) => T;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Exception classes for the Vaikora SDK
|
|
435
|
+
*/
|
|
436
|
+
declare class VaikoraError extends Error {
|
|
437
|
+
statusCode?: number;
|
|
438
|
+
responseData?: Record<string, unknown>;
|
|
439
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
440
|
+
}
|
|
441
|
+
declare class AuthenticationError extends VaikoraError {
|
|
442
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
443
|
+
}
|
|
444
|
+
declare class AuthorizationError extends VaikoraError {
|
|
445
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
446
|
+
}
|
|
447
|
+
declare class RateLimitError extends VaikoraError {
|
|
448
|
+
retryAfter?: number;
|
|
449
|
+
constructor(message: string, retryAfter?: number, statusCode?: number, responseData?: Record<string, unknown>);
|
|
450
|
+
}
|
|
451
|
+
declare class PolicyViolationError extends VaikoraError {
|
|
452
|
+
policyId?: string;
|
|
453
|
+
policyName?: string;
|
|
454
|
+
constructor(message: string, policyId?: string, policyName?: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
455
|
+
}
|
|
456
|
+
declare class NetworkError extends VaikoraError {
|
|
457
|
+
constructor(message: string);
|
|
458
|
+
}
|
|
459
|
+
declare class TimeoutError extends NetworkError {
|
|
460
|
+
constructor(message: string);
|
|
461
|
+
}
|
|
462
|
+
declare class ValidationError extends VaikoraError {
|
|
463
|
+
errors?: Array<{
|
|
464
|
+
msg: string;
|
|
465
|
+
loc?: string[];
|
|
466
|
+
}>;
|
|
467
|
+
constructor(message: string, errors?: Array<{
|
|
468
|
+
msg: string;
|
|
469
|
+
loc?: string[];
|
|
470
|
+
}>, statusCode?: number, responseData?: Record<string, unknown>);
|
|
471
|
+
}
|
|
472
|
+
declare class NotFoundError extends VaikoraError {
|
|
473
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
474
|
+
}
|
|
475
|
+
declare class ConflictError extends VaikoraError {
|
|
476
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
477
|
+
}
|
|
478
|
+
declare class ServerError extends VaikoraError {
|
|
479
|
+
constructor(message: string, statusCode?: number, responseData?: Record<string, unknown>);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Raise appropriate exception based on status code
|
|
483
|
+
*/
|
|
484
|
+
declare function raiseForStatus(statusCode: number, responseData: Record<string, unknown>): never;
|
|
485
|
+
|
|
486
|
+
interface AgentCredentials {
|
|
487
|
+
agentId: string;
|
|
488
|
+
apiKey: string;
|
|
489
|
+
secretKey: string;
|
|
490
|
+
issuedAt: Date;
|
|
491
|
+
expiresAt?: Date;
|
|
492
|
+
scopes: string[];
|
|
493
|
+
metadata: Record<string, unknown>;
|
|
494
|
+
}
|
|
495
|
+
interface SignedRequest {
|
|
496
|
+
requestId: string;
|
|
497
|
+
agentId: string;
|
|
498
|
+
timestamp: string;
|
|
499
|
+
signature: string;
|
|
500
|
+
payloadHash: string;
|
|
501
|
+
nonce: string;
|
|
502
|
+
}
|
|
503
|
+
interface SignedHeaders {
|
|
504
|
+
'X-Vaikora-Agent-ID': string;
|
|
505
|
+
'X-Vaikora-Request-ID': string;
|
|
506
|
+
'X-Vaikora-Timestamp': string;
|
|
507
|
+
'X-Vaikora-Nonce': string;
|
|
508
|
+
'X-Vaikora-Signature': string;
|
|
509
|
+
'X-Vaikora-Payload-Hash': string;
|
|
510
|
+
[key: string]: string;
|
|
511
|
+
}
|
|
512
|
+
interface VerificationResult {
|
|
513
|
+
isValid: boolean;
|
|
514
|
+
errorMessage?: string;
|
|
515
|
+
}
|
|
516
|
+
interface AttestationClaims {
|
|
517
|
+
[key: string]: unknown;
|
|
518
|
+
}
|
|
519
|
+
interface Attestation {
|
|
520
|
+
agentId: string;
|
|
521
|
+
claims: AttestationClaims;
|
|
522
|
+
issuedAt: string;
|
|
523
|
+
environment: string;
|
|
524
|
+
signature?: string;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Manages agent identity and cryptographic operations.
|
|
528
|
+
*/
|
|
529
|
+
declare class AgentIdentity {
|
|
530
|
+
private static readonly NONCE_LENGTH;
|
|
531
|
+
private static readonly MAX_TIMESTAMP_DRIFT_SECONDS;
|
|
532
|
+
private agentId;
|
|
533
|
+
private apiKey;
|
|
534
|
+
private secretKey;
|
|
535
|
+
private environment;
|
|
536
|
+
private requestCounter;
|
|
537
|
+
private usedNonces;
|
|
538
|
+
private nonceExpiry;
|
|
539
|
+
constructor(agentId: string, apiKey: string, secretKey?: string, environment?: string);
|
|
540
|
+
/**
|
|
541
|
+
* Generate a cryptographically secure secret key.
|
|
542
|
+
*/
|
|
543
|
+
private generateSecretKey;
|
|
544
|
+
/**
|
|
545
|
+
* Generate a unique nonce for request signing.
|
|
546
|
+
*/
|
|
547
|
+
private generateNonce;
|
|
548
|
+
/**
|
|
549
|
+
* Get current timestamp in ISO format.
|
|
550
|
+
*/
|
|
551
|
+
private getTimestamp;
|
|
552
|
+
/**
|
|
553
|
+
* Create SHA-256 hash of payload.
|
|
554
|
+
*/
|
|
555
|
+
private hashPayload;
|
|
556
|
+
/**
|
|
557
|
+
* Sign an API request.
|
|
558
|
+
*/
|
|
559
|
+
signRequest(method: string, path: string, payload?: unknown, additionalHeaders?: Record<string, string>): {
|
|
560
|
+
headers: SignedHeaders;
|
|
561
|
+
signature: SignedRequest;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Verify a signed request.
|
|
565
|
+
*/
|
|
566
|
+
verifySignature(method: string, path: string, timestamp: string, nonce: string, payloadHash: string, providedSignature: string, agentId: string): VerificationResult;
|
|
567
|
+
/**
|
|
568
|
+
* Clean up expired nonces.
|
|
569
|
+
*/
|
|
570
|
+
private cleanupNonces;
|
|
571
|
+
/**
|
|
572
|
+
* Create a signed attestation of claims.
|
|
573
|
+
*/
|
|
574
|
+
createAttestation(claims: AttestationClaims): string;
|
|
575
|
+
/**
|
|
576
|
+
* Verify a signed attestation.
|
|
577
|
+
*/
|
|
578
|
+
verifyAttestation(encodedAttestation: string): {
|
|
579
|
+
isValid: boolean;
|
|
580
|
+
attestation?: Attestation;
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* Rotate the secret key.
|
|
584
|
+
*/
|
|
585
|
+
rotateSecret(): string;
|
|
586
|
+
/**
|
|
587
|
+
* Get identity information (without secrets).
|
|
588
|
+
*/
|
|
589
|
+
getIdentityInfo(): Record<string, unknown>;
|
|
590
|
+
/**
|
|
591
|
+
* Get the agent ID.
|
|
592
|
+
*/
|
|
593
|
+
getAgentId(): string;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
declare enum ExecutionMode {
|
|
597
|
+
ENFORCE = "enforce",// Full policy enforcement, block violations
|
|
598
|
+
MONITOR = "monitor",// Log violations but don't block
|
|
599
|
+
SIMULATE = "simulate"
|
|
600
|
+
}
|
|
601
|
+
declare enum ContextLevel {
|
|
602
|
+
ROOT = "root",
|
|
603
|
+
CHILD = "child",
|
|
604
|
+
NESTED = "nested"
|
|
605
|
+
}
|
|
606
|
+
interface TraceLog {
|
|
607
|
+
timestamp: string;
|
|
608
|
+
level: string;
|
|
609
|
+
message: string;
|
|
610
|
+
}
|
|
611
|
+
interface ExecutionTrace {
|
|
612
|
+
traceId: string;
|
|
613
|
+
spanId: string;
|
|
614
|
+
parentSpanId?: string;
|
|
615
|
+
operationName: string;
|
|
616
|
+
startTime: number;
|
|
617
|
+
endTime?: number;
|
|
618
|
+
durationMs?: number;
|
|
619
|
+
status: string;
|
|
620
|
+
tags: Record<string, unknown>;
|
|
621
|
+
logs: TraceLog[];
|
|
622
|
+
}
|
|
623
|
+
interface ExecutionContextOptions {
|
|
624
|
+
agentId: string;
|
|
625
|
+
sessionId?: string;
|
|
626
|
+
mode?: ExecutionMode;
|
|
627
|
+
environment?: string;
|
|
628
|
+
traceId?: string;
|
|
629
|
+
spanId?: string;
|
|
630
|
+
parentSpanId?: string;
|
|
631
|
+
level?: ContextLevel;
|
|
632
|
+
depth?: number;
|
|
633
|
+
userId?: string;
|
|
634
|
+
tenantId?: string;
|
|
635
|
+
correlationId?: string;
|
|
636
|
+
timeoutSeconds?: number;
|
|
637
|
+
attributes?: Record<string, unknown>;
|
|
638
|
+
baggage?: Record<string, string>;
|
|
639
|
+
}
|
|
640
|
+
interface ContextHeaders {
|
|
641
|
+
'X-Vaikora-Trace-ID': string;
|
|
642
|
+
'X-Vaikora-Span-ID': string;
|
|
643
|
+
'X-Vaikora-Agent-ID': string;
|
|
644
|
+
'X-Vaikora-Session-ID': string;
|
|
645
|
+
'X-Vaikora-Mode': string;
|
|
646
|
+
[key: string]: string;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Context for agent execution.
|
|
650
|
+
*/
|
|
651
|
+
declare class ExecutionContext {
|
|
652
|
+
readonly agentId: string;
|
|
653
|
+
readonly sessionId: string;
|
|
654
|
+
mode: ExecutionMode;
|
|
655
|
+
readonly environment: string;
|
|
656
|
+
readonly traceId: string;
|
|
657
|
+
readonly spanId: string;
|
|
658
|
+
readonly parentSpanId?: string;
|
|
659
|
+
readonly level: ContextLevel;
|
|
660
|
+
readonly depth: number;
|
|
661
|
+
readonly userId?: string;
|
|
662
|
+
readonly tenantId?: string;
|
|
663
|
+
readonly correlationId?: string;
|
|
664
|
+
readonly createdAt: Date;
|
|
665
|
+
readonly timeoutSeconds?: number;
|
|
666
|
+
readonly deadline?: Date;
|
|
667
|
+
attributes: Record<string, unknown>;
|
|
668
|
+
baggage: Record<string, string>;
|
|
669
|
+
private traces;
|
|
670
|
+
private activeTrace?;
|
|
671
|
+
constructor(options: ExecutionContextOptions);
|
|
672
|
+
/**
|
|
673
|
+
* Check if this is a dry-run (simulate mode).
|
|
674
|
+
*/
|
|
675
|
+
isDryRun(): boolean;
|
|
676
|
+
/**
|
|
677
|
+
* Check if policy enforcement is active.
|
|
678
|
+
*/
|
|
679
|
+
shouldEnforce(): boolean;
|
|
680
|
+
/**
|
|
681
|
+
* Check if violations should block execution.
|
|
682
|
+
*/
|
|
683
|
+
shouldBlockViolations(): boolean;
|
|
684
|
+
/**
|
|
685
|
+
* Check if context deadline has passed.
|
|
686
|
+
*/
|
|
687
|
+
isExpired(): boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Get remaining time before deadline.
|
|
690
|
+
*/
|
|
691
|
+
remainingTimeSeconds(): number | undefined;
|
|
692
|
+
/**
|
|
693
|
+
* Start a new trace span.
|
|
694
|
+
*/
|
|
695
|
+
startSpan(operationName: string, tags?: Record<string, unknown>): ExecutionTrace;
|
|
696
|
+
/**
|
|
697
|
+
* End the current trace span.
|
|
698
|
+
*/
|
|
699
|
+
endSpan(status?: string): void;
|
|
700
|
+
/**
|
|
701
|
+
* Add a log entry to the current trace.
|
|
702
|
+
*/
|
|
703
|
+
addLog(message: string, level?: string): void;
|
|
704
|
+
/**
|
|
705
|
+
* Create a child context for nested operations.
|
|
706
|
+
*/
|
|
707
|
+
childContext(_operation?: string): ExecutionContext;
|
|
708
|
+
/**
|
|
709
|
+
* Create a new context with different execution mode.
|
|
710
|
+
*/
|
|
711
|
+
withMode(mode: ExecutionMode): ExecutionContext;
|
|
712
|
+
/**
|
|
713
|
+
* Set a context attribute.
|
|
714
|
+
*/
|
|
715
|
+
setAttribute(key: string, value: unknown): void;
|
|
716
|
+
/**
|
|
717
|
+
* Get a context attribute.
|
|
718
|
+
*/
|
|
719
|
+
getAttribute<T>(key: string, defaultValue?: T): T | undefined;
|
|
720
|
+
/**
|
|
721
|
+
* Set baggage (propagated across service boundaries).
|
|
722
|
+
*/
|
|
723
|
+
setBaggage(key: string, value: string): void;
|
|
724
|
+
/**
|
|
725
|
+
* Get baggage value.
|
|
726
|
+
*/
|
|
727
|
+
getBaggage(key: string, defaultValue?: string): string;
|
|
728
|
+
/**
|
|
729
|
+
* Export context to HTTP headers for propagation.
|
|
730
|
+
*/
|
|
731
|
+
toHeaders(): ContextHeaders;
|
|
732
|
+
/**
|
|
733
|
+
* Create context from HTTP headers.
|
|
734
|
+
*/
|
|
735
|
+
static fromHeaders(headers: Record<string, string>, agentId: string): ExecutionContext;
|
|
736
|
+
/**
|
|
737
|
+
* Export context to dictionary.
|
|
738
|
+
*/
|
|
739
|
+
toDict(): Record<string, unknown>;
|
|
740
|
+
/**
|
|
741
|
+
* Get all traces.
|
|
742
|
+
*/
|
|
743
|
+
getTraces(): ExecutionTrace[];
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Get the current execution context.
|
|
747
|
+
*/
|
|
748
|
+
declare function getCurrentContext(): ExecutionContext | undefined;
|
|
749
|
+
/**
|
|
750
|
+
* Set the current execution context.
|
|
751
|
+
*/
|
|
752
|
+
declare function setCurrentContext(ctx: ExecutionContext): void;
|
|
753
|
+
/**
|
|
754
|
+
* Clear the current execution context.
|
|
755
|
+
*/
|
|
756
|
+
declare function clearContext(): void;
|
|
757
|
+
/**
|
|
758
|
+
* Run a function within a context scope.
|
|
759
|
+
*/
|
|
760
|
+
declare function withContextScope<T>(ctx: ExecutionContext, fn: () => Promise<T>): Promise<T>;
|
|
761
|
+
/**
|
|
762
|
+
* Decorator-like function to wrap async functions with context.
|
|
763
|
+
*/
|
|
764
|
+
declare function withContext(mode?: ExecutionMode, timeoutSeconds?: number): <T extends (...args: unknown[]) => Promise<unknown>>(target: T, context?: ClassMethodDecoratorContext) => T;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Vaikora Interceptor - Function wrapper for AI agent security
|
|
768
|
+
*
|
|
769
|
+
* Provides decorator-like functionality for securing AI agent actions:
|
|
770
|
+
* - Data validation (PII, anomalies, toxicity)
|
|
771
|
+
* - Policy evaluation
|
|
772
|
+
* - Human-in-the-loop approval
|
|
773
|
+
*/
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Action to take when policy denies or issues are found
|
|
777
|
+
*/
|
|
778
|
+
declare enum InterceptorAction {
|
|
779
|
+
BLOCK = "block",
|
|
780
|
+
WARN = "warn",
|
|
781
|
+
QUEUE = "queue",
|
|
782
|
+
FALLBACK = "fallback"
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Result from an intercepted function call
|
|
786
|
+
*/
|
|
787
|
+
interface InterceptorResult<T = unknown> {
|
|
788
|
+
success: boolean;
|
|
789
|
+
actionId?: string;
|
|
790
|
+
result?: T;
|
|
791
|
+
error?: string;
|
|
792
|
+
validationIssues: string[];
|
|
793
|
+
policyViolation?: string;
|
|
794
|
+
approvalRequired: boolean;
|
|
795
|
+
approvalId?: string;
|
|
796
|
+
executionTimeMs: number;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Configuration for the interceptor
|
|
800
|
+
*/
|
|
801
|
+
interface InterceptorConfig {
|
|
802
|
+
actionType: string;
|
|
803
|
+
resource?: string;
|
|
804
|
+
agentId?: string;
|
|
805
|
+
validateInputs?: boolean;
|
|
806
|
+
validateOutputs?: boolean;
|
|
807
|
+
validationStrict?: boolean;
|
|
808
|
+
checkPii?: boolean;
|
|
809
|
+
checkAnomalies?: boolean;
|
|
810
|
+
checkToxicity?: boolean;
|
|
811
|
+
autoClean?: boolean;
|
|
812
|
+
evaluatePolicy?: boolean;
|
|
813
|
+
onPolicyDeny?: InterceptorAction;
|
|
814
|
+
requireApproval?: boolean;
|
|
815
|
+
approvalTimeoutSeconds?: number;
|
|
816
|
+
approvalNotifyChannels?: string[];
|
|
817
|
+
approvalMessage?: string;
|
|
818
|
+
fallbackFunction?: (...args: unknown[]) => Promise<unknown>;
|
|
819
|
+
metadata?: Record<string, unknown>;
|
|
820
|
+
tags?: string[];
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Exception thrown when policy denies the action
|
|
824
|
+
*/
|
|
825
|
+
declare class PolicyDeniedException extends Error {
|
|
826
|
+
policyId?: string | undefined;
|
|
827
|
+
actionId?: string | undefined;
|
|
828
|
+
constructor(message: string, policyId?: string | undefined, actionId?: string | undefined);
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Exception thrown when validation fails
|
|
832
|
+
*/
|
|
833
|
+
declare class ValidationException extends Error {
|
|
834
|
+
issues: string[];
|
|
835
|
+
constructor(message: string, issues: string[]);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Exception thrown when approval is required
|
|
839
|
+
*/
|
|
840
|
+
declare class ApprovalRequiredException extends Error {
|
|
841
|
+
approvalId: string;
|
|
842
|
+
actionId?: string | undefined;
|
|
843
|
+
constructor(message: string, approvalId: string, actionId?: string | undefined);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Exception thrown when approval is denied
|
|
847
|
+
*/
|
|
848
|
+
declare class ApprovalDeniedException extends Error {
|
|
849
|
+
approvalId: string;
|
|
850
|
+
reason?: string | undefined;
|
|
851
|
+
constructor(message: string, approvalId: string, reason?: string | undefined);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Vaikora Interceptor class
|
|
855
|
+
*/
|
|
856
|
+
declare class VaikoraInterceptor {
|
|
857
|
+
private client;
|
|
858
|
+
private config;
|
|
859
|
+
constructor(client: VaikoraClient, config: InterceptorConfig);
|
|
860
|
+
/**
|
|
861
|
+
* Wrap a function with Vaikora security
|
|
862
|
+
*/
|
|
863
|
+
wrap<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<InterceptorResult<TResult>>;
|
|
864
|
+
/**
|
|
865
|
+
* Validate data using Vaikora API
|
|
866
|
+
*/
|
|
867
|
+
private validateData;
|
|
868
|
+
/**
|
|
869
|
+
* Wait for approval to be granted or denied
|
|
870
|
+
*/
|
|
871
|
+
private waitForApproval;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Create an interceptor decorator
|
|
875
|
+
*/
|
|
876
|
+
declare function createInterceptor(client: VaikoraClient, config: InterceptorConfig): <TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>) => (...args: TArgs) => Promise<InterceptorResult<TResult>>;
|
|
877
|
+
/**
|
|
878
|
+
* Decorator factory for intercepting functions
|
|
879
|
+
*/
|
|
880
|
+
declare function interceptor(client: VaikoraClient, config: InterceptorConfig): <TArgs extends unknown[], TResult>(_target: unknown, _propertyKey: string, descriptor: TypedPropertyDescriptor<(...args: TArgs) => Promise<TResult>>) => TypedPropertyDescriptor<(...args: TArgs) => Promise<TResult>>;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Agents API
|
|
884
|
+
*/
|
|
885
|
+
declare class AgentsAPI {
|
|
886
|
+
private client;
|
|
887
|
+
constructor(client: VaikoraClient);
|
|
888
|
+
register(data: AgentCreate): Promise<Agent>;
|
|
889
|
+
get(agentId: string): Promise<Agent>;
|
|
890
|
+
list(params?: AgentListParams): Promise<PaginatedList<Agent>>;
|
|
891
|
+
update(agentId: string, data: AgentUpdate): Promise<Agent>;
|
|
892
|
+
deactivate(agentId: string): Promise<Agent>;
|
|
893
|
+
delete(agentId: string): Promise<void>;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Actions API
|
|
897
|
+
*/
|
|
898
|
+
declare class ActionsAPI {
|
|
899
|
+
private client;
|
|
900
|
+
constructor(client: VaikoraClient);
|
|
901
|
+
submit(data: SDKActionSubmit): Promise<SDKActionResult>;
|
|
902
|
+
submitSandbox(data: SDKActionSubmit): Promise<any>;
|
|
903
|
+
get(actionId: string): Promise<Action>;
|
|
904
|
+
list(params?: ActionListParams): Promise<PaginatedList<Action>>;
|
|
905
|
+
complete(actionId: string, data: ActionComplete): Promise<Action>;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Policies API
|
|
909
|
+
*/
|
|
910
|
+
declare class PoliciesAPI {
|
|
911
|
+
private client;
|
|
912
|
+
constructor(client: VaikoraClient);
|
|
913
|
+
list(params?: PolicyListParams): Promise<PaginatedList<Policy>>;
|
|
914
|
+
get(policyId: string): Promise<Policy>;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Alerts API
|
|
918
|
+
*/
|
|
919
|
+
declare class AlertsAPI {
|
|
920
|
+
private client;
|
|
921
|
+
constructor(client: VaikoraClient);
|
|
922
|
+
list(params?: AlertListParams): Promise<PaginatedList<Alert>>;
|
|
923
|
+
get(alertId: string): Promise<Alert>;
|
|
924
|
+
acknowledge(alertId: string): Promise<Alert>;
|
|
925
|
+
resolve(alertId: string, options?: {
|
|
926
|
+
notes?: string;
|
|
927
|
+
}): Promise<Alert>;
|
|
928
|
+
ignore(alertId: string): Promise<Alert>;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Main Vaikora Client
|
|
932
|
+
*/
|
|
933
|
+
declare class VaikoraClient {
|
|
934
|
+
private httpClient;
|
|
935
|
+
private defaultAgentId?;
|
|
936
|
+
agents: AgentsAPI;
|
|
937
|
+
actions: ActionsAPI;
|
|
938
|
+
policies: PoliciesAPI;
|
|
939
|
+
alerts: AlertsAPI;
|
|
940
|
+
constructor(config: VaikoraClientConfig);
|
|
941
|
+
/**
|
|
942
|
+
* Make an HTTP request
|
|
943
|
+
*/
|
|
944
|
+
request<T>(method: string, path: string, data?: Record<string, unknown>, params?: Record<string, unknown>): Promise<T>;
|
|
945
|
+
/**
|
|
946
|
+
* Get the default agent ID
|
|
947
|
+
*/
|
|
948
|
+
getDefaultAgentId(): string | undefined;
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Higher-order function to wrap actions with Vaikora security evaluation
|
|
952
|
+
*/
|
|
953
|
+
declare function secureAction<TArgs extends unknown[], TResult>(client: VaikoraClient, options: SecureActionOptions): (fn: (...args: TArgs) => Promise<TResult>) => (...args: TArgs) => Promise<TResult>;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Configure the global Vaikora client
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* import { configure } from '@vaikora/sdk';
|
|
961
|
+
*
|
|
962
|
+
* configure('your-api-key', {
|
|
963
|
+
* baseUrl: 'https://api.vaikora.ai',
|
|
964
|
+
* timeout: 30000,
|
|
965
|
+
* });
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
declare function configure(apiKey: string, options?: ConfigureOptions): VaikoraClient;
|
|
969
|
+
/**
|
|
970
|
+
* Get the global client instance
|
|
971
|
+
*
|
|
972
|
+
* @throws Error if client is not configured
|
|
973
|
+
*/
|
|
974
|
+
declare function getClient(): VaikoraClient;
|
|
975
|
+
/**
|
|
976
|
+
* Register an AI agent with Vaikora
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```typescript
|
|
980
|
+
* import { configure, register } from '@vaikora/sdk';
|
|
981
|
+
*
|
|
982
|
+
* configure('your-api-key');
|
|
983
|
+
*
|
|
984
|
+
* const agent = await register({
|
|
985
|
+
* name: 'my-assistant',
|
|
986
|
+
* agentType: 'autonomous',
|
|
987
|
+
* capabilities: ['data_access', 'email_send'],
|
|
988
|
+
* });
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
declare function register(options: RegisterOptions): Promise<Agent>;
|
|
992
|
+
/**
|
|
993
|
+
* Get the globally registered agent ID
|
|
994
|
+
*/
|
|
995
|
+
declare function getAgentId(): string | null;
|
|
996
|
+
/**
|
|
997
|
+
* Set the global agent ID (for existing agents)
|
|
998
|
+
*/
|
|
999
|
+
declare function setAgentId(agentId: string): void;
|
|
1000
|
+
/**
|
|
1001
|
+
* Validate data for PII, anomalies, and toxicity
|
|
1002
|
+
*
|
|
1003
|
+
* @example
|
|
1004
|
+
* ```typescript
|
|
1005
|
+
* import { configure, validateData } from '@vaikora/sdk';
|
|
1006
|
+
*
|
|
1007
|
+
* configure('your-api-key');
|
|
1008
|
+
*
|
|
1009
|
+
* const result = await validateData(
|
|
1010
|
+
* { email: 'user@example.com', message: 'Hello world' },
|
|
1011
|
+
* { checkPii: true, checkToxicity: true }
|
|
1012
|
+
* );
|
|
1013
|
+
*
|
|
1014
|
+
* if (!result.isValid) {
|
|
1015
|
+
* console.log('Issues found:', result.issues);
|
|
1016
|
+
* }
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
declare function validateData(data: unknown, options?: ValidateDataOptions): Promise<DataValidationResult>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Submit an action for policy evaluation
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* import { configure, register, submitAction } from '@vaikora/sdk';
|
|
1026
|
+
*
|
|
1027
|
+
* configure('your-api-key');
|
|
1028
|
+
* await register({ name: 'my-agent' });
|
|
1029
|
+
*
|
|
1030
|
+
* const result = await submitAction({
|
|
1031
|
+
* actionType: 'data_export',
|
|
1032
|
+
* resource: 'users',
|
|
1033
|
+
* payload: { format: 'csv', limit: 1000 },
|
|
1034
|
+
* });
|
|
1035
|
+
*
|
|
1036
|
+
* if (result.approved) {
|
|
1037
|
+
* // Execute the action
|
|
1038
|
+
* }
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
declare function submitAction(options: {
|
|
1042
|
+
actionType: string;
|
|
1043
|
+
resource?: string;
|
|
1044
|
+
payload?: Record<string, unknown>;
|
|
1045
|
+
metadata?: Record<string, unknown>;
|
|
1046
|
+
agentId?: string;
|
|
1047
|
+
}): Promise<SDKActionResult>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Create a secure action wrapper using the global client
|
|
1050
|
+
*
|
|
1051
|
+
* @example
|
|
1052
|
+
* ```typescript
|
|
1053
|
+
* import { configure, register, wrapAction } from '@vaikora/sdk';
|
|
1054
|
+
*
|
|
1055
|
+
* configure('your-api-key');
|
|
1056
|
+
* await register({ name: 'my-agent' });
|
|
1057
|
+
*
|
|
1058
|
+
* const secureExport = wrapAction(
|
|
1059
|
+
* { actionType: 'data_export', resource: 'users' },
|
|
1060
|
+
* async (query: string) => {
|
|
1061
|
+
* return await database.query(query);
|
|
1062
|
+
* }
|
|
1063
|
+
* );
|
|
1064
|
+
*
|
|
1065
|
+
* // Now the function is secured
|
|
1066
|
+
* const data = await secureExport('SELECT * FROM users');
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
declare function wrapAction<TArgs extends unknown[], TResult>(options: SecureActionOptions, fn: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<TResult>;
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Immediately freeze the agent
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```typescript
|
|
1076
|
+
* import { freezeAgent, FreezeReason } from '@vaikora/sdk';
|
|
1077
|
+
*
|
|
1078
|
+
* await freezeAgent({
|
|
1079
|
+
* reason: FreezeReason.ANOMALY_DETECTED,
|
|
1080
|
+
* message: 'Unusual behavior detected',
|
|
1081
|
+
* durationSeconds: 3600, // 1 hour
|
|
1082
|
+
* });
|
|
1083
|
+
* ```
|
|
1084
|
+
*/
|
|
1085
|
+
declare function freezeAgent(options: FreezeOptions): FreezeState;
|
|
1086
|
+
/**
|
|
1087
|
+
* Resume agent operations after a freeze
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* ```typescript
|
|
1091
|
+
* import { resumeAgent } from '@vaikora/sdk';
|
|
1092
|
+
*
|
|
1093
|
+
* resumeAgent({ notes: 'Issue resolved' });
|
|
1094
|
+
* ```
|
|
1095
|
+
*/
|
|
1096
|
+
declare function resumeAgent(options?: ResumeOptions): FreezeState;
|
|
1097
|
+
/**
|
|
1098
|
+
* Check if the agent is currently frozen
|
|
1099
|
+
*/
|
|
1100
|
+
declare function isAgentFrozen(): boolean;
|
|
1101
|
+
/**
|
|
1102
|
+
* Get the current freeze state
|
|
1103
|
+
*/
|
|
1104
|
+
declare function getFreezeState(): FreezeState | null;
|
|
1105
|
+
|
|
1106
|
+
export { type Action, type ActionComplete, type ActionDecision, type ActionListParams, type ActionResponse, type ActionResult, type ActionStatus, type ActionSubmit, type ActionSubmitResult, type Agent, type AgentCreate, type AgentCredentials, AgentFrozenError, AgentIdentity, type AgentListParams, type AgentStatus, type AgentType, type AgentUpdate, type Alert, type AlertListParams, type AlertSeverity, type AlertStats, type AlertStatus, ApprovalDeniedException, ApprovalRequiredException, ApprovalStatus, type Attestation, type AttestationClaims, AuthenticationError, AuthorizationError, CircuitBreaker, type CircuitBreakerConfig, CircuitBreakerOpenError, CircuitState, type ConfigureOptions, ConflictError, type ContextHeaders, ContextLevel, type DataValidationResult, EmergencyController, ExecutionContext, type ExecutionContextOptions, ExecutionMode, type ExecutionTrace, type FreezeCallback, type FreezeOptions, FreezeReason, FreezeScope, type FreezeState, InterceptorAction, type InterceptorConfig, type InterceptorResult, type ListParams, NetworkError, NotFoundError, type OrganizationStats, type PaginatedList, type PaginatedResponse, type Policy, PolicyDeniedException, type PolicyListParams, PolicyViolationError, RateLimitError, type RegisterOptions, type ResumeCallback, type ResumeOptions, type RiskFactor, type SDKActionResult, type SDKActionSubmit, type SecureActionOptions, ServerError, type SignedHeaders, type SignedRequest, type ThreatDetail, TimeoutError, type TraceLog, VaikoraClient, type VaikoraClientConfig, VaikoraError, VaikoraInterceptor, type ValidateDataOptions, ValidationError, ValidationException, type VerificationResult, assertNotFrozen, clearContext, configure, createInterceptor, freezeAgent, frozenGuard, getAgentId, getClient, getCurrentContext, getFreezeState, interceptor, isAgentFrozen, raiseForStatus, register, resumeAgent, secureAction, setAgentId, setCurrentContext, submitAction, validateData, withContext, withContextScope, wrapAction };
|