ralphx 0.3.5__py3-none-any.whl → 0.4.1__py3-none-any.whl
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.
- ralphx/__init__.py +1 -1
- ralphx/adapters/base.py +18 -2
- ralphx/adapters/claude_cli.py +415 -350
- ralphx/api/routes/auth.py +105 -32
- ralphx/api/routes/items.py +4 -0
- ralphx/api/routes/loops.py +101 -15
- ralphx/api/routes/planning.py +866 -17
- ralphx/api/routes/resources.py +528 -6
- ralphx/api/routes/stream.py +161 -114
- ralphx/api/routes/templates.py +1 -0
- ralphx/api/routes/workflows.py +257 -25
- ralphx/core/auth.py +32 -7
- ralphx/core/checkpoint.py +118 -0
- ralphx/core/executor.py +292 -85
- ralphx/core/loop_templates.py +59 -14
- ralphx/core/planning_iteration_executor.py +633 -0
- ralphx/core/planning_service.py +11 -4
- ralphx/core/project_db.py +835 -85
- ralphx/core/resources.py +28 -2
- ralphx/core/session.py +62 -10
- ralphx/core/templates.py +74 -87
- ralphx/core/workflow_executor.py +35 -3
- ralphx/mcp/tools/diagnostics.py +1 -1
- ralphx/mcp/tools/monitoring.py +10 -16
- ralphx/mcp/tools/workflows.py +5 -5
- ralphx/models/loop.py +1 -1
- ralphx/models/session.py +5 -0
- ralphx/static/assets/index-DnihHetG.js +265 -0
- ralphx/static/assets/index-DnihHetG.js.map +1 -0
- ralphx/static/assets/index-nIDWmtzm.css +1 -0
- ralphx/static/index.html +2 -2
- ralphx/templates/loop_templates/consumer.md +2 -2
- {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/METADATA +1 -1
- {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/RECORD +36 -35
- ralphx/static/assets/index-0ovNnfOq.css +0 -1
- ralphx/static/assets/index-CY9s08ZB.js +0 -251
- ralphx/static/assets/index-CY9s08ZB.js.map +0 -1
- {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/WHEEL +0 -0
- {ralphx-0.3.5.dist-info → ralphx-0.4.1.dist-info}/entry_points.txt +0 -0
ralphx/__init__.py
CHANGED
ralphx/adapters/base.py
CHANGED
|
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
|
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
from enum import Enum
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Any, AsyncIterator, Optional
|
|
8
|
+
from typing import Any, AsyncIterator, Callable, Optional
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class AdapterEvent(str, Enum):
|
|
@@ -15,6 +15,8 @@ class AdapterEvent(str, Enum):
|
|
|
15
15
|
TEXT = "text" # Text output from model
|
|
16
16
|
TOOL_USE = "tool_use" # Model is using a tool
|
|
17
17
|
TOOL_RESULT = "tool_result" # Tool returned a result
|
|
18
|
+
THINKING = "thinking" # Model's reasoning/thinking
|
|
19
|
+
USAGE = "usage" # Token usage data
|
|
18
20
|
ERROR = "error" # Error occurred
|
|
19
21
|
COMPLETE = "complete" # Execution completed
|
|
20
22
|
|
|
@@ -37,6 +39,12 @@ class StreamEvent:
|
|
|
37
39
|
# Tool result for TOOL_RESULT events
|
|
38
40
|
tool_result: Optional[str] = None
|
|
39
41
|
|
|
42
|
+
# Thinking content for THINKING events
|
|
43
|
+
thinking: Optional[str] = None
|
|
44
|
+
|
|
45
|
+
# Token usage data for USAGE events
|
|
46
|
+
usage: Optional[dict] = None
|
|
47
|
+
|
|
40
48
|
# Error details for ERROR events
|
|
41
49
|
error_message: Optional[str] = None
|
|
42
50
|
error_code: Optional[str] = None
|
|
@@ -100,6 +108,8 @@ class LLMAdapter(ABC):
|
|
|
100
108
|
tools: Optional[list[str]] = None,
|
|
101
109
|
timeout: int = 300,
|
|
102
110
|
json_schema: Optional[dict] = None,
|
|
111
|
+
on_session_start: Optional[Callable[[str], None]] = None,
|
|
112
|
+
on_event: Optional[Callable[["StreamEvent"], None]] = None,
|
|
103
113
|
) -> ExecutionResult:
|
|
104
114
|
"""Execute a prompt and return the result.
|
|
105
115
|
|
|
@@ -110,6 +120,8 @@ class LLMAdapter(ABC):
|
|
|
110
120
|
timeout: Timeout in seconds.
|
|
111
121
|
json_schema: Optional JSON schema for structured output validation.
|
|
112
122
|
When provided, the result will include structured_output.
|
|
123
|
+
on_session_start: Optional callback fired when session ID is available.
|
|
124
|
+
on_event: Optional callback fired for each streaming event (for persistence).
|
|
113
125
|
|
|
114
126
|
Returns:
|
|
115
127
|
ExecutionResult with session info and output.
|
|
@@ -174,6 +186,10 @@ class LLMAdapter(ABC):
|
|
|
174
186
|
Marker string to append to prompt.
|
|
175
187
|
"""
|
|
176
188
|
now = datetime.utcnow().isoformat()
|
|
189
|
+
# Sanitize values to prevent HTML comment injection (e.g., --> in mode name)
|
|
190
|
+
safe_run_id = run_id.replace("--", "").replace('"', "")
|
|
191
|
+
safe_slug = project_slug.replace("--", "").replace('"', "")
|
|
192
|
+
safe_mode = mode.replace("--", "").replace('"', "")
|
|
177
193
|
return f"""
|
|
178
194
|
|
|
179
|
-
<!-- RALPHX_TRACKING run_id="{
|
|
195
|
+
<!-- RALPHX_TRACKING run_id="{safe_run_id}" project="{safe_slug}" iteration={iteration} mode="{safe_mode}" ts="{now}" -->"""
|