loki-mode 5.7.2 → 5.7.3

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.
@@ -0,0 +1,614 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: Loki Mode API
4
+ description: |
5
+ HTTP/SSE API for controlling and monitoring Loki Mode autonomous agent sessions.
6
+
7
+ ## Authentication
8
+
9
+ By default, the API only accepts connections from localhost without authentication.
10
+ For remote access, set the `LOKI_API_TOKEN` environment variable and include the
11
+ token in requests using Bearer authentication.
12
+
13
+ ## Server-Sent Events
14
+
15
+ The `/api/events` endpoint provides real-time streaming of session events using
16
+ Server-Sent Events (SSE). Connect using an EventSource client:
17
+
18
+ ```javascript
19
+ const events = new EventSource('http://localhost:8420/api/events');
20
+ events.addEventListener('task:completed', (e) => {
21
+ console.log(JSON.parse(e.data));
22
+ });
23
+ ```
24
+ version: 1.0.0
25
+ contact:
26
+ name: Loki Mode
27
+ url: https://github.com/asklokesh/loki-mode
28
+ license:
29
+ name: MIT
30
+ url: https://opensource.org/licenses/MIT
31
+
32
+ servers:
33
+ - url: http://localhost:8420
34
+ description: Local development server
35
+
36
+ tags:
37
+ - name: Health
38
+ description: Health check endpoints
39
+ - name: Sessions
40
+ description: Session management
41
+ - name: Tasks
42
+ description: Task management
43
+ - name: Events
44
+ description: Real-time event streaming
45
+
46
+ paths:
47
+ /health:
48
+ get:
49
+ tags: [Health]
50
+ summary: Health check
51
+ description: Returns the health status of the API server
52
+ operationId: healthCheck
53
+ responses:
54
+ '200':
55
+ description: Server is healthy
56
+ content:
57
+ application/json:
58
+ schema:
59
+ $ref: '#/components/schemas/HealthResponse'
60
+ '503':
61
+ description: Server is unhealthy or degraded
62
+
63
+ /health/ready:
64
+ get:
65
+ tags: [Health]
66
+ summary: Readiness probe
67
+ description: Kubernetes-style readiness probe
68
+ operationId: readinessCheck
69
+ responses:
70
+ '200':
71
+ description: Server is ready
72
+ '503':
73
+ description: Server is not ready
74
+
75
+ /health/live:
76
+ get:
77
+ tags: [Health]
78
+ summary: Liveness probe
79
+ description: Kubernetes-style liveness probe
80
+ operationId: livenessCheck
81
+ responses:
82
+ '200':
83
+ description: Server is alive
84
+
85
+ /api/status:
86
+ get:
87
+ tags: [Health]
88
+ summary: Detailed status
89
+ description: Returns detailed status information including system metrics
90
+ operationId: detailedStatus
91
+ responses:
92
+ '200':
93
+ description: Status information
94
+ content:
95
+ application/json:
96
+ schema:
97
+ type: object
98
+
99
+ /api/sessions:
100
+ get:
101
+ tags: [Sessions]
102
+ summary: List sessions
103
+ description: Returns all sessions
104
+ operationId: listSessions
105
+ responses:
106
+ '200':
107
+ description: List of sessions
108
+ content:
109
+ application/json:
110
+ schema:
111
+ type: object
112
+ properties:
113
+ sessions:
114
+ type: array
115
+ items:
116
+ $ref: '#/components/schemas/Session'
117
+ total:
118
+ type: integer
119
+ running:
120
+ type: integer
121
+
122
+ post:
123
+ tags: [Sessions]
124
+ summary: Start a new session
125
+ description: Starts a new autonomous session with the specified provider
126
+ operationId: startSession
127
+ requestBody:
128
+ content:
129
+ application/json:
130
+ schema:
131
+ $ref: '#/components/schemas/StartSessionRequest'
132
+ responses:
133
+ '201':
134
+ description: Session started
135
+ content:
136
+ application/json:
137
+ schema:
138
+ $ref: '#/components/schemas/StartSessionResponse'
139
+ '409':
140
+ description: Session already running
141
+ content:
142
+ application/json:
143
+ schema:
144
+ $ref: '#/components/schemas/ApiError'
145
+ '422':
146
+ description: Validation error
147
+ content:
148
+ application/json:
149
+ schema:
150
+ $ref: '#/components/schemas/ApiError'
151
+
152
+ /api/sessions/{sessionId}:
153
+ get:
154
+ tags: [Sessions]
155
+ summary: Get session details
156
+ description: Returns detailed status for a specific session
157
+ operationId: getSession
158
+ parameters:
159
+ - name: sessionId
160
+ in: path
161
+ required: true
162
+ schema:
163
+ type: string
164
+ responses:
165
+ '200':
166
+ description: Session details
167
+ content:
168
+ application/json:
169
+ schema:
170
+ $ref: '#/components/schemas/SessionStatusResponse'
171
+ '404':
172
+ description: Session not found
173
+
174
+ delete:
175
+ tags: [Sessions]
176
+ summary: Delete session
177
+ description: Deletes a stopped session record
178
+ operationId: deleteSession
179
+ parameters:
180
+ - name: sessionId
181
+ in: path
182
+ required: true
183
+ schema:
184
+ type: string
185
+ responses:
186
+ '200':
187
+ description: Session deleted
188
+ '404':
189
+ description: Session not found
190
+ '409':
191
+ description: Cannot delete running session
192
+
193
+ /api/sessions/{sessionId}/stop:
194
+ post:
195
+ tags: [Sessions]
196
+ summary: Stop session
197
+ description: Sends stop signal to a running session
198
+ operationId: stopSession
199
+ parameters:
200
+ - name: sessionId
201
+ in: path
202
+ required: true
203
+ schema:
204
+ type: string
205
+ responses:
206
+ '200':
207
+ description: Stop signal sent
208
+ '404':
209
+ description: Session not found
210
+ '409':
211
+ description: Session not running
212
+
213
+ /api/sessions/{sessionId}/input:
214
+ post:
215
+ tags: [Sessions]
216
+ summary: Inject human input
217
+ description: Injects human input into a running session
218
+ operationId: injectInput
219
+ parameters:
220
+ - name: sessionId
221
+ in: path
222
+ required: true
223
+ schema:
224
+ type: string
225
+ requestBody:
226
+ content:
227
+ application/json:
228
+ schema:
229
+ type: object
230
+ required: [input]
231
+ properties:
232
+ input:
233
+ type: string
234
+ description: The input text to inject
235
+ context:
236
+ type: string
237
+ description: Optional context for the input
238
+ responses:
239
+ '200':
240
+ description: Input injected
241
+ '404':
242
+ description: Session not found
243
+ '409':
244
+ description: Session not accepting input
245
+
246
+ /api/sessions/{sessionId}/tasks:
247
+ get:
248
+ tags: [Tasks]
249
+ summary: List session tasks
250
+ description: Returns tasks for a specific session
251
+ operationId: listTasks
252
+ parameters:
253
+ - name: sessionId
254
+ in: path
255
+ required: true
256
+ schema:
257
+ type: string
258
+ - name: status
259
+ in: query
260
+ schema:
261
+ type: string
262
+ enum: [pending, queued, running, completed, failed, skipped]
263
+ - name: limit
264
+ in: query
265
+ schema:
266
+ type: integer
267
+ default: 100
268
+ - name: offset
269
+ in: query
270
+ schema:
271
+ type: integer
272
+ default: 0
273
+ responses:
274
+ '200':
275
+ description: Task list
276
+ content:
277
+ application/json:
278
+ schema:
279
+ type: object
280
+ properties:
281
+ tasks:
282
+ type: array
283
+ items:
284
+ $ref: '#/components/schemas/Task'
285
+ pagination:
286
+ type: object
287
+ summary:
288
+ type: object
289
+ '404':
290
+ description: Session not found
291
+
292
+ /api/tasks:
293
+ get:
294
+ tags: [Tasks]
295
+ summary: List all tasks
296
+ description: Returns tasks across all sessions
297
+ operationId: listAllTasks
298
+ parameters:
299
+ - name: status
300
+ in: query
301
+ schema:
302
+ type: string
303
+ - name: limit
304
+ in: query
305
+ schema:
306
+ type: integer
307
+ default: 100
308
+ - name: offset
309
+ in: query
310
+ schema:
311
+ type: integer
312
+ default: 0
313
+ responses:
314
+ '200':
315
+ description: Task list
316
+
317
+ /api/tasks/active:
318
+ get:
319
+ tags: [Tasks]
320
+ summary: Get active tasks
321
+ description: Returns currently running tasks
322
+ operationId: getActiveTasks
323
+ responses:
324
+ '200':
325
+ description: Active tasks
326
+ content:
327
+ application/json:
328
+ schema:
329
+ type: object
330
+ properties:
331
+ tasks:
332
+ type: array
333
+ items:
334
+ $ref: '#/components/schemas/Task'
335
+ count:
336
+ type: integer
337
+
338
+ /api/tasks/queue:
339
+ get:
340
+ tags: [Tasks]
341
+ summary: Get queued tasks
342
+ description: Returns pending/queued tasks
343
+ operationId: getQueuedTasks
344
+ responses:
345
+ '200':
346
+ description: Queued tasks
347
+
348
+ /api/events:
349
+ get:
350
+ tags: [Events]
351
+ summary: SSE event stream
352
+ description: |
353
+ Server-Sent Events stream for real-time updates.
354
+ Connect using EventSource API.
355
+ operationId: streamEvents
356
+ parameters:
357
+ - name: sessionId
358
+ in: query
359
+ description: Filter events by session
360
+ schema:
361
+ type: string
362
+ - name: types
363
+ in: query
364
+ description: Comma-separated event types to subscribe to
365
+ schema:
366
+ type: string
367
+ - name: history
368
+ in: query
369
+ description: Number of historical events to replay
370
+ schema:
371
+ type: integer
372
+ default: 0
373
+ - name: minLevel
374
+ in: query
375
+ description: Minimum log level
376
+ schema:
377
+ type: string
378
+ enum: [debug, info, warn, error]
379
+ responses:
380
+ '200':
381
+ description: SSE stream
382
+ content:
383
+ text/event-stream:
384
+ schema:
385
+ type: string
386
+
387
+ /api/events/history:
388
+ get:
389
+ tags: [Events]
390
+ summary: Get event history
391
+ description: Returns recent events from history
392
+ operationId: getEventHistory
393
+ parameters:
394
+ - name: sessionId
395
+ in: query
396
+ schema:
397
+ type: string
398
+ - name: types
399
+ in: query
400
+ schema:
401
+ type: string
402
+ - name: limit
403
+ in: query
404
+ schema:
405
+ type: integer
406
+ default: 100
407
+ responses:
408
+ '200':
409
+ description: Event history
410
+ content:
411
+ application/json:
412
+ schema:
413
+ type: object
414
+ properties:
415
+ events:
416
+ type: array
417
+ count:
418
+ type: integer
419
+
420
+ /api/events/stats:
421
+ get:
422
+ tags: [Events]
423
+ summary: Get event statistics
424
+ description: Returns event system statistics
425
+ operationId: getEventStats
426
+ responses:
427
+ '200':
428
+ description: Event statistics
429
+
430
+ components:
431
+ securitySchemes:
432
+ bearerAuth:
433
+ type: http
434
+ scheme: bearer
435
+ description: API token for remote access
436
+
437
+ schemas:
438
+ Session:
439
+ type: object
440
+ properties:
441
+ id:
442
+ type: string
443
+ prdPath:
444
+ type: string
445
+ nullable: true
446
+ provider:
447
+ type: string
448
+ enum: [claude, codex, gemini]
449
+ status:
450
+ type: string
451
+ enum: [starting, running, paused, stopping, stopped, failed, completed]
452
+ startedAt:
453
+ type: string
454
+ format: date-time
455
+ updatedAt:
456
+ type: string
457
+ format: date-time
458
+ pid:
459
+ type: integer
460
+ nullable: true
461
+ currentPhase:
462
+ type: string
463
+ nullable: true
464
+ taskCount:
465
+ type: integer
466
+ completedTasks:
467
+ type: integer
468
+
469
+ Task:
470
+ type: object
471
+ properties:
472
+ id:
473
+ type: string
474
+ sessionId:
475
+ type: string
476
+ title:
477
+ type: string
478
+ description:
479
+ type: string
480
+ status:
481
+ type: string
482
+ enum: [pending, queued, running, completed, failed, skipped]
483
+ priority:
484
+ type: integer
485
+ createdAt:
486
+ type: string
487
+ format: date-time
488
+ startedAt:
489
+ type: string
490
+ format: date-time
491
+ nullable: true
492
+ completedAt:
493
+ type: string
494
+ format: date-time
495
+ nullable: true
496
+ agent:
497
+ type: string
498
+ nullable: true
499
+ output:
500
+ type: string
501
+ nullable: true
502
+ error:
503
+ type: string
504
+ nullable: true
505
+
506
+ StartSessionRequest:
507
+ type: object
508
+ properties:
509
+ prdPath:
510
+ type: string
511
+ description: Path to PRD file
512
+ provider:
513
+ type: string
514
+ enum: [claude, codex, gemini]
515
+ default: claude
516
+ options:
517
+ type: object
518
+ properties:
519
+ dryRun:
520
+ type: boolean
521
+ verbose:
522
+ type: boolean
523
+ timeout:
524
+ type: integer
525
+
526
+ StartSessionResponse:
527
+ type: object
528
+ properties:
529
+ sessionId:
530
+ type: string
531
+ status:
532
+ type: string
533
+ message:
534
+ type: string
535
+
536
+ SessionStatusResponse:
537
+ type: object
538
+ properties:
539
+ session:
540
+ $ref: '#/components/schemas/Session'
541
+ tasks:
542
+ type: object
543
+ properties:
544
+ total:
545
+ type: integer
546
+ pending:
547
+ type: integer
548
+ running:
549
+ type: integer
550
+ completed:
551
+ type: integer
552
+ failed:
553
+ type: integer
554
+ agents:
555
+ type: object
556
+ properties:
557
+ active:
558
+ type: integer
559
+ spawned:
560
+ type: integer
561
+ completed:
562
+ type: integer
563
+
564
+ HealthResponse:
565
+ type: object
566
+ properties:
567
+ status:
568
+ type: string
569
+ enum: [healthy, degraded, unhealthy]
570
+ version:
571
+ type: string
572
+ uptime:
573
+ type: integer
574
+ providers:
575
+ type: object
576
+ properties:
577
+ claude:
578
+ type: boolean
579
+ codex:
580
+ type: boolean
581
+ gemini:
582
+ type: boolean
583
+ activeSession:
584
+ type: string
585
+ nullable: true
586
+
587
+ ApiError:
588
+ type: object
589
+ properties:
590
+ error:
591
+ type: string
592
+ code:
593
+ type: string
594
+ details:
595
+ type: object
596
+
597
+ SSEEvent:
598
+ type: object
599
+ properties:
600
+ id:
601
+ type: string
602
+ type:
603
+ type: string
604
+ timestamp:
605
+ type: string
606
+ format: date-time
607
+ sessionId:
608
+ type: string
609
+ data:
610
+ type: object
611
+
612
+ security:
613
+ - {}
614
+ - bearerAuth: []