agent-protocol
581 строка · 16.7 Кб
1openapi: 3.0.1
2info:
3title: Agent Protocol
4description: Specification of the API protocol for communication with an agent.
5version: v1
6servers:
7- url: 'http://0.0.0.0:8000'
8description: Agent Protocol API
9paths:
10/ap/v1/agent/tasks:
11post:
12operationId: createAgentTask
13summary: Creates a task for the agent.
14requestBody:
15content:
16application/json:
17schema:
18$ref: '#/components/schemas/TaskRequestBody'
19responses:
20'200':
21description: A new agent task was successfully created.
22content:
23application/json:
24schema:
25$ref: '#/components/schemas/Task'
26x-postman-variables:
27- type: save
28name: task_id
29path: .task_id
30'422':
31$ref: '#/components/responses/UnprocessableEntity'
32default:
33description: Internal Server Error
34tags:
35- agent
36get:
37operationId: listAgentTasks
38summary: List all tasks that have been created for the agent.
39parameters:
40- name: current_page
41in: query
42description: Page number
43required: false
44schema:
45type: integer
46format: int32
47default: 1
48minimum: 1
49example: 2
50- name: page_size
51in: query
52description: Number of items per page
53required: false
54schema:
55type: integer
56format: int32
57default: 10
58minimum: 1
59example: 25
60responses:
61'200':
62description: Returned list of agent's tasks.
63content:
64application/json:
65schema:
66$ref: '#/components/schemas/TaskListResponse'
67default:
68description: Internal Server Error
69tags:
70- agent
71'/ap/v1/agent/tasks/{task_id}':
72get:
73operationId: getAgentTask
74summary: Get details about a specified agent task.
75parameters:
76- name: task_id
77in: path
78description: ID of the task
79required: true
80schema:
81type: string
82example: 1d5a533e-3904-4401-8a07-c49adf88b981
83x-postman-variables:
84- type: load
85name: task_id
86responses:
87'200':
88description: Returned details about an agent task.
89content:
90application/json:
91schema:
92$ref: '#/components/schemas/Task'
93'404':
94$ref: '#/components/responses/NotFound'
95default:
96description: Internal Server Error
97tags:
98- agent
99'/ap/v1/agent/tasks/{task_id}/steps':
100get:
101operationId: listAgentTaskSteps
102summary: List all steps for the specified task.
103parameters:
104- name: task_id
105in: path
106description: ID of the task.
107required: true
108schema:
109type: string
110example: 50da533e-3904-4401-8a07-c49adf88b5eb
111x-postman-variables:
112- type: load
113name: task_id
114- name: current_page
115in: query
116description: Page number
117required: false
118schema:
119type: integer
120format: int32
121default: 1
122minimum: 1
123example: 2
124- name: page_size
125in: query
126description: Number of items per page
127required: false
128schema:
129type: integer
130format: int32
131default: 10
132minimum: 1
133example: 25
134responses:
135'200':
136description: Returned list of agent's steps for the specified task.
137content:
138application/json:
139schema:
140$ref: '#/components/schemas/TaskStepsListResponse'
141'404':
142$ref: '#/components/responses/NotFound'
143default:
144description: Internal Server Error
145tags:
146- agent
147post:
148operationId: executeAgentTaskStep
149summary: Execute a step in the specified agent task.
150parameters:
151- name: task_id
152in: path
153description: ID of the task
154required: true
155schema:
156type: string
157example: 50da533e-3904-4401-8a07-c49adf88b5eb
158x-postman-variables:
159- type: load
160name: task_id
161requestBody:
162content:
163application/json:
164schema:
165$ref: '#/components/schemas/StepRequestBody'
166responses:
167'200':
168description: Executed step for the agent task.
169content:
170application/json:
171schema:
172$ref: '#/components/schemas/Step'
173x-postman-variables:
174- type: save
175name: step_id
176path: .step_id
177'404':
178$ref: '#/components/responses/NotFound'
179'422':
180$ref: '#/components/responses/UnprocessableEntity'
181default:
182description: Internal Server Error
183tags:
184- agent
185'/ap/v1/agent/tasks/{task_id}/steps/{step_id}':
186get:
187operationId: getAgentTaskStep
188summary: Get details about a specified task step.
189parameters:
190- name: task_id
191in: path
192description: ID of the task
193required: true
194schema:
195type: string
196example: 50da533e-3904-4401-8a07-c49adf88b5eb
197x-postman-variables:
198- type: load
199name: task_id
200- type: load
201name: step_id
202- name: step_id
203in: path
204description: ID of the step
205required: true
206schema:
207type: string
208example: 28ca533e-3904-4401-8a07-c49adf8891c2
209x-postman-variables:
210- type: load
211name: step_id
212responses:
213'200':
214description: Returned details about an agent task step.
215content:
216application/json:
217schema:
218$ref: '#/components/schemas/Step'
219'404':
220$ref: '#/components/responses/NotFound'
221default:
222description: Internal Server Error
223tags:
224- agent
225'/ap/v1/agent/tasks/{task_id}/artifacts':
226get:
227operationId: listAgentTaskArtifacts
228summary: List all artifacts that have been created for the given task.
229parameters:
230- name: task_id
231in: path
232description: ID of the task
233required: true
234schema:
235type: string
236example: 50da533e-3904-4401-8a07-c49adf88b5eb
237x-postman-variables:
238- type: load
239name: task_id
240- name: current_page
241in: query
242description: Page number
243required: false
244schema:
245type: integer
246format: int32
247default: 1
248minimum: 1
249example: 2
250- name: page_size
251in: query
252description: Number of items per page
253required: false
254schema:
255type: integer
256format: int32
257default: 10
258minimum: 1
259example: 25
260responses:
261'200':
262description: Returned the list of artifacts for the task.
263content:
264application/json:
265schema:
266$ref: '#/components/schemas/TaskArtifactsListResponse'
267'404':
268$ref: '#/components/responses/NotFound'
269default:
270description: Internal Server Error
271tags:
272- agent
273post:
274operationId: uploadAgentTaskArtifacts
275summary: Upload an artifact for the specified task.
276parameters:
277- name: task_id
278in: path
279description: ID of the task
280required: true
281schema:
282type: string
283example: 50da533e-3904-4401-8a07-c49adf88b5eb
284x-postman-variables:
285- type: load
286name: task_id
287requestBody:
288content:
289multipart/form-data:
290schema:
291$ref: '#/components/schemas/ArtifactUpload'
292responses:
293'200':
294description: Returned the content of the artifact.
295content:
296application/json:
297schema:
298$ref: '#/components/schemas/Artifact'
299'404':
300$ref: '#/components/responses/NotFound'
301default:
302description: Internal Server Error
303tags:
304- agent
305'/ap/v1/agent/tasks/{task_id}/artifacts/{artifact_id}':
306get:
307operationId: downloadAgentTaskArtifact
308summary: Download a specified artifact.
309parameters:
310- name: task_id
311in: path
312description: ID of the task
313required: true
314schema:
315type: string
316example: 50da533e-3904-4401-8a07-c49adf88b5eb
317x-postman-variables:
318- type: load
319name: task_id
320- name: artifact_id
321in: path
322description: ID of the artifact
323required: true
324schema:
325type: string
326example: 1e41533e-3904-4401-8a07-c49adf8893de
327responses:
328'200':
329description: Returned the content of the artifact.
330content:
331application/octet-stream:
332schema:
333type: string
334format: binary
335'404':
336$ref: '#/components/responses/NotFound'
337default:
338description: Internal Server Error
339tags:
340- agent
341components:
342schemas:
343Pagination:
344type: object
345properties:
346total_items:
347description: Total number of items.
348type: integer
349example: 42
350total_pages:
351description: Total number of pages.
352type: integer
353example: 97
354current_page:
355description: Current_page page number.
356type: integer
357example: 1
358page_size:
359description: Number of items per page.
360type: integer
361example: 25
362required:
363- total_items
364- total_pages
365- current_page
366- page_size
367TaskListResponse:
368type: object
369properties:
370tasks:
371type: array
372items:
373$ref: '#/components/schemas/Task'
374pagination:
375$ref: '#/components/schemas/Pagination'
376required:
377- tasks
378- pagination
379TaskStepsListResponse:
380type: object
381properties:
382steps:
383type: array
384items:
385$ref: '#/components/schemas/Step'
386pagination:
387$ref: '#/components/schemas/Pagination'
388required:
389- steps
390- pagination
391TaskArtifactsListResponse:
392type: object
393properties:
394artifacts:
395type: array
396items:
397$ref: '#/components/schemas/Artifact'
398pagination:
399$ref: '#/components/schemas/Pagination'
400required:
401- artifacts
402- pagination
403TaskInput:
404description: Input parameters for the task. Any value is allowed.
405type: object
406example: |-
407{
408"debug": false,
409"mode": "benchmarks"
410}
411Artifact:
412description: An Artifact either created by or submitted to the agent.
413type: object
414properties:
415artifact_id:
416description: ID of the artifact.
417type: string
418example: b225e278-8b4c-4f99-a696-8facf19f0e56
419agent_created:
420description: Whether the artifact has been created by the agent.
421type: boolean
422example: false
423file_name:
424description: Filename of the artifact.
425type: string
426example: main.py
427relative_path:
428description: Relative path of the artifact in the agent's workspace.
429type: string
430example: python/code/
431nullable: true
432required:
433- artifact_id
434- agent_created
435- file_name
436ArtifactUpload:
437description: Artifact to upload to the agent.
438type: object
439properties:
440file:
441description: File to upload.
442type: string
443format: binary
444example: binary representation of file
445relative_path:
446description: Relative path of the artifact in the agent's workspace.
447type: string
448example: python/code
449required:
450- file
451StepInput:
452description: Input parameters for the task step. Any value is allowed.
453type: object
454example: |-
455{
456"file_to_refactor": "models.py"
457}
458StepOutput:
459description: Output that the task step has produced. Any value is allowed.
460type: object
461example: |-
462{
463"tokens": 7894,
464"estimated_cost": "0,24$"
465}
466nullable: true
467TaskRequestBody:
468description: Body of the task request.
469type: object
470properties:
471input:
472description: Input prompt for the task.
473type: string
474example: Write 'Washington' to the file 'output.txt'.
475nullable: true
476additional_input:
477$ref: '#/components/schemas/TaskInput'
478Task:
479allOf:
480- $ref: '#/components/schemas/TaskRequestBody'
481- type: object
482description: Definition of an agent task.
483required:
484- task_id
485- artifacts
486properties:
487task_id:
488description: The ID of the task.
489type: string
490example: 50da533e-3904-4401-8a07-c49adf88b5eb
491artifacts:
492description: A list of artifacts that the task has produced.
493type: array
494items:
495$ref: '#/components/schemas/Artifact'
496example:
497- 7a49f31c-f9c6-4346-a22c-e32bc5af4d8e
498- ab7b4091-2560-4692-a4fe-d831ea3ca7d6
499default: []
500StepRequestBody:
501description: Body of the task request.
502type: object
503properties:
504input:
505description: Input prompt for the step.
506type: string
507example: Write the words you receive to the file 'output.txt'.
508nullable: true
509additional_input:
510$ref: '#/components/schemas/StepInput'
511Step:
512allOf:
513- $ref: '#/components/schemas/StepRequestBody'
514- type: object
515required:
516- step_id
517- task_id
518- status
519- is_last
520- artifacts
521properties:
522task_id:
523description: The ID of the task this step belongs to.
524type: string
525example: 50da533e-3904-4401-8a07-c49adf88b5eb
526step_id:
527description: The ID of the task step.
528type: string
529example: 6bb1801a-fd80-45e8-899a-4dd723cc602e
530name:
531description: The name of the task step.
532type: string
533example: Write to file
534nullable: true
535status:
536description: The status of the task step.
537type: string
538example: created
539enum:
540- created
541- running
542- completed
543output:
544description: Output of the task step.
545type: string
546example: "I am going to use the write_to_file command and write Washington to a file called output.txt <write_to_file('output.txt', 'Washington')"
547nullable: true
548additional_output:
549$ref: '#/components/schemas/StepOutput'
550artifacts:
551description: A list of artifacts that the step has produced.
552type: array
553items:
554$ref: '#/components/schemas/Artifact'
555default: []
556is_last:
557description: Whether this is the last step in the task.
558type: boolean
559example: true
560default: false
561responses:
562UnprocessableEntity:
563description: Unable to process request. Likely due to improperly formatted request.
564content:
565application/json:
566schema:
567description: A generic JSON object without any specific requirements.
568type: object
569NotFound:
570description: Unable to find entity with a given identifier
571content:
572application/json:
573schema:
574type: object
575properties:
576message:
577description: Message stating the entity was not found
578type: string
579example: Unable to find entity with the provided id
580required:
581- message
582