Library
Library overview
Find OCaml integration, subsystem maps, and repository module references.
View Markdown source ↗This directory holds free-form Markdown files that go beyond inline
*.mli comments. They capture design notes, usage examples, historical
decisions, and any other background that helps a human (or an indexing tool)
understand the code-base.
Choose an integration path
Section titled “Choose an integration path”Start with a subsystem guide, then follow its exact interfaces. The complete module index below also links to repository-only internals and historical notes; those links are not a claim of website publication or runnable examples.
| Task | Entry point | Boundary |
|---|---|---|
| Embed an agent or client | Agent-core integration, client library | Hosts own execution; client projections do not own durable state. |
| Register an OCaml tool | Custom tools | Registration and progress callbacks do not create authorization or output filtering. |
| Consume MCP tools | MCP client, HTTP transport, OAuth cache | Maintained outbound tools are separate from deprecated prompt serving. |
| Compose ChatMD files | Source loader, imports | Captured source closures and relative paths have host-specific semantics. |
| Program a moderator | Runtime guide, language internals | UI capabilities and automatic work limits depend on the host. |
| Manage conversation size | Compaction, archives | Summaries are lossy; an archive is not a running continuation. |
| Add retrieval | Search setup | Embedding-backed agent retrieval is separate from website search. |
| Refine prompts | mp-refine-run | Local and paid strategies differ; the broad older library overview needs API reconciliation. |
| Reuse additional components | Embedding and caching | Keep identity-bearing histories and host-owned resources. |
| Maintain older file-backed sessions | Prompt sessions, snapshot store | Compatibility APIs do not administer daemon sessions. |
| Extend the terminal UI | Application hosts, controller, display types | Editor state is local; native/daemon mutations go through the actor. |
Naming rules
Section titled “Naming rules”-
Use the same basename as the module you’re describing plus the suffix
.doc.md– e.g.vector_db.doc.md → relates to `vector_db.ml` / `vector_db.mli` -
Longer, thematic docs are welcome; pick a concise slug such as
embedding_pipeline.doc.md. -
Keep language plain Markdown; no special tooling required.
These Markdown sidecars are repository documentation for users and maintainers.
They are not automatically shipped as generated odoc API pages or installed
package docs. Public .mli comments define exact APIs; sidecars explain design and
integration. Historical/TODO material must be labelled, not presented as current
behavior. Start at the documentation index or
agent library map.
When adding a new module, consider whether a side-car .doc.md would help
future readers. If so, drop it here under the same sub-directory structure
as the source code.
Browse library references
Section titled “Browse library references”Additional topic references and historical notes
Section titled “Additional topic references and historical notes”These pages live outside lib/ but cover related implementation topics. Research
and older design notes are not current command or host-parity promises; prefer
the current guides and interfaces when they differ.
- Context compaction: configuration, compactor, relevance judge.
- Prompt refinement: recursive flow, evaluator.
- Provider tool outputs: response output notes, image output support.
- TUI rendering research: whitepaper, Notty examples, research report.
- Type-ahead tests: synchronous UI checks, debounce and cancellation.
- Older TUI link locations (forward to canonical library pages): app, controller, renderer, model, types, grammar registry, grammars, theme, TextMate engine.
- Historical source-only commands: gpt, mp_prompt, eio_get.
Current library pages
Section titled “Current library pages”For agent integrations start with agent-core embedding. For other components, use the index below. These pages mix API explanations and historical design notes; exact signatures are in the linked current interfaces. A link here is navigation, not a claim that every legacy example was executed.
Core tools and retrieval
Section titled “Core tools and retrieval”- Io
- apply_patch
- apply_patch_error
- bin_prot_utils_eio
- bm25
- definitions
- dune_describe
- embed_service
- embedding
- environment
- functions
- github
- gpt_function
- indexer
- jsonaf_ext
- log
- lru_cache
- markdown_crawler
- markdown_indexer
- markdown_snippet
- md_index_catalog
- merlin
- meta_prompting
- mime
- notty_scroll_box
- ocaml_parser
- odoc_crawler
- odoc_indexer
- odoc_snippet
- package_index
- parallel_tool_calls
- prompt_session
- session
- session_store
- source
- template
- tikitoken
- ttl_lru_cache
- vector_db
agent_client
Section titled “agent_client”agent_protocol
Section titled “agent_protocol”agent_server
Section titled “agent_server”agent_session
Section titled “agent_session”agent_store
Section titled “agent_store”agent_transport_client
Section titled “agent_transport_client”agent_transport_http
Section titled “agent_transport_http”agent_transport_socket
Section titled “agent_transport_socket”agent_transport_stdio
Section titled “agent_transport_stdio”chat_response
Section titled “chat_response”- chat_response/agent_runtime
- chat_response/cache
- chat_response/chatml_moderation
- chat_response/config
- chat_response/converter
- chat_response/ctx
- chat_response/driver
- chat_response/fetch
- chat_response/fork
- chat_response/history_stream_event
- chat_response/in_memory_stream
- chat_response/mcp_discovery_cache
- chat_response/moderation
- chat_response/response_loop
- chat_response/tool
chat_tui
Section titled “chat_tui”- chat_tui/agent_event_apply
- chat_tui/agent_history_layout
- chat_tui/agent_permission_view
- chat_tui/agent_projection
- chat_tui/agent_security_projection
- chat_tui/agent_session_client
- chat_tui/app
- chat_tui/app_compaction
- chat_tui/app_events
- chat_tui/app_reducer
- chat_tui/app_runtime
- chat_tui/app_stream_apply
- chat_tui/app_streaming
- chat_tui/app_submit
- chat_tui/cmd
- chat_tui/connection_status
- chat_tui/controller
- chat_tui/controller_cmdline
- chat_tui/controller_normal
- chat_tui/controller_shared
- chat_tui/controller_shell_security
- chat_tui/controller_types
- chat_tui/conversation
- chat_tui/highlight_grammars
- chat_tui/highlight_registry
- chat_tui/highlight_styles
- chat_tui/highlight_theme
- chat_tui/highlight_tm_engine
- chat_tui/highlight_tm_loader
- chat_tui/markdown_fences
- chat_tui/model
- chat_tui/path_completion
- chat_tui/persistence
- chat_tui/renderer
- chat_tui/renderer2
- chat_tui/renderer_component_history
- chat_tui/renderer_component_input_box
- chat_tui/renderer_component_message
- chat_tui/renderer_component_status_bar
- chat_tui/renderer_highlight_engine
- chat_tui/renderer_lang
- chat_tui/renderer_page_chat
- chat_tui/renderer_page_shell_security
- chat_tui/renderer_pages
- chat_tui/renderer_shell_approval
- chat_tui/renderer_shell_security_palette
- chat_tui/shell_management_service
- chat_tui/shell_security_page_state
- chat_tui/shell_security_snapshot
- chat_tui/snippet
- chat_tui/stream
- chat_tui/type_ahead_provider
- chat_tui/types
- chat_tui/ui_helpers
- chat_tui/util
- chat_tui/utf8_edit
chatmd
Section titled “chatmd”- chatmd/chatmd_ast
- chatmd/chatmd_import_expansion
- chatmd/chatmd_lexer
- chatmd/chatmd_parser
- chatmd/chatmd_script_declaration
- chatmd/prompt
- chatmd/source_loader
chatmd_shell_spec
Section titled “chatmd_shell_spec”chatml
Section titled “chatml”- chatml/chatml_builtin_modules
- chatml/chatml_lang
- chatml/chatml_lexer
- chatml/chatml_parser
- chatml/chatml_resolver
- chatml/chatml_typechecker
- chatml/frame_env
context_compaction
Section titled “context_compaction”- mcp/mcp_client
- mcp/mcp_prompt_agent
- mcp/mcp_server_core
- mcp/mcp_server_http
- mcp/mcp_server_router
- mcp/mcp_tool
- mcp/mcp_transport
- mcp/mcp_transport_http
- mcp/mcp_transport_interface
- mcp/mcp_transport_stdio
- mcp/mcp_types
meta_prompting
Section titled “meta_prompting”- meta_prompting/aggregator
- meta_prompting/context
- meta_prompting/evaluator
- meta_prompting/meta_prompting
- meta_prompting/mp_flow
- meta_prompting/preprocessor
- meta_prompting/prompt_factory
- meta_prompting/prompt_factory_online
- meta_prompting/prompt_intf
- meta_prompting/prompting_guides
- meta_prompting/prompts
- meta_prompting/recursive_mp
- meta_prompting/task_intf
notty-eio
Section titled “notty-eio”- oauth/oauth2_client_credentials
- oauth/oauth2_client_store
- oauth/oauth2_http
- oauth/oauth2_manager
- oauth/oauth2_pkce
- oauth/oauth2_pkce_flow
- oauth/oauth2_server_client_storage
- oauth/oauth2_server_routes
- oauth/oauth2_server_storage
- oauth/oauth2_server_types
- oauth/oauth2_types