Skip to main content

claude_code_sdk_rust/internal/
protocol.rs

1//! Protocol constants for Claude CLI communication.
2
3/// Message types used in CLI communication.
4pub mod message_types {
5    pub const USER: &str = "user";
6    pub const ASSISTANT: &str = "assistant";
7    pub const SYSTEM: &str = "system";
8    pub const TASK_START: &str = "task_start";
9    pub const TASK_PROGRESS: &str = "task_progress";
10    pub const TASK_COMPLETE: &str = "task_complete";
11    pub const TASK_USAGE: &str = "task_usage";
12    pub const RESULT: &str = "result";
13    pub const RATE_LIMIT: &str = "rate_limit";
14    pub const STREAM_EVENT: &str = "stream_event";
15    pub const SERVER_ERROR: &str = "server_error";
16}
17
18/// Content block types.
19pub mod content_types {
20    pub const TEXT: &str = "text";
21    pub const THINKING: &str = "thinking";
22    pub const TOOL_USE: &str = "tool_use";
23    pub const TOOL_RESULT: &str = "tool_result";
24    pub const UNKNOWN: &str = "unknown";
25}
26
27/// Stream event types.
28pub mod stream_event_types {
29    pub const CONTENT_BLOCK_START: &str = "content_block_start";
30    pub const CONTENT_BLOCK_DELTA: &str = "content_block_delta";
31    pub const CONTENT_BLOCK_STOP: &str = "content_block_stop";
32    pub const MESSAGE_START: &str = "message_start";
33    pub const MESSAGE_DELTA: &str = "message_delta";
34    pub const MESSAGE_STOP: &str = "message_stop";
35}
36
37/// Field names for protocol maps.
38pub mod fields {
39    pub const TYPE: &str = "type";
40    pub const SESSION_ID: &str = "session_id";
41    pub const MESSAGE: &str = "message";
42    pub const CONTENT: &str = "content";
43    pub const ROLE: &str = "role";
44    pub const MODEL: &str = "model";
45    pub const STOP_REASON: &str = "stop_reason";
46    pub const USAGE: &str = "usage";
47    pub const INPUT_TOKENS: &str = "input_tokens";
48    pub const OUTPUT_TOKENS: &str = "output_tokens";
49    pub const TOTAL_TOKENS: &str = "total_tokens";
50    pub const ERROR: &str = "error";
51    pub const EVENT: &str = "event";
52    pub const ID: &str = "id";
53    pub const NAME: &str = "name";
54    pub const INPUT: &str = "input";
55    pub const OUTPUT: &str = "output";
56    pub const IS_ERROR: &str = "is_error";
57    pub const THINKING: &str = "thinking";
58    pub const SIGNATURE: &str = "signature";
59    pub const DELTA: &str = "delta";
60    pub const TEXT: &str = "text";
61    pub const PARTIAL_JSON: &str = "partial_json";
62    pub const INDEX: &str = "index";
63}
64
65/// CLI argument constants.
66pub mod cli_args {
67    pub const VERSION: &str = "--version";
68    pub const JSON: &str = "--json";
69    pub const SESSION: &str = "--session";
70    pub const RESUME: &str = "--resume";
71    pub const PRINT_CONFIG: &str = "--print-config";
72    pub const MODEL: &str = "--model";
73    pub const MAX_TURNS: &str = "--max-turns";
74    pub const CWD: &str = "--cwd";
75    pub const NO_AUTO: &str = "--no-auto";
76    pub const ONLY: &str = "--only";
77}