-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
146 lines (124 loc) · 3.43 KB
/
Copy pathtypes.d.ts
File metadata and controls
146 lines (124 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
export interface TrustLoopOptions {
apiKey: string;
baseUrl?: string;
}
export interface InterceptResult {
allowed: boolean;
status?: 'ALLOWED' | 'BLOCKED' | 'PENDING';
message?: string;
approval_id?: string;
rule_matched?: string;
}
export interface ToolCall {
id: string;
tenant_id: string;
tool_name: string;
arguments: Record<string, unknown>;
status: 'ALLOWED' | 'BLOCKED' | 'PENDING' | 'APPROVED' | 'DENIED' | 'ERROR';
result?: unknown;
rule_matched?: string;
created_at: string;
}
export interface Stats {
total: number;
allowed: number;
blocked: number;
pending: number;
errors: number;
tenant: {
name: string | null;
};
usage: {
plan: string;
used: number;
limit: number | null;
};
}
export interface Rule {
id: string;
tenant_id: string;
rule_text: string;
action: 'approve' | 'block';
approver_email: string | null;
enabled: boolean;
created_at: string;
}
export interface CreateRuleOptions {
rule_text: string;
action?: 'approve' | 'block';
approver_email?: string;
}
export interface BlockedTool {
id: string;
tenant_id: string;
tool_name: string;
reason: string | null;
created_at: string;
}
export interface PendingApproval {
id: string;
tenant_id: string;
tool_name: string;
arguments: Record<string, unknown>;
rule_matched: string | null;
approver_email: string | null;
status: 'pending' | 'approved' | 'denied' | 'expired';
decided_by: string | null;
expires_at: string;
created_at: string;
}
export interface NotificationSettings {
notify_email: string | null;
slack_webhook_url: string | null;
teams_webhook_url: string | null;
discord_webhook_url: string | null;
}
export interface GetLogsOptions {
limit?: number;
offset?: number;
status?: 'ALLOWED' | 'BLOCKED' | 'PENDING' | 'APPROVED' | 'DENIED' | 'ERROR';
toolName?: string;
}
export interface OpenAIConfig {
apiKey: string;
baseURL: string;
defaultHeaders: Record<string, string>;
}
export interface OpenAIHelperOptions {
baseUrl?: string;
}
export interface McpUrlOptions {
baseUrl?: string;
}
export declare class TrustLoopError extends Error {
name: 'TrustLoopError';
status: number;
constructor(message: string, status: number);
}
export declare class TrustLoop {
constructor(options: TrustLoopOptions);
// Core governance
intercept(toolName: string, args?: Record<string, unknown>): Promise<InterceptResult>;
// Audit
getLogs(options?: GetLogsOptions): Promise<ToolCall[]>;
exportLogs(): Promise<string>;
getStats(): Promise<Stats>;
// Rules
getRules(): Promise<Rule[]>;
createRule(rule: CreateRuleOptions): Promise<Rule>;
deleteRule(ruleId: string): Promise<{ success: boolean }>;
// Kill switch
getBlockedTools(): Promise<BlockedTool[]>;
blockTool(toolName: string, reason?: string): Promise<BlockedTool>;
unblockTool(toolName: string): Promise<{ success: boolean }>;
// Human approvals
getPendingApprovals(): Promise<PendingApproval[]>;
decide(approvalId: string, action: 'approved' | 'denied'): Promise<PendingApproval>;
// Notifications
getNotifications(): Promise<NotificationSettings>;
updateNotifications(settings: Partial<NotificationSettings>): Promise<NotificationSettings>;
// Static helpers
static openai(openaiApiKey: string, trustLoopApiKey: string, options?: OpenAIHelperOptions): OpenAIConfig;
static mcpUrl(trustLoopApiKey: string, options?: McpUrlOptions): string;
}
export default TrustLoop;