OCaml Claude SDK using Eio and Jsont
at main 49 lines 1.8 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Control messages for Claude session management. 7 8 Control messages are used to manage the interaction flow with Claude, 9 including session control, cancellation requests, and other operational 10 commands. *) 11 12val src : Logs.Src.t 13(** The log source for control message operations *) 14 15type t 16(** The type of control messages. *) 17 18val jsont : t Jsont.t 19(** [jsont] is the jsont codec for control messages. *) 20 21val create : request_id:string -> subtype:string -> data:Jsont.json -> t 22(** [create ~request_id ~subtype ~data] creates a new control message. 23 @param request_id Unique identifier for this control request 24 @param subtype The specific type of control message 25 @param data Additional JSON data for the control message *) 26 27val request_id : t -> string 28(** [request_id t] returns the unique request identifier. *) 29 30val subtype : t -> string 31(** [subtype t] returns the control message subtype. *) 32 33val data : t -> Jsont.json 34(** [data t] returns the additional data associated with the control message. *) 35 36val to_json : t -> Jsont.json 37(** [to_json t] converts the control message to its JSON representation. *) 38 39val of_json : Jsont.json -> t 40(** [of_json json] parses a control message from JSON. 41 @raise Invalid_argument if the JSON is not a valid control message. *) 42 43(** {1 Logging} *) 44 45val log_received : t -> unit 46(** [log_received t] logs that a control message was received. *) 47 48val log_sending : t -> unit 49(** [log_sending t] logs that a control message is being sent. *)