You can search for identifiers within the package.
in-package search v0.2.0
Source file a2a_client_testing.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167openA2a_client(* Payload encoders of one protocol version. *)typecodec={stream_response:Stream_response.t->Yojson.Safe.t;send_message_response:Send_message_response.t->Yojson.Safe.t;task:Task.t->Yojson.Safe.t;}letcodec:Protocol_version.t->codec=function|V1_0->{stream_response=Codec.stream_response_to_json;send_message_response=Codec.send_message_response_to_json;task=Codec.task_to_json}|V0_3->{stream_response=Codec_v0_3.stream_response_to_json;send_message_response=Codec_v0_3.send_message_response_to_json;task=Codec_v0_3.task_to_json}(* What an encoder needs to know about the request being answered. *)typewire={codec:codec;binding:Protocol_binding.t;id:Yojson.Safe.t;(* the JSON-RPC request id, or [`Null] *)}letrequest_json(req:Transport.request)=matchreq.bodywith|None->None|Someb->(trySome(Yojson.Safe.from_stringb)withYojson.Json_error_->None)letmemberk=functionSome(`Assockvs)->List.assoc_optkkvs|_->Noneletrpc_methodreq=matchmember"method"(request_jsonreq)withSome(`Stringm)->Somem|_->Noneletparamsreq=letjson=request_jsonreqinmatch(member"jsonrpc"json,json)with|Some_,_->Option.value(member"params"json)~default:`Null|None,Somej->j|None,None->`Nullletresultw(json:Yojson.Safe.t):Yojson.Safe.t=matchw.bindingwith|Jsonrpc->`Assoc[("jsonrpc",`String"2.0");("id",w.id);("result",json)]|Http_json->jsonleterrorw~statuscodemessage:Yojson.Safe.t=matchw.bindingwith|Jsonrpc->`Assoc[("jsonrpc",`String"2.0");("id",w.id);("error",`Assoc[("code",`Int(Error.Code.to_intcode));("message",`Stringmessage)])]|Http_json->(* Without a known reason, the client reads the error code from [code]. *)letcode,details=matchError.Code.to_reasoncodewith|None->(Error.Code.to_intcode,[])|Somereason->(status,[`Assoc[("@type",`String"type.googleapis.com/google.rpc.ErrorInfo");("reason",`Stringreason);("domain",`String"a2a-protocol.org")]])in`Assoc[("error",`Assoc[("code",`Intcode);("message",`Stringmessage);("details",`Listdetails)])](* The body of a response, as the client will read it. *)typechunk=Dataofstring|Pauseoffloat|Break|StallmoduleBody=structtypet={mutablechunks:chunklist;mutablepending:string;clock:Eio.Time.Mono.tyEio.Resource.t}letread_methods=[]letrecsingle_readtbuf=ift.pending<>""thenbeginletn=min(Cstruct.lengthbuf)(String.lengtht.pending)inCstruct.blit_from_stringt.pending0buf0n;t.pending<-String.subt.pendingn(String.lengtht.pending-n);nendelsematcht.chunkswith|[]->raiseEnd_of_file|c::rest->(t.chunks<-rest;matchcwith|Datas->t.pending<-s;single_readtbuf|Paused->Eio.Time.Mono.sleept.clockd;single_readtbuf|Break->failwith"connection reset (A2a_client_testing.Step.drop)"|Stall->Eio.Fiber.await_cancel())endletbody~clockchunks:Eio.Flow.source_tyEio.Resource.t=Eio.Resource.T({Body.chunks;pending="";clock},Eio.Flow.Pi.source(moduleBody))letssejson=Data("data: "^Yojson.Safe.to_stringjson^"\n\n")moduleStep=structtypet=wire->chunkleteventevw=sse(resultw(w.codec.stream_responseev))leterrorcodemessagew=sse(errorw~status:400codemessage)letraws_=Datasletsleepd_=Pausedletdrop_=Breaklethang_=StallendmoduleReply=structtyperesponse={status:int;content_type:string;chunks:chunklist}typet={delay:float;respond:wire->responseoption}letnowrespond={delay=0.;respond=(funw->Some(respondw))}letjson?(status=200)j={status;content_type="application/json";chunks=[Data(Yojson.Safe.to_stringj)]}letstreamsteps=now(funw->{status=200;content_type="text/event-stream";chunks=List.map(funs->sw)steps})letsend_message_responser=now(funw->json(resultw(w.codec.send_message_responser)))lettaskt=now(funw->json(resultw(w.codec.taskt)))leterror?(status=400)codemessage=now(funw->letstatus=matchw.bindingwithJsonrpc->200|Http_json->statusinjson~status(errorw~statuscodemessage))lethttp~status?(content_type="text/plain")body=now(fun_->{status;content_type;chunks=[Databody]})letrefuse={delay=0.;respond=(fun_->None)}letafterdr={rwithdelay=r.delay+.d}endtypeagent={codec:codec;binding:Protocol_binding.t;clock:Eio.Time.Mono.tyEio.Resource.t;handler:Transport.request->Reply.t;mutablereceived:Transport.requestlist;(* newest first *)}letagent?(protocol=Protocol.default)~clockhandler={codec=codec(Protocol.versionprotocol);binding=Protocol.bindingprotocol;clock=(clock:>Eio.Time.Mono.tyEio.Resource.t);handler;received=[]}letrequestsa=List.reva.receivedlettransporta:Transport.t=fun~sw:_req->a.received<-req::a.received;letreply=a.handlerreqinifreply.delay>0.thenEio.Time.Mono.sleepa.clockreply.delay;letid=Option.value(member"id"(request_jsonreq))~default:`Nullinmatchreply.respond{codec=a.codec;binding=a.binding;id}with|None->failwith"connection refused (A2a_client_testing.Reply.refuse)"|Somer->{Transport.status=r.status;headers=[("content-type",r.content_type)];body=body~clock:a.clockr.chunks}