apteva 0.2.8 → 0.2.9

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/src/openapi.ts ADDED
@@ -0,0 +1,1724 @@
1
+ // OpenAPI 3.0 Specification for Apteva API
2
+
3
+ export const openApiSpec = {
4
+ openapi: "3.0.3",
5
+ info: {
6
+ title: "Apteva API",
7
+ description: `API for managing AI agents, MCP servers, and related resources.
8
+
9
+ ## Authentication
10
+
11
+ All endpoints (except /health, /version, and /auth/*) require JWT authentication.
12
+
13
+ ### Getting a Token
14
+
15
+ \`\`\`bash
16
+ curl -X POST /api/auth/login \\
17
+ -H "Content-Type: application/json" \\
18
+ -d '{"username": "admin", "password": "yourpassword"}'
19
+ \`\`\`
20
+
21
+ Response (refresh token set as httpOnly cookie):
22
+ \`\`\`json
23
+ {
24
+ "accessToken": "eyJhbGciOiJIUzI1NiIs...",
25
+ "expiresIn": 900,
26
+ "user": { "id": "...", "username": "admin", "role": "admin" }
27
+ }
28
+ \`\`\`
29
+
30
+ ### Using the Token
31
+
32
+ Include the access token in the Authorization header:
33
+
34
+ \`\`\`bash
35
+ curl /api/agents \\
36
+ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
37
+ \`\`\`
38
+
39
+ ### Token Refresh
40
+
41
+ Access tokens expire after 15 minutes. The refresh token is stored as an httpOnly cookie, so just call:
42
+
43
+ \`\`\`bash
44
+ curl -X POST /api/auth/refresh
45
+ \`\`\`
46
+
47
+ The new access token will be returned and a new refresh token cookie will be set.
48
+ `,
49
+ version: "0.2.8",
50
+ contact: {
51
+ name: "Apteva",
52
+ },
53
+ },
54
+ servers: [
55
+ {
56
+ url: "/api",
57
+ description: "Apteva API",
58
+ },
59
+ ],
60
+ tags: [
61
+ { name: "Auth", description: "Authentication endpoints" },
62
+ { name: "Agents", description: "AI Agent management" },
63
+ { name: "Chat", description: "Agent conversations" },
64
+ { name: "Threads", description: "Conversation threads" },
65
+ { name: "Memory", description: "Agent memory/knowledge" },
66
+ { name: "Files", description: "Agent file management" },
67
+ { name: "Tasks", description: "Scheduled tasks" },
68
+ { name: "Telemetry", description: "Agent telemetry and usage tracking" },
69
+ { name: "MCP", description: "Model Context Protocol servers" },
70
+ { name: "Providers", description: "LLM providers and API keys" },
71
+ { name: "Projects", description: "Agent grouping" },
72
+ { name: "System", description: "Health and version info" },
73
+ ],
74
+ security: [{ BearerAuth: [] }],
75
+ paths: {
76
+ "/auth/login": {
77
+ post: {
78
+ tags: ["Auth"],
79
+ summary: "Login and get access token",
80
+ security: [],
81
+ requestBody: {
82
+ required: true,
83
+ content: {
84
+ "application/json": {
85
+ schema: { $ref: "#/components/schemas/LoginRequest" },
86
+ },
87
+ },
88
+ },
89
+ responses: {
90
+ "200": {
91
+ description: "Login successful",
92
+ content: {
93
+ "application/json": {
94
+ schema: { $ref: "#/components/schemas/LoginResponse" },
95
+ },
96
+ },
97
+ },
98
+ "401": { description: "Invalid credentials" },
99
+ },
100
+ },
101
+ },
102
+ "/auth/refresh": {
103
+ post: {
104
+ tags: ["Auth"],
105
+ summary: "Refresh access token",
106
+ description: "Refresh token is read from httpOnly cookie (set during login). No request body needed.",
107
+ security: [],
108
+ responses: {
109
+ "200": {
110
+ description: "Token refreshed. New refresh token set as httpOnly cookie.",
111
+ content: {
112
+ "application/json": {
113
+ schema: { $ref: "#/components/schemas/RefreshResponse" },
114
+ },
115
+ },
116
+ },
117
+ "401": { description: "Invalid or expired refresh token" },
118
+ },
119
+ },
120
+ },
121
+ "/auth/logout": {
122
+ post: {
123
+ tags: ["Auth"],
124
+ summary: "Logout and invalidate tokens",
125
+ responses: {
126
+ "200": { description: "Logged out successfully" },
127
+ },
128
+ },
129
+ },
130
+ "/health": {
131
+ get: {
132
+ tags: ["System"],
133
+ summary: "Health check",
134
+ security: [],
135
+ responses: {
136
+ "200": {
137
+ description: "Service is healthy",
138
+ content: {
139
+ "application/json": {
140
+ schema: { $ref: "#/components/schemas/HealthResponse" },
141
+ },
142
+ },
143
+ },
144
+ },
145
+ },
146
+ },
147
+ "/version": {
148
+ get: {
149
+ tags: ["System"],
150
+ summary: "Get version info",
151
+ security: [],
152
+ responses: {
153
+ "200": {
154
+ description: "Version information",
155
+ content: {
156
+ "application/json": {
157
+ schema: { $ref: "#/components/schemas/VersionResponse" },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ },
163
+ },
164
+ "/dashboard": {
165
+ get: {
166
+ tags: ["System"],
167
+ summary: "Get dashboard statistics",
168
+ responses: {
169
+ "200": {
170
+ description: "Dashboard stats",
171
+ content: {
172
+ "application/json": {
173
+ schema: { $ref: "#/components/schemas/DashboardStats" },
174
+ },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ },
180
+ "/agents": {
181
+ get: {
182
+ tags: ["Agents"],
183
+ summary: "List all agents",
184
+ responses: {
185
+ "200": {
186
+ description: "List of agents",
187
+ content: {
188
+ "application/json": {
189
+ schema: { $ref: "#/components/schemas/AgentListResponse" },
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ post: {
196
+ tags: ["Agents"],
197
+ summary: "Create a new agent",
198
+ requestBody: {
199
+ required: true,
200
+ content: {
201
+ "application/json": {
202
+ schema: { $ref: "#/components/schemas/CreateAgent" },
203
+ },
204
+ },
205
+ },
206
+ responses: {
207
+ "201": {
208
+ description: "Agent created",
209
+ content: {
210
+ "application/json": {
211
+ schema: { $ref: "#/components/schemas/AgentResponse" },
212
+ },
213
+ },
214
+ },
215
+ },
216
+ },
217
+ },
218
+ "/agents/{agentId}": {
219
+ get: {
220
+ tags: ["Agents"],
221
+ summary: "Get agent by ID",
222
+ parameters: [
223
+ {
224
+ name: "agentId",
225
+ in: "path",
226
+ required: true,
227
+ schema: { type: "string" },
228
+ },
229
+ ],
230
+ responses: {
231
+ "200": {
232
+ description: "Agent details",
233
+ content: {
234
+ "application/json": {
235
+ schema: { $ref: "#/components/schemas/AgentResponse" },
236
+ },
237
+ },
238
+ },
239
+ "404": { description: "Agent not found" },
240
+ },
241
+ },
242
+ put: {
243
+ tags: ["Agents"],
244
+ summary: "Update agent",
245
+ parameters: [
246
+ {
247
+ name: "agentId",
248
+ in: "path",
249
+ required: true,
250
+ schema: { type: "string" },
251
+ },
252
+ ],
253
+ requestBody: {
254
+ required: true,
255
+ content: {
256
+ "application/json": {
257
+ schema: { $ref: "#/components/schemas/UpdateAgent" },
258
+ },
259
+ },
260
+ },
261
+ responses: {
262
+ "200": {
263
+ description: "Agent updated",
264
+ content: {
265
+ "application/json": {
266
+ schema: { $ref: "#/components/schemas/AgentResponse" },
267
+ },
268
+ },
269
+ },
270
+ },
271
+ },
272
+ delete: {
273
+ tags: ["Agents"],
274
+ summary: "Delete agent",
275
+ parameters: [
276
+ {
277
+ name: "agentId",
278
+ in: "path",
279
+ required: true,
280
+ schema: { type: "string" },
281
+ },
282
+ ],
283
+ responses: {
284
+ "200": { description: "Agent deleted" },
285
+ },
286
+ },
287
+ },
288
+ "/agents/{agentId}/start": {
289
+ post: {
290
+ tags: ["Agents"],
291
+ summary: "Start an agent",
292
+ parameters: [
293
+ {
294
+ name: "agentId",
295
+ in: "path",
296
+ required: true,
297
+ schema: { type: "string" },
298
+ },
299
+ ],
300
+ responses: {
301
+ "200": {
302
+ description: "Agent started",
303
+ content: {
304
+ "application/json": {
305
+ schema: {
306
+ type: "object",
307
+ properties: {
308
+ success: { type: "boolean" },
309
+ port: { type: "integer" },
310
+ },
311
+ },
312
+ },
313
+ },
314
+ },
315
+ },
316
+ },
317
+ },
318
+ "/agents/{agentId}/stop": {
319
+ post: {
320
+ tags: ["Agents"],
321
+ summary: "Stop an agent",
322
+ parameters: [
323
+ {
324
+ name: "agentId",
325
+ in: "path",
326
+ required: true,
327
+ schema: { type: "string" },
328
+ },
329
+ ],
330
+ responses: {
331
+ "200": {
332
+ description: "Agent stopped",
333
+ content: {
334
+ "application/json": {
335
+ schema: {
336
+ type: "object",
337
+ properties: {
338
+ success: { type: "boolean" },
339
+ },
340
+ },
341
+ },
342
+ },
343
+ },
344
+ },
345
+ },
346
+ },
347
+ "/agents/{agentId}/chat": {
348
+ post: {
349
+ tags: ["Chat"],
350
+ summary: "Send a message to an agent",
351
+ description: `Proxies the chat request to the running agent and streams the response.
352
+
353
+ **Requirements:**
354
+ - Agent must be running (status: "running")
355
+ - Agent must have an assigned port
356
+
357
+ **Response Format:**
358
+ The response is streamed as Server-Sent Events (SSE) or newline-delimited JSON.
359
+
360
+ **Event Types:**
361
+ - \`content\` - Text content from the agent
362
+ - \`tool_call\` - Agent is calling a tool
363
+ - \`tool_result\` - Result from a tool call
364
+ - \`done\` - Response complete
365
+ - \`error\` - Error occurred
366
+
367
+ **Example:**
368
+ \`\`\`javascript
369
+ const response = await fetch('/api/agents/{id}/chat', {
370
+ method: 'POST',
371
+ headers: { 'Content-Type': 'application/json' },
372
+ body: JSON.stringify({ message: 'Hello!' })
373
+ });
374
+
375
+ const reader = response.body.getReader();
376
+ while (true) {
377
+ const { done, value } = await reader.read();
378
+ if (done) break;
379
+ // Process streaming chunks
380
+ }
381
+ \`\`\``,
382
+ parameters: [
383
+ {
384
+ name: "agentId",
385
+ in: "path",
386
+ required: true,
387
+ schema: { type: "string" },
388
+ description: "The agent's unique ID",
389
+ },
390
+ ],
391
+ requestBody: {
392
+ required: true,
393
+ content: {
394
+ "application/json": {
395
+ schema: {
396
+ type: "object",
397
+ required: ["message"],
398
+ properties: {
399
+ message: { type: "string", description: "The user's message to send to the agent" },
400
+ threadId: { type: "string", description: "Optional thread ID for conversation context. If omitted, uses default thread." },
401
+ images: {
402
+ type: "array",
403
+ items: { type: "string" },
404
+ description: "Optional array of image URLs or base64 data (requires vision feature)",
405
+ },
406
+ },
407
+ },
408
+ example: {
409
+ message: "What can you help me with?",
410
+ threadId: "thread_abc123",
411
+ },
412
+ },
413
+ },
414
+ },
415
+ responses: {
416
+ "200": {
417
+ description: "Streaming response from the agent",
418
+ content: {
419
+ "text/event-stream": {
420
+ schema: {
421
+ type: "string",
422
+ description: "SSE stream with events: content, tool_call, tool_result, done, error",
423
+ },
424
+ },
425
+ },
426
+ },
427
+ "400": {
428
+ description: "Agent is not running",
429
+ content: {
430
+ "application/json": {
431
+ schema: {
432
+ type: "object",
433
+ properties: {
434
+ error: { type: "string", example: "Agent is not running" },
435
+ },
436
+ },
437
+ },
438
+ },
439
+ },
440
+ "404": {
441
+ description: "Agent not found",
442
+ content: {
443
+ "application/json": {
444
+ schema: {
445
+ type: "object",
446
+ properties: {
447
+ error: { type: "string", example: "Agent not found" },
448
+ },
449
+ },
450
+ },
451
+ },
452
+ },
453
+ },
454
+ },
455
+ },
456
+ "/agents/{agentId}/threads": {
457
+ get: {
458
+ tags: ["Threads"],
459
+ summary: "List agent threads",
460
+ parameters: [
461
+ {
462
+ name: "agentId",
463
+ in: "path",
464
+ required: true,
465
+ schema: { type: "string" },
466
+ },
467
+ ],
468
+ responses: {
469
+ "200": {
470
+ description: "List of threads",
471
+ content: {
472
+ "application/json": {
473
+ schema: {
474
+ type: "array",
475
+ items: { $ref: "#/components/schemas/Thread" },
476
+ },
477
+ },
478
+ },
479
+ },
480
+ },
481
+ },
482
+ post: {
483
+ tags: ["Threads"],
484
+ summary: "Create a new thread",
485
+ parameters: [
486
+ {
487
+ name: "agentId",
488
+ in: "path",
489
+ required: true,
490
+ schema: { type: "string" },
491
+ },
492
+ ],
493
+ requestBody: {
494
+ content: {
495
+ "application/json": {
496
+ schema: {
497
+ type: "object",
498
+ properties: {
499
+ title: { type: "string" },
500
+ },
501
+ },
502
+ },
503
+ },
504
+ },
505
+ responses: {
506
+ "201": {
507
+ description: "Thread created",
508
+ content: {
509
+ "application/json": {
510
+ schema: { $ref: "#/components/schemas/Thread" },
511
+ },
512
+ },
513
+ },
514
+ },
515
+ },
516
+ },
517
+ "/agents/{agentId}/threads/{threadId}": {
518
+ get: {
519
+ tags: ["Threads"],
520
+ summary: "Get thread details",
521
+ parameters: [
522
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
523
+ { name: "threadId", in: "path", required: true, schema: { type: "string" } },
524
+ ],
525
+ responses: {
526
+ "200": {
527
+ description: "Thread details with messages",
528
+ content: {
529
+ "application/json": {
530
+ schema: { $ref: "#/components/schemas/Thread" },
531
+ },
532
+ },
533
+ },
534
+ },
535
+ },
536
+ delete: {
537
+ tags: ["Threads"],
538
+ summary: "Delete a thread",
539
+ parameters: [
540
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
541
+ { name: "threadId", in: "path", required: true, schema: { type: "string" } },
542
+ ],
543
+ responses: {
544
+ "200": { description: "Thread deleted" },
545
+ },
546
+ },
547
+ },
548
+ "/agents/{agentId}/memories": {
549
+ get: {
550
+ tags: ["Memory"],
551
+ summary: "List agent memories",
552
+ parameters: [
553
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
554
+ ],
555
+ responses: {
556
+ "200": {
557
+ description: "List of memories",
558
+ content: {
559
+ "application/json": {
560
+ schema: {
561
+ type: "array",
562
+ items: { $ref: "#/components/schemas/Memory" },
563
+ },
564
+ },
565
+ },
566
+ },
567
+ },
568
+ },
569
+ post: {
570
+ tags: ["Memory"],
571
+ summary: "Add a memory",
572
+ parameters: [
573
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
574
+ ],
575
+ requestBody: {
576
+ required: true,
577
+ content: {
578
+ "application/json": {
579
+ schema: {
580
+ type: "object",
581
+ required: ["content"],
582
+ properties: {
583
+ content: { type: "string" },
584
+ type: { type: "string", enum: ["fact", "preference", "instruction"] },
585
+ },
586
+ },
587
+ },
588
+ },
589
+ },
590
+ responses: {
591
+ "201": { description: "Memory added" },
592
+ },
593
+ },
594
+ },
595
+ "/agents/{agentId}/memories/{memoryId}": {
596
+ delete: {
597
+ tags: ["Memory"],
598
+ summary: "Delete a memory",
599
+ parameters: [
600
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
601
+ { name: "memoryId", in: "path", required: true, schema: { type: "string" } },
602
+ ],
603
+ responses: {
604
+ "200": { description: "Memory deleted" },
605
+ },
606
+ },
607
+ },
608
+ "/agents/{agentId}/files": {
609
+ get: {
610
+ tags: ["Files"],
611
+ summary: "List agent files",
612
+ parameters: [
613
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
614
+ ],
615
+ responses: {
616
+ "200": {
617
+ description: "List of files",
618
+ content: {
619
+ "application/json": {
620
+ schema: {
621
+ type: "array",
622
+ items: { $ref: "#/components/schemas/File" },
623
+ },
624
+ },
625
+ },
626
+ },
627
+ },
628
+ },
629
+ post: {
630
+ tags: ["Files"],
631
+ summary: "Upload a file",
632
+ parameters: [
633
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
634
+ ],
635
+ requestBody: {
636
+ required: true,
637
+ content: {
638
+ "multipart/form-data": {
639
+ schema: {
640
+ type: "object",
641
+ properties: {
642
+ file: { type: "string", format: "binary" },
643
+ },
644
+ },
645
+ },
646
+ },
647
+ },
648
+ responses: {
649
+ "201": { description: "File uploaded" },
650
+ },
651
+ },
652
+ },
653
+ "/agents/{agentId}/files/{fileId}": {
654
+ get: {
655
+ tags: ["Files"],
656
+ summary: "Get file metadata",
657
+ parameters: [
658
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
659
+ { name: "fileId", in: "path", required: true, schema: { type: "string" } },
660
+ ],
661
+ responses: {
662
+ "200": {
663
+ description: "File metadata",
664
+ content: {
665
+ "application/json": {
666
+ schema: { $ref: "#/components/schemas/File" },
667
+ },
668
+ },
669
+ },
670
+ },
671
+ },
672
+ delete: {
673
+ tags: ["Files"],
674
+ summary: "Delete a file",
675
+ parameters: [
676
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
677
+ { name: "fileId", in: "path", required: true, schema: { type: "string" } },
678
+ ],
679
+ responses: {
680
+ "200": { description: "File deleted" },
681
+ },
682
+ },
683
+ },
684
+ "/agents/{agentId}/files/{fileId}/download": {
685
+ get: {
686
+ tags: ["Files"],
687
+ summary: "Download a file",
688
+ parameters: [
689
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
690
+ { name: "fileId", in: "path", required: true, schema: { type: "string" } },
691
+ ],
692
+ responses: {
693
+ "200": {
694
+ description: "File content",
695
+ content: {
696
+ "application/octet-stream": {},
697
+ },
698
+ },
699
+ },
700
+ },
701
+ },
702
+ "/agents/{agentId}/tasks": {
703
+ get: {
704
+ tags: ["Tasks"],
705
+ summary: "List agent tasks",
706
+ parameters: [
707
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
708
+ ],
709
+ responses: {
710
+ "200": {
711
+ description: "List of tasks",
712
+ content: {
713
+ "application/json": {
714
+ schema: {
715
+ type: "array",
716
+ items: { $ref: "#/components/schemas/Task" },
717
+ },
718
+ },
719
+ },
720
+ },
721
+ },
722
+ },
723
+ },
724
+ "/agents/{agentId}/peers": {
725
+ get: {
726
+ tags: ["Agents"],
727
+ summary: "List peer agents (for multi-agent)",
728
+ parameters: [
729
+ { name: "agentId", in: "path", required: true, schema: { type: "string" } },
730
+ ],
731
+ responses: {
732
+ "200": {
733
+ description: "List of peer agents",
734
+ content: {
735
+ "application/json": {
736
+ schema: {
737
+ type: "array",
738
+ items: { $ref: "#/components/schemas/Agent" },
739
+ },
740
+ },
741
+ },
742
+ },
743
+ },
744
+ },
745
+ },
746
+ "/tasks": {
747
+ get: {
748
+ tags: ["Tasks"],
749
+ summary: "List all tasks",
750
+ responses: {
751
+ "200": {
752
+ description: "List of tasks",
753
+ content: {
754
+ "application/json": {
755
+ schema: {
756
+ type: "array",
757
+ items: { $ref: "#/components/schemas/Task" },
758
+ },
759
+ },
760
+ },
761
+ },
762
+ },
763
+ },
764
+ },
765
+ "/mcp/servers": {
766
+ get: {
767
+ tags: ["MCP"],
768
+ summary: "List MCP servers",
769
+ responses: {
770
+ "200": {
771
+ description: "List of MCP servers",
772
+ content: {
773
+ "application/json": {
774
+ schema: { $ref: "#/components/schemas/McpServerListResponse" },
775
+ },
776
+ },
777
+ },
778
+ },
779
+ },
780
+ post: {
781
+ tags: ["MCP"],
782
+ summary: "Create MCP server",
783
+ requestBody: {
784
+ required: true,
785
+ content: {
786
+ "application/json": {
787
+ schema: { $ref: "#/components/schemas/CreateMcpServer" },
788
+ },
789
+ },
790
+ },
791
+ responses: {
792
+ "201": {
793
+ description: "MCP server created",
794
+ content: {
795
+ "application/json": {
796
+ schema: { $ref: "#/components/schemas/McpServer" },
797
+ },
798
+ },
799
+ },
800
+ },
801
+ },
802
+ },
803
+ "/mcp/servers/{serverId}": {
804
+ delete: {
805
+ tags: ["MCP"],
806
+ summary: "Delete MCP server",
807
+ parameters: [
808
+ { name: "serverId", in: "path", required: true, schema: { type: "string" } },
809
+ ],
810
+ responses: {
811
+ "200": { description: "Server deleted" },
812
+ },
813
+ },
814
+ },
815
+ "/mcp/servers/{serverId}/start": {
816
+ post: {
817
+ tags: ["MCP"],
818
+ summary: "Start MCP server",
819
+ parameters: [
820
+ { name: "serverId", in: "path", required: true, schema: { type: "string" } },
821
+ ],
822
+ responses: {
823
+ "200": {
824
+ description: "Server started",
825
+ content: {
826
+ "application/json": {
827
+ schema: {
828
+ type: "object",
829
+ properties: {
830
+ success: { type: "boolean" },
831
+ port: { type: "integer" },
832
+ },
833
+ },
834
+ },
835
+ },
836
+ },
837
+ },
838
+ },
839
+ },
840
+ "/mcp/servers/{serverId}/stop": {
841
+ post: {
842
+ tags: ["MCP"],
843
+ summary: "Stop MCP server",
844
+ parameters: [
845
+ { name: "serverId", in: "path", required: true, schema: { type: "string" } },
846
+ ],
847
+ responses: {
848
+ "200": { description: "Server stopped" },
849
+ },
850
+ },
851
+ },
852
+ "/mcp/servers/{serverId}/tools": {
853
+ get: {
854
+ tags: ["MCP"],
855
+ summary: "List tools from MCP server",
856
+ parameters: [
857
+ { name: "serverId", in: "path", required: true, schema: { type: "string" } },
858
+ ],
859
+ responses: {
860
+ "200": {
861
+ description: "List of tools",
862
+ content: {
863
+ "application/json": {
864
+ schema: {
865
+ type: "array",
866
+ items: { $ref: "#/components/schemas/McpTool" },
867
+ },
868
+ },
869
+ },
870
+ },
871
+ },
872
+ },
873
+ },
874
+ "/mcp/servers/{serverId}/tools/{toolName}/call": {
875
+ post: {
876
+ tags: ["MCP"],
877
+ summary: "Call an MCP tool",
878
+ parameters: [
879
+ { name: "serverId", in: "path", required: true, schema: { type: "string" } },
880
+ { name: "toolName", in: "path", required: true, schema: { type: "string" } },
881
+ ],
882
+ requestBody: {
883
+ required: true,
884
+ content: {
885
+ "application/json": {
886
+ schema: {
887
+ type: "object",
888
+ description: "Tool arguments (varies by tool)",
889
+ },
890
+ },
891
+ },
892
+ },
893
+ responses: {
894
+ "200": {
895
+ description: "Tool result",
896
+ content: {
897
+ "application/json": {
898
+ schema: { $ref: "#/components/schemas/McpToolResult" },
899
+ },
900
+ },
901
+ },
902
+ },
903
+ },
904
+ },
905
+ "/mcp/registry": {
906
+ get: {
907
+ tags: ["MCP"],
908
+ summary: "Search MCP registry (Smithery)",
909
+ parameters: [
910
+ { name: "q", in: "query", schema: { type: "string" }, description: "Search query" },
911
+ ],
912
+ responses: {
913
+ "200": {
914
+ description: "Registry results",
915
+ content: {
916
+ "application/json": {
917
+ schema: {
918
+ type: "array",
919
+ items: {
920
+ type: "object",
921
+ properties: {
922
+ name: { type: "string" },
923
+ description: { type: "string" },
924
+ package: { type: "string" },
925
+ },
926
+ },
927
+ },
928
+ },
929
+ },
930
+ },
931
+ },
932
+ },
933
+ },
934
+ "/providers": {
935
+ get: {
936
+ tags: ["Providers"],
937
+ summary: "List available providers",
938
+ responses: {
939
+ "200": {
940
+ description: "List of providers",
941
+ content: {
942
+ "application/json": {
943
+ schema: {
944
+ type: "array",
945
+ items: { $ref: "#/components/schemas/Provider" },
946
+ },
947
+ },
948
+ },
949
+ },
950
+ },
951
+ },
952
+ },
953
+ "/keys/{providerId}": {
954
+ post: {
955
+ tags: ["Providers"],
956
+ summary: "Save API key for provider",
957
+ parameters: [
958
+ { name: "providerId", in: "path", required: true, schema: { type: "string" } },
959
+ ],
960
+ requestBody: {
961
+ required: true,
962
+ content: {
963
+ "application/json": {
964
+ schema: {
965
+ type: "object",
966
+ required: ["key"],
967
+ properties: {
968
+ key: { type: "string" },
969
+ },
970
+ },
971
+ },
972
+ },
973
+ },
974
+ responses: {
975
+ "200": { description: "Key saved" },
976
+ },
977
+ },
978
+ },
979
+ "/keys/{providerId}/test": {
980
+ post: {
981
+ tags: ["Providers"],
982
+ summary: "Test API key validity",
983
+ parameters: [
984
+ { name: "providerId", in: "path", required: true, schema: { type: "string" } },
985
+ ],
986
+ responses: {
987
+ "200": {
988
+ description: "Key validation result",
989
+ content: {
990
+ "application/json": {
991
+ schema: {
992
+ type: "object",
993
+ properties: {
994
+ valid: { type: "boolean" },
995
+ error: { type: "string" },
996
+ },
997
+ },
998
+ },
999
+ },
1000
+ },
1001
+ },
1002
+ },
1003
+ },
1004
+ "/projects": {
1005
+ get: {
1006
+ tags: ["Projects"],
1007
+ summary: "List projects",
1008
+ responses: {
1009
+ "200": {
1010
+ description: "List of projects",
1011
+ content: {
1012
+ "application/json": {
1013
+ schema: {
1014
+ type: "array",
1015
+ items: { $ref: "#/components/schemas/Project" },
1016
+ },
1017
+ },
1018
+ },
1019
+ },
1020
+ },
1021
+ },
1022
+ post: {
1023
+ tags: ["Projects"],
1024
+ summary: "Create project",
1025
+ requestBody: {
1026
+ required: true,
1027
+ content: {
1028
+ "application/json": {
1029
+ schema: {
1030
+ type: "object",
1031
+ required: ["name"],
1032
+ properties: {
1033
+ name: { type: "string" },
1034
+ description: { type: "string" },
1035
+ },
1036
+ },
1037
+ },
1038
+ },
1039
+ },
1040
+ responses: {
1041
+ "201": { description: "Project created" },
1042
+ },
1043
+ },
1044
+ },
1045
+ "/projects/{projectId}": {
1046
+ put: {
1047
+ tags: ["Projects"],
1048
+ summary: "Update project",
1049
+ parameters: [
1050
+ { name: "projectId", in: "path", required: true, schema: { type: "string" } },
1051
+ ],
1052
+ requestBody: {
1053
+ content: {
1054
+ "application/json": {
1055
+ schema: {
1056
+ type: "object",
1057
+ properties: {
1058
+ name: { type: "string" },
1059
+ description: { type: "string" },
1060
+ },
1061
+ },
1062
+ },
1063
+ },
1064
+ },
1065
+ responses: {
1066
+ "200": { description: "Project updated" },
1067
+ },
1068
+ },
1069
+ delete: {
1070
+ tags: ["Projects"],
1071
+ summary: "Delete project",
1072
+ parameters: [
1073
+ { name: "projectId", in: "path", required: true, schema: { type: "string" } },
1074
+ ],
1075
+ responses: {
1076
+ "200": { description: "Project deleted" },
1077
+ },
1078
+ },
1079
+ },
1080
+ "/telemetry": {
1081
+ post: {
1082
+ tags: ["Telemetry"],
1083
+ summary: "Receive telemetry events from agents",
1084
+ description: `Endpoint for agents to send telemetry data. Agents are configured to send to this endpoint automatically.
1085
+
1086
+ Events are batched and sent periodically. Debug-level events are filtered out.`,
1087
+ requestBody: {
1088
+ required: true,
1089
+ content: {
1090
+ "application/json": {
1091
+ schema: { $ref: "#/components/schemas/TelemetryBatch" },
1092
+ },
1093
+ },
1094
+ },
1095
+ responses: {
1096
+ "200": {
1097
+ description: "Events received",
1098
+ content: {
1099
+ "application/json": {
1100
+ schema: {
1101
+ type: "object",
1102
+ properties: {
1103
+ received: { type: "integer", description: "Number of events received" },
1104
+ inserted: { type: "integer", description: "Number of events inserted" },
1105
+ },
1106
+ },
1107
+ },
1108
+ },
1109
+ },
1110
+ },
1111
+ },
1112
+ },
1113
+ "/telemetry/stream": {
1114
+ get: {
1115
+ tags: ["Telemetry"],
1116
+ summary: "Real-time telemetry stream (SSE)",
1117
+ description: `Server-Sent Events stream for real-time telemetry updates.
1118
+
1119
+ Connect to this endpoint to receive live telemetry events as they are received from agents.
1120
+
1121
+ **Example:**
1122
+ \`\`\`javascript
1123
+ const eventSource = new EventSource('/api/telemetry/stream');
1124
+ eventSource.onmessage = (event) => {
1125
+ const data = JSON.parse(event.data);
1126
+ console.log('Telemetry:', data);
1127
+ };
1128
+ \`\`\``,
1129
+ responses: {
1130
+ "200": {
1131
+ description: "SSE stream of telemetry events",
1132
+ content: {
1133
+ "text/event-stream": {
1134
+ schema: {
1135
+ type: "string",
1136
+ description: "Server-Sent Events stream. Each event contains JSON with telemetry data.",
1137
+ },
1138
+ },
1139
+ },
1140
+ },
1141
+ },
1142
+ },
1143
+ },
1144
+ "/telemetry/events": {
1145
+ get: {
1146
+ tags: ["Telemetry"],
1147
+ summary: "Query telemetry events",
1148
+ description: "Query stored telemetry events with optional filters.",
1149
+ parameters: [
1150
+ { name: "agent_id", in: "query", schema: { type: "string" }, description: "Filter by agent ID" },
1151
+ { name: "project_id", in: "query", schema: { type: "string" }, description: "Filter by project ID (use 'null' for unassigned)" },
1152
+ { name: "category", in: "query", schema: { type: "string" }, description: "Filter by category (llm, tool, memory, etc.)" },
1153
+ { name: "level", in: "query", schema: { type: "string" }, description: "Filter by level (info, warn, error)" },
1154
+ { name: "trace_id", in: "query", schema: { type: "string" }, description: "Filter by trace ID" },
1155
+ { name: "since", in: "query", schema: { type: "string", format: "date-time" }, description: "Events after this timestamp" },
1156
+ { name: "until", in: "query", schema: { type: "string", format: "date-time" }, description: "Events before this timestamp" },
1157
+ { name: "limit", in: "query", schema: { type: "integer", default: 100 }, description: "Max events to return" },
1158
+ { name: "offset", in: "query", schema: { type: "integer", default: 0 }, description: "Offset for pagination" },
1159
+ ],
1160
+ responses: {
1161
+ "200": {
1162
+ description: "List of telemetry events",
1163
+ content: {
1164
+ "application/json": {
1165
+ schema: {
1166
+ type: "object",
1167
+ properties: {
1168
+ events: {
1169
+ type: "array",
1170
+ items: { $ref: "#/components/schemas/TelemetryEvent" },
1171
+ },
1172
+ },
1173
+ },
1174
+ },
1175
+ },
1176
+ },
1177
+ },
1178
+ },
1179
+ },
1180
+ "/telemetry/usage": {
1181
+ get: {
1182
+ tags: ["Telemetry"],
1183
+ summary: "Get usage statistics",
1184
+ description: "Get token usage statistics, optionally grouped by agent or day.",
1185
+ parameters: [
1186
+ { name: "agent_id", in: "query", schema: { type: "string" }, description: "Filter by agent ID" },
1187
+ { name: "project_id", in: "query", schema: { type: "string" }, description: "Filter by project ID" },
1188
+ { name: "since", in: "query", schema: { type: "string", format: "date-time" }, description: "Start of time range" },
1189
+ { name: "until", in: "query", schema: { type: "string", format: "date-time" }, description: "End of time range" },
1190
+ { name: "group_by", in: "query", schema: { type: "string", enum: ["agent", "day"] }, description: "Group results by agent or day" },
1191
+ ],
1192
+ responses: {
1193
+ "200": {
1194
+ description: "Usage statistics",
1195
+ content: {
1196
+ "application/json": {
1197
+ schema: { $ref: "#/components/schemas/TelemetryUsage" },
1198
+ },
1199
+ },
1200
+ },
1201
+ },
1202
+ },
1203
+ },
1204
+ "/telemetry/stats": {
1205
+ get: {
1206
+ tags: ["Telemetry"],
1207
+ summary: "Get summary statistics",
1208
+ description: "Get aggregated telemetry statistics for dashboard display.",
1209
+ parameters: [
1210
+ { name: "agent_id", in: "query", schema: { type: "string" }, description: "Filter by agent ID" },
1211
+ { name: "project_id", in: "query", schema: { type: "string" }, description: "Filter by project ID" },
1212
+ ],
1213
+ responses: {
1214
+ "200": {
1215
+ description: "Summary statistics",
1216
+ content: {
1217
+ "application/json": {
1218
+ schema: { $ref: "#/components/schemas/TelemetryStats" },
1219
+ },
1220
+ },
1221
+ },
1222
+ },
1223
+ },
1224
+ },
1225
+ "/telemetry/clear": {
1226
+ post: {
1227
+ tags: ["Telemetry"],
1228
+ summary: "Clear all telemetry data",
1229
+ description: "Permanently deletes all stored telemetry data. Use with caution.",
1230
+ responses: {
1231
+ "200": {
1232
+ description: "Telemetry cleared",
1233
+ content: {
1234
+ "application/json": {
1235
+ schema: {
1236
+ type: "object",
1237
+ properties: {
1238
+ deleted: { type: "integer", description: "Number of events deleted" },
1239
+ },
1240
+ },
1241
+ },
1242
+ },
1243
+ },
1244
+ },
1245
+ },
1246
+ },
1247
+ "/integrations/composio/configs": {
1248
+ get: {
1249
+ tags: ["MCP"],
1250
+ summary: "List Composio MCP server configs",
1251
+ description: "Lists MCP server configurations from your Composio account.",
1252
+ responses: {
1253
+ "200": {
1254
+ description: "List of Composio configs",
1255
+ content: {
1256
+ "application/json": {
1257
+ schema: {
1258
+ type: "object",
1259
+ properties: {
1260
+ configs: {
1261
+ type: "array",
1262
+ items: {
1263
+ type: "object",
1264
+ properties: {
1265
+ id: { type: "string" },
1266
+ name: { type: "string" },
1267
+ toolkits: { type: "array", items: { type: "string" } },
1268
+ toolsCount: { type: "integer" },
1269
+ },
1270
+ },
1271
+ },
1272
+ },
1273
+ },
1274
+ },
1275
+ },
1276
+ },
1277
+ },
1278
+ },
1279
+ },
1280
+ "/integrations/composio/configs/{configId}/add": {
1281
+ post: {
1282
+ tags: ["MCP"],
1283
+ summary: "Add Composio config as MCP server",
1284
+ description: "Creates an MCP server from a Composio config. Automatically fetches your Composio user ID from connected accounts.",
1285
+ parameters: [
1286
+ { name: "configId", in: "path", required: true, schema: { type: "string" } },
1287
+ ],
1288
+ responses: {
1289
+ "200": {
1290
+ description: "MCP server created from Composio config",
1291
+ content: {
1292
+ "application/json": {
1293
+ schema: { $ref: "#/components/schemas/McpServerResponse" },
1294
+ },
1295
+ },
1296
+ },
1297
+ },
1298
+ },
1299
+ },
1300
+ },
1301
+ components: {
1302
+ securitySchemes: {
1303
+ BearerAuth: {
1304
+ type: "http",
1305
+ scheme: "bearer",
1306
+ bearerFormat: "JWT",
1307
+ description: "JWT token obtained from /auth/login",
1308
+ },
1309
+ },
1310
+ schemas: {
1311
+ // Auth schemas
1312
+ LoginRequest: {
1313
+ type: "object",
1314
+ required: ["username", "password"],
1315
+ properties: {
1316
+ username: { type: "string", example: "admin" },
1317
+ password: { type: "string", example: "yourpassword" },
1318
+ },
1319
+ },
1320
+ LoginResponse: {
1321
+ type: "object",
1322
+ properties: {
1323
+ accessToken: { type: "string", description: "JWT access token (expires in 15min)" },
1324
+ expiresIn: { type: "integer", description: "Token expiry in seconds", example: 900 },
1325
+ user: { $ref: "#/components/schemas/User" },
1326
+ },
1327
+ description: "Refresh token is set as httpOnly cookie",
1328
+ },
1329
+ RefreshResponse: {
1330
+ type: "object",
1331
+ properties: {
1332
+ accessToken: { type: "string" },
1333
+ expiresIn: { type: "integer", description: "Token expiry in seconds" },
1334
+ },
1335
+ description: "Refresh token read from httpOnly cookie, new one set as cookie",
1336
+ },
1337
+ User: {
1338
+ type: "object",
1339
+ properties: {
1340
+ id: { type: "string" },
1341
+ username: { type: "string" },
1342
+ email: { type: "string", format: "email", nullable: true },
1343
+ role: { type: "string", example: "admin" },
1344
+ createdAt: { type: "string", format: "date-time" },
1345
+ lastLoginAt: { type: "string", format: "date-time", nullable: true },
1346
+ },
1347
+ },
1348
+ // System schemas
1349
+ HealthResponse: {
1350
+ type: "object",
1351
+ properties: {
1352
+ status: { type: "string", example: "ok" },
1353
+ version: { type: "string", example: "0.2.8" },
1354
+ agents: {
1355
+ type: "object",
1356
+ properties: {
1357
+ total: { type: "integer", example: 3 },
1358
+ running: { type: "integer", example: 1 },
1359
+ },
1360
+ },
1361
+ },
1362
+ },
1363
+ VersionResponse: {
1364
+ type: "object",
1365
+ properties: {
1366
+ apteva: { $ref: "#/components/schemas/VersionInfo" },
1367
+ agent: { $ref: "#/components/schemas/VersionInfo" },
1368
+ isDocker: { type: "boolean" },
1369
+ },
1370
+ },
1371
+ VersionInfo: {
1372
+ type: "object",
1373
+ properties: {
1374
+ installed: { type: "string", nullable: true, example: "0.2.8" },
1375
+ latest: { type: "string", nullable: true, example: "0.2.9" },
1376
+ updateAvailable: { type: "boolean" },
1377
+ lastChecked: { type: "string", format: "date-time", nullable: true },
1378
+ },
1379
+ },
1380
+ // Agent schemas
1381
+ Agent: {
1382
+ type: "object",
1383
+ properties: {
1384
+ id: { type: "string" },
1385
+ name: { type: "string" },
1386
+ model: { type: "string" },
1387
+ provider: { type: "string" },
1388
+ systemPrompt: { type: "string" },
1389
+ status: { type: "string", enum: ["stopped", "running"] },
1390
+ port: { type: "integer" },
1391
+ features: { $ref: "#/components/schemas/AgentFeatures" },
1392
+ mcpServers: { type: "array", items: { type: "string" } },
1393
+ projectId: { type: "string", nullable: true },
1394
+ createdAt: { type: "string", format: "date-time" },
1395
+ },
1396
+ },
1397
+ AgentResponse: {
1398
+ type: "object",
1399
+ properties: {
1400
+ agent: { $ref: "#/components/schemas/Agent" },
1401
+ },
1402
+ },
1403
+ AgentListResponse: {
1404
+ type: "object",
1405
+ properties: {
1406
+ agents: {
1407
+ type: "array",
1408
+ items: { $ref: "#/components/schemas/Agent" },
1409
+ },
1410
+ },
1411
+ },
1412
+ CreateAgent: {
1413
+ type: "object",
1414
+ required: ["name", "model", "provider"],
1415
+ properties: {
1416
+ name: { type: "string" },
1417
+ model: { type: "string" },
1418
+ provider: { type: "string" },
1419
+ systemPrompt: { type: "string" },
1420
+ features: { $ref: "#/components/schemas/AgentFeatures" },
1421
+ mcpServers: { type: "array", items: { type: "string" } },
1422
+ projectId: { type: "string" },
1423
+ },
1424
+ },
1425
+ UpdateAgent: {
1426
+ type: "object",
1427
+ properties: {
1428
+ name: { type: "string" },
1429
+ model: { type: "string" },
1430
+ provider: { type: "string" },
1431
+ systemPrompt: { type: "string" },
1432
+ features: { $ref: "#/components/schemas/AgentFeatures" },
1433
+ mcpServers: { type: "array", items: { type: "string" } },
1434
+ projectId: { type: "string", nullable: true },
1435
+ },
1436
+ },
1437
+ AgentFeatures: {
1438
+ type: "object",
1439
+ properties: {
1440
+ memory: { type: "boolean" },
1441
+ tasks: { type: "boolean" },
1442
+ vision: { type: "boolean" },
1443
+ operator: { type: "boolean" },
1444
+ mcp: { type: "boolean" },
1445
+ realtime: { type: "boolean" },
1446
+ files: { type: "boolean" },
1447
+ agents: { type: "boolean" },
1448
+ },
1449
+ },
1450
+ Thread: {
1451
+ type: "object",
1452
+ properties: {
1453
+ id: { type: "string" },
1454
+ title: { type: "string" },
1455
+ createdAt: { type: "string", format: "date-time" },
1456
+ updatedAt: { type: "string", format: "date-time" },
1457
+ messageCount: { type: "integer" },
1458
+ },
1459
+ },
1460
+ Memory: {
1461
+ type: "object",
1462
+ properties: {
1463
+ id: { type: "string" },
1464
+ content: { type: "string" },
1465
+ type: { type: "string" },
1466
+ createdAt: { type: "string", format: "date-time" },
1467
+ },
1468
+ },
1469
+ File: {
1470
+ type: "object",
1471
+ properties: {
1472
+ id: { type: "string" },
1473
+ name: { type: "string" },
1474
+ size: { type: "integer" },
1475
+ mimeType: { type: "string" },
1476
+ createdAt: { type: "string", format: "date-time" },
1477
+ },
1478
+ },
1479
+ Task: {
1480
+ type: "object",
1481
+ properties: {
1482
+ id: { type: "string" },
1483
+ title: { type: "string" },
1484
+ description: { type: "string" },
1485
+ type: { type: "string", enum: ["once", "recurring"] },
1486
+ status: { type: "string", enum: ["pending", "running", "completed", "failed", "cancelled"] },
1487
+ priority: { type: "integer" },
1488
+ source: { type: "string", enum: ["local", "delegated"] },
1489
+ createdAt: { type: "string", format: "date-time" },
1490
+ executeAt: { type: "string", format: "date-time" },
1491
+ executedAt: { type: "string", format: "date-time" },
1492
+ agentId: { type: "string" },
1493
+ agentName: { type: "string" },
1494
+ },
1495
+ },
1496
+ McpServer: {
1497
+ type: "object",
1498
+ properties: {
1499
+ id: { type: "string" },
1500
+ name: { type: "string" },
1501
+ type: { type: "string", enum: ["npm", "github", "http", "custom"] },
1502
+ package: { type: "string", nullable: true },
1503
+ command: { type: "string", nullable: true },
1504
+ url: { type: "string", nullable: true },
1505
+ port: { type: "integer", nullable: true },
1506
+ status: { type: "string", enum: ["stopped", "running"] },
1507
+ source: { type: "string", nullable: true },
1508
+ },
1509
+ },
1510
+ McpServerListResponse: {
1511
+ type: "object",
1512
+ properties: {
1513
+ servers: {
1514
+ type: "array",
1515
+ items: { $ref: "#/components/schemas/McpServer" },
1516
+ },
1517
+ },
1518
+ },
1519
+ CreateMcpServer: {
1520
+ type: "object",
1521
+ required: ["name", "type"],
1522
+ properties: {
1523
+ name: { type: "string" },
1524
+ type: { type: "string", enum: ["npm", "github", "http", "custom"] },
1525
+ package: { type: "string", description: "NPM package name (for npm type)" },
1526
+ command: { type: "string", description: "Command to run (for custom type)" },
1527
+ url: { type: "string", description: "Server URL (for http type)" },
1528
+ headers: { type: "object", description: "HTTP headers (for http type)" },
1529
+ },
1530
+ },
1531
+ McpTool: {
1532
+ type: "object",
1533
+ properties: {
1534
+ name: { type: "string" },
1535
+ description: { type: "string" },
1536
+ inputSchema: { type: "object" },
1537
+ },
1538
+ },
1539
+ McpToolResult: {
1540
+ type: "object",
1541
+ properties: {
1542
+ content: {
1543
+ type: "array",
1544
+ items: {
1545
+ type: "object",
1546
+ properties: {
1547
+ type: { type: "string", enum: ["text", "image", "resource"] },
1548
+ text: { type: "string" },
1549
+ data: { type: "string" },
1550
+ mimeType: { type: "string" },
1551
+ },
1552
+ },
1553
+ },
1554
+ isError: { type: "boolean" },
1555
+ },
1556
+ },
1557
+ Provider: {
1558
+ type: "object",
1559
+ properties: {
1560
+ id: { type: "string" },
1561
+ name: { type: "string" },
1562
+ type: { type: "string", enum: ["llm", "integration"] },
1563
+ docsUrl: { type: "string" },
1564
+ models: {
1565
+ type: "array",
1566
+ items: {
1567
+ type: "object",
1568
+ properties: {
1569
+ value: { type: "string" },
1570
+ label: { type: "string" },
1571
+ recommended: { type: "boolean" },
1572
+ },
1573
+ },
1574
+ },
1575
+ hasKey: { type: "boolean" },
1576
+ isValid: { type: "boolean", nullable: true },
1577
+ },
1578
+ },
1579
+ Project: {
1580
+ type: "object",
1581
+ properties: {
1582
+ id: { type: "string" },
1583
+ name: { type: "string" },
1584
+ description: { type: "string" },
1585
+ createdAt: { type: "string", format: "date-time" },
1586
+ },
1587
+ },
1588
+ DashboardStats: {
1589
+ type: "object",
1590
+ properties: {
1591
+ agents: {
1592
+ type: "object",
1593
+ properties: {
1594
+ total: { type: "integer" },
1595
+ running: { type: "integer" },
1596
+ },
1597
+ },
1598
+ tasks: {
1599
+ type: "object",
1600
+ properties: {
1601
+ total: { type: "integer" },
1602
+ pending: { type: "integer" },
1603
+ running: { type: "integer" },
1604
+ completed: { type: "integer" },
1605
+ },
1606
+ },
1607
+ providers: {
1608
+ type: "object",
1609
+ properties: {
1610
+ configured: { type: "integer" },
1611
+ },
1612
+ },
1613
+ },
1614
+ },
1615
+ // Telemetry schemas
1616
+ TelemetryBatch: {
1617
+ type: "object",
1618
+ required: ["agent_id", "events"],
1619
+ properties: {
1620
+ agent_id: { type: "string", description: "ID of the agent sending telemetry" },
1621
+ sent_at: { type: "string", format: "date-time", description: "When the batch was sent" },
1622
+ events: {
1623
+ type: "array",
1624
+ items: { $ref: "#/components/schemas/TelemetryEventInput" },
1625
+ },
1626
+ },
1627
+ },
1628
+ TelemetryEventInput: {
1629
+ type: "object",
1630
+ required: ["id", "timestamp", "category", "type", "level"],
1631
+ properties: {
1632
+ id: { type: "string", description: "Unique event ID" },
1633
+ timestamp: { type: "string", format: "date-time" },
1634
+ category: {
1635
+ type: "string",
1636
+ description: "Event category",
1637
+ enum: ["llm", "tool", "memory", "task", "agent", "mcp", "system"],
1638
+ },
1639
+ type: { type: "string", description: "Event type within category (e.g., 'request', 'response', 'error')" },
1640
+ level: { type: "string", enum: ["debug", "info", "warn", "error"] },
1641
+ trace_id: { type: "string", description: "Trace ID for correlating related events" },
1642
+ span_id: { type: "string", description: "Span ID within a trace" },
1643
+ thread_id: { type: "string", description: "Conversation thread ID" },
1644
+ data: {
1645
+ type: "object",
1646
+ description: "Event-specific data (tokens, model, tool name, etc.)",
1647
+ },
1648
+ metadata: { type: "object", description: "Additional metadata" },
1649
+ duration_ms: { type: "integer", description: "Duration in milliseconds (for timed events)" },
1650
+ error: { type: "string", description: "Error message if event represents an error" },
1651
+ },
1652
+ },
1653
+ TelemetryEvent: {
1654
+ type: "object",
1655
+ properties: {
1656
+ id: { type: "string" },
1657
+ agent_id: { type: "string" },
1658
+ timestamp: { type: "string", format: "date-time" },
1659
+ category: { type: "string" },
1660
+ type: { type: "string" },
1661
+ level: { type: "string" },
1662
+ trace_id: { type: "string", nullable: true },
1663
+ thread_id: { type: "string", nullable: true },
1664
+ data: { type: "object", nullable: true },
1665
+ duration_ms: { type: "integer", nullable: true },
1666
+ error: { type: "string", nullable: true },
1667
+ },
1668
+ },
1669
+ TelemetryUsage: {
1670
+ type: "object",
1671
+ properties: {
1672
+ usage: {
1673
+ type: "object",
1674
+ properties: {
1675
+ total_tokens: { type: "integer" },
1676
+ prompt_tokens: { type: "integer" },
1677
+ completion_tokens: { type: "integer" },
1678
+ request_count: { type: "integer" },
1679
+ by_agent: {
1680
+ type: "array",
1681
+ items: {
1682
+ type: "object",
1683
+ properties: {
1684
+ agent_id: { type: "string" },
1685
+ total_tokens: { type: "integer" },
1686
+ request_count: { type: "integer" },
1687
+ },
1688
+ },
1689
+ },
1690
+ by_day: {
1691
+ type: "array",
1692
+ items: {
1693
+ type: "object",
1694
+ properties: {
1695
+ date: { type: "string", format: "date" },
1696
+ total_tokens: { type: "integer" },
1697
+ request_count: { type: "integer" },
1698
+ },
1699
+ },
1700
+ },
1701
+ },
1702
+ },
1703
+ },
1704
+ },
1705
+ TelemetryStats: {
1706
+ type: "object",
1707
+ properties: {
1708
+ stats: {
1709
+ type: "object",
1710
+ properties: {
1711
+ total_events: { type: "integer" },
1712
+ events_by_category: { type: "object", additionalProperties: { type: "integer" } },
1713
+ events_by_level: { type: "object", additionalProperties: { type: "integer" } },
1714
+ total_tokens: { type: "integer" },
1715
+ total_requests: { type: "integer" },
1716
+ avg_response_time_ms: { type: "number" },
1717
+ error_count: { type: "integer" },
1718
+ },
1719
+ },
1720
+ },
1721
+ },
1722
+ },
1723
+ },
1724
+ };