OCaml Claude SDK using Eio and Jsont

metadata

+473 -5
+17 -1
.gitignore
··· 1 - _build 1 + # OCaml build artifacts 2 + _build/ 3 + *.install 4 + *.merlin 5 + 6 + # Third-party sources (fetch locally with opam source) 7 + third_party/ 8 + 9 + # Editor and OS files 10 + .DS_Store 11 + *.swp 12 + *~ 13 + .vscode/ 14 + .idea/ 15 + 16 + # Opam local switch 17 + _opam/
+53
.tangled/workflows/build.yml
··· 1 + when: 2 + - event: ["push", "pull_request"] 3 + branch: ["main"] 4 + 5 + engine: nixery 6 + 7 + dependencies: 8 + nixpkgs: 9 + - shell 10 + - stdenv 11 + - findutils 12 + - binutils 13 + - libunwind 14 + - ncurses 15 + - opam 16 + - git 17 + - gawk 18 + - gnupatch 19 + - gnum4 20 + - gnumake 21 + - gnutar 22 + - gnused 23 + - gnugrep 24 + - diffutils 25 + - gzip 26 + - bzip2 27 + - gcc 28 + - ocaml 29 + - pkg-config 30 + 31 + steps: 32 + - name: opam 33 + command: | 34 + opam init --disable-sandboxing -a -y 35 + - name: repo 36 + command: | 37 + opam repo add aoah https://tangled.org/anil.recoil.org/aoah-opam-repo.git 38 + - name: switch 39 + command: | 40 + opam install . --confirm-level=unsafe-yes --deps-only 41 + - name: build 42 + command: | 43 + opam exec -- dune build 44 + - name: switch-test 45 + command: | 46 + opam install . --confirm-level=unsafe-yes --deps-only --with-test 47 + - name: test 48 + command: | 49 + opam exec -- dune runtest --verbose 50 + - name: doc 51 + command: | 52 + opam install -y odoc 53 + opam exec -- dune build @doc
+15
LICENSE.md
··· 1 + ISC License 2 + 3 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> 4 + 5 + Permission to use, copy, modify, and distribute this software for any 6 + purpose with or without fee is hereby granted, provided that the above 7 + copyright notice and this permission notice appear in all copies. 8 + 9 + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+7 -2
claude.opam
··· 3 3 synopsis: "OCaml client library for Claude Code" 4 4 description: 5 5 "An Eio-based OCaml library for interacting with the Claude CLI using JSON streaming" 6 + maintainer: ["Anil Madhavapeddy <anil@recoil.org>"] 7 + authors: ["Anil Madhavapeddy"] 8 + license: "ISC" 9 + homepage: "https://tangled.org/@anil.recoil.org/claudeio" 10 + bug-reports: "https://tangled.org/@anil.recoil.org/claudeio/issues" 6 11 depends: [ 7 12 "dune" {>= "3.18"} 8 - "ocaml" 13 + "ocaml" {>= "5.1.0"} 9 14 "eio" 10 15 "fmt" 11 16 "logs" 12 17 "jsont" {>= "0.2.0"} 13 18 "jsont_bytesrw" {>= "0.2.0"} 14 - "alcotest" {with-test} 15 19 "odoc" {with-doc} 20 + "alcotest" {with-test & >= "1.7.0"} 16 21 ] 17 22 build: [ 18 23 ["dune" "subst"] {dev}
+4
dune
··· 1 + ; Root dune file 2 + 3 + ; Ignore third_party directory (for fetched dependency sources) 4 + (data_only_dirs third_party)
+12 -2
dune-project
··· 1 1 (lang dune 3.18) 2 + 2 3 (name claude) 4 + 3 5 (generate_opam_files true) 4 6 7 + (license ISC) 8 + (authors "Anil Madhavapeddy") 9 + (homepage "https://tangled.org/@anil.recoil.org/claudeio") 10 + (maintainers "Anil Madhavapeddy <anil@recoil.org>") 11 + (bug_reports "https://tangled.org/@anil.recoil.org/claudeio/issues") 12 + (maintenance_intent "(latest)") 13 + 5 14 (package 6 15 (name claude) 7 16 (synopsis "OCaml client library for Claude Code") 8 17 (description "An Eio-based OCaml library for interacting with the Claude CLI using JSON streaming") 9 18 (depends 10 - ocaml 19 + (ocaml (>= 5.1.0)) 11 20 eio 12 21 fmt 13 22 logs 14 23 (jsont (>= 0.2.0)) 15 24 (jsont_bytesrw (>= 0.2.0)) 16 - (alcotest :with-test))) 25 + (odoc :with-doc) 26 + (alcotest (and :with-test (>= 1.7.0)))))
+5
lib/claude.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 module Err = Err 2 7 module Client = Client 3 8 module Options = Options
+5
lib/claude.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** OCaml Eio library for Claude Code CLI. 2 7 3 8 This library provides an interface to the Claude Code command-line interface
+5
lib/client.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.client" ~doc:"Claude client" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/client.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Client interface for interacting with Claude. 2 7 3 8 This module provides the high-level client API for sending messages to
+5
lib/content_block.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.content_block" ~doc:"Claude content blocks" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/content_block.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Content blocks in messages. Opaque types without wire concerns. 2 7 3 8 This module provides opaque wrapper types around the proto content block
+5
lib/control.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.control" ~doc:"Claude control messages" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/control.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Control messages for Claude session management. 2 7 3 8 Control messages are used to manage the interaction flow with Claude,
+5
lib/err.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Error handling for claudeio. *) 2 7 3 8 type t =
+5
lib/err.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Error handling for claudeio. *) 2 7 3 8 type t =
+5
lib/handler.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Object-oriented response handler implementations. *) 2 7 3 8 (** {1 Handler Interface} *)
+5
lib/handler.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Object-oriented response handler with sensible defaults. 2 7 3 8 This module provides an object-oriented interface for handling response
+5
lib/hooks.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.hooks" ~doc:"Claude hooks system" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/hooks.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Fully typed hook callbacks. 2 7 3 8 Hooks allow you to intercept and control events in Claude Code sessions,
+5
lib/incoming.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = 2 7 Logs.Src.create "claude.incoming" ~doc:"Incoming messages from Claude CLI" 3 8
+5
lib/incoming.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Incoming messages from the Claude CLI. 2 7 3 8 This module defines a discriminated union of all possible message types that
+5
lib/message.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.message" ~doc:"Claude messages" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/message.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Messages exchanged with Claude. Opaque types. 2 7 3 8 This module provides opaque message types that wrap the proto types but hide
+5
lib/model.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = 2 7 [ `Sonnet_4_5 3 8 | `Sonnet_4
+5
lib/model.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Claude AI model identifiers. 2 7 3 8 This module provides type-safe model identifiers based on the Python SDK's
+5
lib/options.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claudeio.options" ~doc:"Claude configuration options" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/options.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Configuration options for Claude sessions. 2 7 3 8 This module provides comprehensive configuration options for controlling
+5
lib/permissions.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.permission" ~doc:"Claude permission system" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/permissions.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Permission control for tool usage. 2 7 3 8 This module provides a permission system for controlling which tools Claude
+5
lib/response.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 module Text = struct 2 7 type t = Content_block.Text.t 3 8
+5
lib/response.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** High-level response events from Claude. 2 7 3 8 This module provides a unified interface for handling different types of
+5
lib/sdk_control.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = 2 7 Logs.Src.create "claude.sdk_control" ~doc:"Claude SDK control protocol" 3 8
+5
lib/sdk_control.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** SDK Control Protocol for Claude. 2 7 3 8 This module defines the typed SDK control protocol for bidirectional
+5
lib/server_info.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Server capabilities and metadata. *) 2 7 3 8 type t = {
+5
lib/server_info.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Server capabilities and metadata. 2 7 3 8 This module provides a high-level interface for querying server capabilities
+5
lib/structured_output.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = Logs.Src.create "claude.structured_output" ~doc:"Structured output" 2 7 3 8 module Log = (val Logs.src_log src : Logs.LOG)
+5
lib/structured_output.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Structured output configuration using JSON Schema. 2 7 3 8 This module provides structured output support for Claude, allowing you to
+5
lib/tool_input.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Opaque tool input with typed accessors. *) 2 7 3 8 type t = Jsont.json
+5
lib/tool_input.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Opaque tool input with typed accessors. 2 7 3 8 Tool inputs are JSON objects representing parameters passed to tools. This
+5
lib/transport.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src = Logs.Src.create "claude.transport" ~doc:"Claude transport layer"
+5
lib/transport.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 val src : Logs.Src.t 2 7 (** The log source for transport operations *) 3 8
+5
lib/unknown.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Unknown fields for capturing extra JSON object members. 2 7 3 8 This module provides a type and utilities for preserving unknown/extra
+5
lib/unknown.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Unknown fields for capturing extra JSON object members. 2 7 3 8 This module provides a type and utilities for preserving unknown/extra
+5
proto/content_block.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 module Text = struct 2 7 type t = { text : string; unknown : Unknown.t } 3 8
+5
proto/content_block.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Content blocks for Claude messages wire format. 2 7 3 8 This module defines the wire format types for content blocks that can appear
+5
proto/control.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Control protocol wire format for SDK communication. *) 2 7 3 8 module Request = struct
+5
proto/control.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Control protocol wire format for SDK communication. 2 7 3 8 This module defines the wire format for the SDK control protocol used for
+5
proto/hooks.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Claude Code Hooks System - Wire Format 2 7 3 8 This module defines the wire format for hook configuration. *)
+5
proto/hooks.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Claude Code Hooks System - Wire Format 2 7 3 8 This module defines the wire format for hook configuration. Hooks allow you
+5
proto/incoming.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Incoming messages from Claude CLI. 2 7 3 8 This uses the Control module's request_envelope_jsont and
+5
proto/incoming.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Incoming messages from the Claude CLI. 2 7 3 8 This module defines a discriminated union of all possible message types that
+5
proto/message.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 module User = struct 2 7 type content = String of string | Blocks of Content_block.t list 3 8 type t = { content : content; unknown : Unknown.t }
+5
proto/message.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Messages exchanged with Claude wire format. 2 7 3 8 This module defines the wire format types for messages that can be sent to
+5
proto/model.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 type t = 2 7 [ `Sonnet_4_5 3 8 | `Sonnet_4
+5
proto/model.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Claude AI model identifiers for protocol encoding. 2 7 3 8 This module provides type-safe model identifiers with JSON encoding/decoding
+5
proto/options.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Wire format for Claude configuration options. *) 2 7 3 8 (** Setting sources *)
+5
proto/options.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Wire format for Claude configuration options. 2 7 3 8 This module provides the protocol-level wire format encoding/decoding for
+5
proto/outgoing.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Outgoing messages to Claude CLI. 2 7 3 8 This uses the Message.jsont for conversation messages and Control envelope
+5
proto/outgoing.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Outgoing messages to the Claude CLI. 2 7 3 8 This module provides encoding for all message types that can be sent to the
+5
proto/permissions.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Permission system wire format for Claude tool invocations. 2 7 3 8 This module provides the wire format encoding/decoding for permission types
+5
proto/permissions.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Permission system wire format for Claude tool invocations. 2 7 3 8 This module provides the wire format encoding/decoding for permission types
+5
proto/structured_output.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Structured output wire format implementation. *) 2 7 3 8 type t = { json_schema : Jsont.json }
+5
proto/structured_output.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Structured output configuration using JSON Schema. 2 7 3 8 This module provides the wire format types for structured output support,
+5
proto/unknown.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Unknown fields for preserving extra JSON object members during 2 7 round-tripping. 3 8
+5
proto/unknown.mli
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Unknown fields for preserving extra JSON object members during 2 7 round-tripping. 3 8
+5
test/advanced_config_demo.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Advanced Configuration Demo 2 7 3 8 This example demonstrates the advanced configuration options available
+5
test/camel_jokes.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src = Logs.Src.create "camel_jokes" ~doc:"Camel joke competition"
+5
test/discovery_demo.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src =
+5
test/dynamic_control_demo.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Claude 2 7 open Eio.Std 3 8
+5
test/hooks_example.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src = Logs.Src.create "hooks_example" ~doc:"Hooks example"
+5
test/permission_demo.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src =
+5
test/simple_permission_test.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src = Logs.Src.create "simple_permission_test" ~doc:"Simple permission test"
+5
test/simulated_permissions.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 let src = 2 7 Logs.Src.create "simulated_permissions" 3 8 ~doc:"Simulated permission demonstration"
+5
test/structured_output_demo.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Example demonstrating structured output with JSON Schema *) 2 7 3 8 module C = Claude
+5
test/structured_output_simple.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Simple example showing structured output with explicit JSON Schema *) 2 7 3 8 module C = Claude
+5
test/test_incoming.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (** Test the Incoming message codec *) 2 7 3 8 let test_decode_user_message () =
+5
test/test_json_utils.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 (* Helper functions for JSON operations in tests using jsont codecs *) 2 7 3 8 let to_string ?(minify = false) json =
+5
test/test_permissions.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 1 6 open Eio.Std 2 7 3 8 let src = Logs.Src.create "test_permissions" ~doc:"Permission callback test"