OCaml Claude SDK using Eio and Jsont

proto fixes

+16 -11
+1 -1
lib/client.ml
··· 92 92 (if Permissions.Decision.is_allow decision then "ALLOW" else "DENY")); 93 93 94 94 (* Convert permission decision to proto result *) 95 - let proto_result = Permissions.Decision.to_proto_result decision in 95 + let proto_result = Permissions.Decision.to_proto_result ~original_input:input decision in 96 96 97 97 (* Encode to JSON *) 98 98 let response_data =
+4 -2
lib/permissions.ml
··· 75 75 76 76 let deny_interrupt = function Allow _ -> false | Deny { interrupt; _ } -> interrupt 77 77 78 - let to_proto_result (t : t) : Proto.Permissions.Result.t = 78 + let to_proto_result ~original_input (t : t) : Proto.Permissions.Result.t = 79 79 match t with 80 80 | Allow { updated_input } -> 81 81 let updated_input_json = 82 - Option.map Tool_input.to_json updated_input 82 + match updated_input with 83 + | Some input -> Some (Tool_input.to_json input) 84 + | None -> Some (Tool_input.to_json original_input) (* Return original when not modified *) 83 85 in 84 86 Proto.Permissions.Result.allow ?updated_input:updated_input_json () 85 87 | Deny { message; interrupt } ->
+3 -2
lib/permissions.mli
··· 92 92 val deny_interrupt : t -> bool 93 93 (** [deny_interrupt t] returns whether to interrupt if the decision is deny. *) 94 94 95 - val to_proto_result : t -> Proto.Permissions.Result.t 96 - (** [to_proto_result t] converts to the protocol result representation. *) 95 + val to_proto_result : original_input:Tool_input.t -> t -> Proto.Permissions.Result.t 96 + (** [to_proto_result ~original_input t] converts to the protocol result representation. 97 + When the decision allows without modification, the original_input is returned. *) 97 98 end 98 99 99 100 (** {1 Permission Context} *)
+8 -6
proto/permissions.ml
··· 72 72 { tool_name; rule_content; unknown } 73 73 in 74 74 Jsont.Object.map ~kind:"Rule" make 75 - |> Jsont.Object.mem "tool_name" Jsont.string ~enc:tool_name 76 - |> Jsont.Object.opt_mem "rule_content" Jsont.string ~enc:rule_content 75 + |> Jsont.Object.mem "toolName" Jsont.string ~enc:tool_name 76 + |> Jsont.Object.opt_mem "ruleContent" Jsont.string ~enc:rule_content 77 77 |> Jsont.Object.keep_unknown Unknown.mems ~enc:unknown 78 78 |> Jsont.Object.finish 79 79 end ··· 193 193 Allow { updated_input; updated_permissions; unknown } 194 194 in 195 195 Jsont.Object.map ~kind:"AllowRecord" make 196 - |> Jsont.Object.opt_mem "updated_input" Jsont.json ~enc:(function 197 - | Allow { updated_input; _ } -> updated_input 198 - | _ -> None) 199 - |> Jsont.Object.opt_mem "updated_permissions" (Jsont.list Update.jsont) 196 + |> Jsont.Object.mem "updatedInput" (Jsont.option Jsont.json) 197 + ~enc:(function 198 + | Allow { updated_input; _ } -> updated_input 199 + | _ -> None) 200 + ~dec_absent:None 201 + |> Jsont.Object.opt_mem "updatedPermissions" (Jsont.list Update.jsont) 200 202 ~enc:(function 201 203 | Allow { updated_permissions; _ } -> updated_permissions 202 204 | _ -> None)