-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
2189 lines (2114 loc) · 59.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
2189 lines (2114 loc) · 59.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: CodeForge API
description: Remote AI code task runner. Submit code tasks, monitor progress via SSE, and create pull requests.
version: 1.0.0
contact:
name: CodeForge
servers:
- url: http://localhost:8080
description: Local development
security:
- BearerAuth: []
paths:
/health:
get:
summary: Health check
operationId: health
security: []
tags: [System]
responses:
"200":
description: Service health status
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: ok
version:
type: string
example: "1.0.0"
redis:
type: string
example: connected
sqlite:
type: string
example: connected
workspace_disk_usage_mb:
type: number
example: 123.45
/ready:
get:
summary: Readiness probe
operationId: ready
security: []
tags: [System]
responses:
"200":
description: Service is ready
content:
application/json:
schema:
type: object
properties:
ready:
type: boolean
"503":
description: Service is not ready
/metrics:
get:
summary: Prometheus metrics
operationId: metrics
security: []
tags: [System]
responses:
"200":
description: Prometheus text format metrics
content:
text/plain:
schema:
type: string
/api/v1/auth/verify:
get:
summary: Verify authentication token
operationId: verifyAuth
tags: [Auth]
description: |
Returns 200 if the provided Bearer token is valid.
Returns 401 if the token is missing or invalid.
Use this endpoint to validate API tokens from your UI before making other API calls.
responses:
"200":
description: Token is valid
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: authenticated
"401":
$ref: "#/components/responses/Unauthorized"
/api/v1/tasks:
post:
summary: Create a new task
operationId: createTask
tags: [Tasks]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateTaskRequest"
responses:
"201":
description: Task created
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
status:
type: string
example: pending
created_at:
type: string
format: date-time
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"429":
$ref: "#/components/responses/RateLimited"
/api/v1/tasks/{taskID}:
get:
summary: Get task status and result
operationId: getTask
tags: [Tasks]
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
- name: include
in: query
description: Include additional data (e.g., "iterations")
schema:
type: string
enum: [iterations]
responses:
"200":
description: Task details
content:
application/json:
schema:
$ref: "#/components/schemas/Task"
"404":
$ref: "#/components/responses/NotFound"
/api/v1/tasks/{taskID}/instruct:
post:
summary: Send follow-up instruction to a completed task
operationId: instructTask
tags: [Tasks]
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [prompt]
properties:
prompt:
type: string
description: Follow-up instruction
responses:
"200":
description: Instruction accepted, new iteration started
content:
application/json:
schema:
type: object
properties:
id:
type: string
status:
type: string
iteration:
type: integer
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
/api/v1/tasks/{taskID}/cancel:
post:
summary: Cancel a running task
operationId: cancelTask
description: |
Requests cancellation of a running or cloning task. Returns a transient
"canceling" status indicating the request was accepted. The task will
transition to "failed" once cancellation completes. Poll GET /tasks/{taskID}
to observe the final state.
tags: [Tasks]
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: Cancellation requested
content:
application/json:
schema:
$ref: "#/components/schemas/CancelResponse"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
/api/v1/tasks/{taskID}/create-pr:
post:
summary: Create a pull request from task changes
operationId: createPR
tags: [Tasks]
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePRRequest"
responses:
"200":
description: PR created
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePRResponse"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
/api/v1/tasks/{taskID}/review:
post:
summary: Run code review on a completed task
operationId: reviewTask
tags: [Tasks]
description: |
Enqueues a code review of the task's workspace for async worker execution.
The task must be in completed or awaiting_instruction status.
Returns 202 immediately — review runs in the worker pool with SSE streaming.
Transitions: completed/awaiting_instruction → reviewing → completed (with review_result).
Monitor progress via GET /tasks/{taskID}/stream (SSE events: review_started, review_completed).
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
type: object
properties:
cli:
type: string
description: CLI tool override for review (e.g., "codex", "claude-code")
model:
type: string
description: AI model override for the review
responses:
"202":
description: Review enqueued for worker execution
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
status:
type: string
example: reviewing
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"409":
$ref: "#/components/responses/Conflict"
/api/v1/tasks/{taskID}/post-review:
post:
summary: Post review comments to PR/MR
operationId: postReviewComments
tags: [Tasks]
description: |
Posts the task's ReviewResult as comments to the associated GitHub PR or GitLab MR.
Task must have a review_result (run a review first).
Token is resolved from the task's provider_key or access_token.
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
requestBody:
content:
application/json:
schema:
type: object
properties:
pr_number:
type: integer
description: Override PR/MR number (defaults to task config or task field)
responses:
"200":
description: Review comments posted
content:
application/json:
schema:
type: object
properties:
review_url:
type: string
description: URL to the posted review on GitHub/GitLab
comments_posted:
type: integer
description: Number of line-level comments posted
pr_number:
type: integer
description: The PR/MR number used
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
/api/v1/webhooks/github:
post:
summary: GitHub webhook receiver for PR reviews
operationId: githubWebhook
security: []
tags: [Webhooks]
description: |
Receives GitHub pull_request webhook events and automatically creates pr_review tasks.
Verified via HMAC-SHA256 signature (X-Hub-Signature-256 header).
Handles actions: opened, synchronize, reopened. Skips drafts unless configured.
requestBody:
required: true
content:
application/json:
schema:
type: object
description: GitHub pull_request webhook payload
responses:
"201":
description: Review task created
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: created
task_id:
type: string
format: uuid
"200":
description: Event ignored (not a handled action or draft)
"401":
description: Invalid webhook signature
/api/v1/webhooks/gitlab:
post:
summary: GitLab webhook receiver for MR reviews
operationId: gitlabWebhook
security: []
tags: [Webhooks]
description: |
Receives GitLab Merge Request Hook events and automatically creates pr_review tasks.
Verified via X-Gitlab-Token header constant-time comparison.
Handles actions: open, update, reopen. Skips draft/WIP unless configured.
requestBody:
required: true
content:
application/json:
schema:
type: object
description: GitLab merge_request webhook payload
responses:
"201":
description: Review task created
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: created
task_id:
type: string
format: uuid
"200":
description: Event ignored (not a handled action or draft/WIP)
"401":
description: Invalid webhook token
/api/v1/tasks/{taskID}/stream:
get:
summary: Stream task events via SSE
operationId: streamTask
tags: [Tasks]
description: |
Opens a Server-Sent Events (SSE) connection to stream real-time task progress.
**Event types:**
- `connected` — Initial event with task ID and current status.
- `data` (unnamed) — Stream events from Redis history and live Pub/Sub.
Each event is a JSON object: `{ type, event, data, ts }`.
Types: `system`, `git`, `cli`, `stream`, `result`.
- `done` — Task finished (completed/failed). Connection closes after this.
- `timeout` — Connection closed after 10 minutes.
**Behavior:**
1. Replays all historical events from Redis.
2. Subscribes to live events via Redis Pub/Sub.
3. Sends keepalive comments (`: keepalive`) every 15 seconds.
4. For terminal tasks (completed/failed/pr_created), sends history + done immediately.
**Client example (fetch + ReadableStream):**
```javascript
// Browser EventSource does NOT support custom headers.
// Use fetch with a ReadableStream instead:
const resp = await fetch('/api/v1/tasks/abc/stream', {
headers: { Authorization: 'Bearer TOKEN' },
});
const reader = resp.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
// Parse SSE frames: lines starting with "data: "
for (const line of text.split('\n')) {
if (line.startsWith('data: ')) {
console.log(JSON.parse(line.slice(6)));
}
}
}
```
**Alternative — token via query parameter:**
```javascript
// If the server supports ?token= auth, EventSource works:
const es = new EventSource('/api/v1/tasks/abc/stream?token=TOKEN');
es.onmessage = (e) => console.log(JSON.parse(e.data));
es.addEventListener('done', () => es.close());
```
parameters:
- name: taskID
in: path
required: true
schema:
type: string
format: uuid
responses:
"200":
description: SSE event stream
content:
text/event-stream:
schema:
type: string
description: Server-Sent Events stream
"404":
$ref: "#/components/responses/NotFound"
"401":
$ref: "#/components/responses/Unauthorized"
/api/v1/keys:
post:
summary: Register a provider access key
operationId: createKey
tags: [Keys]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name, provider, token]
properties:
name:
type: string
description: Unique key name
example: my-github-key
provider:
type: string
description: Provider type
enum: [github, gitlab, sentry]
example: github
token:
type: string
description: Access token (stored encrypted)
scope:
type: string
description: Optional scope restriction
responses:
"201":
description: Key registered
content:
application/json:
schema:
type: object
properties:
name:
type: string
provider:
type: string
message:
type: string
"400":
$ref: "#/components/responses/BadRequest"
"409":
$ref: "#/components/responses/Conflict"
get:
summary: List registered keys (tokens redacted)
operationId: listKeys
tags: [Keys]
responses:
"200":
description: List of keys
content:
application/json:
schema:
type: object
properties:
keys:
type: array
items:
type: object
properties:
name:
type: string
provider:
type: string
scope:
type: string
created_at:
type: string
format: date-time
/api/v1/keys/{name}/verify:
get:
summary: Verify a stored provider token
operationId: verifyKey
tags: [Keys]
description: |
Decrypts the stored token and validates it against the provider API (GitHub/GitLab/Sentry).
Returns token validity, associated username, email, and scopes.
Use this to show a green/red status indicator in the UI after adding a key.
parameters:
- name: name
in: path
required: true
schema:
type: string
responses:
"200":
description: Token is valid
content:
application/json:
schema:
$ref: "#/components/schemas/KeyVerifyResponse"
"404":
$ref: "#/components/responses/NotFound"
"422":
description: Token is invalid or expired
content:
application/json:
schema:
$ref: "#/components/schemas/KeyVerifyResponse"
/api/v1/keys/{name}:
delete:
summary: Delete a registered key
operationId: deleteKey
tags: [Keys]
parameters:
- name: name
in: path
required: true
schema:
type: string
responses:
"200":
description: Key deleted
content:
application/json:
schema:
type: object
properties:
message:
type: string
"404":
$ref: "#/components/responses/NotFound"
/api/v1/mcp/servers:
post:
summary: Register a global MCP server
operationId: createMCPServer
tags: [MCP]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name]
properties:
name:
type: string
description: Unique server name
example: context7
transport:
type: string
enum: [stdio, http]
default: stdio
description: Transport type (stdio for local process, http for remote)
package:
type: string
description: NPM package or binary path (required for stdio transport)
example: "@anthropic-ai/context7"
command:
type: string
description: Command to run (e.g. npx, uvx) — stdio transport only
args:
type: array
items:
type: string
description: Command arguments — stdio transport only
env:
type: object
additionalProperties:
type: string
description: Environment variables — stdio transport only
url:
type: string
format: uri
description: Server URL (required for http transport)
example: "https://mcp.context7.com/mcp"
headers:
type: object
additionalProperties:
type: string
description: HTTP headers — http transport only
responses:
"201":
description: MCP server registered
content:
application/json:
schema:
type: object
properties:
name:
type: string
message:
type: string
"400":
$ref: "#/components/responses/BadRequest"
"409":
$ref: "#/components/responses/Conflict"
get:
summary: List global MCP servers
operationId: listMCPServers
tags: [MCP]
responses:
"200":
description: List of MCP servers
content:
application/json:
schema:
type: object
properties:
servers:
type: array
items:
$ref: "#/components/schemas/MCPServer"
/api/v1/mcp/servers/{name}:
delete:
summary: Delete a global MCP server
operationId: deleteMCPServer
tags: [MCP]
parameters:
- name: name
in: path
required: true
schema:
type: string
responses:
"200":
description: MCP server deleted
content:
application/json:
schema:
type: object
properties:
message:
type: string
"404":
$ref: "#/components/responses/NotFound"
/api/v1/repositories:
get:
summary: List repositories accessible with a provider token
operationId: listRepositories
tags: [Repositories]
description: |
Lists repositories from GitHub or GitLab. Supports two auth modes:
1. `provider_key` — uses a stored key from the key registry
2. `provider` + `X-Provider-Token` header — inline token
parameters:
- name: provider_key
in: query
description: Name of a registered key to use
schema:
type: string
- name: provider
in: query
description: Git provider (github, gitlab). Required when using X-Provider-Token.
schema:
type: string
enum: [github, gitlab]
- name: X-Provider-Token
in: header
description: Inline provider access token
schema:
type: string
- name: page
in: query
schema:
type: integer
default: 1
- name: per_page
in: query
schema:
type: integer
default: 30
maximum: 100
responses:
"200":
description: Repository list
content:
application/json:
schema:
type: object
properties:
repositories:
type: array
items:
$ref: "#/components/schemas/Repository"
count:
type: integer
provider:
type: string
page:
type: integer
per_page:
type: integer
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"502":
description: Provider API error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/sentry/organizations:
get:
summary: List Sentry organizations
operationId: listSentryOrganizations
tags: [Sentry]
description: Proxies request to Sentry API using a stored auth token.
parameters:
- name: key_name
in: query
required: true
description: Name of the stored Sentry key
schema:
type: string
responses:
"200":
description: List of Sentry organizations
content:
application/json:
schema:
type: object
properties:
organizations:
type: array
items:
type: object
properties:
id:
type: string
slug:
type: string
name:
type: string
"400":
$ref: "#/components/responses/BadRequest"
"502":
description: Sentry API error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/sentry/projects:
get:
summary: List Sentry projects in an organization
operationId: listSentryProjects
tags: [Sentry]
parameters:
- name: key_name
in: query
required: true
schema:
type: string
- name: org
in: query
required: true
description: Sentry organization slug
schema:
type: string
responses:
"200":
description: List of Sentry projects
content:
application/json:
schema:
type: object
properties:
projects:
type: array
items:
type: object
properties:
id:
type: string
slug:
type: string
name:
type: string
platform:
type: string
"400":
$ref: "#/components/responses/BadRequest"
"502":
description: Sentry API error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/sentry/issues:
get:
summary: List Sentry issues for a project
operationId: listSentryIssues
tags: [Sentry]
parameters:
- name: key_name
in: query
required: true
schema:
type: string
- name: org
in: query
required: true
description: Sentry organization slug
schema:
type: string
- name: project
in: query
required: true
description: Sentry project slug
schema:
type: string
- name: query
in: query
description: Sentry search query (default "is:unresolved")
schema:
type: string
- name: sort
in: query
description: Sort order (e.g. freq, date, priority)
schema:
type: string
- name: limit
in: query
description: Max results (default 50)
schema:
type: string
responses:
"200":
description: List of Sentry issues (raw Sentry format)
content:
application/json:
schema:
type: object
properties:
issues:
type: array
items:
type: object
"400":
$ref: "#/components/responses/BadRequest"
"502":
description: Sentry API error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/sentry/issues/{issueID}:
get:
summary: Get a Sentry issue detail
operationId: getSentryIssue
tags: [Sentry]
parameters:
- name: issueID
in: path
required: true
schema:
type: string
- name: key_name
in: query
required: true
schema:
type: string
responses:
"200":
description: Sentry issue detail (raw Sentry format)
content:
application/json:
schema:
type: object
"400":
$ref: "#/components/responses/BadRequest"
"502":
description: Sentry API error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/sentry/issues/{issueID}/latest-event:
get:
summary: Get latest event for a Sentry issue
operationId: getSentryIssueLatestEvent
tags: [Sentry]
description: Returns the latest event with full stack trace, breadcrumbs, and context.
parameters:
- name: issueID