ralph-cli-sandboxed 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -3
- package/dist/commands/help.js +2 -1
- package/dist/commands/once.js +63 -142
- package/dist/commands/run.js +92 -149
- package/dist/config/cli-providers.json +28 -3
- package/dist/templates/prompts.d.ts +2 -0
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.js +5 -1
- package/dist/utils/notification.d.ts +28 -0
- package/dist/utils/notification.js +69 -0
- package/dist/utils/stream-json.d.ts +132 -0
- package/dist/utils/stream-json.js +662 -0
- package/docs/SECURITY.md +21 -6
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream JSON parser interface and provider-specific implementations.
|
|
3
|
+
*
|
|
4
|
+
* Each CLI provider has its own stream-json event format. This module provides
|
|
5
|
+
* a unified interface for parsing stream-json output from different providers.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Interface for parsing stream-json lines from CLI providers.
|
|
9
|
+
*/
|
|
10
|
+
export interface StreamJsonParser {
|
|
11
|
+
/**
|
|
12
|
+
* Parse a single line of stream-json output and return displayable text.
|
|
13
|
+
* @param line - A single line of JSON output
|
|
14
|
+
* @returns Human-readable text to display, or empty string if nothing to show
|
|
15
|
+
*/
|
|
16
|
+
parseStreamJsonLine(line: string): string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Base class for stream-json parsers with common utilities.
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class BaseStreamParser implements StreamJsonParser {
|
|
22
|
+
protected debug: boolean;
|
|
23
|
+
constructor(debug?: boolean);
|
|
24
|
+
abstract parseStreamJsonLine(line: string): string;
|
|
25
|
+
protected debugLog(message: string): void;
|
|
26
|
+
protected truncateOutput(output: string | unknown, maxLength?: number): string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parser for Claude Code CLI stream-json events.
|
|
30
|
+
*
|
|
31
|
+
* Event types:
|
|
32
|
+
* - content_block_delta: Incremental text updates (text_delta, input_json_delta)
|
|
33
|
+
* - content_block_start: Tool use or text block start
|
|
34
|
+
* - content_block_stop: End of content block
|
|
35
|
+
* - tool_result: Tool execution results
|
|
36
|
+
* - assistant: Complete assistant message with content blocks
|
|
37
|
+
* - message_start/message_delta/message_stop: Message lifecycle
|
|
38
|
+
* - system/user: System and user messages
|
|
39
|
+
* - result/error: Final results or errors
|
|
40
|
+
* - file_edit/file_write/file_read: File operations
|
|
41
|
+
* - bash/command: Command execution
|
|
42
|
+
* - bash_output/command_output: Command results
|
|
43
|
+
*/
|
|
44
|
+
export declare class ClaudeStreamParser extends BaseStreamParser {
|
|
45
|
+
parseStreamJsonLine(line: string): string;
|
|
46
|
+
private handleFallback;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parser for Gemini CLI stream-json events.
|
|
50
|
+
*
|
|
51
|
+
* Event types:
|
|
52
|
+
* - initialization: Model initialization info
|
|
53
|
+
* - messages: Conversation messages
|
|
54
|
+
* - tools: Tool calls and results
|
|
55
|
+
* - turn_complete: End of turn
|
|
56
|
+
* - response: Final response text
|
|
57
|
+
*/
|
|
58
|
+
export declare class GeminiStreamParser extends BaseStreamParser {
|
|
59
|
+
parseStreamJsonLine(line: string): string;
|
|
60
|
+
private handleFallback;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parser for OpenCode CLI stream-json events.
|
|
64
|
+
*
|
|
65
|
+
* Event types:
|
|
66
|
+
* - step_start/step_end/step_finish: Step lifecycle
|
|
67
|
+
* - tool_use: Tool invocation with nested part structure (part.type="tool", part.tool, part.state)
|
|
68
|
+
* - tool/tool_call: Direct tool invocation (alternate format)
|
|
69
|
+
* - tool_response: Tool results
|
|
70
|
+
* - text: Text output with nested part structure (part.text)
|
|
71
|
+
* - assistant_message/model_response: Model output
|
|
72
|
+
* - thinking/reasoning: Thinking process
|
|
73
|
+
* - done/complete: Completion
|
|
74
|
+
*/
|
|
75
|
+
export declare class OpenCodeStreamParser extends BaseStreamParser {
|
|
76
|
+
parseStreamJsonLine(line: string): string;
|
|
77
|
+
private handleFallback;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parser for Codex CLI stream-json events.
|
|
81
|
+
*
|
|
82
|
+
* Event types:
|
|
83
|
+
* - thread.started: Thread initialization
|
|
84
|
+
* - turn.started/turn.completed/turn.failed: Turn lifecycle
|
|
85
|
+
* - item.started/item.completed/item.failed: Action lifecycle
|
|
86
|
+
* - command_execution, file_change, file_read, mcp_tool_call, web_search, plan_update
|
|
87
|
+
*/
|
|
88
|
+
export declare class CodexStreamParser extends BaseStreamParser {
|
|
89
|
+
parseStreamJsonLine(line: string): string;
|
|
90
|
+
private handleFallback;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Parser for Goose CLI stream-json events.
|
|
94
|
+
*
|
|
95
|
+
* Goose uses a similar event format to Claude Code.
|
|
96
|
+
* Falls back to Claude parser behavior for common events.
|
|
97
|
+
*/
|
|
98
|
+
export declare class GooseStreamParser extends BaseStreamParser {
|
|
99
|
+
private claudeParser;
|
|
100
|
+
constructor(debug?: boolean);
|
|
101
|
+
parseStreamJsonLine(line: string): string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Parser for Aider CLI stream events.
|
|
105
|
+
*
|
|
106
|
+
* Aider's --stream flag outputs JSON events for:
|
|
107
|
+
* - text: Streamed text content
|
|
108
|
+
* - tool_call: Tool/function calls
|
|
109
|
+
* - tool_result: Tool execution results
|
|
110
|
+
* - file_edit: File modifications
|
|
111
|
+
* - error: Error messages
|
|
112
|
+
*/
|
|
113
|
+
export declare class AiderStreamParser extends BaseStreamParser {
|
|
114
|
+
parseStreamJsonLine(line: string): string;
|
|
115
|
+
private handleFallback;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Universal fallback parser that handles common event patterns.
|
|
119
|
+
* Used for providers without specific stream-json support or as a fallback.
|
|
120
|
+
*/
|
|
121
|
+
export declare class DefaultStreamParser extends BaseStreamParser {
|
|
122
|
+
parseStreamJsonLine(line: string): string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get the appropriate stream-json parser for a CLI provider.
|
|
126
|
+
*
|
|
127
|
+
* @param provider - The CLI provider name (e.g., "claude", "gemini", "opencode")
|
|
128
|
+
* @param debug - Enable debug logging
|
|
129
|
+
* @returns The appropriate StreamJsonParser for the provider
|
|
130
|
+
*/
|
|
131
|
+
export declare function getStreamJsonParser(provider: string | undefined, debug?: boolean): StreamJsonParser;
|
|
132
|
+
export {};
|