agent-protocol
1484 строки · 49.2 Кб
1{
2"info": {
3"_postman_id": "84d6bd70-4a9f-4470-be02-f2f9089ec69b",
4"name": "Agent Protocol - REST v1",
5"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
6},
7"item": [
8{
9"name": "Basic User Experience",
10"item": [
11{
12"name": "Cleanup Previous Run Copy",
13"event": [
14{
15"listen": "prerequest",
16"script": {
17"id": "6e0312e1-1276-47b2-92be-b481545de5fb",
18"exec": [
19"// See https://blog.postman.com/2019/05/28/pro-tip-dynamically-unset-postman-environment-variables/\r",
20"// for more details on what we're doing here. \r",
21"\r",
22"cleanupCollectionVariables();\r",
23"\r",
24"function cleanupCollectionVariables() {\r",
25" const clean = _.keys(pm.collectionVariables.toObject());\r",
26"\r",
27" _.each(clean, (arrItem) => {\r",
28" pm.collectionVariables.unset(arrItem);\r",
29" });\r",
30"}"
31],
32"type": "text/javascript"
33}
34},
35{
36"listen": "test",
37"script": {
38"id": "acaabbd4-94fc-4444-8718-b9ca2c087721",
39"exec": [""],
40"type": "text/javascript"
41}
42}
43],
44"id": "5da26248-515e-4feb-b7b5-c7de25a03857",
45"protocolProfileBehavior": {
46"disableBodyPruning": true
47},
48"request": {
49"method": "GET",
50"header": [],
51"url": "https://postman-echo.com/delay/0"
52},
53"response": []
54},
55{
56"name": "Get all the tasks",
57"event": [
58{
59"listen": "test",
60"script": {
61"id": "32b75035-2164-4ec1-b61c-a86515847037",
62"exec": [""],
63"type": "text/javascript"
64}
65},
66{
67"listen": "prerequest",
68"script": {
69"id": "98c48159-7553-4f9b-a1e7-dd66b961ec11",
70"exec": [""],
71"type": "text/javascript"
72}
73}
74],
75"id": "52fdb36d-66c1-41e9-b81a-1084ae813a2d",
76"protocolProfileBehavior": {
77"disableBodyPruning": true
78},
79"request": {
80"method": "GET",
81"header": [
82{
83"key": "mock-match",
84"value": "19",
85"type": "text"
86}
87],
88"body": {
89"mode": "raw",
90"raw": "",
91"options": {
92"raw": {
93"language": "json"
94}
95}
96},
97"url": "{{url}}/ap/v1/agent/tasks"
98},
99"response": [
100{
101"id": "98f96c46-c680-4377-a681-27b93d8425cf",
102"name": "mock response",
103"originalRequest": {
104"method": "GET",
105"header": [
106{
107"key": "Content-Type",
108"value": "application/json",
109"type": "text"
110},
111{
112"key": "mock-match",
113"value": "19",
114"type": "text"
115}
116],
117"body": {
118"mode": "raw",
119"raw": "",
120"options": {
121"raw": {
122"language": "json"
123}
124}
125},
126"url": "{{url}}/ap/v1/agent/tasks"
127},
128"status": "OK",
129"code": 200,
130"_postman_previewlanguage": "json",
131"header": [
132{
133"key": "Date",
134"value": "Thu, 17 Aug 2023 18:03:12 GMT",
135"enabled": true
136},
137{
138"key": "Content-Type",
139"name": "Content-Type",
140"value": "application/json",
141"description": "",
142"type": "text"
143},
144{
145"key": "Content-Length",
146"value": "150",
147"enabled": true
148},
149{
150"key": "Connection",
151"value": "keep-alive",
152"enabled": true
153},
154{
155"key": "x-srv-trace",
156"value": "v=1;t=1c95cd08c248d38f",
157"enabled": true
158},
159{
160"key": "x-srv-span",
161"value": "v=1;s=2527ca982b2b7c75",
162"enabled": true
163},
164{
165"key": "Access-Control-Allow-Origin",
166"value": "*",
167"enabled": true
168},
169{
170"key": "X-RateLimit-Limit",
171"value": "120",
172"enabled": true
173},
174{
175"key": "X-RateLimit-Remaining",
176"value": "117",
177"enabled": true
178},
179{
180"key": "X-RateLimit-Reset",
181"value": "1692295416",
182"enabled": true
183},
184{
185"key": "ETag",
186"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
187"enabled": true
188},
189{
190"key": "Vary",
191"value": "Accept-Encoding",
192"enabled": true
193}
194],
195"cookie": [],
196"responseTime": null,
197"body": "[\n {\n \"task_id\": \"fde559f8-3ab8-11ee-be56-0242ac120002\",\n \"step_id\": \"1a379290-3abc-11ee-be56-0242ac120002\",\n \"status\": \"completed\",\n \"output\": \"I am going to use the write_to_file method to write the word 'Washington' to a .txt file\",\n \"artifacts\": [],\n \"is_last\": false\n }\n]"
198}
199]
200},
201{
202"name": "Create a new task",
203"event": [
204{
205"listen": "prerequest",
206"script": {
207"id": "c5e90382-a818-4e98-9f9b-4a2877e0f129",
208"exec": [""],
209"type": "text/javascript"
210}
211},
212{
213"listen": "test",
214"script": {
215"id": "683fd614-1610-4dab-bf88-6ae830186dac",
216"exec": [
217"var jsonData = pm.response.json();",
218"pm.globals.set(\"task_id\", jsonData.task_id);",
219"",
220"pm.globals.set(",
221" \"step_body\",",
222" JSON.stringify(",
223" {",
224" \"input\": JSON.parse(pm.request.body.raw).input",
225" } ",
226" )",
227");"
228],
229"type": "text/javascript"
230}
231}
232],
233"id": "090b65b7-80e6-4a20-81d7-2a6f72644ad5",
234"protocolProfileBehavior": {
235"disableBodyPruning": true
236},
237"request": {
238"method": "POST",
239"header": [
240{
241"key": "mock-match",
242"value": "34",
243"type": "text"
244},
245{
246"key": "Content-Type",
247"value": "application/json",
248"type": "text"
249}
250],
251"body": {
252"mode": "raw",
253"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\",\n \"additional_input\": {\"test_run_id\": \"123\"}\n}",
254"options": {
255"raw": {
256"language": "json"
257}
258}
259},
260"url": "{{url}}/ap/v1/agent/tasks"
261},
262"response": [
263{
264"id": "5aa13fc7-8099-43ac-81d4-87af8cdbb6fe",
265"name": "mock response",
266"originalRequest": {
267"method": "POST",
268"header": [
269{
270"key": "mock-match",
271"value": "34"
272},
273{
274"key": "Content-Type",
275"value": "application/json",
276"type": "text"
277}
278],
279"body": {
280"mode": "raw",
281"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
282"options": {
283"raw": {
284"language": "json"
285}
286}
287},
288"url": "{{url}}/ap/v1/agent/tasks"
289},
290"status": "OK",
291"code": 200,
292"_postman_previewlanguage": "json",
293"header": [
294{
295"key": "Date",
296"value": "Sun, 13 Aug 2023 23:23:05 GMT",
297"enabled": true
298},
299{
300"key": "Content-Type",
301"value": "application/json; charset=utf-8",
302"enabled": true
303},
304{
305"key": "Content-Length",
306"value": "28",
307"enabled": true
308},
309{
310"key": "Connection",
311"value": "keep-alive",
312"enabled": true
313},
314{
315"key": "x-srv-trace",
316"value": "v=1;t=daef761e243c402b",
317"enabled": true
318},
319{
320"key": "x-srv-span",
321"value": "v=1;s=2c0bd88502372360",
322"enabled": true
323},
324{
325"key": "Access-Control-Allow-Origin",
326"value": "*",
327"enabled": true
328},
329{
330"key": "X-RateLimit-Limit",
331"value": "120",
332"enabled": true
333},
334{
335"key": "X-RateLimit-Remaining",
336"value": "115",
337"enabled": true
338},
339{
340"key": "X-RateLimit-Reset",
341"value": "1691968334",
342"enabled": true
343},
344{
345"key": "ETag",
346"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
347"enabled": true
348},
349{
350"key": "Vary",
351"value": "Accept-Encoding",
352"enabled": true
353}
354],
355"cookie": [],
356"responseTime": null,
357"body": "{\n \"input\": \"Write the word 'Washington' to a .txt file\",\n \"additional_input\": {},\n \"task_id\": \"fde559f8-3ab8-11ee-be56-0242ac120002\",\n \"artifacts\": []\n}"
358}
359]
360},
361{
362"name": "Execute a step",
363"event": [
364{
365"listen": "test",
366"script": {
367"id": "26426e07-115e-4841-9887-24fd9dccca2a",
368"exec": [
369"if (pm.request.url.path[0] == \"agent\" && pm.response.headers.has(\"Content-Type\",`application/json`)) {",
370" var artifacts = pm.response.json().artifacts;",
371"",
372" if (artifacts && artifacts.length > 0) {",
373" pm.globals.set(\"artifactId\", artifacts[0].artifact_id);",
374" }",
375"",
376" var artifacts = pm.response.json().artifacts;",
377" var existingArtifactId = pm.globals.get(\"artifactId\");",
378"/* Commented out artifact checking code and max step code because the SDK doesn't implement simple agents",
379" if (artifacts && artifacts.length > 0) {",
380" if (artifacts.length > 1) {",
381" pm.test(\"This task should only create 1 artifact\", function () {",
382" pm.expect.fail(\"More than one artifact was created.\");",
383" });",
384" } else {",
385" pm.globals.set(\"artifactId\", artifacts[0].artifact_id);",
386" }",
387" }*/",
388" stepNumber = pm.collectionVariables.get(\"step-number\") ?? 1",
389" const maxSteps = 10",
390" if(!pm.response.json().is_last) {",
391" /*if (stepNumber > maxSteps) {",
392" console.log(`Max steps reached (${maxSteps})`);",
393" pm.test(`This task should be completed after ${maxSteps} steps`, function () {",
394" pm.expect.fail(`is_last should be true before max steps reached (${maxSteps})`);",
395" });",
396" } else {",
397" console.log(`Steps reached (${stepNumber})`);",
398"",
399" pm.collectionVariables.set('step-number', stepNumber + 1);",
400" pm.globals.set(",
401" \"step_body\",",
402" JSON.stringify(",
403" {",
404" \"input\": \"y\"",
405" }",
406" )",
407" );",
408"",
409" pm.collectionVariables.set('previous-step', pm.response.json().step_id)",
410" postman.setNextRequest('Execute the steps until completion');",
411" }*/",
412" ",
413" }",
414"}"
415],
416"type": "text/javascript"
417}
418},
419{
420"listen": "prerequest",
421"script": {
422"id": "3bdd2e35-1745-439e-9ef1-ea2e003ddc42",
423"exec": [
424"stepNumber = pm.collectionVariables.get(\"step-number\") ?? 1",
425"console.log(\"Step number:\" + stepNumber)",
426"console.log(\"Task Input:\" + pm.globals.get(\"taskInput\"))",
427"if (stepNumber) {",
428" pm.request.headers.upsert({ key: 'mock-match', value: stepNumber.toString() });",
429" console.log(pm.request)",
430"}"
431],
432"type": "text/javascript"
433}
434}
435],
436"id": "c001b340-752c-45ea-aaa2-22cb52e47297",
437"protocolProfileBehavior": {
438"disableBodyPruning": true
439},
440"request": {
441"method": "POST",
442"header": [
443{
444"key": "Content-Type",
445"value": "application/json",
446"type": "text"
447}
448],
449"body": {
450"mode": "raw",
451"raw": "{{step_body}}",
452"options": {
453"raw": {
454"language": "json"
455}
456}
457},
458"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/steps"
459},
460"response": [
461{
462"id": "1def41e7-04a8-41d6-bcef-b0149882510d",
463"name": "mock response",
464"originalRequest": {
465"method": "POST",
466"header": [
467{
468"key": "mock-match",
469"value": "1",
470"type": "text"
471},
472{
473"key": "Content-Type",
474"value": "application/json",
475"type": "text"
476}
477],
478"body": {
479"mode": "raw",
480"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
481"options": {
482"raw": {
483"language": "json"
484}
485}
486},
487"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/steps"
488},
489"status": "OK",
490"code": 200,
491"_postman_previewlanguage": "json",
492"header": [
493{
494"key": "Date",
495"value": "Mon, 14 Aug 2023 16:28:55 GMT",
496"enabled": true
497},
498{
499"key": "Content-Type",
500"value": "application/json; charset=utf-8",
501"enabled": true
502},
503{
504"key": "Content-Length",
505"value": "275",
506"enabled": true
507},
508{
509"key": "Connection",
510"value": "keep-alive",
511"enabled": true
512},
513{
514"key": "x-srv-trace",
515"value": "v=1;t=daef761e243c402b",
516"enabled": true
517},
518{
519"key": "x-srv-span",
520"value": "v=1;s=2c0bd88502372360",
521"enabled": true
522},
523{
524"key": "Access-Control-Allow-Origin",
525"value": "*",
526"enabled": true
527},
528{
529"key": "X-RateLimit-Limit",
530"value": "120",
531"enabled": true
532},
533{
534"key": "X-RateLimit-Remaining",
535"value": "115",
536"enabled": true
537},
538{
539"key": "X-RateLimit-Reset",
540"value": "1691968334",
541"enabled": true
542},
543{
544"key": "ETag",
545"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
546"enabled": true
547},
548{
549"key": "Vary",
550"value": "Accept-Encoding",
551"enabled": true
552}
553],
554"cookie": [],
555"responseTime": null,
556"body": "{\n \"task_id\": \"fde559f8-3ab8-11ee-be56-0242ac120002\",\n \"step_id\": \"1a379290-3abc-11ee-be56-0242ac120002\",\n \"input\": \"y\",\n \"status\": \"completed\",\n \"output\": \"I am going to use the write_to_file method to write the word 'Washington' to a .txt file\",\n \"artifacts\": [\n ],\n \"is_last\": false\n}"
557},
558{
559"id": "0bca46fd-7401-48fa-b413-6357e53ae19d",
560"name": "mock response",
561"originalRequest": {
562"method": "POST",
563"header": [
564{
565"key": "mock-match",
566"value": "2",
567"type": "text"
568},
569{
570"key": "Content-Type",
571"value": "application/json",
572"type": "text"
573}
574],
575"body": {
576"mode": "raw",
577"raw": "{\n \"input\": \"y\"\n}",
578"options": {
579"raw": {
580"language": "json"
581}
582}
583},
584"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/steps"
585},
586"status": "OK",
587"code": 200,
588"_postman_previewlanguage": "json",
589"header": [
590{
591"key": "Date",
592"value": "Mon, 14 Aug 2023 16:28:55 GMT",
593"enabled": true
594},
595{
596"key": "Content-Type",
597"value": "application/json; charset=utf-8",
598"enabled": true
599},
600{
601"key": "Content-Length",
602"value": "275",
603"enabled": true
604},
605{
606"key": "Connection",
607"value": "keep-alive",
608"enabled": true
609},
610{
611"key": "x-srv-trace",
612"value": "v=1;t=daef761e243c402b",
613"enabled": true
614},
615{
616"key": "x-srv-span",
617"value": "v=1;s=2c0bd88502372360",
618"enabled": true
619},
620{
621"key": "Access-Control-Allow-Origin",
622"value": "*",
623"enabled": true
624},
625{
626"key": "X-RateLimit-Limit",
627"value": "120",
628"enabled": true
629},
630{
631"key": "X-RateLimit-Remaining",
632"value": "115",
633"enabled": true
634},
635{
636"key": "X-RateLimit-Reset",
637"value": "1691968334",
638"enabled": true
639},
640{
641"key": "ETag",
642"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
643"enabled": true
644},
645{
646"key": "Vary",
647"value": "Accept-Encoding",
648"enabled": true
649}
650],
651"cookie": [],
652"responseTime": null,
653"body": "{\n \"task_id\": \"fde559f8-3ab8-11ee-be56-0242ac120002\",\n \"step_id\": \"2a479290-3abc-11ee-be56-0242ac1209c1\",\n \"input\": \"y\",\n \"status\": \"completed\",\n \"output\": \"I used the write_to_file method to write the file test_output.txt\",\n \"artifacts\": [\n {\n \"artifact_id\": \"2ba79290-3abc-11ee-be56-0242ac1209d3\",\n \"agent_created\": true,\n \"uri\": \"file://test_output.txt\"\n }\n ],\n \"is_last\": true\n}"
654}
655]
656},
657{
658"name": "Execute step after completion",
659"event": [
660{
661"listen": "test",
662"script": {
663"id": "26426e07-115e-4841-9887-24fd9dccca2a",
664"exec": [""],
665"type": "text/javascript"
666}
667},
668{
669"listen": "prerequest",
670"script": {
671"id": "3bdd2e35-1745-439e-9ef1-ea2e003ddc42",
672"exec": [""],
673"type": "text/javascript"
674}
675}
676],
677"id": "2db71ce6-f370-4e1e-83de-1990be2026ee",
678"protocolProfileBehavior": {
679"disableBodyPruning": true
680},
681"request": {
682"method": "POST",
683"header": [
684{
685"key": "Content-Type",
686"value": "application/json",
687"type": "text"
688},
689{
690"key": "mock-match",
691"value": "34",
692"type": "text"
693}
694],
695"body": {
696"mode": "raw",
697"raw": "{\n \"input\": \"y\"\n}",
698"options": {
699"raw": {
700"language": "json"
701}
702}
703},
704"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/steps"
705},
706"response": [
707{
708"id": "768252c5-a6aa-4ae5-91a1-253e653a287d",
709"name": "mock response",
710"originalRequest": {
711"method": "POST",
712"header": [
713{
714"key": "mock-match",
715"value": "34",
716"type": "text"
717},
718{
719"key": "Content-Type",
720"value": "application/json",
721"type": "text"
722}
723],
724"body": {
725"mode": "raw",
726"raw": "{\n \"input\": \"y\"\n}",
727"options": {
728"raw": {
729"language": "json"
730}
731}
732},
733"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/steps"
734},
735"status": "OK",
736"code": 200,
737"_postman_previewlanguage": "json",
738"header": [
739{
740"key": "Date",
741"value": "Mon, 14 Aug 2023 16:28:55 GMT",
742"enabled": true
743},
744{
745"key": "Content-Type",
746"value": "application/json; charset=utf-8",
747"enabled": true
748},
749{
750"key": "Content-Length",
751"value": "275",
752"enabled": true
753},
754{
755"key": "Connection",
756"value": "keep-alive",
757"enabled": true
758},
759{
760"key": "x-srv-trace",
761"value": "v=1;t=daef761e243c402b",
762"enabled": true
763},
764{
765"key": "x-srv-span",
766"value": "v=1;s=2c0bd88502372360",
767"enabled": true
768},
769{
770"key": "Access-Control-Allow-Origin",
771"value": "*",
772"enabled": true
773},
774{
775"key": "X-RateLimit-Limit",
776"value": "120",
777"enabled": true
778},
779{
780"key": "X-RateLimit-Remaining",
781"value": "115",
782"enabled": true
783},
784{
785"key": "X-RateLimit-Reset",
786"value": "1691968334",
787"enabled": true
788},
789{
790"key": "ETag",
791"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
792"enabled": true
793},
794{
795"key": "Vary",
796"value": "Accept-Encoding",
797"enabled": true
798}
799],
800"cookie": [],
801"responseTime": null,
802"body": "{\n \"task_id\": \"fde559f8-3ab8-11ee-be56-0242ac120002\",\n \"step_id\": \"2d479290-3abc-11ee-be56-0242ac120b95\",\n \"status\": \"completed\",\n \"output\": \"I am already done with my work.\",\n \"artifacts\": [\n ],\n \"is_last\": true\n}"
803}
804]
805}
806],
807"id": "5ba23d82-afe2-41a2-b782-f41c903d45d6",
808"description": "We ask the agent to write a file in his workspace.",
809"event": [
810{
811"listen": "prerequest",
812"script": {
813"id": "1f74f7f2-ed1c-43d4-88ee-e9688e6caf45",
814"type": "text/javascript",
815"exec": [""]
816}
817},
818{
819"listen": "test",
820"script": {
821"id": "fbbe4b1f-0708-452d-99b7-fe8ad882a7ba",
822"type": "text/javascript",
823"exec": [
824"pm.test(\"Response status code is 200\", function () {",
825" pm.response.to.have.status(200);",
826"});"
827]
828}
829}
830]
831},
832{
833"name": "Tasks",
834"item": [
835{
836"name": "Create a new task",
837"event": [
838{
839"listen": "test",
840"script": {
841"id": "46ca258a-c625-4c17-b413-0c86023e705e",
842"exec": [
843"var jsonData = pm.response.json();",
844"pm.globals.set(\"taskId\", jsonData.task_id);",
845"pm.globals.set(\"taskInput\", JSON.parse(pm.request.body.raw).input);"
846],
847"type": "text/javascript"
848}
849}
850],
851"id": "eb9d0c96-18a1-4e95-8948-9c1894d56409",
852"protocolProfileBehavior": {
853"disableBodyPruning": true,
854"disabledSystemHeaders": {}
855},
856"request": {
857"method": "POST",
858"header": [
859{
860"key": "mock-match",
861"value": "34"
862},
863{
864"key": "Content-Type",
865"value": "application/json",
866"type": "text"
867}
868],
869"body": {
870"mode": "raw",
871"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
872"options": {
873"raw": {
874"language": "json"
875}
876}
877},
878"url": "{{url}}/ap/v1/agent/tasks"
879},
880"response": []
881},
882{
883"name": "Get the task",
884"event": [
885{
886"listen": "test",
887"script": {
888"id": "dae8e511-e80d-478b-81ab-2d66dd6fd5b3",
889"exec": [
890"pm.test(\"Response time is less than 500ms\", function () {\r",
891" pm.expect(pm.response.responseTime).to.be.below(500);\r",
892"});\r",
893"\r",
894"pm.test(\"Content-Type is present\", function () {\r",
895" pm.response.to.have.header(\"Content-Type\");\r",
896"});\r",
897"\r",
898"pm.test(\"Content-Type is application/json\", function () {\r",
899" var contentType = pm.response.headers.get('Content-Type');\r",
900" pm.expect(contentType).to.include('application/json');\r",
901"});\r",
902"\r",
903"pm.test(\"Response has all required properties\", function () {\r",
904" var jsonData = pm.response.json();\r",
905" pm.expect(jsonData).to.have.property('task_id');\r",
906" pm.expect(jsonData).to.have.property('input');\r",
907" pm.expect(jsonData).to.have.property('additional_input');\r",
908" pm.expect(jsonData).to.have.property('artifacts');\r",
909"});\r",
910"\r",
911""
912],
913"type": "text/javascript"
914}
915}
916],
917"id": "f84ed7b1-c97a-4968-a14c-88c231b187fa",
918"protocolProfileBehavior": {
919"disableBodyPruning": true
920},
921"request": {
922"method": "GET",
923"header": [],
924"body": {
925"mode": "raw",
926"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
927"options": {
928"raw": {
929"language": "json"
930}
931}
932},
933"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}"
934},
935"response": [
936{
937"id": "ea9d8d69-ed12-4d2c-85d9-f56028bbc628",
938"name": "mock response",
939"originalRequest": {
940"method": "GET",
941"header": [],
942"body": {
943"mode": "raw",
944"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
945"options": {
946"raw": {
947"language": "json"
948}
949}
950},
951"url": "{{url}}/ap/v1/agent/tasks/{{taskId}}"
952},
953"status": "OK",
954"code": 200,
955"_postman_previewlanguage": "json",
956"header": [
957{
958"key": "Date",
959"value": "Sun, 13 Aug 2023 23:23:05 GMT",
960"enabled": true
961},
962{
963"key": "Content-Type",
964"value": "application/json; charset=utf-8",
965"enabled": true
966},
967{
968"key": "Content-Length",
969"value": "28",
970"enabled": true
971},
972{
973"key": "Connection",
974"value": "keep-alive",
975"enabled": true
976},
977{
978"key": "x-srv-trace",
979"value": "v=1;t=daef761e243c402b",
980"enabled": true
981},
982{
983"key": "x-srv-span",
984"value": "v=1;s=2c0bd88502372360",
985"enabled": true
986},
987{
988"key": "Access-Control-Allow-Origin",
989"value": "*",
990"enabled": true
991},
992{
993"key": "X-RateLimit-Limit",
994"value": "120",
995"enabled": true
996},
997{
998"key": "X-RateLimit-Remaining",
999"value": "115",
1000"enabled": true
1001},
1002{
1003"key": "X-RateLimit-Reset",
1004"value": "1691968334",
1005"enabled": true
1006},
1007{
1008"key": "ETag",
1009"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
1010"enabled": true
1011},
1012{
1013"key": "Vary",
1014"value": "Accept-Encoding",
1015"enabled": true
1016}
1017],
1018"cookie": [],
1019"responseTime": null,
1020"body": "{\n \"input\": \"Write the word 'Washington' to a .txt file\",\n \"additional_input\": null,\n \"task_id\": \"121\",\n \"artifacts\": []\n}"
1021}
1022]
1023},
1024{
1025"name": "Get all the tasks",
1026"event": [
1027{
1028"listen": "test",
1029"script": {
1030"id": "2e4ee6d8-e5d8-4112-be5c-ec8404f38ef0",
1031"exec": [
1032"pm.test(\"Response time is less than 500ms\", function () {",
1033" pm.expect(pm.response.responseTime).to.be.below(500);",
1034"});",
1035"",
1036"pm.test(\"Content-Type is present\", function () {",
1037" pm.response.to.have.header(\"Content-Type\");",
1038"});",
1039"",
1040"pm.test(\"Content-Type is application/json\", function () {",
1041" var contentType = pm.response.headers.get('Content-Type');",
1042" pm.expect(contentType).to.include('application/json');",
1043"});"
1044],
1045"type": "text/javascript"
1046}
1047}
1048],
1049"id": "ca583fa3-bec4-4c73-b989-47f3414a8d51",
1050"protocolProfileBehavior": {
1051"disableBodyPruning": true
1052},
1053"request": {
1054"method": "GET",
1055"header": [],
1056"body": {
1057"mode": "raw",
1058"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
1059"options": {
1060"raw": {
1061"language": "json"
1062}
1063}
1064},
1065"url": "{{url}}/ap/v1/agent/tasks"
1066},
1067"response": []
1068},
1069{
1070"name": "Create a second task",
1071"event": [
1072{
1073"listen": "test",
1074"script": {
1075"id": "2c8c047b-eec5-4015-86a8-0640f3315ce3",
1076"exec": [
1077"var jsonData = pm.response.json();",
1078"pm.globals.set(\"lastTaskId\", jsonData.task_id);"
1079],
1080"type": "text/javascript"
1081}
1082}
1083],
1084"id": "0de5f275-995e-4eb5-b63c-0f2e8996fab1",
1085"protocolProfileBehavior": {
1086"disableBodyPruning": true
1087},
1088"request": {
1089"method": "POST",
1090"header": [
1091{
1092"key": "mock-match",
1093"value": "34"
1094}
1095],
1096"body": {
1097"mode": "raw",
1098"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
1099"options": {
1100"raw": {
1101"language": "json"
1102}
1103}
1104},
1105"url": "{{url}}/ap/v1/agent/tasks"
1106},
1107"response": []
1108},
1109{
1110"name": "Get all the tasks with Pagination",
1111"event": [
1112{
1113"listen": "test",
1114"script": {
1115"id": "697349ba-26c9-431c-a68d-a1c0efeeaeae",
1116"exec": [
1117"var jsonData = pm.response.json();",
1118"",
1119"pm.test(\"Response time is less than 500ms\", function () {",
1120" pm.expect(pm.response.responseTime).to.be.below(500);",
1121"});",
1122"",
1123"pm.test(\"Content-Type is present\", function () {",
1124" pm.response.to.have.header(\"Content-Type\");",
1125"});",
1126"",
1127"pm.test(\"Content-Type is application/json\", function () {",
1128" var contentType = pm.response.headers.get('Content-Type');",
1129" pm.expect(contentType).to.include('application/json');",
1130"});",
1131"",
1132"pm.test(\"Pagination is set\", function () {",
1133" var jsonData = pm.response.json();",
1134" pm.expect(jsonData.pagination).to.be.an('object');",
1135"});",
1136"",
1137"pm.test(\"Page size is 1\", function () {",
1138" var jsonData = pm.response.json();",
1139" pm.expect(jsonData.pagination.page_size).to.eql(1);",
1140"});",
1141"",
1142"pm.test(\"Items is an array with one item\", function () {",
1143" var jsonData = pm.response.json();",
1144" pm.expect(jsonData.tasks).to.be.an('array').that.has.lengthOf(1);",
1145"});",
1146"",
1147"",
1148"pm.test(\"Response length respects page_size\", function() {",
1149" var jsonData = pm.response.json();",
1150" pm.expect(jsonData.tasks.length).to.be.at.most(1);",
1151"});",
1152"",
1153"if (jsonData.items && jsonData.items.length > 0) {",
1154" if (pm.variables.has(\"lastTaskId\") && pm.variables.get(\"page\") > 1) {",
1155" pm.test(\"First task of page \" + pm.variables.get(\"page\") + \" is not the last task of page \" + (pm.variables.get(\"page\") - 1), function() {",
1156" var jsonData = pm.response.json();",
1157" pm.expect(jsonData.items[0].task_id).to.not.equal(pm.variables.get(\"lastTaskId\"));",
1158" });",
1159" }",
1160" if (jsonData.items.length > 0) {",
1161" pm.variables.set(\"lastTaskId\", jsonData.items[jsonData.items.length - 1].task_id);",
1162" }",
1163"}"
1164],
1165"type": "text/javascript"
1166}
1167}
1168],
1169"id": "f41e04c1-b266-4e90-909e-ebb0657958d9",
1170"protocolProfileBehavior": {
1171"disableBodyPruning": true
1172},
1173"request": {
1174"method": "GET",
1175"header": [],
1176"body": {
1177"mode": "raw",
1178"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
1179"options": {
1180"raw": {
1181"language": "json"
1182}
1183}
1184},
1185"url": {
1186"raw": "{{url}}/ap/v1/agent/tasks?page_size=1¤t_page=1",
1187"host": ["{{url}}/ap/v1"],
1188"path": ["agent", "tasks"],
1189"query": [
1190{
1191"key": "page_size",
1192"value": "1"
1193},
1194{
1195"key": "current_page",
1196"value": "1"
1197}
1198]
1199}
1200},
1201"response": []
1202}
1203],
1204"id": "4b743f46-e582-4565-ac7d-c6446a710ee1",
1205"description": "Create tasks and consumes them.",
1206"event": [
1207{
1208"listen": "prerequest",
1209"script": {
1210"id": "7f174c78-2068-4351-a64c-bd4c115470e8",
1211"type": "text/javascript",
1212"exec": [""]
1213}
1214},
1215{
1216"listen": "test",
1217"script": {
1218"id": "ef296737-8c06-47ed-90c3-bfe882c1aa40",
1219"type": "text/javascript",
1220"exec": [
1221"pm.test(\"Response status code is 200\", function () {",
1222" pm.response.to.have.status(200);",
1223"});"
1224]
1225}
1226}
1227]
1228},
1229{
1230"name": "Artifacts",
1231"item": [
1232{
1233"name": "Create a new task",
1234"event": [
1235{
1236"listen": "test",
1237"script": {
1238"id": "65ad57a3-b776-4d7c-86f9-be6fbf17cac6",
1239"exec": [
1240"var jsonData = pm.response.json();",
1241"pm.globals.set(\"task_id\", jsonData.task_id);"
1242],
1243"type": "text/javascript"
1244}
1245}
1246],
1247"id": "1ee1eee8-cc2d-43a2-a6e1-7168b0559c45",
1248"protocolProfileBehavior": {
1249"disableBodyPruning": true
1250},
1251"request": {
1252"method": "POST",
1253"header": [],
1254"body": {
1255"mode": "raw",
1256"raw": "{\n \"input\": \"Write the word 'Washington' to a .txt file\"\n}",
1257"options": {
1258"raw": {
1259"language": "json"
1260}
1261}
1262},
1263"url": "{{url}}/ap/v1/agent/tasks"
1264},
1265"response": []
1266},
1267{
1268"name": "Upload Artifact",
1269"event": [
1270{
1271"listen": "test",
1272"script": {
1273"id": "6cf7a2c4-1b8a-4c11-8c1a-6b56b2eb80e6",
1274"exec": [
1275"var jsonData = pm.response.json();",
1276"pm.globals.set(\"artifact_id\", jsonData.artifact_id);"
1277],
1278"type": "text/javascript"
1279}
1280}
1281],
1282"id": "e71fee13-11cb-4b08-a4bb-c9c0f971efed",
1283"protocolProfileBehavior": {
1284"disableBodyPruning": true
1285},
1286"request": {
1287"method": "POST",
1288"header": [
1289{
1290"key": "Content-Type",
1291"value": "multipart/form-data"
1292}
1293],
1294"body": {
1295"mode": "formdata",
1296"formdata": [
1297{
1298"key": "file",
1299"type": "file",
1300"src": "test_output.txt"
1301}
1302]
1303},
1304"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/artifacts"
1305},
1306"response": []
1307},
1308{
1309"name": "Download Artifact",
1310"event": [
1311{
1312"listen": "test",
1313"script": {
1314"id": "82829e0a-f8c7-4925-b28c-0513b018e83e",
1315"exec": [""],
1316"type": "text/javascript"
1317}
1318}
1319],
1320"id": "b002580c-0d48-42c9-83e0-5fb5eaed38ce",
1321"protocolProfileBehavior": {
1322"disableBodyPruning": true
1323},
1324"request": {
1325"method": "GET",
1326"header": [
1327{
1328"key": "mock-match",
1329"value": "11",
1330"type": "text"
1331}
1332],
1333"body": {
1334"mode": "raw",
1335"raw": "",
1336"options": {
1337"raw": {
1338"language": "json"
1339}
1340}
1341},
1342"url": "{{url}}/ap/v1/agent/tasks/{{task_id}}/artifacts/{{artifact_id}}"
1343},
1344"response": [
1345{
1346"id": "ade2dd37-0f84-45f0-881e-2224636a4956",
1347"name": "mock response",
1348"originalRequest": {
1349"method": "GET",
1350"header": [
1351{
1352"key": "mock-match",
1353"value": "11",
1354"type": "text"
1355}
1356],
1357"body": {
1358"mode": "raw",
1359"raw": "",
1360"options": {
1361"raw": {
1362"language": "json"
1363}
1364}
1365},
1366"url": "{{url}}/ap/v1/agent/tasks/{{taskId}}/artifacts/{{artifactId}}"
1367},
1368"status": "OK",
1369"code": 200,
1370"_postman_previewlanguage": "text",
1371"header": [
1372{
1373"key": "Date",
1374"value": "Mon, 14 Aug 2023 16:28:55 GMT",
1375"enabled": true
1376},
1377{
1378"key": "Content-Type",
1379"value": "application/json; charset=utf-8",
1380"enabled": true
1381},
1382{
1383"key": "Content-Length",
1384"value": "275",
1385"enabled": true
1386},
1387{
1388"key": "Connection",
1389"value": "keep-alive",
1390"enabled": true
1391},
1392{
1393"key": "x-srv-trace",
1394"value": "v=1;t=daef761e243c402b",
1395"enabled": true
1396},
1397{
1398"key": "x-srv-span",
1399"value": "v=1;s=2c0bd88502372360",
1400"enabled": true
1401},
1402{
1403"key": "Access-Control-Allow-Origin",
1404"value": "*",
1405"enabled": true
1406},
1407{
1408"key": "X-RateLimit-Limit",
1409"value": "120",
1410"enabled": true
1411},
1412{
1413"key": "X-RateLimit-Remaining",
1414"value": "115",
1415"enabled": true
1416},
1417{
1418"key": "X-RateLimit-Reset",
1419"value": "1691968334",
1420"enabled": true
1421},
1422{
1423"key": "ETag",
1424"value": "W/\"96-S/5iQ2y1qqIInh5BwoPc+chvDJU\"",
1425"enabled": true
1426},
1427{
1428"key": "Vary",
1429"value": "Accept-Encoding",
1430"enabled": true
1431}
1432],
1433"cookie": [],
1434"responseTime": null,
1435"body": "Washington"
1436}
1437]
1438}
1439],
1440"id": "48e93b55-d463-452f-9d56-f59ee5e95060",
1441"description": "Create Artifacts and consumes them.",
1442"event": [
1443{
1444"listen": "prerequest",
1445"script": {
1446"id": "61be92ef-c1cd-4f2a-a77c-78e5913ea299",
1447"type": "text/javascript",
1448"exec": [""]
1449}
1450},
1451{
1452"listen": "test",
1453"script": {
1454"id": "7dcedb1e-4f42-48b1-ac9b-fd3b842b428b",
1455"type": "text/javascript",
1456"exec": [
1457"pm.test(\"Response status code is 200\", function () {",
1458" pm.response.to.have.status(200);",
1459"});"
1460]
1461}
1462}
1463]
1464}
1465],
1466"event": [
1467{
1468"listen": "prerequest",
1469"script": {
1470"id": "7dd8bbee-357a-44fd-b891-46bcc3a8a41c",
1471"type": "text/javascript",
1472"exec": [""]
1473}
1474},
1475{
1476"listen": "test",
1477"script": {
1478"id": "b5f22749-138a-45fe-b6c7-79fe5cf06017",
1479"type": "text/javascript",
1480"exec": [""]
1481}
1482}
1483]
1484}
1485