@agent-os-sdk/client 0.1.1 → 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.
Files changed (62) hide show
  1. package/dist/client/AgentOsClient.d.ts +28 -4
  2. package/dist/client/AgentOsClient.d.ts.map +1 -1
  3. package/dist/client/AgentOsClient.js +40 -3
  4. package/dist/generated/openapi.d.ts +93 -0
  5. package/dist/generated/openapi.d.ts.map +1 -1
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +10 -0
  9. package/dist/modules/approvals.d.ts +78 -0
  10. package/dist/modules/approvals.d.ts.map +1 -0
  11. package/dist/modules/approvals.js +157 -0
  12. package/dist/modules/artifacts.d.ts +100 -0
  13. package/dist/modules/artifacts.d.ts.map +1 -0
  14. package/dist/modules/artifacts.js +217 -0
  15. package/dist/modules/budgets.d.ts +104 -0
  16. package/dist/modules/budgets.d.ts.map +1 -0
  17. package/dist/modules/budgets.js +161 -0
  18. package/dist/modules/builder.d.ts +2 -2
  19. package/dist/modules/builder.d.ts.map +1 -1
  20. package/dist/modules/builder.js +5 -5
  21. package/dist/modules/capabilities.d.ts +68 -0
  22. package/dist/modules/capabilities.d.ts.map +1 -0
  23. package/dist/modules/capabilities.js +113 -0
  24. package/dist/modules/deployments.d.ts +110 -0
  25. package/dist/modules/deployments.d.ts.map +1 -0
  26. package/dist/modules/deployments.js +230 -0
  27. package/dist/modules/flows.d.ts +104 -0
  28. package/dist/modules/flows.d.ts.map +1 -0
  29. package/dist/modules/flows.js +190 -0
  30. package/dist/modules/handoff.d.ts +88 -0
  31. package/dist/modules/handoff.d.ts.map +1 -0
  32. package/dist/modules/handoff.js +128 -0
  33. package/dist/modules/incidents.d.ts +133 -0
  34. package/dist/modules/incidents.d.ts.map +1 -0
  35. package/dist/modules/incidents.js +231 -0
  36. package/dist/modules/members.d.ts +5 -0
  37. package/dist/modules/members.d.ts.map +1 -1
  38. package/dist/modules/members.js +10 -0
  39. package/dist/modules/policies.d.ts +103 -0
  40. package/dist/modules/policies.d.ts.map +1 -0
  41. package/dist/modules/policies.js +180 -0
  42. package/dist/modules/runs.d.ts.map +1 -1
  43. package/dist/modules/tenants.d.ts +4 -0
  44. package/dist/modules/tenants.d.ts.map +1 -1
  45. package/dist/modules/tenants.js +8 -0
  46. package/package.json +49 -48
  47. package/src/client/AgentOsClient.ts +45 -7
  48. package/src/generated/openapi.ts +93 -0
  49. package/src/generated/swagger.json +107 -0
  50. package/src/index.ts +11 -0
  51. package/src/modules/approvals.ts +210 -0
  52. package/src/modules/artifacts.ts +287 -0
  53. package/src/modules/budgets.ts +236 -0
  54. package/src/modules/builder.ts +3 -3
  55. package/src/modules/capabilities.ts +176 -0
  56. package/src/modules/deployments.ts +315 -0
  57. package/src/modules/flows.ts +259 -0
  58. package/src/modules/handoff.ts +204 -0
  59. package/src/modules/incidents.ts +339 -0
  60. package/src/modules/members.ts +11 -0
  61. package/src/modules/policies.ts +258 -0
  62. package/src/modules/tenants.ts +9 -0
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Handoff Module - Multi-Agent Delegation
3
+ *
4
+ * // MOCK - This module contains mock implementations for future features
5
+ *
6
+ * Provides first-class support for agent handoffs, delegation,
7
+ * thread forking, and run chain management.
8
+ */
9
+
10
+ import type { RawClient, APIResponse } from "../client/raw.js";
11
+
12
+ // ============================================================================
13
+ // Types
14
+ // ============================================================================
15
+
16
+ export type HandoffMode = "same_thread" | "subthread" | "new_thread";
17
+
18
+ export interface HandoffOptions {
19
+ mode: HandoffMode;
20
+ payload?: Record<string, unknown>;
21
+ constraints?: HandoffConstraints;
22
+ inherit_budget?: boolean;
23
+ inherit_policies?: boolean;
24
+ }
25
+
26
+ export interface HandoffConstraints {
27
+ max_tool_calls?: number;
28
+ max_tokens?: number;
29
+ tool_allowlist?: string[];
30
+ tool_denylist?: string[];
31
+ timeout_seconds?: number;
32
+ }
33
+
34
+ export interface HandoffResult {
35
+ run_id: string;
36
+ parent_run_id: string;
37
+ to_agent_id: string;
38
+ mode: HandoffMode;
39
+ thread_id: string;
40
+ status: "pending" | "running" | "completed" | "failed";
41
+ created_at: string;
42
+ }
43
+
44
+ export interface ForkOptions {
45
+ mode?: HandoffMode;
46
+ checkpoint_id?: string;
47
+ copy_messages?: boolean;
48
+ copy_state?: boolean;
49
+ }
50
+
51
+ export interface ForkResult {
52
+ original_thread_id: string;
53
+ forked_thread_id: string;
54
+ checkpoint_id?: string;
55
+ created_at: string;
56
+ }
57
+
58
+ export interface RunChainNode {
59
+ run_id: string;
60
+ agent_id: string;
61
+ agent_name: string;
62
+ status: string;
63
+ parent_run_id?: string;
64
+ children: RunChainNode[];
65
+ depth: number;
66
+ started_at: string;
67
+ completed_at?: string;
68
+ }
69
+
70
+ export interface RunChain {
71
+ root_run_id: string;
72
+ total_runs: number;
73
+ max_depth: number;
74
+ nodes: RunChainNode[];
75
+ }
76
+
77
+ // ============================================================================
78
+ // Module
79
+ // ============================================================================
80
+
81
+ export class HandoffModule {
82
+ constructor(private client: RawClient, private headers: () => Record<string, string>) { }
83
+
84
+ // MOCK - Simulated handoff
85
+ /**
86
+ * Hand off current run to another agent.
87
+ */
88
+ async handoff(
89
+ runId: string,
90
+ toAgentId: string,
91
+ options?: HandoffOptions
92
+ ): Promise<APIResponse<HandoffResult>> {
93
+ // MOCK - Returns simulated data
94
+ const mockResult: HandoffResult = {
95
+ run_id: `run_handoff_${Date.now()}`,
96
+ parent_run_id: runId,
97
+ to_agent_id: toAgentId,
98
+ mode: options?.mode || "subthread",
99
+ thread_id: `thread_${Date.now()}`,
100
+ status: "pending",
101
+ created_at: new Date().toISOString(),
102
+ };
103
+ return { data: mockResult, error: undefined, response: new Response() };
104
+ }
105
+
106
+ // MOCK - Simulated fork
107
+ /**
108
+ * Fork a thread into a new conversation branch.
109
+ */
110
+ async fork(
111
+ threadId: string,
112
+ options?: ForkOptions
113
+ ): Promise<APIResponse<ForkResult>> {
114
+ // MOCK - Returns simulated data
115
+ const mockResult: ForkResult = {
116
+ original_thread_id: threadId,
117
+ forked_thread_id: `thread_fork_${Date.now()}`,
118
+ checkpoint_id: options?.checkpoint_id,
119
+ created_at: new Date().toISOString(),
120
+ };
121
+ return { data: mockResult, error: undefined, response: new Response() };
122
+ }
123
+
124
+ // MOCK - Simulated chain
125
+ /**
126
+ * Get the full run chain (delegation tree).
127
+ */
128
+ async getChain(runId: string): Promise<APIResponse<RunChain>> {
129
+ // MOCK - Returns simulated data
130
+ const mockChain: RunChain = {
131
+ root_run_id: runId,
132
+ total_runs: 3,
133
+ max_depth: 2,
134
+ nodes: [
135
+ {
136
+ run_id: runId,
137
+ agent_id: "agent_1",
138
+ agent_name: "Main Agent",
139
+ status: "completed",
140
+ depth: 0,
141
+ started_at: new Date(Date.now() - 60000).toISOString(),
142
+ completed_at: new Date().toISOString(),
143
+ children: [
144
+ {
145
+ run_id: `${runId}_child_1`,
146
+ agent_id: "agent_2",
147
+ agent_name: "Research Agent",
148
+ status: "completed",
149
+ parent_run_id: runId,
150
+ depth: 1,
151
+ started_at: new Date(Date.now() - 30000).toISOString(),
152
+ completed_at: new Date().toISOString(),
153
+ children: [],
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ };
159
+ return { data: mockChain, error: undefined, response: new Response() };
160
+ }
161
+
162
+ // MOCK - Simulated parents
163
+ /**
164
+ * Get parent runs in the chain.
165
+ */
166
+ async getParents(runId: string): Promise<APIResponse<RunChainNode[]>> {
167
+ // MOCK - Returns simulated data
168
+ const mockParents: RunChainNode[] = [
169
+ {
170
+ run_id: `parent_${runId}`,
171
+ agent_id: "agent_parent",
172
+ agent_name: "Parent Agent",
173
+ status: "completed",
174
+ depth: 0,
175
+ started_at: new Date(Date.now() - 120000).toISOString(),
176
+ completed_at: new Date(Date.now() - 60000).toISOString(),
177
+ children: [],
178
+ },
179
+ ];
180
+ return { data: mockParents, error: undefined, response: new Response() };
181
+ }
182
+
183
+ // MOCK - Simulated children
184
+ /**
185
+ * Get child runs in the chain.
186
+ */
187
+ async getChildren(runId: string): Promise<APIResponse<RunChainNode[]>> {
188
+ // MOCK - Returns simulated data
189
+ const mockChildren: RunChainNode[] = [
190
+ {
191
+ run_id: `child_1_${runId}`,
192
+ agent_id: "agent_child_1",
193
+ agent_name: "Child Agent 1",
194
+ status: "completed",
195
+ parent_run_id: runId,
196
+ depth: 1,
197
+ started_at: new Date(Date.now() - 30000).toISOString(),
198
+ completed_at: new Date().toISOString(),
199
+ children: [],
200
+ },
201
+ ];
202
+ return { data: mockChildren, error: undefined, response: new Response() };
203
+ }
204
+ }
@@ -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
+ }
@@ -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
  }