@agent-os-sdk/client 0.1.0 → 0.1.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/dist/client/AgentOsClient.d.ts +28 -4
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +40 -3
- package/dist/generated/openapi.d.ts +104 -2
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/modules/approvals.d.ts +78 -0
- package/dist/modules/approvals.d.ts.map +1 -0
- package/dist/modules/approvals.js +157 -0
- package/dist/modules/artifacts.d.ts +100 -0
- package/dist/modules/artifacts.d.ts.map +1 -0
- package/dist/modules/artifacts.js +217 -0
- package/dist/modules/budgets.d.ts +104 -0
- package/dist/modules/budgets.d.ts.map +1 -0
- package/dist/modules/budgets.js +161 -0
- package/dist/modules/builder.d.ts +2 -2
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/builder.js +5 -5
- package/dist/modules/capabilities.d.ts +68 -0
- package/dist/modules/capabilities.d.ts.map +1 -0
- package/dist/modules/capabilities.js +113 -0
- package/dist/modules/deployments.d.ts +110 -0
- package/dist/modules/deployments.d.ts.map +1 -0
- package/dist/modules/deployments.js +230 -0
- package/dist/modules/flows.d.ts +104 -0
- package/dist/modules/flows.d.ts.map +1 -0
- package/dist/modules/flows.js +190 -0
- package/dist/modules/handoff.d.ts +88 -0
- package/dist/modules/handoff.d.ts.map +1 -0
- package/dist/modules/handoff.js +128 -0
- package/dist/modules/incidents.d.ts +133 -0
- package/dist/modules/incidents.d.ts.map +1 -0
- package/dist/modules/incidents.js +231 -0
- package/dist/modules/members.d.ts +5 -0
- package/dist/modules/members.d.ts.map +1 -1
- package/dist/modules/members.js +10 -0
- package/dist/modules/policies.d.ts +103 -0
- package/dist/modules/policies.d.ts.map +1 -0
- package/dist/modules/policies.js +180 -0
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/tenants.d.ts +4 -0
- package/dist/modules/tenants.d.ts.map +1 -1
- package/dist/modules/tenants.js +8 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +45 -7
- package/src/generated/openapi.ts +104 -2
- package/src/generated/swagger.json +116 -10
- package/src/index.ts +11 -0
- package/src/modules/approvals.ts +210 -0
- package/src/modules/artifacts.ts +287 -0
- package/src/modules/budgets.ts +236 -0
- package/src/modules/builder.ts +3 -3
- package/src/modules/capabilities.ts +176 -0
- package/src/modules/deployments.ts +315 -0
- package/src/modules/flows.ts +259 -0
- package/src/modules/handoff.ts +204 -0
- package/src/modules/incidents.ts +339 -0
- package/src/modules/members.ts +11 -0
- package/src/modules/policies.ts +258 -0
- package/src/modules/tenants.ts +9 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incidents Module - Operational Incidents & Postmortems
|
|
3
|
+
*
|
|
4
|
+
* // MOCK - This module contains mock implementations for future features
|
|
5
|
+
*
|
|
6
|
+
* Provides incident management, SLO tracking, and postmortem creation.
|
|
7
|
+
* Brings Datadog vibes to agent operations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Types
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
export type IncidentSeverity = "critical" | "major" | "minor" | "warning";
|
|
17
|
+
export type IncidentStatus = "open" | "investigating" | "identified" | "monitoring" | "resolved";
|
|
18
|
+
|
|
19
|
+
export interface Incident {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description: string;
|
|
23
|
+
severity: IncidentSeverity;
|
|
24
|
+
status: IncidentStatus;
|
|
25
|
+
affected_agents: string[];
|
|
26
|
+
affected_runs: string[];
|
|
27
|
+
root_cause?: string;
|
|
28
|
+
resolution?: string;
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
resolved_at?: string;
|
|
32
|
+
created_by: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SLO {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
target_percentage: number;
|
|
40
|
+
current_percentage: number;
|
|
41
|
+
metric_type: "availability" | "latency" | "error_rate" | "success_rate";
|
|
42
|
+
threshold?: number;
|
|
43
|
+
window_days: number;
|
|
44
|
+
status: "healthy" | "at_risk" | "breached";
|
|
45
|
+
budget_remaining: number;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface Postmortem {
|
|
50
|
+
id: string;
|
|
51
|
+
incident_id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
summary: string;
|
|
54
|
+
timeline: PostmortemEvent[];
|
|
55
|
+
root_cause_analysis: string;
|
|
56
|
+
impact: string;
|
|
57
|
+
action_items: ActionItem[];
|
|
58
|
+
lessons_learned: string[];
|
|
59
|
+
created_at: string;
|
|
60
|
+
created_by: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface PostmortemEvent {
|
|
64
|
+
timestamp: string;
|
|
65
|
+
description: string;
|
|
66
|
+
actor?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ActionItem {
|
|
70
|
+
id: string;
|
|
71
|
+
description: string;
|
|
72
|
+
owner: string;
|
|
73
|
+
due_date?: string;
|
|
74
|
+
status: "open" | "in_progress" | "completed";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface IncidentListResponse {
|
|
78
|
+
items: Incident[];
|
|
79
|
+
total: number;
|
|
80
|
+
open_count: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface SLOListResponse {
|
|
84
|
+
items: SLO[];
|
|
85
|
+
total: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Module
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
export class IncidentsModule {
|
|
93
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
94
|
+
|
|
95
|
+
// ========== Incidents ==========
|
|
96
|
+
|
|
97
|
+
// MOCK - Simulated list
|
|
98
|
+
/**
|
|
99
|
+
* List all incidents.
|
|
100
|
+
*/
|
|
101
|
+
async list(params?: {
|
|
102
|
+
status?: IncidentStatus;
|
|
103
|
+
severity?: IncidentSeverity;
|
|
104
|
+
}): Promise<APIResponse<IncidentListResponse>> {
|
|
105
|
+
// MOCK - Returns simulated data
|
|
106
|
+
const mockIncidents: IncidentListResponse = {
|
|
107
|
+
items: [
|
|
108
|
+
{
|
|
109
|
+
id: "inc_1",
|
|
110
|
+
title: "High error rate on Support Agent",
|
|
111
|
+
description: "Error rate exceeded 5% threshold",
|
|
112
|
+
severity: "major",
|
|
113
|
+
status: "investigating",
|
|
114
|
+
affected_agents: ["agent_support"],
|
|
115
|
+
affected_runs: ["run_123", "run_124", "run_125"],
|
|
116
|
+
created_at: new Date(Date.now() - 3600000).toISOString(),
|
|
117
|
+
updated_at: new Date().toISOString(),
|
|
118
|
+
created_by: "system",
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
total: 1,
|
|
122
|
+
open_count: 1,
|
|
123
|
+
};
|
|
124
|
+
return { data: mockIncidents, error: undefined, response: new Response() };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// MOCK - Simulated get
|
|
128
|
+
/**
|
|
129
|
+
* Get an incident by ID.
|
|
130
|
+
*/
|
|
131
|
+
async get(incidentId: string): Promise<APIResponse<Incident>> {
|
|
132
|
+
// MOCK - Returns simulated data
|
|
133
|
+
const mockIncident: Incident = {
|
|
134
|
+
id: incidentId,
|
|
135
|
+
title: "High error rate on Support Agent",
|
|
136
|
+
description: "Error rate exceeded 5% threshold",
|
|
137
|
+
severity: "major",
|
|
138
|
+
status: "investigating",
|
|
139
|
+
affected_agents: ["agent_support"],
|
|
140
|
+
affected_runs: ["run_123", "run_124", "run_125"],
|
|
141
|
+
created_at: new Date(Date.now() - 3600000).toISOString(),
|
|
142
|
+
updated_at: new Date().toISOString(),
|
|
143
|
+
created_by: "system",
|
|
144
|
+
};
|
|
145
|
+
return { data: mockIncident, error: undefined, response: new Response() };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// MOCK - Simulated create
|
|
149
|
+
/**
|
|
150
|
+
* Create a new incident.
|
|
151
|
+
*/
|
|
152
|
+
async create(body: {
|
|
153
|
+
title: string;
|
|
154
|
+
description: string;
|
|
155
|
+
severity: IncidentSeverity;
|
|
156
|
+
affected_agents?: string[];
|
|
157
|
+
}): Promise<APIResponse<Incident>> {
|
|
158
|
+
// MOCK - Returns simulated data
|
|
159
|
+
const mockIncident: Incident = {
|
|
160
|
+
id: `inc_${Date.now()}`,
|
|
161
|
+
title: body.title,
|
|
162
|
+
description: body.description,
|
|
163
|
+
severity: body.severity,
|
|
164
|
+
status: "open",
|
|
165
|
+
affected_agents: body.affected_agents || [],
|
|
166
|
+
affected_runs: [],
|
|
167
|
+
created_at: new Date().toISOString(),
|
|
168
|
+
updated_at: new Date().toISOString(),
|
|
169
|
+
created_by: "user_current",
|
|
170
|
+
};
|
|
171
|
+
return { data: mockIncident, error: undefined, response: new Response() };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// MOCK - Simulated resolve
|
|
175
|
+
/**
|
|
176
|
+
* Resolve an incident.
|
|
177
|
+
*/
|
|
178
|
+
async resolve(incidentId: string, resolution: string): Promise<APIResponse<Incident>> {
|
|
179
|
+
// MOCK - Returns simulated data
|
|
180
|
+
const mockIncident: Incident = {
|
|
181
|
+
id: incidentId,
|
|
182
|
+
title: "High error rate on Support Agent",
|
|
183
|
+
description: "Error rate exceeded 5% threshold",
|
|
184
|
+
severity: "major",
|
|
185
|
+
status: "resolved",
|
|
186
|
+
affected_agents: ["agent_support"],
|
|
187
|
+
affected_runs: [],
|
|
188
|
+
root_cause: "Model provider rate limit",
|
|
189
|
+
resolution,
|
|
190
|
+
created_at: new Date(Date.now() - 7200000).toISOString(),
|
|
191
|
+
updated_at: new Date().toISOString(),
|
|
192
|
+
resolved_at: new Date().toISOString(),
|
|
193
|
+
created_by: "system",
|
|
194
|
+
};
|
|
195
|
+
return { data: mockIncident, error: undefined, response: new Response() };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// MOCK - Simulated linkRuns
|
|
199
|
+
/**
|
|
200
|
+
* Link runs to an incident.
|
|
201
|
+
*/
|
|
202
|
+
async linkRuns(incidentId: string, runIds: string[]): Promise<APIResponse<Incident>> {
|
|
203
|
+
// MOCK - Returns simulated data
|
|
204
|
+
const mockIncident: Incident = {
|
|
205
|
+
id: incidentId,
|
|
206
|
+
title: "High error rate on Support Agent",
|
|
207
|
+
description: "Error rate exceeded 5% threshold",
|
|
208
|
+
severity: "major",
|
|
209
|
+
status: "investigating",
|
|
210
|
+
affected_agents: ["agent_support"],
|
|
211
|
+
affected_runs: runIds,
|
|
212
|
+
created_at: new Date(Date.now() - 3600000).toISOString(),
|
|
213
|
+
updated_at: new Date().toISOString(),
|
|
214
|
+
created_by: "system",
|
|
215
|
+
};
|
|
216
|
+
return { data: mockIncident, error: undefined, response: new Response() };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ========== SLOs ==========
|
|
220
|
+
|
|
221
|
+
// MOCK - Simulated listSLOs
|
|
222
|
+
/**
|
|
223
|
+
* List all SLOs.
|
|
224
|
+
*/
|
|
225
|
+
async listSLOs(): Promise<APIResponse<SLOListResponse>> {
|
|
226
|
+
// MOCK - Returns simulated data
|
|
227
|
+
const mockSLOs: SLOListResponse = {
|
|
228
|
+
items: [
|
|
229
|
+
{
|
|
230
|
+
id: "slo_availability",
|
|
231
|
+
name: "Agent Availability",
|
|
232
|
+
description: "99.9% availability for all agents",
|
|
233
|
+
target_percentage: 99.9,
|
|
234
|
+
current_percentage: 99.95,
|
|
235
|
+
metric_type: "availability",
|
|
236
|
+
window_days: 30,
|
|
237
|
+
status: "healthy",
|
|
238
|
+
budget_remaining: 0.05,
|
|
239
|
+
created_at: new Date(Date.now() - 86400000 * 30).toISOString(),
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: "slo_latency",
|
|
243
|
+
name: "Response Latency",
|
|
244
|
+
description: "P95 latency under 2s",
|
|
245
|
+
target_percentage: 95,
|
|
246
|
+
current_percentage: 97.5,
|
|
247
|
+
metric_type: "latency",
|
|
248
|
+
threshold: 2000,
|
|
249
|
+
window_days: 7,
|
|
250
|
+
status: "healthy",
|
|
251
|
+
budget_remaining: 2.5,
|
|
252
|
+
created_at: new Date(Date.now() - 86400000 * 7).toISOString(),
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
id: "slo_errors",
|
|
256
|
+
name: "Error Rate",
|
|
257
|
+
description: "Error rate below 1%",
|
|
258
|
+
target_percentage: 99,
|
|
259
|
+
current_percentage: 98.2,
|
|
260
|
+
metric_type: "error_rate",
|
|
261
|
+
window_days: 7,
|
|
262
|
+
status: "at_risk",
|
|
263
|
+
budget_remaining: -0.8,
|
|
264
|
+
created_at: new Date(Date.now() - 86400000 * 7).toISOString(),
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
total: 3,
|
|
268
|
+
};
|
|
269
|
+
return { data: mockSLOs, error: undefined, response: new Response() };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// MOCK - Simulated setSLO
|
|
273
|
+
/**
|
|
274
|
+
* Create or update an SLO.
|
|
275
|
+
*/
|
|
276
|
+
async setSLO(body: {
|
|
277
|
+
name: string;
|
|
278
|
+
description?: string;
|
|
279
|
+
target_percentage: number;
|
|
280
|
+
metric_type: SLO["metric_type"];
|
|
281
|
+
threshold?: number;
|
|
282
|
+
window_days: number;
|
|
283
|
+
}): Promise<APIResponse<SLO>> {
|
|
284
|
+
// MOCK - Returns simulated data
|
|
285
|
+
const mockSLO: SLO = {
|
|
286
|
+
id: `slo_${Date.now()}`,
|
|
287
|
+
name: body.name,
|
|
288
|
+
description: body.description,
|
|
289
|
+
target_percentage: body.target_percentage,
|
|
290
|
+
current_percentage: 100,
|
|
291
|
+
metric_type: body.metric_type,
|
|
292
|
+
threshold: body.threshold,
|
|
293
|
+
window_days: body.window_days,
|
|
294
|
+
status: "healthy",
|
|
295
|
+
budget_remaining: 100 - body.target_percentage,
|
|
296
|
+
created_at: new Date().toISOString(),
|
|
297
|
+
};
|
|
298
|
+
return { data: mockSLO, error: undefined, response: new Response() };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ========== Postmortems ==========
|
|
302
|
+
|
|
303
|
+
// MOCK - Simulated createPostmortem
|
|
304
|
+
/**
|
|
305
|
+
* Create a postmortem for an incident.
|
|
306
|
+
*/
|
|
307
|
+
async createPostmortem(incidentId: string, body: {
|
|
308
|
+
title: string;
|
|
309
|
+
summary: string;
|
|
310
|
+
root_cause_analysis: string;
|
|
311
|
+
impact: string;
|
|
312
|
+
lessons_learned: string[];
|
|
313
|
+
action_items: Omit<ActionItem, "id" | "status">[];
|
|
314
|
+
}): Promise<APIResponse<Postmortem>> {
|
|
315
|
+
// MOCK - Returns simulated data
|
|
316
|
+
const mockPostmortem: Postmortem = {
|
|
317
|
+
id: `pm_${Date.now()}`,
|
|
318
|
+
incident_id: incidentId,
|
|
319
|
+
title: body.title,
|
|
320
|
+
summary: body.summary,
|
|
321
|
+
timeline: [
|
|
322
|
+
{ timestamp: new Date(Date.now() - 7200000).toISOString(), description: "Incident detected" },
|
|
323
|
+
{ timestamp: new Date(Date.now() - 3600000).toISOString(), description: "Root cause identified" },
|
|
324
|
+
{ timestamp: new Date().toISOString(), description: "Incident resolved" },
|
|
325
|
+
],
|
|
326
|
+
root_cause_analysis: body.root_cause_analysis,
|
|
327
|
+
impact: body.impact,
|
|
328
|
+
action_items: body.action_items.map((item, i) => ({
|
|
329
|
+
...item,
|
|
330
|
+
id: `action_${i}`,
|
|
331
|
+
status: "open" as const,
|
|
332
|
+
})),
|
|
333
|
+
lessons_learned: body.lessons_learned,
|
|
334
|
+
created_at: new Date().toISOString(),
|
|
335
|
+
created_by: "user_current",
|
|
336
|
+
};
|
|
337
|
+
return { data: mockPostmortem, error: undefined, response: new Response() };
|
|
338
|
+
}
|
|
339
|
+
}
|
package/src/modules/members.ts
CHANGED
|
@@ -114,4 +114,15 @@ export class MembersModule {
|
|
|
114
114
|
headers: this.headers(),
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Ensure membership exists (auto-create on first access).
|
|
120
|
+
* This is used by the frontend for onboarding.
|
|
121
|
+
*/
|
|
122
|
+
async ensure(tenantId?: string): Promise<APIResponse<Member>> {
|
|
123
|
+
return this.client.POST<Member>("/v1/api/memberships/ensure", {
|
|
124
|
+
body: { tenant_id: tenantId ?? null },
|
|
125
|
+
headers: this.headers(),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
117
128
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policies Module - Governance Rules
|
|
3
|
+
*
|
|
4
|
+
* // MOCK - This module contains mock implementations for future features
|
|
5
|
+
*
|
|
6
|
+
* Defines and evaluates policies that control agent behavior.
|
|
7
|
+
* Enables enterprise governance and compliance.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Types
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
export type PolicyType = "allow" | "deny" | "require_approval" | "audit";
|
|
17
|
+
export type PolicyScope = "tenant" | "workspace" | "agent" | "run";
|
|
18
|
+
|
|
19
|
+
export interface Policy {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
type: PolicyType;
|
|
24
|
+
scope: PolicyScope;
|
|
25
|
+
scope_id?: string;
|
|
26
|
+
conditions: PolicyCondition[];
|
|
27
|
+
actions: PolicyAction[];
|
|
28
|
+
priority: number;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
created_at: string;
|
|
31
|
+
updated_at: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PolicyCondition {
|
|
35
|
+
field: string;
|
|
36
|
+
operator: "eq" | "neq" | "in" | "not_in" | "gt" | "lt" | "contains" | "regex";
|
|
37
|
+
value: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PolicyAction {
|
|
41
|
+
type: "block" | "allow" | "require_approval" | "log" | "alert" | "modify";
|
|
42
|
+
config?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PolicyEvaluationInput {
|
|
46
|
+
action: string;
|
|
47
|
+
resource: string;
|
|
48
|
+
context: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PolicyEvaluationResult {
|
|
52
|
+
allowed: boolean;
|
|
53
|
+
matched_policies: string[];
|
|
54
|
+
required_approvals: string[];
|
|
55
|
+
warnings: string[];
|
|
56
|
+
audit_entries: PolicyAuditEntry[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface PolicyAuditEntry {
|
|
60
|
+
policy_id: string;
|
|
61
|
+
policy_name: string;
|
|
62
|
+
decision: "allow" | "deny" | "pending_approval";
|
|
63
|
+
reason: string;
|
|
64
|
+
evaluated_at: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PolicyListResponse {
|
|
68
|
+
items: Policy[];
|
|
69
|
+
total: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// Module
|
|
74
|
+
// ============================================================================
|
|
75
|
+
|
|
76
|
+
export class PoliciesModule {
|
|
77
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
78
|
+
|
|
79
|
+
// MOCK - Simulated list
|
|
80
|
+
/**
|
|
81
|
+
* List all policies.
|
|
82
|
+
*/
|
|
83
|
+
async list(params?: {
|
|
84
|
+
scope?: PolicyScope;
|
|
85
|
+
enabled?: boolean;
|
|
86
|
+
}): Promise<APIResponse<PolicyListResponse>> {
|
|
87
|
+
// MOCK - Returns simulated data
|
|
88
|
+
const mockPolicies: PolicyListResponse = {
|
|
89
|
+
items: [
|
|
90
|
+
{
|
|
91
|
+
id: "policy_1",
|
|
92
|
+
name: "Block External Email",
|
|
93
|
+
description: "Prevent agents from sending external emails without approval",
|
|
94
|
+
type: "require_approval",
|
|
95
|
+
scope: "tenant",
|
|
96
|
+
conditions: [
|
|
97
|
+
{ field: "action", operator: "eq", value: "send_email" },
|
|
98
|
+
{ field: "recipient.domain", operator: "not_in", value: ["company.com"] },
|
|
99
|
+
],
|
|
100
|
+
actions: [
|
|
101
|
+
{ type: "require_approval", config: { approver_role: "admin" } },
|
|
102
|
+
],
|
|
103
|
+
priority: 100,
|
|
104
|
+
enabled: true,
|
|
105
|
+
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
106
|
+
updated_at: new Date().toISOString(),
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "policy_2",
|
|
110
|
+
name: "Audit All Tool Calls",
|
|
111
|
+
description: "Log all tool calls for compliance",
|
|
112
|
+
type: "audit",
|
|
113
|
+
scope: "tenant",
|
|
114
|
+
conditions: [
|
|
115
|
+
{ field: "action", operator: "eq", value: "tool_call" },
|
|
116
|
+
],
|
|
117
|
+
actions: [
|
|
118
|
+
{ type: "log" },
|
|
119
|
+
],
|
|
120
|
+
priority: 50,
|
|
121
|
+
enabled: true,
|
|
122
|
+
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
123
|
+
updated_at: new Date().toISOString(),
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
total: 2,
|
|
127
|
+
};
|
|
128
|
+
return { data: mockPolicies, error: undefined, response: new Response() };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// MOCK - Simulated get
|
|
132
|
+
/**
|
|
133
|
+
* Get a policy by ID.
|
|
134
|
+
*/
|
|
135
|
+
async get(policyId: string): Promise<APIResponse<Policy>> {
|
|
136
|
+
// MOCK - Returns simulated data
|
|
137
|
+
const mockPolicy: Policy = {
|
|
138
|
+
id: policyId,
|
|
139
|
+
name: "Block External Email",
|
|
140
|
+
description: "Prevent agents from sending external emails without approval",
|
|
141
|
+
type: "require_approval",
|
|
142
|
+
scope: "tenant",
|
|
143
|
+
conditions: [
|
|
144
|
+
{ field: "action", operator: "eq", value: "send_email" },
|
|
145
|
+
],
|
|
146
|
+
actions: [
|
|
147
|
+
{ type: "require_approval" },
|
|
148
|
+
],
|
|
149
|
+
priority: 100,
|
|
150
|
+
enabled: true,
|
|
151
|
+
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
152
|
+
updated_at: new Date().toISOString(),
|
|
153
|
+
};
|
|
154
|
+
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// MOCK - Simulated create
|
|
158
|
+
/**
|
|
159
|
+
* Create a new policy.
|
|
160
|
+
*/
|
|
161
|
+
async create(body: {
|
|
162
|
+
name: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
type: PolicyType;
|
|
165
|
+
scope: PolicyScope;
|
|
166
|
+
scope_id?: string;
|
|
167
|
+
conditions: PolicyCondition[];
|
|
168
|
+
actions: PolicyAction[];
|
|
169
|
+
priority?: number;
|
|
170
|
+
}): Promise<APIResponse<Policy>> {
|
|
171
|
+
// MOCK - Returns simulated data
|
|
172
|
+
const mockPolicy: Policy = {
|
|
173
|
+
id: `policy_${Date.now()}`,
|
|
174
|
+
name: body.name,
|
|
175
|
+
description: body.description,
|
|
176
|
+
type: body.type,
|
|
177
|
+
scope: body.scope,
|
|
178
|
+
scope_id: body.scope_id,
|
|
179
|
+
conditions: body.conditions,
|
|
180
|
+
actions: body.actions,
|
|
181
|
+
priority: body.priority || 50,
|
|
182
|
+
enabled: true,
|
|
183
|
+
created_at: new Date().toISOString(),
|
|
184
|
+
updated_at: new Date().toISOString(),
|
|
185
|
+
};
|
|
186
|
+
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// MOCK - Simulated update
|
|
190
|
+
/**
|
|
191
|
+
* Update a policy.
|
|
192
|
+
*/
|
|
193
|
+
async update(policyId: string, body: Partial<Policy>): Promise<APIResponse<Policy>> {
|
|
194
|
+
// MOCK - Returns simulated data
|
|
195
|
+
const mockPolicy: Policy = {
|
|
196
|
+
id: policyId,
|
|
197
|
+
name: body.name || "Updated Policy",
|
|
198
|
+
type: body.type || "allow",
|
|
199
|
+
scope: body.scope || "tenant",
|
|
200
|
+
conditions: body.conditions || [],
|
|
201
|
+
actions: body.actions || [],
|
|
202
|
+
priority: body.priority || 50,
|
|
203
|
+
enabled: body.enabled ?? true,
|
|
204
|
+
created_at: new Date(Date.now() - 86400000).toISOString(),
|
|
205
|
+
updated_at: new Date().toISOString(),
|
|
206
|
+
};
|
|
207
|
+
return { data: mockPolicy, error: undefined, response: new Response() };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// MOCK - Simulated delete
|
|
211
|
+
/**
|
|
212
|
+
* Delete a policy.
|
|
213
|
+
*/
|
|
214
|
+
async delete(policyId: string): Promise<APIResponse<void>> {
|
|
215
|
+
// MOCK - Returns success
|
|
216
|
+
return { data: undefined, error: undefined, response: new Response() };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// MOCK - Simulated evaluate
|
|
220
|
+
/**
|
|
221
|
+
* Evaluate policies against an action (simulation).
|
|
222
|
+
*/
|
|
223
|
+
async evaluate(input: PolicyEvaluationInput): Promise<APIResponse<PolicyEvaluationResult>> {
|
|
224
|
+
// MOCK - Returns simulated evaluation
|
|
225
|
+
const mockResult: PolicyEvaluationResult = {
|
|
226
|
+
allowed: true,
|
|
227
|
+
matched_policies: ["policy_2"],
|
|
228
|
+
required_approvals: [],
|
|
229
|
+
warnings: [],
|
|
230
|
+
audit_entries: [
|
|
231
|
+
{
|
|
232
|
+
policy_id: "policy_2",
|
|
233
|
+
policy_name: "Audit All Tool Calls",
|
|
234
|
+
decision: "allow",
|
|
235
|
+
reason: "Action logged for audit",
|
|
236
|
+
evaluated_at: new Date().toISOString(),
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
};
|
|
240
|
+
return { data: mockResult, error: undefined, response: new Response() };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// MOCK - Simulated enforce
|
|
244
|
+
/**
|
|
245
|
+
* Enforce policies (apply to current context).
|
|
246
|
+
*/
|
|
247
|
+
async enforce(runId: string): Promise<APIResponse<PolicyEvaluationResult>> {
|
|
248
|
+
// MOCK - Returns simulated enforcement
|
|
249
|
+
const mockResult: PolicyEvaluationResult = {
|
|
250
|
+
allowed: true,
|
|
251
|
+
matched_policies: [],
|
|
252
|
+
required_approvals: [],
|
|
253
|
+
warnings: [],
|
|
254
|
+
audit_entries: [],
|
|
255
|
+
};
|
|
256
|
+
return { data: mockResult, error: undefined, response: new Response() };
|
|
257
|
+
}
|
|
258
|
+
}
|
package/src/modules/tenants.ts
CHANGED
|
@@ -24,6 +24,15 @@ export interface TenantListResponse {
|
|
|
24
24
|
export class TenantsModule {
|
|
25
25
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* List all tenants the user has access to.
|
|
29
|
+
*/
|
|
30
|
+
async list(): Promise<APIResponse<Tenant[]>> {
|
|
31
|
+
return this.client.GET<Tenant[]>("/v1/api/tenants", {
|
|
32
|
+
headers: this.headers(),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* Get the current tenant.
|
|
29
38
|
*/
|