-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
502 lines (471 loc) · 15.1 KB
/
openapi.yaml
File metadata and controls
502 lines (471 loc) · 15.1 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
openapi: 3.1.0
info:
title: CometCode Local Serve API
version: 0.1.0
description: |
Minimal local HTTP + SSE surface for CometCode Phase 8.
v1 is localhost-only, has no app-layer auth, keeps `/api/v1` path versioning,
and exposes only the first serve slice endpoints.
servers:
- url: http://127.0.0.1:7700
description: Default local bind address
tags:
- name: Health
- name: Sessions
paths:
/api/v1/health:
get:
tags: [Health]
summary: Check server liveness
operationId: getHealth
responses:
'200':
description: Server is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: ok
/api/v1/sessions:
post:
tags: [Sessions]
summary: Create a session
description: |
Creates a new session for an explicit workspace selection.
Provide either `workspace_id` or `workspace_path`.
When `workspace_path` is provided and the workspace is not yet registered,
CometCode auto-registers it before creating the session.
operationId: createSession
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateSessionRequest'
examples:
byWorkspacePath:
summary: Create by workspace path
value:
workspace_path: /Users/tomlord/workspace/personal-project/cometline
byWorkspaceId:
summary: Create by workspace id
value:
workspace_id: ws_01JABCDEF
model_id: claude-sonnet-4-5
provider_id: anthropic
responses:
'201':
description: Session created
content:
application/json:
schema:
$ref: '#/components/schemas/Session'
example:
id: sess_01JABCDEF
workspace_id: ws_01JABCDEF
workspace_path: /Users/tomlord/workspace/personal-project/cometline
title: ""
model_id: claude-sonnet-4-5
provider_id: anthropic
status: active
token_usage:
input_tokens: 0
output_tokens: 0
cache_read: 0
cache_write: 0
created_at: 1746880000000
updated_at: 1746880000000
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
get:
tags: [Sessions]
summary: List sessions for one workspace
description: |
Lists sessions for exactly one workspace scope.
Supply either `workspace_id` or `workspace_path`.
This endpoint is workspace-scoped and requires one of those query parameters.
Unlike session creation, `workspace_path` does not auto-register missing workspaces.
operationId: listSessions
parameters:
- name: workspace_id
in: query
required: false
schema:
type: string
description: Registered workspace identifier.
- name: workspace_path
in: query
required: false
schema:
type: string
description: Absolute workspace path for an already-registered workspace.
responses:
'200':
description: Sessions for the requested workspace
content:
application/json:
schema:
$ref: '#/components/schemas/SessionListResponse'
example:
sessions:
- id: sess_01JABCDEF
workspace_id: ws_01JABCDEF
workspace_path: /Users/tomlord/workspace/personal-project/cometline
title: Investigate serve slice
model_id: claude-sonnet-4-5
provider_id: anthropic
status: active
token_usage:
input_tokens: 1200
output_tokens: 340
cache_read: 0
cache_write: 0
created_at: 1746880000000
updated_at: 1746880200000
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/sessions/{id}:
get:
tags: [Sessions]
summary: Get one session
operationId: getSession
parameters:
- $ref: '#/components/parameters/SessionId'
responses:
'200':
description: Session resource
content:
application/json:
schema:
$ref: '#/components/schemas/Session'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/sessions/{id}/messages:
get:
tags: [Sessions]
summary: Get transcript-style session messages
description: |
Returns a transcript-style API model rather than raw database rows.
Tool rows include both the tool input and the recorded tool output.
operationId: getSessionMessages
parameters:
- $ref: '#/components/parameters/SessionId'
responses:
'200':
description: Transcript items for the session
content:
application/json:
schema:
$ref: '#/components/schemas/TranscriptResponse'
example:
session_id: sess_01JABCDEF
items:
- type: user
text: Inspect the entrypoint.
- type: reasoning
text: I should inspect the entrypoint before changing the server wiring.
- type: assistant
text: I found the serve command entrypoint.
- type: tool
tool_name: read_file
tool_input:
path: main.go
tool_output: |-
package main
tool_error: false
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/sessions/{id}/message:
post:
tags: [Sessions]
summary: Send one text message and stream events over SSE
description: |
Accepts text-only input for v1 and responds with `text/event-stream`.
The SSE payloads reuse CometCode-native event names:
`text_delta`, `reasoning_start`, `reasoning_delta`, `tool_call`,
`tool_result`, `step_finish`, `error`, and `done`.
`tool_call.input` is opaque JSON.
`tool_result.output` is text.
operationId: postSessionMessage
parameters:
- $ref: '#/components/parameters/SessionId'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostMessageRequest'
example:
text: Inspect the server package and summarize the next change.
responses:
'200':
description: SSE event stream
content:
text/event-stream:
schema:
type: string
description: |
A sequence of SSE `data:` frames. Each frame body is one JSON event object.
examples:
minimalConversation:
summary: Text, tool, step, and done events
value: |-
data: {"type":"reasoning_start"}
data: {"type":"reasoning_delta","text":"I should inspect the session service first."}
data: {"type":"tool_call","id":"tc_01","tool":"read_file","input":{"path":"internal/session/service.go"}}
data: {"type":"tool_result","id":"tc_01","tool":"read_file","output":"package session\n\nimport (\n\t\"context\"\n..."}
data: {"type":"text_delta","delta":"The HTTP layer should resolve workspaces through SessionService."}
data: {"type":"step_finish","usage":{"input_tokens":1200,"output_tokens":340,"cache_read":0,"cache_write":0}}
data: {"type":"done"}
withError:
summary: Stream ending with an error event
value: |-
data: {"type":"text_delta","delta":"Starting request..."}
data: {"type":"error","message":"provider returned an error","code":"llm"}
data: {"type":"done"}
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/NotFound'
'409':
description: Session already has an in-flight run
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error:
code: session_running
message: session sess_01JABCDEF already running
'500':
$ref: '#/components/responses/InternalError'
/api/v1/sessions/{id}/abort:
post:
tags: [Sessions]
summary: Abort an in-flight session run
description: Cancels the currently running loop for the specified session.
operationId: abortSession
parameters:
- $ref: '#/components/parameters/SessionId'
responses:
'202':
description: Abort accepted
content:
application/json:
schema:
$ref: '#/components/schemas/StatusResponse'
example:
status: aborting
'404':
$ref: '#/components/responses/NotFound'
'409':
description: Session is not currently running
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error:
code: session_not_running
message: session is not currently running
'500':
$ref: '#/components/responses/InternalError'
components:
parameters:
SessionId:
name: id
in: path
required: true
schema:
type: string
description: Persisted CometCode session identifier.
responses:
BadRequest:
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error:
code: bad_request
message: invalid request
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error:
code: session_not_found
message: session was not found
InternalError:
description: Unexpected server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error:
code: internal_error
message: unexpected server error
schemas:
HealthResponse:
type: object
additionalProperties: false
required: [status]
properties:
status:
type: string
const: ok
CreateSessionRequest:
type: object
additionalProperties: false
properties:
workspace_id:
type: string
description: Registered workspace identifier.
workspace_path:
type: string
description: Absolute filesystem path for the workspace.
model_id:
type: string
description: Optional model override; defaults to current config.
provider_id:
type: string
description: Optional provider override; defaults to current config.
description: Provide either `workspace_id` or `workspace_path`.
PostMessageRequest:
type: object
additionalProperties: false
required: [text]
properties:
text:
type: string
minLength: 1
description: Text-only user input for v1.
Session:
type: object
additionalProperties: false
required:
- id
- workspace_id
- workspace_path
- title
- model_id
- provider_id
- status
- token_usage
- created_at
- updated_at
properties:
id:
type: string
workspace_id:
type: string
workspace_path:
type: string
title:
type: string
model_id:
type: string
provider_id:
type: string
status:
type: string
enum: [active, archived]
token_usage:
$ref: '#/components/schemas/TokenUsage'
created_at:
type: integer
format: int64
description: Unix epoch milliseconds.
updated_at:
type: integer
format: int64
description: Unix epoch milliseconds.
SessionListResponse:
type: object
additionalProperties: false
required: [sessions]
properties:
sessions:
type: array
items:
$ref: '#/components/schemas/Session'
TranscriptResponse:
type: object
additionalProperties: false
required: [session_id, items]
properties:
session_id:
type: string
items:
type: array
items:
$ref: '#/components/schemas/TranscriptItem'
TranscriptItem:
type: object
required: [type]
properties:
type:
type: string
enum: [user, reasoning, assistant, tool]
text:
type: string
tool_name:
type: string
tool_input:
description: Opaque JSON tool input.
tool_output:
type: string
tool_error:
type: boolean
TokenUsage:
type: object
additionalProperties: false
required: [input_tokens, output_tokens, cache_read, cache_write]
properties:
input_tokens:
type: integer
output_tokens:
type: integer
cache_read:
type: integer
cache_write:
type: integer
StatusResponse:
type: object
additionalProperties: false
required: [status]
properties:
status:
type: string
ErrorResponse:
type: object
additionalProperties: false
required: [error]
properties:
error:
type: object
additionalProperties: false
required: [code, message]
properties:
code:
type: string
message:
type: string