My agentic slop goes here. Not intended for anyone else!
1(** Incoming messages from the Claude CLI.
2
3 This module defines a discriminated union of all possible message types
4 that can be received from the Claude CLI, with a single jsont codec.
5
6 The codec uses the "type" field to discriminate between message types:
7 - "user", "assistant", "system", "result" -> Message variant
8 - "control_response" -> Control_response variant
9 - "control_request" -> Control_request variant
10
11 This provides a clean, type-safe way to decode incoming messages in a single
12 operation, avoiding the parse-then-switch-then-parse pattern. *)
13
14(** Control request types for incoming control_request messages *)
15module Control_request : sig
16 (** Can use tool permission request *)
17 module Can_use_tool : sig
18 type t
19
20 val tool_name : t -> string
21 val input : t -> Jsont.json
22 val permission_suggestions : t -> Jsont.json list
23 val jsont : t Jsont.t
24 end
25
26 (** Hook callback request *)
27 module Hook_callback : sig
28 type t
29
30 val callback_id : t -> string
31 val input : t -> Jsont.json
32 val tool_use_id : t -> string option
33 val jsont : t Jsont.t
34 end
35
36 (** Request payload - discriminated by subtype *)
37 type request =
38 | Can_use_tool of Can_use_tool.t
39 | Hook_callback of Hook_callback.t
40 | Unknown of string * Jsont.json
41
42 (** Full control request message *)
43 type t
44
45 val request_id : t -> string
46 val request : t -> request
47 val subtype : t -> string
48 val jsont : t Jsont.t
49end
50
51type t =
52 | Message of Message.t
53 | Control_response of Sdk_control.control_response
54 | Control_request of Control_request.t
55
56val jsont : t Jsont.t
57(** Codec for incoming messages. Uses the "type" field to discriminate. *)
58
59val pp : Format.formatter -> t -> unit
60(** [pp fmt t] pretty-prints the incoming message. *)